:root {
  color-scheme: dark;
  --ink: #f7f9fc;
  --muted: #9ca6b6;
  --blue: #6fc2ff;
  --gold: #f5d64e;
  --purple: #b97aff;
  --night: #05070d;
  --panel: rgba(17, 23, 34, .82);
  --line: rgba(255, 255, 255, .15);
  --cell: rgba(255, 255, 255, .08);
  --board-size: min(92vw, 56dvh, 540px);
  --display: "SF Pro Display", "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --body: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--night); -webkit-text-size-adjust: 100%; }
body { min-width: 320px; min-height: 100%; margin: 0; overflow-x: hidden; color: var(--ink); background: #05070d; font-family: var(--body); overscroll-behavior: none; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { color: inherit; }
[hidden] { display: none !important; }
.launching .mission-launch { pointer-events: none; opacity: .72; }

.space-backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, rgba(4, 7, 13, .4), rgba(4, 7, 13, .96)),
    url("../assets/bg-stargazer.png") center 18% / cover;
  transition: background-image .5s ease;
}

.space-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 28%, rgba(76, 149, 232, .16), transparent 30rem),
    linear-gradient(180deg, transparent 50%, #05070d 96%);
}

.game-app { width: min(1180px, calc(100% - 32px)); min-height: 100dvh; margin: 0 auto; }
.game-header { min-height: calc(76px + env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; padding-top: env(safe-area-inset-top); border-bottom: 1px solid rgba(255,255,255,.1); }
.game-brand { display: inline-flex; align-items: center; gap: 10px; color: white; text-decoration: none; }
.game-brand img { width: 34px; height: 34px; border-radius: 9px; box-shadow: 0 0 22px rgba(69,151,241,.25); }
.game-brand span { font-family: var(--display); font-size: 17px; font-weight: 800; letter-spacing: -.04em; }
.game-brand b { color: var(--blue); }
.header-actions { display: flex; gap: 8px; }
.icon-button, .back-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.07); backdrop-filter: blur(15px); cursor: pointer; }
.icon-button:hover, .back-button:hover { border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.12); }

.menu-view { padding: clamp(58px, 8vw, 100px) 0 80px; }
.menu-intro { max-width: 700px; }
.eyebrow { margin: 0 0 18px; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.menu-intro h1 { margin: 0; font-family: var(--display); font-size: clamp(58px, 9vw, 108px); line-height: .87; letter-spacing: -.07em; }
.menu-intro h1 span { color: transparent; -webkit-text-stroke: 1px rgba(255,255,255,.65); }
.menu-intro > p:last-child { max-width: 590px; margin: 28px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; }

.quick-actions { display: flex; max-width: 700px; margin-top: 38px; }
.stat-summary { width: 190px; min-height: 76px; border: 1px solid var(--line); border-radius: 16px; color: white; background: rgba(13,18,27,.78); box-shadow: 0 22px 50px rgba(0,0,0,.24); backdrop-filter: blur(18px); cursor: pointer; }
.stat-summary { display: flex; align-items: center; justify-content: center; gap: 11px; }
.stat-summary strong { color: var(--blue); font-family: var(--display); font-size: 28px; }
.stat-summary span { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .12em; line-height: 1.4; text-align: left; }

.mission-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 90px 0 24px; }
.mission-heading p { margin: 0 0 4px; color: var(--blue); font-size: 9px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.mission-heading h2 { margin: 0; font-family: var(--display); font-size: 34px; letter-spacing: -.05em; }
.mission-heading > span { color: var(--muted); font-size: 12px; }

.mission-carousel { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.mission-launch { position: relative; isolation: isolate; min-height: 390px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; padding: 20px; border: 1px solid var(--line); border-radius: 20px; color: white; background-position: center; background-size: cover; text-align: left; cursor: pointer; box-shadow: 0 26px 60px rgba(0,0,0,.35); transition: transform .3s ease, border-color .3s ease; }
.mission-launch::before { content: ""; position: absolute; z-index: -1; inset: 0; background: linear-gradient(180deg, rgba(4,7,13,.14), rgba(4,7,13,.28) 38%, rgba(4,7,13,.96)); }
.mission-launch:hover { transform: translateY(-5px); border-color: rgba(255,255,255,.38); }
.mission-launch .mission-top { display: flex; align-items: center; justify-content: space-between; }
.mission-launch .mission-icon { font-size: 23px; text-shadow: 0 0 20px currentColor; }
.mission-launch .mission-difficulty { padding: 6px 9px; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; color: #dce3ed; background: rgba(3,6,11,.44); font-size: 9px; font-weight: 800; letter-spacing: .09em; backdrop-filter: blur(10px); }
.mission-launch small { color: var(--gold); font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.mission-launch h3 { margin: 8px 0 6px; font-family: var(--display); font-size: 30px; letter-spacing: -.04em; }
.mission-launch p { margin: 0; color: #adb6c4; font-size: 12px; line-height: 1.5; }
.mission-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.12); color: #dce4ef; font-size: 10px; }
.mission-meta span:last-child { color: var(--blue); }
.menu-actions { display: flex; gap: 12px; justify-content: center; margin-top: 34px; }
.secondary-button { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 10px 18px; border: 1px solid var(--line); border-radius: 999px; color: #d8dfe9; background: rgba(255,255,255,.06); font-size: 12px; font-weight: 700; text-decoration: none; cursor: pointer; }
.secondary-button span { color: var(--blue); }

/* Active game */
.play-view { width: min(100%, 620px); min-height: calc(100dvh - 76px); margin: 0 auto; padding: 18px 0 calc(28px + env(safe-area-inset-bottom)); }
.play-toolbar { min-height: 52px; display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; }
.mission-title-block { text-align: center; }
.mission-title-block small { display: block; color: var(--gold); font-size: 8px; font-weight: 800; letter-spacing: .17em; }
.mission-title-block h1 { margin: 3px 0 0; font-family: var(--display); font-size: 22px; letter-spacing: -.04em; }
.mission-chip { min-height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: white; background: rgba(255,255,255,.07); font-size: 10px; font-weight: 700; cursor: pointer; }
.mission-chip:first-letter { color: var(--gold); }

.game-status { display: flex; align-items: center; justify-content: center; gap: 22px; padding: 12px 0 14px; }
.game-status > div { display: grid; min-width: 76px; text-align: right; }
.game-status strong { font-family: var(--display); font-size: 24px; font-variant-numeric: tabular-nums; }
.game-status span { color: var(--muted); font-size: 9px; }
.pause-button { min-height: 40px; padding: 8px 17px; border: 1px solid var(--line); border-radius: 999px; color: white; background: rgba(255,255,255,.07); font-size: 11px; font-weight: 700; cursor: pointer; }
.pause-button span { margin-right: 7px; color: var(--gold); }

.board-wrap { position: relative; width: var(--board-size); height: var(--board-size); margin: 0 auto; }
.sudoku-board { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(9, 1fr); overflow: hidden; border: 2px solid rgba(255,255,255,.86); border-radius: 13px; background: rgba(7,11,18,.64); box-shadow: 0 24px 70px rgba(0,0,0,.42), 0 0 40px rgba(54,128,208,.1); backdrop-filter: blur(8px); }
.cell { position: relative; min-width: 0; display: grid; place-items: center; padding: 0; border: 0; border-right: 1px solid rgba(255,255,255,.28); border-bottom: 1px solid rgba(255,255,255,.28); color: white; background: var(--cell); font-family: var(--display); font-size: clamp(17px, calc(var(--board-size) / 22), 26px); font-weight: 650; cursor: pointer; user-select: none; }
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(n+73) { border-bottom: 0; }
.cell:nth-child(9n+3), .cell:nth-child(9n+6) { border-right: 2px solid rgba(255,255,255,.8); }
.cell:nth-child(n+19):nth-child(-n+27), .cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid rgba(255,255,255,.8); }
.cell.given { color: #f7f8fa; font-weight: 780; }
.cell.user-value { color: var(--blue); }
.cell.related { background: rgba(118,191,255,.1); }
.cell.same-number { background: rgba(118,191,255,.18); }
.cell.selected { z-index: 1; background: rgba(245,214,78,.24); box-shadow: inset 0 0 0 2px var(--gold); color: white; }
.cell.error { color: #ff737d; background: rgba(255,76,89,.16); animation: cell-shake .25s linear; }
.cell.hinted { color: var(--gold); }
@keyframes cell-shake { 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
.notes { position: absolute; inset: 3px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); color: #9ed3ff; font-family: var(--body); font-size: clamp(6px, calc(var(--board-size) / 68), 9px); font-weight: 700; }
.notes i { display: grid; place-items: center; font-style: normal; }
.paused-cover { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; border-radius: 13px; background: rgba(5,7,13,.96); backdrop-filter: blur(14px); }
.paused-cover span { color: var(--gold); font-size: 34px; }
.paused-cover strong { font-family: var(--display); }

.progress-status { width: var(--board-size); margin: 11px auto 0; }
.progress-status > div:first-child { display: flex; justify-content: space-between; gap: 8px; color: #b9c1cc; font-size: 9px; font-weight: 600; }
.progress-track { height: 3px; overflow: hidden; margin-top: 8px; border-radius: 999px; background: rgba(255,255,255,.12); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), #ff9f43); transition: width .25s ease; }

.game-controls { width: var(--board-size); margin: 12px auto 0; }
.tool-button { min-height: 38px; display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 auto 9px; padding: 7px 16px; border: 1px solid var(--line); border-radius: 999px; color: white; background: rgba(27,46,65,.76); font-size: 10px; cursor: pointer; }
.tool-button span { color: var(--blue); font-size: 15px; }
.tool-button[aria-pressed="true"] { border-color: var(--blue); background: rgba(50,126,195,.28); box-shadow: 0 0 24px rgba(72,154,226,.15); }
.number-pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.number-button { aspect-ratio: 1; min-width: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; color: white; background: rgba(255,255,255,.09); font-family: var(--display); font-size: clamp(15px, calc(var(--board-size) / 25), 22px); font-weight: 700; cursor: pointer; }
.number-button:hover, .number-button:active { background: rgba(255,255,255,.17); }
.number-button.exhausted { opacity: .28; }
.number-button.note-active { color: var(--gold); }
.utility-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.utility-button { min-height: 38px; border: 1px solid var(--line); border-radius: 999px; color: #e6ebf2; background: rgba(255,255,255,.07); font-size: 10px; font-weight: 700; cursor: pointer; }
.utility-button span { margin-right: 5px; color: var(--blue); }
.utility-button.hint { background: rgba(128,107,13,.44); }
.utility-button.hint span { color: var(--gold); }
.utility-button:disabled, .tool-button:disabled { opacity: .35; cursor: default; }

/* Dialogs */
.game-dialog { width: min(92vw, 470px); max-height: min(88dvh, 760px); overflow-y: auto; padding: 32px; border: 1px solid rgba(255,255,255,.2); border-radius: 24px; color: white; background: rgba(12,17,26,.97); box-shadow: 0 40px 120px rgba(0,0,0,.7); text-align: center; backdrop-filter: blur(25px); }
.game-dialog::backdrop { background: rgba(1,3,7,.76); backdrop-filter: blur(6px); }
.game-dialog h2 { margin: 4px 0 10px; font-family: var(--display); font-size: 34px; letter-spacing: -.05em; }
.game-dialog > p:not(.dialog-kicker) { margin: 0 auto 24px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.dialog-symbol { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 18px; border: 1px solid rgba(245,214,78,.3); border-radius: 50%; color: var(--gold); background: rgba(245,214,78,.1); font-size: 28px; }
.dialog-symbol.success { color: #07111c; background: linear-gradient(145deg, #fff, var(--gold)); box-shadow: 0 0 38px rgba(245,214,78,.28); }
.dialog-kicker { margin: 0 0 6px; color: var(--gold); font-size: 9px; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; }
.dialog-primary { width: 100%; min-height: 48px; margin-top: 10px; border: 0; border-radius: 12px; color: #07111d; background: linear-gradient(135deg, white, #b9dcff); font-size: 13px; font-weight: 800; cursor: pointer; }
.dialog-link { min-height: 42px; margin-top: 8px; border: 0; color: var(--muted); background: transparent; font-size: 12px; cursor: pointer; }
.rank-status { min-height: 18px; margin: 4px 0 8px !important; color: var(--blue) !important; font-size: 11px !important; font-weight: 700; }
.dialog-close { position: sticky; top: 0; float: right; width: 36px; height: 36px; margin: -12px -12px 0 0; border: 1px solid var(--line); border-radius: 50%; color: white; background: rgba(255,255,255,.08); font-size: 22px; cursor: pointer; }
.result-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 20px 0 14px; }
.result-stats div { display: grid; gap: 3px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.06); }
.result-stats div > span { color: var(--gold); font-size: 14px; }
.result-stats strong { font-family: var(--display); font-size: 20px; }
.result-stats small { color: var(--muted); font-size: 9px; }
.help-grid { display: grid; gap: 8px; clear: both; margin: 24px 0 10px; text-align: left; }
.help-grid article { display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.04); }
.help-grid article > span { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid rgba(111,194,255,.28); border-radius: 50%; color: var(--blue); font-size: 10px; font-weight: 800; }
.help-grid h3 { margin: 0 0 3px; font-size: 13px; }
.help-grid p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 0; border-bottom: 1px solid var(--line); text-align: left; }
.setting-row:first-of-type { margin-top: 18px; }
.setting-row div { display: grid; gap: 4px; }
.setting-row strong { font-size: 13px; }
.setting-row div span { color: var(--muted); font-size: 10px; }
.switch { width: 48px; height: 28px; flex: none; padding: 3px; border: 0; border-radius: 999px; background: #363c47; cursor: pointer; }
.switch span { display: block; width: 22px; height: 22px; border-radius: 50%; background: white; box-shadow: 0 3px 8px rgba(0,0,0,.3); transition: transform .2s ease; }
.switch[aria-checked="true"] { background: #368fd8; }
.switch[aria-checked="true"] span { transform: translateX(20px); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 22px 0; }
.stats-grid div { display: grid; gap: 4px; padding: 14px 5px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.05); }
.stats-grid strong { font-family: var(--display); font-size: 20px; }
.stats-grid span { color: var(--muted); font-size: 8px; }
.badge-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.badge-item { display: grid; justify-items: center; gap: 4px; padding: 9px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: rgba(255,255,255,.04); font-size: 8px; }
.badge-item img { width: 62px; height: 62px; filter: grayscale(1); opacity: .3; }
.badge-item.earned { color: white; }
.badge-item.earned img { filter: none; opacity: 1; }

.leaderboard-dialog { width: min(94vw, 560px); padding: 30px; }
.pilot-name-field { clear: both; margin: 22px 0 12px; text-align: left; }
.pilot-name-field > label, .leaderboard-filters label { display: grid; gap: 6px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.pilot-name-field > div { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-top: 6px; }
.pilot-name-field input, .leaderboard-filters select { min-width: 0; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; color: white; background: rgba(255,255,255,.07); outline: 0; font-size: 13px; }
.pilot-name-field input:focus, .leaderboard-filters select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(111,194,255,.1); }
.pilot-name-field button { min-width: 70px; border: 0; border-radius: 10px; color: #07111d; background: #cde8ff; font-size: 11px; font-weight: 800; cursor: pointer; }
.pilot-name-field small { min-height: 15px; display: block; margin-top: 5px; color: var(--blue); font-size: 9px; }
.leaderboard-filters { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 14px 0; }
.leaderboard-state { padding: 28px 16px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.leaderboard-list { display: grid; gap: 6px; max-height: min(42dvh, 390px); overflow-y: auto; margin: 0; padding: 0; list-style: none; scrollbar-width: thin; }
.leaderboard-list li { min-height: 52px; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid rgba(255,255,255,.09); border-radius: 12px; background: rgba(255,255,255,.035); text-align: left; }
.leaderboard-list li:nth-child(-n+3) { border-color: rgba(245,214,78,.2); background: linear-gradient(100deg, rgba(245,214,78,.08), rgba(255,255,255,.03)); }
.leaderboard-list li.is-player { border-color: rgba(111,194,255,.38); background: rgba(64,145,215,.12); }
.leaderboard-rank { color: var(--gold); font-family: var(--display); font-size: 13px; text-align: center; }
.leaderboard-pilot { display: grid; gap: 2px; overflow: hidden; font-size: 12px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-pilot small { color: var(--muted); font-size: 8px; font-weight: 500; }
.leaderboard-list li > b { font-family: var(--display); font-size: 15px; font-variant-numeric: tabular-nums; }
.player-rank { margin-top: 8px; padding: 12px; border: 1px solid rgba(111,194,255,.24); border-radius: 12px; color: var(--blue); background: rgba(64,145,215,.08); font-size: 11px; font-weight: 700; }
.leaderboard-note { margin: 14px 0 0 !important; color: #6f7988 !important; font-size: 9px !important; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); padding: 11px 16px; border: 1px solid var(--line); border-radius: 999px; color: white; background: rgba(12,17,26,.94); box-shadow: 0 16px 50px rgba(0,0,0,.5); font-size: 11px; font-weight: 700; opacity: 0; transform: translate(-50%, 20px); pointer-events: none; transition: opacity .25s, transform .25s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 800px) {
  :root { --board-size: min(94vw, 54dvh, 520px); }
  .game-app { width: min(100% - 24px, 700px); }
  .menu-view { padding-top: 55px; }
  .mission-carousel { display: flex; gap: 12px; overflow-x: auto; margin: 0; padding: 4px 0 24px; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .mission-carousel::-webkit-scrollbar { display: none; }
  .mission-launch { min-width: min(78vw, 330px); min-height: 430px; scroll-snap-align: center; }
}

@media (max-width: 560px) {
  :root { --board-size: min(calc(100vw - 20px), 49dvh); }
  .game-app { width: calc(100% - 20px); }
  .game-header { min-height: calc(64px + env(safe-area-inset-top)); }
  .game-brand span { font-size: 15px; }
  .header-actions .icon-button { width: 38px; height: 38px; }
  .menu-view { padding: 44px 0 calc(42px + env(safe-area-inset-bottom)); }
  .menu-intro h1 { font-size: clamp(52px, 17vw, 76px); }
  .menu-intro > p:last-child { font-size: 15px; line-height: 1.6; }
  .quick-actions { margin-top: 28px; }
  .stat-summary { width: 150px; }
  .stat-summary { display: grid; align-content: center; gap: 0; text-align: center; }
  .stat-summary span { text-align: center; }
  .mission-heading { margin-top: 60px; }
  .mission-heading > span { display: none; }
  .mission-launch { min-width: 82vw; min-height: min(480px, 62dvh); }
  .menu-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .menu-actions > :first-child { grid-column: 1 / -1; }
  .play-view { min-height: calc(100dvh - 64px); padding-top: 8px; }
  .play-toolbar { min-height: 45px; grid-template-columns: 42px 1fr 42px; }
  .back-button { width: 38px; height: 38px; }
  .mission-chip { width: 38px; min-height: 38px; justify-content: center; padding: 0; font-size: 13px; }
  .mission-chip span { display: none; }
  .mission-title-block h1 { font-size: 18px; }
  .game-status { padding: 6px 0 8px; }
  .game-status strong { font-size: 20px; }
  .cell { border-color: rgba(255,255,255,.3); }
  .progress-status { margin-top: 7px; }
  .game-controls { margin-top: 8px; }
  .tool-button { min-height: 34px; margin-bottom: 7px; }
  .number-pad { gap: 3px; }
  .number-button { border-radius: 8px; }
  .utility-row { gap: 5px; margin-top: 6px; }
  .utility-button { min-height: 34px; }
  .game-dialog { padding: 26px 20px calc(24px + env(safe-area-inset-bottom)); border-radius: 21px; }
  .leaderboard-dialog { padding: 24px 16px calc(22px + env(safe-area-inset-bottom)); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 380px), (max-height: 700px) and (max-width: 560px) {
  :root { --board-size: min(calc(100vw - 16px), 46dvh); }
  .game-app { width: calc(100% - 16px); }
  .game-header { min-height: calc(55px + env(safe-area-inset-top)); }
  .game-brand img { width: 30px; height: 30px; }
  .game-brand span { font-size: 13px; }
  .play-view { min-height: calc(100dvh - 55px); padding-top: 3px; }
  .play-toolbar { min-height: 40px; }
  .mission-title-block h1 { font-size: 16px; }
  .game-status { padding: 2px 0 5px; }
  .game-status strong { font-size: 17px; }
  .pause-button { min-height: 34px; }
  .progress-status > div:first-child { font-size: 8px; }
  .tool-button { min-height: 31px; margin-bottom: 5px; }
  .utility-button { min-height: 31px; }
}

@media (orientation: landscape) and (max-height: 600px) {
  :root { --board-size: min(68vh, 480px); }
  .game-header { min-height: 54px; }
  .play-view { width: min(100%, 1040px); display: grid; grid-template-columns: var(--board-size) minmax(260px, 1fr); grid-template-rows: auto auto 1fr; column-gap: 28px; padding: 7px 0 calc(10px + env(safe-area-inset-bottom)); }
  .play-toolbar { grid-column: 1 / -1; }
  .game-status { grid-column: 2; grid-row: 2; justify-content: flex-start; }
  .board-wrap { grid-column: 1; grid-row: 2 / span 2; }
  .progress-status { grid-column: 2; grid-row: 3; width: 100%; margin: 0; align-self: start; }
  .game-controls { grid-column: 2; grid-row: 3; width: 100%; margin-top: 40px; align-self: start; }
  .number-pad { grid-template-columns: repeat(5, 1fr); }
  .number-button { aspect-ratio: auto; min-height: 40px; }
  .tool-button { margin-left: 0; }
}

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