/* ============================================================
   NINJA TOÁN HỌC – style.css
   Giao diện thân thiện với trẻ nhỏ, tối ưu cho iPad (cảm ứng)
   ============================================================ */

:root {
  --font: "Baloo 2", "Arial Rounded MT Bold", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --orange: #ff6b35;
  --orange-dark: #d84f1d;
  --teal: #2ec4b6;
  --teal-dark: #1e9a8e;
  --yellow: #ffd166;
  --yellow-dark: #e0a800;
  --purple: #7b5ea7;
  --purple-dark: #5a3f85;
  --green: #06d6a0;
  --green-dark: #04a67c;
  --red: #ef476f;
  --red-dark: #c42b52;
  --blue: #118ab2;
  --blue-dark: #0c6a8a;
  --ink: #2b2d42;
  --ink-soft: #5b5f7a;
  --paper: #ffffff;
  --paper-soft: #fff8ec;
  --shadow: 0 12px 40px rgba(20, 30, 60, 0.22);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #6ec6ff;
  font-family: var(--font);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- Màn hình (overlay) ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sat) + 12px) calc(var(--sar) + 12px) calc(var(--sab) + 12px) calc(var(--sal) + 12px);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.25s ease;
}
.screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.screen > * { pointer-events: auto; }
.screen.dim { background: rgba(20, 30, 60, 0.45); }

.panel {
  background: var(--paper);
  border-radius: 32px;
  padding: 28px 30px;
  max-width: 760px;
  width: min(100%, 760px);
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  box-shadow: var(--shadow);
  text-align: center;
  position: relative;
}
.panel.wide { max-width: 900px; width: min(100%, 900px); }
.panel h1, .panel h2 {
  margin: 0 0 8px;
  font-weight: 800;
  line-height: 1.1;
}
.panel h2 { font-size: 34px; color: var(--ink); }
.panel p { margin: 6px 0; font-size: 19px; color: var(--ink-soft); font-weight: 600; }

/* ---------- Nút bấm ---------- */
.btn {
  font-family: var(--font);
  font-weight: 800;
  font-size: 24px;
  line-height: 1;
  border: none;
  border-radius: 999px;
  padding: 18px 34px;
  min-height: 62px;
  color: #fff;
  background: linear-gradient(180deg, var(--orange) 0%, #ff8b5a 100%);
  box-shadow: 0 7px 0 var(--orange-dark), 0 12px 24px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn:active, .btn.pressed {
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--orange-dark), 0 4px 10px rgba(0, 0, 0, 0.18);
}
.btn.big { font-size: 32px; padding: 22px 46px; min-height: 78px; }
.btn.teal { background: linear-gradient(180deg, var(--teal), #4fd8cb); box-shadow: 0 7px 0 var(--teal-dark), 0 12px 24px rgba(0,0,0,0.18); }
.btn.teal:active { box-shadow: 0 2px 0 var(--teal-dark), 0 4px 10px rgba(0,0,0,0.18); }
.btn.purple { background: linear-gradient(180deg, var(--purple), #9b7fc7); box-shadow: 0 7px 0 var(--purple-dark), 0 12px 24px rgba(0,0,0,0.18); }
.btn.purple:active { box-shadow: 0 2px 0 var(--purple-dark), 0 4px 10px rgba(0,0,0,0.18); }
.btn.green { background: linear-gradient(180deg, var(--green), #3ee8b8); box-shadow: 0 7px 0 var(--green-dark), 0 12px 24px rgba(0,0,0,0.18); }
.btn.green:active { box-shadow: 0 2px 0 var(--green-dark), 0 4px 10px rgba(0,0,0,0.18); }
.btn.blue { background: linear-gradient(180deg, var(--blue), #2aa8d4); box-shadow: 0 7px 0 var(--blue-dark), 0 12px 24px rgba(0,0,0,0.18); }
.btn.blue:active { box-shadow: 0 2px 0 var(--blue-dark), 0 4px 10px rgba(0,0,0,0.18); }
.btn.ghost {
  background: #f1f3fa;
  color: var(--ink);
  text-shadow: none;
  box-shadow: 0 6px 0 #cfd4e6, 0 8px 16px rgba(0,0,0,0.08);
}
.btn.ghost:active { box-shadow: 0 2px 0 #cfd4e6; }
.btn.small { font-size: 19px; padding: 12px 22px; min-height: 50px; }
.btn.icon {
  width: 60px; height: 60px; min-height: 60px;
  padding: 0; font-size: 28px; border-radius: 50%;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 18px;
}

/* ---------- Menu chính ---------- */
#menu .panel {
  background: rgba(255, 255, 255, 0.94);
  padding: 22px 30px 26px;
}
.logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}
.logo-row svg {
  width: 150px;
  height: 150px;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,0.18));
  animation: logo-bob 3s ease-in-out infinite;
}
@keyframes logo-bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-10px) rotate(3deg); }
}
.title {
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 800;
  line-height: 0.95;
  margin: 0;
  background: linear-gradient(180deg, #ff6b35 0%, #ff3d77 55%, #7b5ea7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 0;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,0.12));
  letter-spacing: -1px;
}
.title small {
  display: block;
  font-size: 0.42em;
  letter-spacing: 3px;
  color: var(--teal-dark);
  background: none;
  -webkit-text-fill-color: var(--teal-dark);
}
.subtitle { font-size: 21px; color: var(--ink-soft); margin: 10px 0 18px; font-weight: 700; }
.menu-options {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
}
.chip-group {
  display: inline-flex;
  background: #eef1f8;
  border-radius: 999px;
  padding: 5px;
  gap: 4px;
}
.chip-group button {
  font-family: var(--font);
  font-weight: 800;
  font-size: 17px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  padding: 9px 16px;
  min-height: 42px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}
.chip-group button.on {
  background: #fff;
  color: var(--orange-dark);
  box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}
.chip-label { font-size: 17px; font-weight: 800; color: var(--ink-soft); margin-right: 4px; }
.toggle-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.toggle {
  font-family: var(--font);
  font-weight: 800;
  font-size: 16px;
  border: 3px solid #dfe3ef;
  background: #f1f3fa;
  color: var(--ink-soft);
  padding: 8px 14px;
  min-height: 42px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s;
}
.toggle:active { transform: scale(0.96); }
.toggle.on { background: #e3fff4; border-color: var(--green); color: #05603f; }
.toggle.off { text-decoration: line-through; opacity: 0.8; }
.toggle[disabled] { opacity: 0.5; cursor: default; text-decoration: none; }
.footer-note { margin-top: 14px; font-size: 15px; color: #98a0bd; font-weight: 700; }
.footer-note a { color: var(--blue); text-decoration: none; }

/* ---------- Chọn màn ---------- */
.screen-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.screen-head h2 { flex: 1; text-align: center; margin: 0; }
.tabs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 8px 0 16px;
}
.tab {
  font-family: var(--font);
  font-weight: 800;
  font-size: 20px;
  border: 3px solid #e4e8f3;
  background: #f6f7fb;
  color: var(--ink-soft);
  padding: 12px 24px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 54px;
}
.tab.on { background: var(--yellow); border-color: var(--yellow-dark); color: #6a4a00; }
.mode-desc { font-size: 18px; margin: -6px 0 14px; }
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px;
  text-align: left;
}
.level-card {
  position: relative;
  background: linear-gradient(180deg, #ffffff, #f4f6fc);
  border: 3px solid #e3e7f2;
  border-radius: 24px;
  padding: 16px 16px 14px;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 6px 0 #dfe3ef;
  transition: transform 0.08s;
  min-height: 150px;
  display: flex;
  flex-direction: column;
}
.level-card:active { transform: translateY(4px); box-shadow: 0 2px 0 #dfe3ef; }
.level-card .icon { font-size: 40px; line-height: 1; }
.level-card .name { font-size: 22px; font-weight: 800; margin-top: 6px; line-height: 1.15; }
.level-card .desc { font-size: 15px; color: var(--ink-soft); font-weight: 600; margin-top: 2px; }
.level-card .grade {
  position: absolute; top: 12px; right: 12px;
  font-size: 13px; font-weight: 800; color: #fff;
  background: var(--purple); border-radius: 999px; padding: 4px 10px;
}
.level-card .grade.g1 { background: var(--green-dark); }
.level-card .grade.g2 { background: var(--blue); }
.level-card .grade.g3 { background: var(--purple); }
.level-card .grade.gx { background: var(--red); }
.level-card .meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto; padding-top: 10px; font-size: 16px; font-weight: 800;
}
.level-card .best { color: var(--orange-dark); }
.level-card .stars { color: #ffbf1f; letter-spacing: 2px; font-size: 20px; }
.level-card .stars .off { color: #d5d9e6; }

/* ---------- HUD ---------- */
#hud {
  align-items: flex-start;
  justify-content: stretch;
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 10px) 0 calc(var(--sal) + 10px);
}
#hud > * { pointer-events: none; }
.hud-top {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "left center right";
  align-items: start;
  gap: 10px;
}
.hud-left { grid-area: left; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.hud-center { grid-area: center; }
.hud-right { grid-area: right; display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.score-box {
  background: rgba(255,255,255,0.92);
  border-radius: 18px;
  padding: 6px 16px 4px;
  min-width: 120px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  line-height: 1;
}
.score-box .label { display: block; font-size: 13px; letter-spacing: 2px; font-weight: 800; color: var(--ink-soft); }
.score-box .value { display: block; font-size: 34px; font-weight: 800; color: var(--orange-dark); transition: transform 0.1s; }
.score-box .value.bump { transform: scale(1.18); }
.stage-chip {
  background: var(--purple); color: #fff; font-weight: 800; font-size: 15px;
  padding: 5px 12px; border-radius: 999px; box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}
.combo-chip {
  background: linear-gradient(90deg, #ff7a00, #ffb800); color: #fff; font-weight: 800; font-size: 16px;
  padding: 5px 12px; border-radius: 999px; box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  transform-origin: left center;
  animation: chip-pop 0.3s ease;
}
@keyframes chip-pop { 0% { transform: scale(0.5); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

.hud-center { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.question-card {
  background: #fff;
  border-radius: 24px;
  padding: 8px 30px 6px;
  font-size: clamp(34px, 5.6vw, 58px);
  font-weight: 800;
  color: var(--ink);
  box-shadow: 0 8px 0 #dfe3ef, 0 14px 30px rgba(0,0,0,0.18);
  line-height: 1.1;
  min-width: 240px;
  text-align: center;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.2s;
}
.question-card .q { color: var(--orange); display: inline-block; animation: q-bounce 0.9s ease-in-out infinite; }
.question-card .held { color: var(--teal-dark); }
@keyframes q-bounce { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-5px) } }
.question-card.pop { animation: card-pop 0.35s ease; }
@keyframes card-pop { 0% { transform: scale(0.7); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
.question-card.shake { animation: card-shake 0.4s ease; background: #ffe3e8; }
@keyframes card-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(5px); }
}
.question-card.ok { background: #e3fff4; }
.timer {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.9);
  border-radius: 999px;
  padding: 4px 12px 4px 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.timer .bar { width: 150px; height: 12px; background: #e6e9f3; border-radius: 999px; overflow: hidden; }
.timer .fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--teal), var(--green)); border-radius: 999px; transition: width 0.25s linear; }
.timer .fill.warn { background: linear-gradient(90deg, #ff8a00, #ffcf00); }
.timer .fill.danger { background: linear-gradient(90deg, #ff2d55, #ff7a90); }
.timer .time { font-weight: 800; font-size: 19px; color: var(--ink); min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.timer.danger .time { color: var(--red); animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.hint {
  background: rgba(43,45,66,0.92); color: #fff; font-weight: 800; font-size: 21px;
  padding: 6px 18px; border-radius: 999px; box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  max-width: 92vw; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  animation: chip-pop 0.3s ease;
}
.hint.bad { background: var(--red); }
.hint.ok { background: var(--green); color: #063b2c; }
.hearts { display: flex; gap: 4px; background: rgba(255,255,255,0.9); border-radius: 999px; padding: 6px 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.hearts span { font-size: 28px; line-height: 1; transition: transform 0.2s, filter 0.2s; display: inline-block; }
.hearts span.lost { filter: grayscale(1) opacity(0.35); transform: scale(0.8); }
.hearts span.gain { animation: heart-gain 0.5s ease; }
.hearts.hit { animation: hearts-hit 0.45s ease; }
@keyframes heart-gain { 0% { transform: scale(0.3); } 60% { transform: scale(1.4); } 100% { transform: scale(1); } }
@keyframes hearts-hit { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-4px); } }

#btn-pause {
  pointer-events: auto;
  width: 56px; height: 56px; min-height: 56px; padding: 0;
  font-size: 24px; border-radius: 50%;
  background: rgba(255,255,255,0.92); color: var(--ink);
  box-shadow: 0 5px 0 #cfd4e6, 0 8px 16px rgba(0,0,0,0.12);
  text-shadow: none;
}
#btn-pause:active { box-shadow: 0 1px 0 #cfd4e6; }

/* ---------- Đếm ngược ---------- */
#countdown { pointer-events: none; }
#countdown .count {
  font-size: clamp(120px, 28vw, 260px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 8px 0 rgba(0,0,0,0.18), 0 0 40px rgba(255,255,255,0.7);
  -webkit-text-stroke: 4px var(--orange-dark);
  line-height: 1;
  animation: count-pop 1s ease both;
}
#countdown .count.go { color: var(--yellow); -webkit-text-stroke: 4px var(--red-dark); font-size: clamp(90px, 20vw, 190px); }
@keyframes count-pop {
  0% { transform: scale(0.2); opacity: 0; }
  25% { transform: scale(1.2); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ---------- Kết quả ---------- */
.result-title { font-size: 40px; margin-bottom: 2px; }
.result-title.timeup { color: var(--blue); }
.result-title.nolife { color: var(--red); }
.result-score {
  font-size: clamp(56px, 12vw, 92px);
  font-weight: 800;
  line-height: 1;
  color: var(--orange-dark);
  margin: 4px 0 0;
}
.result-score-label { font-size: 16px; letter-spacing: 3px; color: var(--ink-soft); font-weight: 800; }
.result-stars { font-size: 52px; line-height: 1; margin: 6px 0; letter-spacing: 4px; color: #ffbf1f; }
.result-stars .off { color: #dfe3ef; }
.result-stars .on { display: inline-block; animation: star-in 0.5s ease both; }
.result-stars .on:nth-child(2) { animation-delay: 0.2s; }
.result-stars .on:nth-child(3) { animation-delay: 0.4s; }
@keyframes star-in { 0% { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.3) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }
.record-badge {
  display: inline-block;
  background: linear-gradient(90deg, #ffb300, #ff6b35);
  color: #fff; font-weight: 800; font-size: 20px;
  padding: 6px 18px; border-radius: 999px; margin: 6px 0 4px;
  animation: badge-pulse 1s ease-in-out infinite;
  box-shadow: 0 6px 16px rgba(255, 120, 0, 0.35);
}
@keyframes badge-pulse { 50% { transform: scale(1.06); } }
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 12px 0 8px;
}
.stat {
  background: #f4f6fc; border-radius: 18px; padding: 10px 6px 8px;
}
.stat .v { font-size: 30px; font-weight: 800; line-height: 1; }
.stat .k { font-size: 14px; font-weight: 800; color: var(--ink-soft); margin-top: 4px; }
.stat.ok .v { color: var(--green-dark); }
.stat.bad .v { color: var(--red); }
.stat.combo .v { color: var(--orange-dark); }
.stat.acc .v { color: var(--blue); }
.name-entry {
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  margin: 10px 0 6px;
}
.name-entry input {
  font-family: var(--font); font-weight: 800; font-size: 22px;
  border: 3px solid #dfe3ef; border-radius: 999px; padding: 10px 18px; width: 220px;
  outline: none; color: var(--ink); text-align: center;
  -webkit-user-select: text; user-select: text;
}
.name-entry input:focus { border-color: var(--teal); }
.name-chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.name-chips button {
  font-family: var(--font); font-weight: 800; font-size: 16px;
  background: #eef1f8; border: none; border-radius: 999px; padding: 8px 14px; color: var(--ink-soft);
  cursor: pointer; touch-action: manipulation; min-height: 38px;
}
.leader {
  margin: 10px auto 0; max-width: 420px; text-align: left;
  background: #fffaf0; border-radius: 18px; padding: 10px 16px;
}
.leader h3 { margin: 0 0 6px; font-size: 18px; color: var(--orange-dark); text-align: center; }
.leader ol { margin: 0; padding-left: 26px; font-size: 18px; font-weight: 700; }
.leader li { display: flex; justify-content: space-between; padding: 3px 0; }
.leader li.me { color: var(--orange-dark); }
.leader li span:last-child { font-variant-numeric: tabular-nums; }
.leader .empty { text-align: center; font-size: 16px; color: var(--ink-soft); }

/* ---------- Hướng dẫn ---------- */
.howto-list { text-align: left; display: grid; gap: 12px; margin: 10px 0 6px; }
.howto-item {
  display: flex; gap: 14px; align-items: center;
  background: #f6f7fb; border-radius: 20px; padding: 12px 16px;
}
.howto-item .em { font-size: 38px; line-height: 1; width: 52px; text-align: center; flex-shrink: 0; }
.howto-item .tx { font-size: 19px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.howto-item .tx b { color: var(--orange-dark); }
.tip {
  margin-top: 12px; font-size: 16px; color: var(--ink-soft); font-weight: 700;
  background: #fff4d6; border-radius: 16px; padding: 10px 14px;
}

/* ---------- Toast ---------- */
#toast {
  position: absolute; left: 50%; bottom: calc(var(--sab) + 22px);
  transform: translateX(-50%);
  background: rgba(43,45,66,0.92); color: #fff; font-weight: 800; font-size: 18px;
  padding: 12px 22px; border-radius: 999px; pointer-events: none;
  opacity: 0; transition: opacity 0.3s; z-index: 20; max-width: 90%; text-align: center;
}
#toast.show { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .panel { padding: 20px 16px; border-radius: 24px; }
  .btn { font-size: 20px; padding: 14px 24px; }
  .btn.big { font-size: 26px; padding: 18px 34px; min-height: 66px; }
  .logo-row svg { width: 110px; height: 110px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .score-box { min-width: 90px; padding: 5px 12px 3px; }
  .score-box .value { font-size: 26px; }
  .hearts span { font-size: 22px; }
  .timer .bar { width: 90px; }
  .question-card { padding: 6px 18px 4px; min-width: 160px; font-size: clamp(30px, 9vw, 44px); }
  .hud-top {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "left right" "center center";
    gap: 6px 10px;
  }
  .hud-left { flex-direction: row; align-items: center; }
  .hud-center { justify-self: center; }
  .hint { font-size: 17px; padding: 5px 14px; }
  .screen-head h2 { font-size: 22px; white-space: nowrap; }
  .screen-head .btn { font-size: 16px; padding: 10px 14px; min-height: 44px; }
  .tab { font-size: 17px; padding: 10px 16px; }
  .mode-desc { font-size: 16px; }
  .level-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .level-card { min-height: 130px; padding: 12px; }
  .level-card .name { font-size: 18px; }
}
@media (max-height: 900px) {
  #gameover .panel { padding: 16px 26px 18px; }
  .result-title { font-size: 32px; }
  .result-score { font-size: clamp(48px, 9vw, 72px); }
  .result-stars { font-size: 40px; margin: 2px 0; }
  .stats { margin: 8px 0 4px; gap: 8px; }
  .stat { padding: 6px 4px 6px; }
  .stat .v { font-size: 24px; }
  .stat .k { font-size: 13px; }
  .name-entry { margin: 6px 0 2px; }
  .leader { padding: 6px 14px; }
  .leader h3 { font-size: 16px; margin-bottom: 2px; }
  .leader ol { font-size: 16px; }
  #gameover .btn-row { margin-top: 10px; }
  #gameover .btn.big { font-size: 26px; padding: 16px 36px; min-height: 64px; }
}
@media (max-height: 520px) {
  .logo-row svg { width: 90px; height: 90px; }
  .subtitle { margin: 4px 0 10px; }
  .panel { padding: 16px 22px; }
  .howto-item { padding: 8px 12px; }
}
