* {
  box-sizing: border-box;
}
:root {
  --bg: #202122;
  --panel: #303133;
  --line: #56575a;
  --text: #f4f4f5;
  --muted: #a9aaad;
  --accent: #ff8a22;
  --good: #45c982;
  --bad: #ef6461;
}
html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  font-family:
    -apple-system, BlinkMacSystemFont, "Noto Sans JP", "Helvetica Neue", Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
}
body {
  min-height: 100svh;
  overflow-x: hidden;
}
button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.app {
  width: min(720px, 100%);
  min-height: 100svh;
  margin: auto;
  padding: env(safe-area-inset-top) 18px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 62px;
  flex: 0 0 62px;
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  gap: 8px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
}
.home-screen {
  width: 100%;
  max-width: 560px;
  margin: auto;
  padding: clamp(32px, 9svh, 76px) 0 28px;
}
.home-hero {
  margin-bottom: 34px;
}
.eyebrow {
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.14em;
}
.home-hero h1 {
  margin: 8px 0;
  font-size: clamp(34px, 9vw, 52px);
  line-height: 1.12;
}
.home-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}
.home-panel,
.history-panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  padding: 20px;
}
.history-panel {
  margin-top: 16px;
}
.home-panel h2,
.history-panel h2 {
  margin: 0 0 15px;
  font-size: 18px;
}
.course-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.timer-setting {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}
.timer-setting > span {
  margin-right: auto;
  font-weight: 700;
}
.timer-option {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  padding: 5px 12px;
  cursor: pointer;
}
.timer-option.selected {
  border-color: var(--accent);
  background: #4b3524;
  color: var(--text);
}
.course {
  min-height: 92px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #28292b;
  padding: 14px;
  text-align: left;
  cursor: pointer;
}
.course strong {
  display: block;
  font-size: 22px;
}
.course span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}
.course.featured {
  position: relative;
  border-color: var(--accent);
  background: #3d3025;
}
.course.featured em {
  position: absolute;
  top: -10px;
  right: -8px;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--accent);
  color: #1c1c1c;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}
.course:has(em) {
  position: relative;
}
.course:has(em) em {
  position: absolute;
  top: -10px;
  right: -8px;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--accent);
  color: #1c1c1c;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}
.course.selected {
  border-color: var(--accent);
  background: #4b3524;
  box-shadow: 0 0 0 2px #ff8a2244;
}
.course:active {
  transform: scale(0.98);
}
.start-btn {
  margin-top: 16px;
}
.weak-start {
  margin-top: 10px;
}
.start-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.history-empty {
  color: var(--muted);
  line-height: 1.6;
}
.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.history-list li {
  display: flex;
  justify-content: space-between;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.history-list strong {
  color: var(--text);
}
.text-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 8px 0;
  font-weight: 700;
}
.home-link {
  margin-top: 18px;
}
.icon-btn {
  border: 0;
  background: none;
  font-size: 32px;
  color: #aaa;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}
.progress-wrap {
  height: 12px;
  background: #57585c;
  border-radius: 999px;
  overflow: hidden;
}
.progress {
  height: 100%;
  width: 2%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.35s ease;
}
#quizScreen {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.counter {
  flex: 0 0 auto;
  text-align: center;
  color: #aaa;
  font-size: 17px;
  margin: 5px 0 10px;
}
.card {
  height: clamp(190px, 30svh, 280px);
  flex: 0 0 auto;
  min-height: 170px;
  border: 3px solid #55565a;
  border-radius: 18px;
  background: #303133;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 4px 18px #0002;
}
.word {
  font-size: clamp(42px, 10vw, 72px);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 16px;
  max-width: calc(100% - 64px);
  white-space: nowrap;
}
.timer-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.bookmark {
  position: absolute;
  right: 12px;
  bottom: 8px;
  border: 0;
  background: none;
  font-size: 32px;
  color: #bbb;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
}
.bookmark.active {
  color: #ffbd24;
}
.feedback {
  position: absolute;
  left: -9999px;
  min-height: 0;
}
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  flex: 0 0 auto;
}
.choice {
  min-height: 64px;
  border: 3px solid #4f5054;
  background: #303133;
  border-radius: 30px;
  padding: 9px 14px;
  margin: 0;
  text-align: left;
  font-size: clamp(16px, 2.8vw, 20px);
  line-height: 1.25;
  cursor: pointer;
  transition:
    transform 0.12s,
    background 0.15s,
    border-color 0.15s;
}
.choice:active {
  transform: scale(0.985);
}
.choice:focus-visible,
.icon-btn:focus-visible,
.bookmark:focus-visible,
.primary:focus-visible,
.secondary:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
.choice .num {
  display: inline-flex;
  width: 27px;
  color: #777;
  font-weight: 700;
}
.choice.correct {
  border-color: var(--good);
  background: #263c33;
}
.choice.wrong {
  border-color: var(--bad);
  background: #3e2929;
}
.choice.disabled {
  cursor: default;
}
.next {
  width: 100%;
  border: 0;
  border-radius: 30px;
  padding: 12px 20px;
  margin-top: 10px;
  background: var(--accent);
  color: #181818;
  font-weight: 700;
  cursor: pointer;
}
.result-card {
  text-align: center;
  padding-top: 18svh;
}
.result-label {
  color: #aaa;
  letter-spacing: 0.12em;
  font-size: 14px;
}
.score {
  font-size: clamp(56px, 13vw, 72px);
  font-weight: 800;
  margin: 14px 0;
}
.rank {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}
.result-card p {
  color: #bbb;
  line-height: 1.7;
}
.primary,
.secondary {
  width: 100%;
  border-radius: 40px;
  min-height: 52px;
  padding: 14px 24px;
  margin-top: 10px;
  cursor: pointer;
}
.primary {
  border: 0;
  background: var(--accent);
  color: #181818;
  font-weight: 700;
}
.secondary {
  border: 2px solid #5c5d60;
  background: transparent;
}
[hidden] {
  display: none !important;
}
@media (max-width: 520px) {
  .app {
    padding-left: 14px;
    padding-right: 14px;
  }
  .topbar {
    height: 58px;
    flex-basis: 58px;
    grid-template-columns: 42px 1fr 42px;
  }
  .counter {
    margin: 3px 0 8px;
    font-size: 16px;
  }
  .card {
    height: clamp(170px, 25svh, 220px);
    min-height: 150px;
    border-width: 3px;
  }
  .word {
    font-size: clamp(40px, 12vw, 58px);
  }
  .bookmark {
    font-size: 30px;
    right: 8px;
    bottom: 5px;
  }
  .choices {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 10px;
  }
  .choice {
    min-height: 56px;
    border-width: 3px;
    padding: 8px 10px;
    font-size: 16px;
    border-radius: 28px;
  }
  .choice .num {
    width: 23px;
  }
  .home-screen {
    padding-top: 32px;
  }
  .home-panel,
  .history-panel {
    padding: 16px;
    border-radius: 18px;
  }
}

@media (max-height: 700px) and (min-width: 521px) {
  .topbar {
    height: 50px;
    flex-basis: 50px;
  }
  .counter {
    margin: 2px 0 5px;
    font-size: 15px;
  }
  .card {
    height: 155px;
    flex-basis: 155px;
    min-height: 145px;
  }
  .word {
    font-size: 42px;
  }
  .choices {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 7px;
  }
  .choice {
    min-height: 48px;
    padding: 6px 9px;
    font-size: 14px;
  }
}
