:root {
  --navy-950: #0b1f33;
  --navy-900: #102a43;
  --navy-700: #24506e;
  --blue-500: #3c91c9;
  --blue-100: #e7f3fb;
  --mint-500: #35b69f;
  --mint-100: #e2f7f1;
  --coral-500: #ef7b69;
  --coral-100: #fff0ed;
  --yellow-500: #f4b942;
  --ink: #183247;
  --muted: #6e8291;
  --line: #d9e4eb;
  --surface: #ffffff;
  --canvas: #f3f7fa;
  --shadow: 0 16px 40px rgba(17, 47, 73, 0.1);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 95% 0%, rgba(53, 182, 159, 0.11), transparent 25rem),
    var(--canvas);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid rgba(60, 145, 201, 0.45);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(243, 247, 250, 0.94);
  border-bottom: 1px solid rgba(217, 228, 235, 0.8);
  backdrop-filter: blur(18px);
}

.topbar-inner,
.page,
.bottom-nav-inner {
  width: min(100%, 560px);
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--navy-900);
  color: #fff;
  font-size: 1.32rem;
  font-weight: 800;
  box-shadow: 0 7px 16px rgba(16, 42, 67, 0.22);
}

.brand-copy {
  min-width: 0;
}

.brand-title {
  margin: 0;
  color: var(--navy-900);
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.67rem;
  letter-spacing: 0.08em;
}

.topbar-stat {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--navy-900);
  font-size: 0.73rem;
  font-weight: 800;
  white-space: nowrap;
}

.topbar-stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint-500);
  box-shadow: 0 0 0 4px var(--mint-100);
}

.page {
  flex: 1;
  padding: 18px 16px calc(106px + env(safe-area-inset-bottom));
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 14px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue-500);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.page-title {
  margin: 0;
  color: var(--navy-900);
  font-size: clamp(1.65rem, 7vw, 2.05rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.page-description {
  max-width: 26rem;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.session-strip,
.panel,
.stage-map,
.question-card,
.stat-card,
.setting-card,
.empty-card,
.complete-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 7px 22px rgba(24, 50, 71, 0.05);
}

.session-strip {
  padding: 12px 14px;
  border-radius: 18px;
}

.session-strip-head,
.panel-head,
.stage-map-head,
.setting-row,
.weak-item,
.stat-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.session-strip-head {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
}

.session-strip-head strong {
  color: var(--navy-900);
}

.progress-track {
  height: 7px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f5;
}

.progress-fill {
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint-500), var(--blue-500));
  transition: width 180ms ease-out;
}

.stage-map {
  margin-top: 12px;
  padding: 13px 14px 12px;
  border-radius: 18px;
}

.stage-map-head {
  margin-bottom: 11px;
}

.stage-map-title {
  color: var(--navy-900);
  font-size: 0.78rem;
  font-weight: 800;
}

.stage-map-note {
  color: var(--muted);
  font-size: 0.69rem;
  text-align: right;
}

.stage-steps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.stage-step {
  position: relative;
  min-width: 0;
  padding: 8px 4px 7px;
  border-radius: 12px;
  background: #f4f7f8;
  color: var(--muted);
  text-align: center;
}

.stage-step.is-active {
  background: var(--blue-100);
  color: var(--blue-500);
}

.stage-step.is-complete {
  background: var(--mint-100);
  color: #147e6d;
}

.stage-step.is-locked {
  opacity: 0.54;
}

.stage-step-number {
  display: block;
  font-size: 0.66rem;
  font-weight: 800;
}

.stage-step-label {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 0.58rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-card {
  position: relative;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 24px;
}

.question-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--coral-500), var(--yellow-500));
  content: "";
}

.question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 17px 18px 0;
}

.question-badge,
.new-badge,
.review-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.question-badge {
  color: var(--blue-500);
  background: var(--blue-100);
}

.new-badge {
  color: #b2553d;
  background: var(--coral-100);
}

.review-badge {
  color: #6c7d86;
  background: #f1f4f5;
}

.question-direction {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.character-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 244px;
  margin: 14px 12px 0;
  overflow: hidden;
  border-radius: 20px;
  background:
    radial-gradient(circle at 18% 15%, rgba(255, 255, 255, 0.13), transparent 8rem),
    linear-gradient(145deg, var(--navy-900), var(--navy-950));
  color: #fff;
  text-align: center;
}

.character-stage::after {
  position: absolute;
  right: -50px;
  bottom: -65px;
  width: 170px;
  height: 170px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  box-shadow: 0 0 0 24px rgba(255, 255, 255, 0.03), 0 0 0 48px rgba(255, 255, 255, 0.025);
  content: "";
}

.character-content {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 26px 22px 24px;
}

.part-line {
  min-height: 21px;
  margin-bottom: 3px;
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.character-main {
  margin: 0;
  font-size: clamp(4.9rem, 23vw, 7.8rem);
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: 0.02em;
  text-shadow: 0 7px 22px rgba(0, 0, 0, 0.18);
}

.character-main.is-romaji {
  font-size: clamp(2.9rem, 14vw, 5rem);
  letter-spacing: -0.04em;
}

.character-romanization {
  margin: 15px 0 0;
  color: #9de3d4;
  font-size: 1.26rem;
  font-weight: 800;
  letter-spacing: 0.07em;
}

.character-hint {
  margin: 7px auto 0;
  color: rgba(255, 255, 255, 0.71);
  font-size: 0.77rem;
  line-height: 1.45;
}

.speak-button {
  position: absolute;
  z-index: 2;
  top: 13px;
  right: 13px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
  font-size: 1.15rem;
}

.speak-button:active {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(0.95);
}

.choice-intro {
  margin: 15px 16px 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.cheat-toggle {
  width: calc(100% - 32px);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 16px 0;
  padding: 9px 13px;
  border: 1px solid #e5d4a1;
  border-radius: 13px;
  background: #fffaf0;
  color: #856319;
  font-size: 0.76rem;
  font-weight: 800;
  text-align: left;
}

.cheat-toggle:active,
.cheat-toggle.is-open {
  background: #fff4d5;
  border-color: var(--yellow-500);
}

.cheat-toggle-state {
  color: #aa8b45;
  font-size: 0.67rem;
  white-space: nowrap;
}

.cheat-sheet {
  margin: 10px 16px 0;
  padding: 13px 11px 12px;
  overflow: hidden;
  border: 1px solid #e8d9ae;
  border-radius: 16px;
  background: #fffdf7;
}

.cheat-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #6f5416;
  font-size: 0.78rem;
}

.cheat-sheet-head span {
  color: #ad8a3c;
  font-size: 0.66rem;
  font-weight: 700;
}

.cheat-sheet-note {
  margin: 6px 0 11px;
  color: #8d7440;
  font-size: 0.66rem;
  line-height: 1.45;
}

.cheat-group + .cheat-group {
  margin-top: 11px;
}

.cheat-group-label {
  margin-bottom: 5px;
  color: #9a7b35;
  font-size: 0.66rem;
  font-weight: 800;
}

.cheat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.cheat-cell {
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 4px 2px;
  border: 1px solid #efe4c8;
  border-radius: 9px;
  background: #fff;
  text-align: center;
}

.cheat-cell strong {
  color: var(--navy-900);
  font-size: 1.02rem;
  line-height: 1;
}

.cheat-cell span {
  margin-top: 3px;
  color: #8b7956;
  font-size: 0.59rem;
  font-weight: 800;
  line-height: 1;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 15px 16px 18px;
}

.choice-button {
  min-height: 65px;
  padding: 10px 7px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfcfd;
  color: var(--navy-900);
  font-size: clamp(1.04rem, 5.5vw, 1.3rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.choice-button:not(:disabled):active {
  background: var(--blue-100);
  border-color: var(--blue-500);
  transform: scale(0.97);
}

.choice-button:disabled {
  cursor: default;
}

.choice-button.is-selected-wrong {
  border-color: var(--coral-500);
  background: var(--coral-100);
  color: #ad4a37;
}

.choice-button.is-correct {
  border-color: var(--mint-500);
  background: var(--mint-100);
  color: #147e6d;
}

.choice-button.is-cheat-answer {
  border-color: var(--yellow-500);
  background: #fff7df;
  color: #9a6a0a;
}

.feedback {
  min-height: 44px;
  padding: 0 17px 15px;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.5;
  text-align: center;
}

.feedback.is-correct {
  color: #147e6d;
  font-weight: 800;
}

.feedback.is-wrong {
  color: #ad4a37;
  font-weight: 700;
}

.intro-footnote {
  padding: 11px 18px 18px;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.microcopy {
  margin: 12px 3px 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.5;
  text-align: center;
}

.complete-card {
  margin-top: 14px;
  padding: 30px 22px 24px;
  border-radius: 24px;
  text-align: center;
}

.complete-emoji {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 15px;
  border-radius: 20px;
  background: var(--mint-100);
  font-size: 2rem;
}

.complete-card h2 {
  margin: 0;
  color: var(--navy-900);
  font-size: 1.45rem;
}

.complete-card p {
  margin: 9px auto 20px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.primary-button,
.secondary-button {
  min-height: 52px;
  padding: 12px 18px;
  border-radius: 15px;
  font-weight: 800;
}

.primary-button {
  background: var(--navy-900);
  color: #fff;
  box-shadow: 0 8px 16px rgba(16, 42, 67, 0.18);
}

.primary-button:active,
.secondary-button:active {
  transform: scale(0.98);
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy-900);
}

.wide-button {
  width: 100%;
}

.panel {
  margin-top: 14px;
  padding: 16px;
  border-radius: 20px;
}

.panel-head {
  margin-bottom: 13px;
}

.panel-title {
  margin: 0;
  color: var(--navy-900);
  font-size: 0.96rem;
}

.panel-note {
  color: var(--muted);
  font-size: 0.7rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  min-height: 105px;
  padding: 14px;
  border-radius: 17px;
}

.stat-card-label {
  color: var(--muted);
  font-size: 0.71rem;
  font-weight: 700;
  line-height: 1.4;
}

.stat-card-value {
  margin-top: 9px;
  color: var(--navy-900);
  font-size: clamp(1.45rem, 8vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.stat-card-unit {
  margin-left: 3px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
}

.stat-line {
  padding: 10px 0;
  border-bottom: 1px solid #edf1f3;
  font-size: 0.78rem;
}

.stat-line:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.stat-line:first-child {
  padding-top: 0;
}

.stat-line-label {
  color: var(--muted);
}

.stat-line-value {
  color: var(--navy-900);
  font-weight: 800;
}

.weak-list {
  display: grid;
  gap: 2px;
}

.weak-item {
  min-height: 54px;
  padding: 8px 0;
  border-bottom: 1px solid #edf1f3;
}

.weak-item:last-child {
  border-bottom: 0;
}

.weak-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.weak-glyph {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 11px;
  background: var(--blue-100);
  color: var(--navy-900);
  font-size: 1.05rem;
  font-weight: 800;
}

.weak-copy {
  min-width: 0;
}

.weak-name {
  overflow: hidden;
  color: var(--navy-900);
  font-size: 0.84rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weak-meta {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weak-score {
  color: var(--coral-500);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.empty-card {
  margin-top: 14px;
  padding: 24px 18px;
  border-radius: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
  text-align: center;
}

.setting-card {
  margin-top: 12px;
  padding: 4px 16px;
  border-radius: 20px;
}

.setting-row {
  min-height: 65px;
  padding: 12px 0;
  border-bottom: 1px solid #edf1f3;
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-copy {
  min-width: 0;
}

.setting-label {
  color: var(--navy-900);
  font-size: 0.84rem;
  font-weight: 800;
}

.setting-description {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.45;
}

.toggle {
  position: relative;
  width: 50px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #d5e0e5;
  transition: background 150ms ease;
}

.toggle::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(24, 50, 71, 0.2);
  content: "";
  transition: transform 150ms ease;
}

.toggle.is-on {
  background: var(--mint-500);
}

.toggle.is-on::after {
  transform: translateX(20px);
}

.setting-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.option-chip {
  min-width: 43px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.option-chip.is-selected {
  border-color: var(--blue-500);
  background: var(--blue-100);
  color: var(--blue-500);
}

.danger-zone {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid #f3d4ce;
  border-radius: 20px;
  background: #fff9f7;
}

.danger-zone h2 {
  margin: 0;
  color: #a04b3b;
  font-size: 0.9rem;
}

.danger-zone p {
  margin: 7px 0 13px;
  color: #866b64;
  font-size: 0.71rem;
  line-height: 1.55;
}

.danger-button {
  width: 100%;
  min-height: 45px;
  border: 1px solid #e8b7ad;
  border-radius: 13px;
  background: #fff;
  color: #a04b3b;
  font-size: 0.78rem;
  font-weight: 800;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(217, 228, 235, 0.9);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.nav-button {
  min-height: 54px;
  border-radius: 15px;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.nav-button-icon {
  display: block;
  margin-bottom: 3px;
  font-size: 1.18rem;
  line-height: 1;
}

.nav-button.is-active {
  background: var(--blue-100);
  color: var(--blue-500);
}

.toast {
  position: fixed;
  z-index: 50;
  right: 16px;
  bottom: calc(86px + env(safe-area-inset-bottom));
  left: 16px;
  width: min(calc(100% - 32px), 420px);
  margin: 0 auto;
  padding: 12px 15px;
  border-radius: 14px;
  background: var(--navy-900);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  animation: toast-in 180ms ease-out;
}

.noscript-message {
  margin: 2rem auto;
  padding: 1rem;
  max-width: 30rem;
  color: var(--navy-900);
  text-align: center;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 700px) {
  body {
    padding: 0 18px;
  }

  .topbar {
    margin: 0 -18px;
  }

  .bottom-nav {
    right: auto;
    left: 50%;
    width: min(100% - 36px, 596px);
    transform: translateX(-50%);
    border: 1px solid rgba(217, 228, 235, 0.9);
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
  }
}

@media (max-width: 360px) {
  .page {
    padding-right: 12px;
    padding-left: 12px;
  }

  .character-stage {
    min-height: 220px;
  }

  .question-head {
    padding-right: 14px;
    padding-left: 14px;
  }

  .choices {
    padding-right: 12px;
    padding-left: 12px;
  }
}
