:root {
  color-scheme: light;
  --paper: #f7f7f2;
  --surface: #ffffff;
  --surface-sunken: #eceef3;
  --ink: #11131a;
  --ink-secondary: #4d5361;
  --ink-tertiary: #747b89;
  --hairline: rgba(17, 19, 26, 0.1);
  --hairline-strong: rgba(17, 19, 26, 0.22);
  --route-red: #ff5c8a;
  --route-orange: #ff9f6e;
  --route-gold: #eed07a;
  --route-blue: #69e7ff;
  --route-violet: #a78bfa;
  --shadow: 8px 8px 0 var(--route-blue);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: "Manrope", Helvetica, Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 8%, rgba(105, 231, 255, 0.18), transparent 26rem),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 30px;
  align-items: center;
  min-height: 72px;
  border-bottom: 1px solid var(--hairline);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
}

.brand-name {
  font-family: "Space Grotesk", Helvetica, Arial, sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
}

.brand-sep {
  color: var(--ink-tertiary);
  font-weight: 500;
}

.brand-kana {
  width: 24px;
  height: 17px;
  object-fit: contain;
  filter: invert(1);
}

.topbar-actions,
.daily-status {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 14px;
  justify-self: end;
}

.daily-status {
  gap: 8px;
  color: var(--ink-secondary);
  font-size: 0.7rem;
}

.daily-status b {
  color: var(--ink);
}

.status-divider {
  width: 1px;
  height: 16px;
  background: var(--hairline-strong);
}

.text-button,
.icon-button,
.inline-button,
.secondary-button {
  padding: 0;
  font-size: 0.72rem;
  font-weight: 700;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.text-button {
  padding: 8px 11px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
}

.text-button:hover,
.text-button:focus-visible,
.icon-button:hover,
.icon-button:focus-visible,
.inline-button:hover,
.inline-button:focus-visible {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-button {
  color: var(--ink-secondary);
}

.main-content {
  display: grid;
  gap: 28px;
  padding: 54px 0 76px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.38fr);
  gap: clamp(32px, 8vw, 120px);
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--route-red);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.intro h1,
.practice-heading h2,
.settings-heading h2,
.finish-view h3 {
  margin: 0;
  font-family: "Space Grotesk", Helvetica, Arial, sans-serif;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 0.98;
  text-wrap: balance;
}

.intro h1 {
  max-width: 12ch;
  font-size: clamp(3rem, 6vw, 5.3rem);
}

.intro-note {
  max-width: 31ch;
  margin: 0 0 3px;
  color: var(--ink-secondary);
  font-size: 0.88rem;
  line-height: 1.6;
  text-wrap: pretty;
}

.path-panel {
  display: grid;
  gap: 12px;
}

.path-heading {
  display: flex;
  gap: 16px;
  align-items: baseline;
}

.path-heading b {
  font-size: 0.82rem;
}

.path-heading span {
  color: var(--ink-tertiary);
  font-size: 0.7rem;
}

.stage-list {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
}

.stage-button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 70px;
  padding: 9px 10px;
  color: var(--ink-secondary);
  text-align: left;
  background: var(--surface);
  border: 0;
  border-right: 1px solid var(--hairline);
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}

.stage-button:last-child {
  border-right: 0;
}

.stage-button:hover:not(:disabled),
.stage-button:focus-visible {
  color: var(--ink);
  background: var(--surface-sunken);
  outline: 0;
}

.stage-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.stage-button.is-active {
  color: var(--ink);
  background: var(--route-blue);
}

.stage-button.is-mastered:not(.is-active) {
  background: color-mix(in srgb, var(--route-gold), var(--surface) 55%);
}

.stage-icon {
  display: grid;
  width: 30px;
  height: 30px;
  color: currentColor;
  border: 1px solid currentColor;
  border-radius: 50%;
  font: 700 0.75rem/1 "Hiragino Sans", "Yu Gothic", sans-serif;
  place-items: center;
}

.stage-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.stage-copy b,
.stage-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-copy b {
  font-size: 0.72rem;
  line-height: 1.1;
}

.stage-copy small {
  color: currentColor;
  font-size: 0.6rem;
  line-height: 1.1;
  opacity: 0.68;
}

.stage-percent {
  display: none;
}

.practice-panel {
  width: min(100%, 820px);
  margin: 8px auto 0;
}

.practice-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.stage-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--route-red);
  font-size: 0.72rem;
  font-weight: 800;
}

.practice-heading h2 {
  font-size: clamp(2.4rem, 5vw, 4rem);
}

.mastery-badge {
  display: flex;
  gap: 6px;
  align-items: baseline;
  padding: 8px 10px;
  background: var(--route-gold);
  border-radius: 5px;
}

.mastery-badge span {
  font-size: 1rem;
  font-weight: 800;
}

.mastery-badge small {
  font-size: 0.62rem;
  font-weight: 800;
}

.game-card {
  min-height: 480px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.start-view,
.finish-view {
  display: grid;
  min-height: 480px;
  padding: 36px clamp(28px, 7vw, 76px);
  align-content: center;
}

.flashcard-top,
.round-header {
  display: flex;
  justify-content: space-between;
  color: var(--ink-tertiary);
  font-size: 0.68rem;
  font-weight: 700;
}

.flashcard-content {
  display: grid;
  gap: 18px;
  justify-items: center;
  padding: 56px 0 34px;
  text-align: center;
}

.stage-glyph {
  display: grid;
  width: 148px;
  height: 148px;
  color: var(--ink);
  background: var(--surface-sunken);
  border-radius: 50%;
  font: 700 6.2rem/1 "Hiragino Sans", "Yu Gothic", sans-serif;
  place-items: center;
}

.stage-description {
  max-width: 38ch;
  margin: 0;
  color: var(--ink-secondary);
  font-size: 1.1rem;
  line-height: 1.45;
  text-align: center;
  text-wrap: balance;
}

.flashcard-footer {
  display: grid;
  justify-items: center;
  gap: 15px;
}

.practice-style {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 480px);
  padding: 4px;
  background: var(--surface-sunken);
  border-radius: 8px;
}

.practice-style button {
  display: grid;
  gap: 2px;
  min-height: 50px;
  padding: 7px 12px;
  color: var(--ink-secondary);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.practice-style button.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 4px var(--hairline-strong);
}

.practice-style button span {
  color: var(--ink-tertiary);
  font-size: 0.62rem;
}

.primary-button,
.submit-button {
  display: inline-flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 19px;
  color: var(--ink);
  font-weight: 800;
  background: var(--route-blue);
  border: 0;
  border-radius: 5px;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
  transition: transform 140ms var(--ease), box-shadow 140ms var(--ease), filter 140ms var(--ease);
}

.primary-button:hover,
.submit-button:hover {
  filter: saturate(1.08);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--ink);
}

.primary-button:active,
.submit-button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.primary-button:disabled {
  cursor: wait;
  filter: grayscale(0.5);
  opacity: 0.6;
}

.session-facts {
  color: var(--ink-tertiary);
  font-size: 0.68rem;
}

.session-facts b {
  color: var(--ink);
}

.play-view {
  min-height: 480px;
  padding: 28px clamp(24px, 7vw, 66px) 36px;
}

.round-header {
  display: grid;
  grid-template-columns: auto minmax(80px, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.round-meter {
  height: 4px;
  overflow: hidden;
  background: var(--surface-sunken);
  border-radius: 999px;
}

.round-meter i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--route-blue);
  border-radius: inherit;
  transition: width 220ms var(--ease);
}

.game-world {
  width: 100%;
  height: 132px !important;
  margin-top: 18px;
  overflow: hidden;
  background: var(--paper);
  border-radius: 8px;
}

.game-world canvas {
  display: block;
  pointer-events: none;
}

.prompt-area {
  display: grid;
  min-height: 190px;
  padding-top: 20px;
  text-align: center;
  place-content: center;
}

.prompt-label {
  color: var(--ink-tertiary);
  font-size: 0.7rem;
  font-weight: 700;
}

.prompt-tools {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.listen-button {
  padding: 5px 8px;
  color: var(--ink-secondary);
  background: transparent;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 800;
  cursor: pointer;
}

.prompt {
  margin: 12px 0 4px;
  color: var(--ink);
  font: 700 clamp(5rem, 15vw, 8.5rem)/1 "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  letter-spacing: -0.04em;
}

.prompt-hint {
  min-height: 20px;
  margin: 0;
  color: var(--ink-secondary);
  font-size: 0.86rem;
}

.answer-form {
  max-width: 520px;
  margin: 0 auto;
}

.answer-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
}

.choice-button {
  min-height: 50px;
  color: var(--ink);
  background: var(--surface-sunken);
  border: 1px solid var(--hairline-strong);
  border-radius: 5px;
  font-weight: 800;
  cursor: pointer;
}

.choice-button:hover:not(:disabled),
.choice-button:focus-visible {
  border-color: var(--route-blue);
  outline: 2px solid var(--route-blue);
}

.choice-button.is-correct {
  background: color-mix(in srgb, var(--route-blue), white 65%);
  border-color: var(--route-blue);
}

.choice-button.is-wrong {
  color: var(--ink-tertiary);
  background: color-mix(in srgb, var(--route-red), white 88%);
  border-color: var(--route-red);
}

.answer-form label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.72rem;
  font-weight: 800;
}

.answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

.answer-form input,
.setting-row select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--surface-sunken);
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 0.96rem;
}

.answer-form input:focus-visible,
.setting-row select:focus-visible {
  border-color: var(--route-blue);
  outline: 3px solid color-mix(in srgb, var(--route-blue), transparent 55%);
  outline-offset: 1px;
}

.answer-form input::placeholder {
  color: var(--ink-tertiary);
}

.answer-form input.is-correct {
  background: color-mix(in srgb, var(--route-blue), white 70%);
  border-color: var(--route-blue);
}

.answer-form input.is-wrong {
  background: color-mix(in srgb, var(--route-red), white 86%);
  border-color: var(--route-red);
}

.submit-button {
  min-width: 96px;
}

.answer-help,
.keyboard-tip {
  color: var(--ink-tertiary);
  font-size: 0.66rem;
}

.answer-help {
  margin: 7px 0 0;
}

.feedback {
  min-height: 42px;
  max-width: 520px;
  margin: 10px auto 0;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.45;
}

.feedback.good {
  color: #1b7d68;
}

.feedback.bad {
  color: #c53f67;
}

.finish-view {
  justify-items: center;
  text-align: center;
}

.finish-mark {
  display: grid;
  width: 76px;
  height: 76px;
  margin-bottom: 18px;
  color: var(--ink);
  background: var(--route-gold);
  border-radius: 50%;
  font: 700 1.15rem/1 "Hiragino Sans", "Yu Gothic", sans-serif;
  place-items: center;
}

.finish-label {
  margin-bottom: 6px;
  color: var(--route-red);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.finish-view h3 {
  font-size: clamp(2.6rem, 7vw, 4.6rem);
}

.finish-view p {
  max-width: 43ch;
  margin: 16px 0 26px;
  color: var(--ink-secondary);
  line-height: 1.55;
}

.keyboard-tip {
  margin: 17px 0 0;
  text-align: center;
}

.inline-button {
  color: var(--ink-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

kbd {
  padding: 2px 6px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 3px;
  font: inherit;
  font-weight: 800;
}

.settings-dialog {
  width: min(520px, calc(100% - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  box-shadow: 8px 8px 0 var(--route-violet);
}

.settings-dialog::backdrop {
  background: rgba(17, 19, 26, 0.25);
}

.settings-panel {
  display: grid;
  gap: 22px;
  padding: 28px;
}

.settings-heading {
  display: flex;
  gap: 18px;
  align-items: start;
  justify-content: space-between;
}

.settings-heading h2 {
  font-size: 2rem;
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr minmax(160px, 0.8fr);
  gap: 20px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--hairline);
}

.setting-row span,
.setting-check span {
  display: grid;
  gap: 4px;
}

.setting-row small,
.setting-check small,
.settings-footer p {
  color: var(--ink-tertiary);
  font-size: 0.68rem;
  line-height: 1.45;
}

.setting-check {
  display: flex;
  gap: 10px;
  align-items: start;
}

.setting-check input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--route-blue);
}

.settings-footer {
  display: flex;
  gap: 20px;
  align-items: end;
  justify-content: space-between;
}

.settings-footer p {
  max-width: 30ch;
  margin: 0;
}

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

.friend-card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.friend-card.is-active {
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--friend-color);
}

.friend-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  background: color-mix(in srgb, var(--friend-color), white 55%);
  border-radius: 50%;
  font-size: 1.35rem;
  place-items: center;
}

.friend-card > span:last-child {
  display: grid;
  gap: 3px;
}

.friend-card small,
.friends-note {
  color: var(--ink-tertiary);
  font-size: 0.65rem;
  line-height: 1.35;
}

.friends-note {
  margin: 0;
}

.cookie-banner {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  display: flex;
  gap: 28px;
  align-items: end;
  justify-content: space-between;
  width: min(620px, calc(100% - 40px));
  padding: 18px 20px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 7px 7px 0 var(--route-gold);
}

.cookie-banner p {
  max-width: 46ch;
  margin: 5px 0 0;
  color: #c7cad3;
  font-size: 0.7rem;
  line-height: 1.45;
}

.cookie-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.cookie-actions .secondary-button {
  color: var(--paper);
}

.cookie-actions .primary-button {
  min-height: 40px;
  padding-inline: 14px;
  font-size: 0.72rem;
  box-shadow: 3px 3px 0 var(--route-gold);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 11;
  max-width: 320px;
  padding: 12px 15px;
  color: var(--paper);
  background: var(--ink);
  font-size: 0.72rem;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

[hidden] {
  display: none !important;
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: auto 1fr;
    gap: 16px;
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 17px;
  }

  .intro h1 {
    max-width: 15ch;
  }

  .intro-note {
    max-width: 55ch;
  }

  .stage-list {
    display: flex;
    overflow-x: auto;
  }

  .stage-button {
    flex: 0 0 142px;
  }
}

@media (max-width: 600px) {
  .page-shell {
    width: min(100% - 28px, 520px);
  }

  .topbar {
    min-height: 64px;
  }

  .topbar-actions {
    gap: 10px;
  }

  .text-button {
    max-width: 36px;
    overflow: hidden;
    padding: 8px 4px;
    border: 0;
    font-size: 0;
  }

  .text-button::before {
    content: "G";
    font-size: 0.78rem;
  }

  .daily-status {
    display: none;
  }

  .friends-grid {
    grid-template-columns: 1fr;
  }

  .main-content {
    gap: 22px;
    padding: 34px 0 58px;
  }

  .intro h1 {
    font-size: clamp(2.7rem, 12vw, 4.2rem);
  }

  .intro-note {
    font-size: 0.8rem;
  }

  .path-heading {
    justify-content: space-between;
  }

  .path-heading span {
    max-width: 24ch;
    text-align: right;
  }

  .practice-heading h2 {
    font-size: 2.6rem;
  }

  .mastery-badge {
    padding: 7px 9px;
  }

  .game-card {
    box-shadow: 5px 5px 0 var(--route-blue);
  }

  .start-view,
  .finish-view,
  .play-view {
    min-height: 470px;
    padding-inline: 22px;
  }

  .flashcard-content {
    padding: 42px 0 28px;
  }

  .stage-glyph {
    width: 124px;
    height: 124px;
    font-size: 5rem;
  }

  .stage-description {
    font-size: 1rem;
  }

  .round-header {
    gap: 9px;
    font-size: 0.62rem;
  }

  .prompt-area {
    min-height: 190px;
  }

  .answer-row {
    grid-template-columns: 1fr;
  }

  .submit-button {
    width: 100%;
  }

  .settings-panel {
    padding: 22px;
  }

  .setting-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .settings-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-footer p {
    max-width: none;
  }

  .cookie-banner {
    right: 14px;
    bottom: 14px;
    width: calc(100% - 28px);
    padding: 16px;
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
  }

  .cookie-actions {
    justify-content: flex-end;
  }

  .toast {
    right: 14px;
    bottom: 14px;
    max-width: calc(100% - 28px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
