@font-face {
  font-family: "Link Sans Product";
  src: url("assets/fonts/LinkSans.woff2") format("woff2");
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
}

:root {
  --page-bg: #93aeb6;
  --panel: #c9f4ff;
  --panel-strong: #b7ecfa;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-solid: #ffffff;
  --text: #06151a;
  --muted: #4d626a;
  --blue: #1477ff;
  --blue-dark: #0757c9;
  --yellow: #ffc842;
  --pink: #ef3654;
  --green: #35b96f;
  --shadow: 0 18px 55px rgba(37, 70, 80, 0.2);
  --soft-shadow: 0 8px 24px rgba(34, 68, 78, 0.12);
}

html[data-theme="dark"] {
  --page-bg: #18242a;
  --panel: #153944;
  --panel-strong: #1c4b57;
  --surface: rgba(246, 251, 252, 0.96);
  --surface-solid: #f7fbfc;
  --text: #ffffff;
  --muted: #cee0e6;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page-bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Link Sans Product", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 4%, rgba(255,255,255,.24), transparent 28%),
    radial-gradient(circle at 88% 90%, rgba(201,244,255,.28), transparent 30%),
    var(--page-bg);
}
button, a { font: inherit; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.game-page {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.game-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.round-button {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: rgba(255,255,255,.88);
  color: #07151a;
  box-shadow: var(--soft-shadow);
}

.game-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: left;
}
.game-brand > div {
  min-width: 0;
}
.game-brand img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 50%;
  background: white;
}
.game-brand h1,
.leaderboard-heading h2,
.meaning-card h2 {
  margin: 0;
  font-weight: 700;
  line-height: 1.15;
}
.game-brand h1 {
  font-size: clamp(20px, 3vw, 31px);
  overflow-wrap: anywhere;
}
.eyebrow,
.intro-kicker,
.overlay-kicker {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--blue-dark);
}
html[data-theme="dark"] .eyebrow,
html[data-theme="dark"] .intro-kicker,
html[data-theme="dark"] .overlay-kicker { color: #7ddfff; }
.topbar-actions { display: flex; gap: 8px; }

.intro-copy {
  max-width: 920px;
  margin: 0 auto 22px;
  padding: 18px 22px;
  border-radius: 24px;
  background: rgba(255,255,255,.78);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(6px);
  text-align: center;
}
.intro-copy p:last-child {
  margin: 0;
  font-size: clamp(16px, 1.65vw, 18px);
  line-height: 1.55;
  color: #36515b;
  font-weight: 600;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}

.game-card,
.leaderboard-card,
.meaning-card {
  border: 1px solid rgba(255,255,255,.55);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.game-card { border-radius: 30px; padding: 16px; }
.leaderboard-card { border-radius: 28px; padding: 20px; }

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, auto)) auto 42px;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.hud-chip,
.hud-icon-button {
  min-height: 42px;
  border: 0;
  border-radius: 16px;
  background: rgba(255,255,255,.82);
  color: #08161b;
  box-shadow: 0 4px 14px rgba(22, 69, 83, .08);
}
.hud-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12px;
}
.hud-chip strong { font-size: 18px; }
.hud-lives { justify-content: center; letter-spacing: 2px; }
.hud-icon-button { width: 42px; }

.chapter-strip {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 11px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.76);
  color: #0b2730;
  box-shadow: 0 5px 16px rgba(22, 69, 83, .08);
}
.chapter-copy {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.chapter-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.chapter-badge {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: #1477ff;
  color: white;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.chapter-progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(20,119,255,.13);
}
.chapter-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1477ff, #54c4ff);
  transition: width .25s ease;
}
.chapter-distance {
  min-width: 74px;
  text-align: right;
  color: #49626b;
  font-size: 11px;
  font-weight: 700;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background: #bfeeff;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.6);
}
#gameCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  touch-action: manipulation;
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 40, 50, .28);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.game-overlay.is-visible { opacity: 1; visibility: visible; }
.overlay-panel {
  width: min(620px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 24px;
  border-radius: 26px;
  background: rgba(255,255,255,.96);
  color: #07151a;
  box-shadow: 0 22px 60px rgba(17, 47, 57, .24);
  text-align: center;
}
.overlay-panel h2 { margin: 0 0 18px; font-size: clamp(20px, 4vw, 30px); }
.compact-panel { width: min(430px, 100%); }

.character-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.character-option {
  min-width: 0;
  border: 2px solid transparent;
  border-radius: 20px;
  padding: 8px;
  background: #eefaff;
  color: #07151a;
  font-weight: 700;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.character-option:hover { transform: translateY(-2px); }
.character-option.is-selected {
  border-color: var(--blue);
  background: #dff5ff;
  box-shadow: 0 0 0 4px rgba(20,119,255,.12);
}
.character-option img {
  width: 100%;
  height: 112px;
  object-fit: contain;
  display: block;
}
.character-option span { display: block; font-size: 12px; }

.player-name-card {
  margin: 14px 0;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-radius: 18px;
  background: #fff7d9;
  text-align: left;
}
.player-name-card span { display: block; font-size: 11px; color: #687279; }
.player-name-card strong { font-size: 17px; }
.player-name-card button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: white;
  color: var(--blue-dark);
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 999px;
  padding: 0 20px;
  font-weight: 700;
}
.primary-button {
  border: 0;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: white;
  box-shadow: 0 10px 22px rgba(20,119,255,.28);
}
.primary-button i { margin-right: 8px; }
.secondary-button {
  border: 1px solid rgba(10,70,90,.16);
  background: rgba(255,255,255,.86);
  color: #07151a;
}
.control-note { margin: 12px 0 0; color: #66767c; font-size: 12px; }

.challenge-icon { font-size: 46px; margin-bottom: 4px; }
.challenge-question-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.challenge-question-row h2 {
  margin: 0;
}
.challenge-voice-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: #e6f6ff;
  color: var(--blue-dark);
  box-shadow: 0 6px 16px rgba(20,119,255,.14);
}
.challenge-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.challenge-choice {
  min-height: 54px;
  border: 2px solid #d7edf4;
  border-radius: 18px;
  padding: 10px 12px;
  background: white;
  color: #07151a;
  font-weight: 700;
}
.challenge-choice:hover { border-color: var(--blue); }
.challenge-choice.is-correct { border-color: var(--green); background: #e9fff2; }
.challenge-choice.is-gentle { border-color: #f7b64a; background: #fff8e9; }
.challenge-feedback { min-height: 24px; margin: 14px 0 0; font-weight: 700; color: var(--blue-dark); }

.final-score {
  margin: 0 auto 14px;
  width: 150px;
  padding: 12px;
  border-radius: 20px;
  background: #e9f8ff;
}
.final-score span { display: block; font-size: 12px; color: #597078; }
.final-score strong { font-size: 34px; color: var(--blue-dark); }
.game-over-panel .secondary-button { margin-top: 10px; }

.floating-message {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 78px;
  transform: translate(-50%, -10px);
  max-width: calc(100% - 36px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  color: #0c2630;
  box-shadow: var(--soft-shadow);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.floating-message.is-visible { opacity: 1; transform: translate(-50%, 0); }

.game-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}
.jump-button {
  min-width: 150px;
  min-height: 58px;
  border: 0;
  border-radius: 22px;
  background: linear-gradient(135deg, #ffdd5f, #ffad33);
  color: #4a2b00;
  box-shadow: 0 10px 20px rgba(255,174,51,.25);
  font-weight: 700;
  font-size: 17px;
}
.jump-button i { margin-right: 8px; }
.jump-button:active { transform: translateY(2px); }
.game-controls p { margin: 0; color: var(--muted); font-size: 13px; }

.leaderboard-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.leaderboard-heading h2 { font-size: 24px; }
.leaderboard-status {
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.78);
  color: #27434c;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.leaderboard-list { list-style: none; padding: 0; margin: 0; }
.leaderboard-entry {
  display: grid;
  grid-template-columns: 30px 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 7px 8px;
  border-radius: 16px;
  background: rgba(255,255,255,.72);
  color: #07151a;
  margin-bottom: 8px;
}
.leaderboard-entry.is-player { box-shadow: 0 0 0 3px rgba(20,119,255,.15); }
.leaderboard-rank { font-weight: 700; color: #60737a; text-align: center; }
.leaderboard-avatar {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 50%;
  background: #eaf9ff;
}
.leaderboard-name { min-width: 0; }
.leaderboard-name strong,
.leaderboard-name span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-name strong { font-size: 13px; }
.leaderboard-name span { font-size: 10px; color: #65747a; }
.leaderboard-score { font-size: 15px; font-weight: 700; color: var(--blue-dark); }
.leaderboard-empty { color: var(--muted); font-size: 13px; text-align: center; }
.leaderboard-refresh { width: 100%; margin-top: 8px; }
.privacy-note { margin: 14px 2px 0; font-size: 11px; color: var(--muted); }

.meaning-card {
  margin-top: 20px;
  padding: 22px;
  border-radius: 28px;
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 16px;
  align-items: center;
}
.meaning-icon {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.82);
  font-size: 26px;
}
.meaning-card h2 { font-size: 21px; }
.meaning-card p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

:focus-visible { outline: 3px solid #1477ff; outline-offset: 3px; }

@media (max-width: 1000px) {
  .game-layout { grid-template-columns: 1fr; }
  .leaderboard-card { max-width: none; }
  .leaderboard-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .leaderboard-entry { margin: 0; }
}

@media (max-width: 700px) {
  .game-page { width: min(100%, 520px); padding: 12px 10px 34px; }
  .game-topbar { grid-template-columns: auto 1fr auto; gap: 8px; }
  .game-brand { justify-content: flex-start; gap: 8px; }
  .game-brand img { width: 42px; height: 42px; }
  .game-brand .eyebrow { display: none; }
  .game-brand h1 { font-size: 18px; line-height: 1.08; }
  .round-button { width: 42px; height: 42px; }
  .topbar-actions { gap: 5px; }
  .intro-copy {
    padding: 14px 16px;
    text-align: left;
  }
  .game-card { border-radius: 24px; padding: 10px; }
  .hud { grid-template-columns: repeat(3, 1fr); }
  .hud-chip { min-width: 0; display: block; text-align: center; padding: 5px; }
  .hud-chip span, .hud-chip strong { display: block; }
  .hud-chip strong { font-size: 15px; }
  .hud-lives { display: none; }
  .hud-icon-button { position: absolute; z-index: 4; right: 16px; top: 68px; background: rgba(255,255,255,.9); }
  .chapter-strip {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 9px 10px;
  }
  .chapter-copy { gap: 7px; }
  .chapter-copy strong { font-size: 12px; }
  .chapter-progress { grid-column: 1 / -1; grid-row: 2; height: 7px; }
  .chapter-distance { grid-column: 2; grid-row: 1; min-width: auto; font-size: 10px; }
  .chapter-badge { padding: 4px 7px; font-size: 9px; }
  .canvas-wrap { border-radius: 18px; }
  .game-overlay { padding: 9px; }
  .overlay-panel { padding: 16px; border-radius: 20px; }
  .selection-panel { max-height: calc(100% - 6px); }
  .selection-panel h2 { margin-bottom: 10px; font-size: 19px; }
  .character-grid { gap: 6px; }
  .character-option { border-radius: 14px; padding: 5px; }
  .character-option img { height: 72px; }
  .character-option span { font-size: 10px; }
  .player-name-card { margin: 8px 0; padding: 8px 10px; }
  .primary-button, .secondary-button { min-height: 42px; }
  .control-note { margin-top: 7px; }
  .challenge-actions { grid-template-columns: 1fr; }
  .game-controls { display: block; }
  .jump-button { width: 100%; min-height: 62px; }
  .game-controls p { margin-top: 10px; text-align: center; }
  .leaderboard-list { grid-template-columns: 1fr; }
  .meaning-card { grid-template-columns: 44px 1fr; padding: 18px; }
  .meaning-icon { width: 44px; height: 44px; border-radius: 14px; }
  .meaning-card h2 { font-size: 18px; }
}

@media (max-width: 380px) {
  .game-brand img { display: none; }
  .game-brand h1 { font-size: 16px; }
  .round-button { width: 38px; height: 38px; }
  .topbar-actions .round-button { width: 36px; height: 36px; }
}

@media (max-width: 700px) {
  .hud {
    grid-template-columns: repeat(3, minmax(0, 1fr)) 42px;
  }

  .hud-icon-button {
    position: static;
    z-index: auto;
    right: auto;
    top: auto;
  }

  .intro-kicker {
    padding-inline: 0;
    margin-bottom: 6px;
    font-size: 11px;
    line-height: 1.4;
  }

  .intro-copy p:last-child {
    font-size: 15px;
    line-height: 1.55;
  }

  /* On phones, decision panels use the full viewport rather than being
     squeezed into the short 16:9 game canvas. */
  .game-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    padding: 12px;
  }

  .game-overlay .overlay-panel {
    width: min(430px, 100%);
    max-height: calc(100dvh - 24px);
  }

  .selection-panel {
    overflow: auto;
  }
}

/* v14 mobile app pass: gameplay first, Play Store wrapper friendly */
@media (max-width: 700px) {
  html,
  body {
    width: 100%;
    min-height: 100%;
    overscroll-behavior: none;
  }

  body {
    background:
      radial-gradient(circle at 18% 0%, rgba(255,255,255,.38), transparent 30%),
      var(--panel);
  }

  .game-page {
    width: 100%;
    min-height: 100dvh;
    padding: max(8px, env(safe-area-inset-top)) 8px calc(104px + env(safe-area-inset-bottom));
  }

  .game-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    margin: 0 0 8px;
    padding: 8px;
    border-radius: 20px;
    background: rgba(255,255,255,.78);
    backdrop-filter: blur(10px);
    box-shadow: var(--soft-shadow);
  }

  .game-brand {
    justify-content: flex-start;
    gap: 8px;
  }

  .game-brand img {
    width: 38px;
    height: 38px;
  }

  .game-brand h1 {
    font-size: clamp(15px, 4.6vw, 18px);
    letter-spacing: -.02em;
  }

  .round-button {
    width: 40px;
    height: 40px;
  }

  .intro-copy,
  .meaning-card {
    display: none;
  }

  .game-layout {
    display: block;
  }

  .game-card {
    padding: 8px;
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(37, 70, 80, .16);
  }

  .hud {
    grid-template-columns: repeat(3, minmax(0,1fr)) 40px;
    gap: 6px;
    margin-bottom: 8px;
  }

  .hud-chip,
  .hud-icon-button {
    min-height: 40px;
    border-radius: 14px;
  }

  .hud-chip {
    padding: 5px 4px;
  }

  .hud-chip span {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .04em;
  }

  .hud-chip strong {
    font-size: 16px;
    line-height: 1.1;
  }

  .chapter-strip {
    margin-bottom: 8px;
    padding: 8px;
    border-radius: 16px;
  }

  .chapter-copy strong {
    font-size: 12px;
  }

  .chapter-badge {
    font-size: 8px;
  }

  .canvas-wrap {
    border-radius: 18px;
  }

  #gameCanvas {
    min-height: 210px;
  }

  .game-controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 0;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(201,244,255,0), rgba(201,244,255,.92) 22%, rgba(201,244,255,.98));
    backdrop-filter: blur(10px);
  }

  .jump-button {
    width: min(100%, 520px);
    margin: 0 auto;
    min-height: 68px;
    border-radius: 24px;
    font-size: 19px;
    box-shadow: 0 12px 24px rgba(255,174,51,.34);
  }

  .game-controls p {
    display: none;
  }

  .leaderboard-card {
    display: none;
  }

  .floating-message {
    top: 66px;
    max-width: calc(100% - 24px);
    border-radius: 18px;
    font-size: 12px;
    text-align: center;
  }

  .game-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    padding: 12px;
    background: rgba(7, 40, 50, .42);
  }

  .game-overlay .overlay-panel {
    width: min(430px, 100%);
    max-height: calc(100dvh - 24px);
    border-radius: 24px;
  }

  .challenge-question-row {
    gap: 8px;
  }

  .challenge-panel h2 {
    font-size: clamp(20px, 5.6vw, 26px);
    line-height: 1.2;
  }

  .challenge-voice-button {
    width: 40px;
    height: 40px;
  }

  .challenge-choice {
    min-height: 58px;
    font-size: 15px;
  }
}

/* v15 desktop immersion pass: the full game should fit above the fold. */
@media (min-width: 701px) {
  html,
  body {
    min-height: 100dvh;
  }

  body {
    overflow: hidden;
  }

  .game-page {
    width: min(1500px, calc(100% - 32px));
    height: 100dvh;
    padding: 12px 0;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 10px;
  }

  .game-topbar {
    width: min(1380px, 100%);
    margin: 0 auto;
    min-height: 54px;
    padding: 6px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.78);
    backdrop-filter: blur(10px);
    box-shadow: var(--soft-shadow);
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .game-brand {
    justify-content: flex-start;
  }

  .round-button {
    width: 42px;
    height: 42px;
  }

  .game-brand img {
    width: 44px;
    height: 44px;
  }

  .game-brand h1 {
    font-size: clamp(24px, 2.45vw, 32px);
  }

  .intro-copy,
  .meaning-card {
    display: none;
  }

  .game-layout {
    width: 100%;
    max-width: 1380px;
    min-height: 0;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1040px) minmax(240px, 286px);
    gap: 14px;
    align-items: start;
    justify-content: center;
  }

  .game-card,
  .leaderboard-card {
    box-shadow: 0 12px 34px rgba(37,70,80,.16);
  }

  .game-card {
    padding: 12px;
    border-radius: 24px;
    max-height: calc(100dvh - 88px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .hud {
    flex: 0 0 auto;
    grid-template-columns: repeat(3, minmax(90px, 1fr)) minmax(140px, .9fr) 40px;
    gap: 7px;
    margin-bottom: 8px;
  }

  .hud-chip,
  .hud-icon-button {
    min-height: 38px;
    border-radius: 14px;
  }

  .hud-chip {
    padding: 6px 10px;
  }

  .hud-chip strong {
    font-size: 17px;
  }

  .chapter-strip {
    flex: 0 0 auto;
    min-height: 42px;
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 16px;
  }

  .canvas-wrap {
    flex: 1 1 auto;
    min-height: 0;
    border-radius: 20px;
  }

  #gameCanvas {
    height: 100%;
    aspect-ratio: auto;
  }

  .game-controls {
    flex: 0 0 auto;
    margin-top: 8px;
  }

  .jump-button {
    min-height: 46px;
    min-width: 132px;
    border-radius: 18px;
    font-size: 15px;
  }

  .game-controls p {
    font-size: 12px;
  }

  .leaderboard-card {
    padding: 16px;
    border-radius: 24px;
    max-height: calc(100dvh - 88px);
    overflow: auto;
  }

  .leaderboard-heading h2 {
    font-size: 22px;
  }

  .leaderboard-entry {
    min-height: 52px;
  }

  .overlay-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .selection-panel {
    width: min(560px, 100%);
  }

  .selection-panel h2 {
    margin-bottom: 12px;
    font-size: clamp(22px, 2.6vw, 30px);
  }

  .character-option img {
    height: 88px;
  }

  .player-name-card {
    margin: 10px 0;
    padding: 10px 12px;
  }

  .primary-button,
  .secondary-button {
    min-height: 42px;
  }

  .control-note {
    margin-top: 8px;
  }
}

@media (min-width: 701px) and (max-height: 860px) {
  .game-page {
    padding: 8px 0;
    gap: 8px;
  }

  .game-topbar {
    min-height: 48px;
    padding: 5px 7px;
  }

  .round-button {
    width: 38px;
    height: 38px;
  }

  .game-brand img {
    width: 38px;
    height: 38px;
  }

  .game-brand h1 {
    font-size: clamp(22px, 2.2vw, 28px);
  }

  .game-layout {
    grid-template-columns: minmax(0, 960px) minmax(230px, 280px);
  }

  .game-card,
  .leaderboard-card {
    max-height: calc(100dvh - 70px);
  }

  .game-card {
    padding: 10px;
  }

  .hud {
    margin-bottom: 6px;
  }

  .hud-chip,
  .hud-icon-button {
    min-height: 34px;
  }

  .chapter-strip {
    min-height: 36px;
    margin-bottom: 6px;
    padding: 7px 10px;
  }

  .game-controls {
    margin-top: 6px;
  }

  .jump-button {
    min-height: 40px;
  }

  .character-option img {
    height: 74px;
  }

  .selection-panel h2 {
    margin-bottom: 8px;
  }
}

/* v15 mobile portrait canvas: larger game window, less blank space. */
@media (max-width: 700px) {
  .game-page {
    padding: max(8px, env(safe-area-inset-top)) 8px calc(96px + env(safe-area-inset-bottom));
  }

  .canvas-wrap {
    min-height: 0;
  }

  #gameCanvas {
    aspect-ratio: 6 / 7;
    min-height: 0;
  }

  .jump-button {
    min-height: 64px;
  }
}

/* v18: polished app-like header + desktop focus mode */
.game-topbar {
  width: 100%;
  min-height: 66px;
  margin: 0 auto 14px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  box-shadow: 0 16px 42px rgba(31, 63, 72, .16);
  backdrop-filter: blur(14px);
}
.game-brand {
  justify-content: flex-start;
  gap: 10px;
  min-width: 0;
}
.game-brand img {
  width: 42px;
  height: 42px;
  box-shadow: 0 4px 14px rgba(20,119,255,.10);
}
.game-brand h1 {
  font-size: clamp(20px, 2vw, 27px);
  letter-spacing: -0.025em;
}
.round-button {
  width: 42px;
  height: 42px;
  background: rgba(255,255,255,.88);
  box-shadow: 0 8px 20px rgba(34, 68, 78, 0.10);
}
.topbar-actions {
  align-items: center;
}
.focus-button {
  display: inline-grid;
}
body.game-focus {
  overflow: hidden;
}
body.game-focus .game-page {
  width: min(1500px, calc(100% - 24px));
  padding-top: 10px;
  padding-bottom: 10px;
}
body.game-focus .intro-copy,
body.game-focus .leaderboard-card,
body.game-focus .meaning-card {
  display: none;
}
body.game-focus .game-layout {
  grid-template-columns: minmax(0, 1fr);
}
body.game-focus .game-topbar {
  min-height: 58px;
  margin-bottom: 10px;
  padding: 6px 9px;
}
body.game-focus .game-brand img {
  width: 38px;
  height: 38px;
}
body.game-focus .game-brand h1 {
  font-size: clamp(19px, 1.7vw, 24px);
}
body.game-focus .game-card {
  max-width: min(1280px, calc((100vh - 190px) * 1.78));
  margin: 0 auto;
  padding: 12px;
  border-radius: 26px;
}
body.game-focus .hud {
  margin-bottom: 9px;
}
body.game-focus .chapter-strip {
  margin-bottom: 9px;
  padding: 9px 12px;
}
body.game-focus .canvas-wrap {
  border-radius: 22px;
}
body.game-focus .game-controls {
  margin-top: 9px;
}
body.game-focus .jump-button {
  min-height: 48px;
  border-radius: 18px;
}
body.game-focus .focus-button i::before {
  content: "\f066";
}

@media (max-width: 700px) {
  .game-topbar {
    min-height: 76px;
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 28px;
  }
  .game-brand img {
    width: 42px;
    height: 42px;
  }
  .game-brand h1 {
    font-size: 18px;
    letter-spacing: -0.02em;
  }
  .focus-button {
    display: none;
  }
  body.game-focus {
    overflow: auto;
  }
}

/* v1.0.5: stacked pause actions */
.pause-panel {
  width: min(460px, 100%);
}
.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px, 100%);
  margin: 0 auto;
}
.pause-actions .primary-button,
.pause-actions .secondary-button,
.pause-home-link {
  width: 100%;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.pause-home-link {
  min-height: 52px;
}
@media (max-width: 700px) {
  .pause-panel {
    width: min(360px, 100%);
  }
  .pause-actions {
    width: 100%;
    gap: 10px;
  }
  .pause-actions .primary-button,
  .pause-actions .secondary-button,
  .pause-home-link {
    min-height: 48px;
  }
}

