/* ─── Self-hosted fonts (eliminates Google Fonts CDN waterfall) ─── */
@font-face {
  font-family: "Bangers";
  src: url("./assets/fonts/bangers-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("./assets/fonts/nunito-latin-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("./assets/fonts/nunito-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("./assets/fonts/nunito-latin-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-deep: #1a1644;
  --bg-mid: #2d2a68;
  --panel: rgba(20, 27, 56, 0.84);
  --panel-border: rgba(255, 255, 255, 0.2);
  --text: #f9fbff;
  --gold: #ffd56a;
  --orange: #ff8e42;
  --mint: #74f3d8;
  --danger: #ff6978;
  --shadow: 0 12px 32px rgba(8, 12, 30, 0.42);
  --app-height: 100vh;
  --viewport-safe-height: calc(var(--app-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  --touch-controls-size: 92px;
  --touch-controls-gap: 8px;
  --touch-controls-padding-x: 10px;
  --touch-controls-bottom-padding: calc(20px + env(safe-area-inset-bottom));
  --touch-controls-top-padding: 12px;
  --touch-controls-zone-height: calc(var(--touch-controls-size) + var(--touch-controls-top-padding) + var(--touch-controls-bottom-padding));
  --controls-safe-bottom-gap: max(20px, env(safe-area-inset-bottom));
  --question-panel-bottom-clearance: calc(var(--touch-controls-zone-height) + 16px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: "Nunito", "Trebuchet MS", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background-image: image-set(
    url("game_assets/backgrounds/fullscreenbackground.webp") type("image/webp"),
    url("game_assets/backgrounds/fullscreenbackground.png") type("image/png")
  );
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

body {
  display: grid;
  place-items: center;
  min-height: var(--app-height);
  padding: 8px;
  overflow: hidden;
  overscroll-behavior: none;
}

.app {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 100vw;
  min-height: var(--app-height);
  height: var(--app-height);
  padding: env(safe-area-inset-top) 8px env(safe-area-inset-bottom);
}

.game-shell {
  position: relative;
  width: min(100%, 560px, calc((var(--app-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 8px) * 9 / 16));
  max-height: min(900px, calc(var(--app-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 8px));
  aspect-ratio: 9 / 16;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border-radius: 30px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: var(--shadow);
  background-image: image-set(
    url("game_assets/backgrounds/fullscreenbackground.webp") type("image/webp"),
    url("game_assets/backgrounds/fullscreenbackground.png") type("image/png")
  );
  background-size: cover;
  background-position: center;
}

.game-viewport {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: transparent;
  display: grid;
  place-items: start center;
  container-type: size;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
  image-rendering: pixelated;
}

@supports (width: 1cqw) {
  #gameCanvas {
    width: min(100cqw, calc(100cqh * 9 / 16));
    height: min(100cqh, calc(100cqw * 16 / 9));
  }
}

.hud {
  --hud-row-size: 56px;
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  min-height: var(--hud-row-size);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) var(--hud-row-size) var(--hud-row-size);
  align-items: stretch;
  gap: 8px;
}

.hud-info {
  display: contents;
}

.hud-item {
  min-height: var(--hud-row-size);
  height: var(--hud-row-size);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  text-align: center;
  touch-action: none;
  -webkit-touch-callout: none;
}

.hud-label {
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 1;
}

#hudScoreValue,
#hudLives,
#hudGoldValue {
  font-size: 0.98rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

#hudLives {
  font-size: 0.68rem;
  line-height: 1;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

#hudScoreValue {
  cursor: pointer;
}

.hud-actions {
  display: contents;
  pointer-events: auto;
}

.icon-button {
  width: 100%;
  height: var(--hud-row-size);
  display: block;
  border: none;
  background: transparent;
  padding: 0;
  margin-top: 0;
}

.icon-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.controls-zone {
  position: relative;
  padding: 12px 10px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
}


.touch-hit-zone {
  display: none;
}

.touch-hit-btn {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  width: 100%;
}

.touch-btn {
  width: min(21vw, 92px);
  justify-self: center;
  aspect-ratio: 1 / 1;
  max-height: 78px;
  border: none;
  background: transparent;
  padding: 0;
}

#jumpBtn {
  grid-column: 4;
  justify-self: end;
}

#jumpHitBtn {
  grid-column: 4;
  justify-self: end;
}

.touch-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 5px 4px rgba(0, 0, 0, 0.4));
}

.touch-btn:active img,
.touch-btn.active img {
  transform: scale(0.95);
  opacity: 0.9;
}

.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92%, 400px);
  max-height: calc(100% - 40px);
  overflow-y: auto;
  background: rgba(11, 18, 43, 0.95);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 14px;
  z-index: 70;
  box-shadow: 0 16px 30px rgba(4, 8, 20, 0.58);
}

.panel h1 {
  margin: 0 0 10px;
  font-family: "Bangers", cursive;
  letter-spacing: 0.05em;
  font-size: 1.8rem;
  color: #ffe17e;
}

.panel h2 {
  margin: 12px 0 8px;
  font-size: 1rem;
}

.hero-shop {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.shop-wallet {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 213, 106, 0.45);
  background: linear-gradient(180deg, rgba(52, 36, 6, 0.85), rgba(24, 18, 7, 0.85));
  font-size: 0.9rem;
}

.shop-wallet strong {
  color: #ffd56a;
  font-size: 1rem;
}

.hero-shop-list {
  display: grid;
  gap: 10px;
}

.hero-shop-item {
  display: grid;
  grid-template-columns: 68px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(8, 12, 28, 0.55);
}

.hero-shop-preview {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(180deg, rgba(121, 155, 218, 0.22), rgba(47, 79, 159, 0.12));
}

.hero-shop-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.hero-shop-item.locked .hero-shop-preview img {
  filter: grayscale(1) brightness(0.8);
}

.hero-shop-lock {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 18, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 12px;
}

.hero-shop-meta {
  line-height: 1.3;
}

.hero-shop-name {
  font-weight: 800;
}

.hero-shop-price {
  font-size: 0.82rem;
  opacity: 0.95;
}

.hero-shop-price .amount {
  color: #ffd56a;
  font-weight: 800;
}

.hero-shop-btn {
  min-width: 96px;
  padding: 8px 10px;
  border-radius: 10px;
  border: none;
  color: #f7fbff;
  font-weight: 800;
  background: linear-gradient(180deg, #4f74d4, #2f4f9f);
  box-shadow: 0 3px 0 #1b2f65;
}

.hero-shop-btn.buy {
  background: linear-gradient(180deg, #ffb15c, #e16b35);
  box-shadow: 0 3px 0 #9f381d;
}

.hero-shop-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  background: linear-gradient(180deg, #98a4be, #6c7892);
  box-shadow: 0 3px 0 #495166;
}

.panel label {
  display: block;
  margin: 10px 0 6px;
  font-size: 0.9rem;
}

.panel select,
.panel button {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #f7fbff;
  padding: 10px;
  font-size: 0.95rem;
  font-weight: 800;
}

.panel select {
  appearance: none;
  background: rgba(8, 12, 28, 0.72);
}

.panel button {
  border: none;
  background: linear-gradient(180deg, #ffb15c, #e16b35);
  box-shadow: 0 4px 0 #9f381d;
}

.panel button.secondary,
.panel .secondary {
  background: linear-gradient(180deg, #4f74d4, #2f4f9f);
  box-shadow: 0 4px 0 #1b2f65;
}


.panel input[type="range"] {
  width: 100%;
  margin: 2px 0 0;
}

.slider-hint-row {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.76rem;
  opacity: 0.9;
}


.settings-apply-row {
  margin-top: 14px;
}

.settings-apply-row button {
  width: 100%;
}

.settings-secondary-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}


.settings-danger-row {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.settings-danger-row button {
  width: 100%;
}

.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.panel-actions-center {
  grid-template-columns: minmax(0, 210px);
  justify-content: center;
}

.pedagogy {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
}

.check-grid label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
}


.pedagogy-block {
  margin-top: 10px;
}

.device-mode-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(7, 10, 24, 0.5);
}

.device-mode-indicator strong {
  color: #ffe17e;
}

.group-verb-lists {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.group-verb-list {
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(7, 10, 24, 0.5);
}

.group-verb-title {
  margin: 0 0 2px;
  font-weight: 800;
  font-size: 0.78rem;
  color: #ffe17e;
}

.group-verb-items {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.3;
  opacity: 0.95;
}

.error-tools {
  margin-top: 8px;
}

.error-list {
  margin-top: 8px;
  max-height: 120px;
  overflow: auto;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
  font-size: 12px;
}

.error-row {
  margin: 0 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.16);
}

.error-row:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.question-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(90%, 400px);
  max-height: calc(100% - 200px);
  overflow-y: auto;
  z-index: 72;
  border-radius: 10px;
  padding: 10px 14px;
  text-align: center;
  background: linear-gradient(180deg, rgba(8, 14, 32, 0.96), rgba(10, 16, 38, 0.96));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}


.question-actors {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 2px;
  margin: 0 0 2px;
}

.question-actor {
  display: grid;
  place-items: center;
  min-width: 62px;
}

.question-actor-hero {
  justify-self: end;
}

.question-actor-enemy {
  justify-self: start;
}

.question-actor-sprite {
  width: 36px;
  height: 36px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 2px rgba(0, 0, 0, 0.35));
}

.question-ask-icon {
  font-size: 1rem;
  color: #ffe17e;
  line-height: 1;
  transform: translateY(-2px);
}

.question-actor-enemy .question-actor-sprite {
  transform: none;
}

.question-enemy {
  margin: 0;
  font-size: 2.2rem;
  line-height: 1;
}

.question-group {
  margin: 0 0 2px;
  font-size: 0.65rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: rgba(210, 230, 255, 0.85);
}

.question-tense {
  margin: 0 0 4px;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: #ffe17e;
  font-weight: 800;
}


.question-countdown {
  margin: 0 0 4px;
  font-size: 0.85rem;
  font-weight: 800;
  color: #ffd56a;
}

.question-prompt {
  margin: 0 0 6px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.question-prompt .verb {
  color: #ffcf73;
  font-weight: 800;
}

.question-prompt .pronoun {
  color: #86c6ff;
  font-weight: 800;
}

.question-prompt .blank {
  display: inline-block;
  min-width: 72px;
  padding: 0 6px;
  border-bottom: 2px solid #ffcf73;
  color: #ffcf73;
  font-weight: 800;
}

.answer-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.answer-btn {
  text-align: center;
  border: 2px solid rgba(129, 177, 255, 0.7);
  border-radius: 8px;
  min-height: 42px;
  color: #f7fbff;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: rgba(72, 114, 204, 0.22);
  box-shadow: none;
}

.question-panel .answer-btn:disabled {
  opacity: 1;
}

.answer-btn.selected {
  outline: 2px solid #67d3ff;
}

.answer-btn.correct {
  background: rgba(68, 190, 99, 0.45);
  border-color: rgba(116, 242, 149, 0.75);
}

.answer-btn.wrong {
  background: rgba(201, 71, 71, 0.4);
  border-color: rgba(255, 117, 117, 0.8);
}

.title-screen {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding:
    max(18px, calc(env(safe-area-inset-top) + 18px))
    max(18px, calc(env(safe-area-inset-right) + 18px))
    max(18px, calc(env(safe-area-inset-bottom) + 18px))
    max(18px, calc(env(safe-area-inset-left) + 18px));
  overflow-y: auto;
  background: radial-gradient(circle at 80% 20%, rgba(255, 234, 153, 0.22), transparent 42%);
}

.title-card {
  width: min(100%, 420px);
  min-height: auto;
  border-radius: 20px;
  padding: clamp(18px, 4vw, 28px) 16px;
  background: rgba(10, 16, 38, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 14px 34px rgba(5, 8, 22, 0.48);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(10px, 2vh, 18px);
}

.title-kicker {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  opacity: 0.86;
}

.title-card h1 {
  margin: 4px 0 10px;
  font-family: "Bangers", cursive;
  font-size: 2.5rem;
  letter-spacing: 0.07em;
  color: #ffe17e;
}

.title-card p {
  margin: 0;
  line-height: 1.5;
}

.title-actions {
  display: grid;
  gap: 10px;
  margin-top: auto;
}


.leaderboard-list {
  margin: 8px 0 12px;
  padding-left: 20px;
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  text-align: left;
}

.leaderboard-entry,
.leaderboard-empty {
  color: rgba(245, 248, 255, 0.95);
}

.title-actions button,
.menu-actions button {
  border: none;
  border-radius: 12px;
  min-height: 44px;
  color: #f7fbff;
  font-weight: 800;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, #ffb15c, #e16b35);
  box-shadow: 0 4px 0 #9f381d;
}

#openLeaderboardBtn,
#openSettingsFromTitleBtn,
#openSettingsFromPauseBtn,
.secondary-btn {
  background: linear-gradient(180deg, #4f74d4, #2f4f9f);
  box-shadow: 0 4px 0 #1b2f65;
}

.menu-modal {
  position: absolute;
  inset: 0;
  z-index: 65;
  display: grid;
  place-items: center;
  padding:
    max(16px, calc(env(safe-area-inset-top) + 16px))
    max(16px, calc(env(safe-area-inset-right) + 16px))
    max(16px, calc(env(safe-area-inset-bottom) + 16px))
    max(16px, calc(env(safe-area-inset-left) + 16px));
  overflow-y: auto;
  background: rgba(5, 10, 24, 0.72);
}

.menu-card {
  width: min(100%, 360px);
  max-height: 100%;
  overflow-y: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(11, 18, 43, 0.96);
  box-shadow: 0 16px 30px rgba(4, 8, 20, 0.58);
  padding: 16px;
  text-align: center;
}

.menu-card h2 {
  margin: 0;
  font-family: "Bangers", cursive;
  letter-spacing: 0.05em;
  font-size: 1.8rem;
  color: #ffe17e;
}

.menu-card p {
  margin: 4px 0 12px;
}

.cheat-card {
  display: grid;
  gap: 8px;
  text-align: left;
}

.cheat-card label {
  font-size: 0.85rem;
  font-weight: 700;
  color: rgba(245, 248, 255, 0.95);
}

.cheat-card select {
  width: 100%;
}

.cheat-zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

#cheatWorldZoomSlider {
  flex: 1;
}

#cheatWorldZoomValue {
  min-width: 52px;
  text-align: right;
}

.menu-actions {
  display: grid;
  gap: 8px;
}

.parental-code-card {
  text-align: left;
  display: grid;
  gap: 10px;
}

.parental-code-card h2,
.parental-code-card p {
  text-align: center;
}

.parental-code-card p {
  white-space: pre-line;
}

.parental-code-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

#parentalCodeInput {
  width: 100%;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(2, 8, 24, 0.82);
  color: #f7fbff;
  padding: 8px 10px;
  font: inherit;
}

.parental-eye-btn {
  min-width: 46px;
  font-size: 1.1rem;
  line-height: 1;
}

.game-over {
  position: absolute;
  inset: 10% 8% 6%;
  background: rgba(17, 22, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  text-align: center;
  padding: 14px;
  gap: 10px;
  overflow-y: auto;
  z-index: 61;
}

.game-over h2 {
  margin: 0;
  font-family: "Bangers", cursive;
  font-size: 2rem;
  letter-spacing: 0.08em;
}

.game-over p {
  margin: 0;
}

.final-score-text {
  font-weight: 800;
  color: #ffe083;
}

.final-coins-text {
  font-weight: 800;
  color: #7ff7d9;
}

.boss-defeat {
  border-color: rgba(255, 117, 117, 0.5);
  background: rgba(38, 14, 14, 0.92);
}

.final-victory {
  border-color: rgba(127, 247, 217, 0.45);
  background: rgba(10, 28, 30, 0.92);
}


.debug-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92%, 420px);
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(10, 16, 34, 0.72);
  backdrop-filter: blur(3px);
  z-index: 85;
  display: grid;
  gap: 8px;
}

.debug-panel h2 {
  margin: 0;
  font-family: "Bangers", cursive;
  letter-spacing: 0.05em;
}

.debug-panel p {
  margin: 0;
  opacity: 0.9;
}

.debug-slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.debug-output {
  margin: 0;
  padding: 8px;
  max-height: 180px;
  overflow-y: auto;
  font-size: 10px;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 767px) {
  body {
    padding: 0;
  }

  .app {
    padding: 0;
  }

  .game-shell {
    width: 100%;
    max-width: none;
    height: var(--viewport-safe-height);
    max-height: none;
    aspect-ratio: auto;
    border-width: 0;
    border-radius: 0;
    box-shadow: none;
    grid-template-rows: 1fr;
  }

  .game-viewport {
    position: absolute;
    inset: 0 0 var(--mobile-game-area-bottom) 0;
    min-height: 0;
    display: flex;
    align-items: flex-end;
  }

  #gameCanvas {
    width: 100%;
    height: auto;
    max-height: none;
  }

  .controls-zone {
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--mobile-buttons-bottom);
    z-index: 40;
    padding:
      var(--touch-controls-top-padding)
      var(--touch-controls-padding-x)
      var(--touch-controls-bottom-padding);
    border-top: none;
    background: linear-gradient(180deg, rgba(28, 53, 86, 0), rgba(34, 76, 138, 0.22) 26%, rgba(34, 76, 138, 0.4) 100%);
    pointer-events: none;
  }

  .touch-controls {
    align-items: end;
  }

  .touch-btn {
    width: min(22vw, var(--touch-controls-size));
    max-height: none;
    pointer-events: auto;
    opacity: 0.7;
  }

  #jumpBtn,
  #jumpHitBtn {
    align-self: end;
  }

  .hud {
    top: calc(env(safe-area-inset-top) + 8px);
  }

  .panel {
    top: calc(env(safe-area-inset-top) + 16px);
    bottom: calc(env(safe-area-inset-bottom) + 16px);
    transform: translateX(-50%);
    width: min(94%, 420px);
    max-height: none;
   }

  .question-panel {
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(90%, 400px);
    max-height: calc(100% - 140px);
    padding: 10px 14px;
  }

  .menu-modal {
    place-items: stretch center;
  }

  .menu-card {
    align-self: center;
  }

  .icon-button {
    opacity: 1;
    margin-top: 0;
  }
}

@media (min-width: 768px) {
  .app {
    padding-bottom: var(--controls-safe-bottom-gap);
  }

  .game-shell {
    height: min(900px, calc(var(--viewport-safe-height) - var(--controls-safe-bottom-gap)));
    max-height: min(900px, calc(var(--viewport-safe-height) - var(--controls-safe-bottom-gap)));
  }

  .controls-zone {
    padding-bottom: calc(20px + var(--controls-safe-bottom-gap));
  }
}

.hidden,
[hidden] {
  display: none !important;
}

@media (max-height: 690px) {
  .hud {
    top: 4px;
    --hud-row-size: 50px;
  }
  .hud-item {
    min-height: var(--hud-row-size);
  }

  .controls-zone {
    padding-top: 6px;
  }

  .touch-btn {
    max-height: 80px;
  }

  .game-shell {
    min-height: 600px;
  }
}

@supports (-webkit-touch-callout: none) {
  @media (max-width: 767px) {
    .touch-hit-zone {
      position: absolute;
      left: var(--touch-controls-padding-x);
      right: var(--touch-controls-padding-x);
      top: var(--touch-controls-top-padding);
      bottom: var(--touch-controls-bottom-padding);
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      align-items: center;
      gap: var(--touch-controls-gap);
      pointer-events: none;
    }

    .touch-hit-btn {
      width: min(22vw, var(--touch-controls-size));
      min-height: 56px;
      justify-self: center;
      border-radius: 14px;
      pointer-events: auto;
    }
  }
}

.warn-btn {
  border: none;
  background: linear-gradient(180deg, #ffb15c, #e16b35);
  box-shadow: 0 4px 0 #9f381d;
  color: #f7fbff;
}

.reset-confirm-card {
  max-width: 520px;
}

.reset-confirm-card p {
  margin: 0;
  line-height: 1.4;
}

.reset-confirm-actions {
  margin-top: 6px;
}

#resetGameConfirmModal {
  z-index: 120;
}

/* ─── Japanese (CJK) font overrides ─── */
:root[data-target-lang="ja"] .question-prompt,
:root[data-target-lang="ja"] .answer-btn,
:root[data-target-lang="ja"] .question-tense,
:root[data-target-lang="ja"] .question-group,
:root[data-target-lang="ja"] .error-list,
:root[data-target-lang="ja"] .check-grid {
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Meiryo", "Noto Sans CJK JP", sans-serif;
}

:root[data-target-lang="ja"] .answer-btn {
  font-size: 1rem;
  letter-spacing: 0;
}

:root[data-target-lang="ja"] .question-prompt {
  font-size: 1rem;
}
