@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  color: #f7f8ff;
  background: #05060a;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --bg: #05060a;
  --panel: rgba(14, 17, 28, .78);
  --panel-strong: rgba(21, 25, 42, .88);
  --line: rgba(255,255,255,.10);
  --line-hot: rgba(121, 124, 255, .66);
  --text: #f7f8ff;
  --muted: #9ca4b8;
  --accent: #797cff;
  --accent-2: #35f2b8;
  --warn: #ffbf5e;
  --danger: #ff6978;
  --radius-xl: clamp(24px, 5vw, 42px);
  --radius-lg: clamp(18px, 3.4vw, 30px);
  --gap: clamp(10px, 1.8vw, 18px);
}

* { box-sizing: border-box; }
html { width: 100%; min-height: 100%; background: var(--bg); }
html, body { margin: 0; }
body {
  width: 100%;
  min-width: 320px;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -10%, rgba(121, 124, 255, .42), transparent 30vw),
    radial-gradient(circle at 92% 10%, rgba(53, 242, 184, .24), transparent 28vw),
    radial-gradient(circle at 40% 105%, rgba(255, 191, 94, .20), transparent 34vw),
    linear-gradient(135deg, #05060a 0%, #070a14 46%, #10101d 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, black, transparent 76%);
}
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:active { transform: translateY(1px) scale(.99); }

body.is-menu .scoreboard { display: none; }
body.is-playing .game-menu { display: none; }
.game-menu {
  width: min(100%, 1120px);
  min-height: calc(100dvh - 20px);
  margin: 0 auto;
  display: grid;
  align-content: center;
  gap: clamp(18px, 4vw, 34px);
}
.app-name {
  margin: 0;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: .18em;
  font: 900 clamp(.68rem, 1.5vw, .9rem)/1.1 'JetBrains Mono', monospace;
}
.app-name span, .topbar .kicker span { color: rgba(247,248,255,.72); }
.menu-hero {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: clamp(22px, 5vw, 54px);
  background: linear-gradient(145deg, rgba(121,124,255,.24), rgba(14,17,28,.78) 52%, rgba(53,242,184,.14));
  box-shadow: 0 24px 90px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(22px) saturate(150%);
}
.menu-hero p:last-child { margin: 14px 0 0; color: var(--muted); font-size: clamp(1rem, 2.3vw, 1.25rem); font-weight: 700; }
.game-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}
.game-card {
  min-height: clamp(128px, 19vw, 190px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 3vw, 28px);
  display: grid;
  align-content: end;
  justify-items: start;
  gap: 10px;
  text-align: left;
  color: var(--text);
  background: linear-gradient(145deg, rgba(255,255,255,.095), rgba(255,255,255,.035));
  box-shadow: 0 20px 70px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.08);
}
.game-card:nth-child(1), .game-card:nth-child(2) { background: linear-gradient(145deg, rgba(121,124,255,.34), rgba(255,255,255,.045)); }
.game-card:nth-child(3) { background: linear-gradient(145deg, rgba(255,191,94,.26), rgba(255,255,255,.045)); }
.game-card:nth-child(4) { background: linear-gradient(145deg, rgba(53,242,184,.24), rgba(255,255,255,.045)); }
.game-card:nth-child(5) { background: linear-gradient(145deg, rgba(255,105,120,.24), rgba(255,255,255,.045)); }
.game-card span { color: var(--muted); font-size: clamp(.78rem, 1.6vw, .95rem); font-weight: 900; text-transform: uppercase; letter-spacing: .12em; }
.game-card strong { font-size: clamp(1.7rem, 4.2vw, 3.2rem); line-height: .92; letter-spacing: -.06em; }
.game-card:disabled { opacity: .6; cursor: progress; }


.tablet-stage {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.scoreboard {
  position: relative;
  width: min(100%, 1440px);
  min-height: calc(100dvh - 20px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 360px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "top top"
    "players history"
    "entry history";
  gap: var(--gap);
}

.topbar, .entry-panel, .history-card, .player-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 24px 90px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(22px) saturate(150%);
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: var(--radius-lg);
  padding: clamp(10px, 1.6vw, 18px) clamp(12px, 2vw, 24px);
}
.kicker { margin: 0 0 3px; color: var(--accent-2); text-transform: uppercase; letter-spacing: .18em; font: 800 clamp(.66rem, 1.4vw, .82rem)/1 'JetBrains Mono', monospace; }
h1 { margin: 0; font-size: clamp(1.25rem, 4vw, 3.7rem); line-height: .9; letter-spacing: -.06em; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: end; }
.ghost-btn, .quick-row button, .numpad button, .match-dialog button {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255,255,255,.07);
  min-height: 48px;
  padding: 0 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.ghost-btn { color: #dfe4ff; font-weight: 800; }

.players {
  grid-area: players;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  min-height: 0;
}
.player-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: clamp(16px, 2.7vw, 30px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  isolation: isolate;
}
.player-card::before, .player-card::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 999px;
  filter: blur(16px);
}
.player-card::before { inset: -18% -18% auto auto; width: 58%; aspect-ratio: 1; background: rgba(121,124,255,.20); }
.player-card::after { inset: auto auto -24% -18%; width: 48%; aspect-ratio: 1; background: rgba(53,242,184,.13); }
.player-card.is-active {
  border-color: var(--line-hot);
  background: linear-gradient(145deg, rgba(121,124,255,.30), rgba(21,25,42,.82) 48%, rgba(53,242,184,.12));
  box-shadow: 0 24px 90px rgba(80, 84, 255, .22), inset 0 0 0 1px rgba(121,124,255,.24);
}
.player-card.is-winner { border-color: rgba(53,242,184,.82); background: linear-gradient(145deg, rgba(53,242,184,.24), rgba(21,25,42,.82)); }
.player-label { color: var(--accent-2); font-weight: 900; letter-spacing: .14em; text-transform: uppercase; font-size: clamp(.72rem, 1.5vw, .92rem); line-height: 1.1; }
.player-card h2 { margin: 7px 0 4px; font-size: clamp(1.1rem, 3vw, 2.4rem); line-height: 1.02; letter-spacing: -.04em; overflow-wrap: anywhere; }
.big-score {
  align-self: center;
  justify-self: start;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(5.6rem, 14vw, 12.8rem);
  font-weight: 900;
  line-height: .82;
  letter-spacing: -.12em;
  text-shadow: 0 0 34px rgba(121,124,255,.32);
}
.finish-arrow-actions {
  display: inline-flex;
  align-items: center;
  gap: clamp(6px, 1vw, 10px);
  margin-left: clamp(8px, 1.3vw, 14px);
  vertical-align: middle;
}
.finish-arrow-btn {
  min-width: clamp(36px, 4.8vw, 50px);
  height: clamp(34px, 4.6vw, 46px);
  border-radius: 12px;
  border: 1px solid rgba(130, 164, 196, 0.38);
  background: linear-gradient(180deg, rgba(25, 46, 72, 0.96), rgba(12, 24, 40, 0.98));
  color: #9fc8f4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(.82rem, 1.5vw, .98rem);
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 24px rgba(0,0,0,.24);
}
.finish-arrow-btn.is-ready {
  border-color: rgba(108, 219, 168, 0.68);
  color: #e9fff6;
  background: linear-gradient(180deg, rgba(40, 132, 97, 0.94), rgba(22, 90, 68, 0.98));
}
.finish-arrow-btn:active {
  transform: translateY(1px) scale(.98);
}

.leg-line { display: flex; align-items: end; justify-content: space-between; gap: 10px; color: rgba(247,248,255,.72); font-size: clamp(.85rem, 1.55vw, 1.15rem); line-height: 1.1; }
.leg-line strong { color: var(--text); font-size: 1.45em; }

.entry-panel {
  grid-area: entry;
  border-radius: var(--radius-lg);
  padding: clamp(12px, 1.8vw, 18px);
  background: linear-gradient(180deg, rgba(18, 30, 48, 0.88), rgba(9, 16, 28, 0.94));
}
.entry-display {
  grid-area: display;
  border-radius: 20px;
  border: 1px solid rgba(149,220,255,.18);
  background: linear-gradient(180deg, rgba(16, 28, 45, 0.95), rgba(8, 16, 28, 0.98));
  padding: clamp(14px, 2vw, 18px);
  display: grid;
  gap: 8px;
  align-content: center;
  min-height: 100%;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.entry-display-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.entry-display-label,
.entry-display-status {
  color: rgba(214,231,255,.74);
  font-size: .82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .11em;
}
.entry-display-status {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  text-align: right;
}
.entry-display strong {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(3.2rem, 10vw, 6.4rem);
  line-height: .88;
  letter-spacing: -.10em;
}
.quick-row, .numpad { display: grid; gap: 10px; }
.quick-row {
  display: grid;
  grid-template-columns: clamp(72px, 8vw, 90px) minmax(260px, 1fr) clamp(72px, 8vw, 90px);
  grid-template-areas: "left display right";
  gap: 10px;
  align-items: stretch;
}
.favorite-bank {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(6, minmax(46px, 1fr));
  gap: 8px;
}
.favorite-bank.left { grid-area: left; }
.favorite-bank.right { grid-area: right; }
.favorite-bank button {
  min-height: 46px;
  padding: 0 8px;
  color: #0f3760;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  font-weight: 900;
  background:
    radial-gradient(circle at 50% 12%, rgba(255,255,255,.88), rgba(255,255,255,0) 54%),
    linear-gradient(180deg, #d1e9ff 0%, #aed3ff 44%, #78b0f1 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.85), 0 10px 20px rgba(0,0,0,.18);
}
.favorite-bank.right button {
  color: #0f3760;
}
.numpad {
  margin-top: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(68px, 1fr));
}
.numpad button {
  min-height: 68px;
  padding: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 900;
  font-size: clamp(1.3rem, 4.4vw, 1.8rem);
  color: #0f3760;
  background:
    radial-gradient(circle at 50% 10%, rgba(255,255,255,.9), rgba(255,255,255,0) 56%),
    linear-gradient(180deg, #d7ecff 0%, #b3d8ff 42%, #7db5f3 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.85), 0 12px 28px rgba(0,0,0,.24);
}
.numpad button.ok,
.numpad button.danger,
.numpad button.utility {
  color: #f4fff9;
  background: linear-gradient(180deg, #3dbb73, #238b54);
}
.numpad-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }


/* TigaScore 2 numblock port for TigaScore 3 */
.entry-panel {
  padding: clamp(12px, 1.8vw, 18px);
  border-radius: clamp(22px, 3vw, 34px);
  background: linear-gradient(180deg, rgba(13, 27, 50, 0.92), rgba(5, 13, 25, 0.98));
}
.quick-row {
  display: grid;
  grid-template-columns: clamp(74px, 9vw, 86px) minmax(280px, 1fr) clamp(74px, 9vw, 86px);
  grid-template-areas: "left keypad right";
  gap: clamp(10px, 1.8vw, 14px);
  align-items: stretch;
}
.side-shortcuts-left { grid-area: left; }
.side-shortcuts-right { grid-area: right; }
.main-keypad-shell {
  grid-area: keypad;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 1.6vw, 14px);
  min-width: 0;
}
.field-label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  color: rgba(230, 240, 255, .86);
  font-size: clamp(.78rem, 1.4vw, .92rem);
  font-weight: 800;
}
.field-label > span:first-child {
  align-self: end;
}
.field-label .entry-display-status {
  min-height: 0;
  align-self: end;
  font-size: clamp(.64rem, 1.1vw, .74rem);
  opacity: .72;
  text-transform: none;
  letter-spacing: 0;
}
.entry-display.input-row-stretch {
  grid-column: 1 / -1;
  min-height: clamp(62px, 8vw, 78px);
  border-radius: clamp(14px, 2vw, 18px);
  padding: 0 clamp(16px, 2.4vw, 22px);
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, rgba(25, 43, 75, .86), rgba(15, 29, 52, .96));
  border: 1px solid rgba(121, 162, 220, .18);
  box-shadow: inset 0 2px 8px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.05);
}
.entry-display.input-row-stretch strong {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: rgba(238, 246, 255, .56);
  font-size: clamp(1.8rem, 4.2vw, 2.55rem);
  letter-spacing: -.08em;
  line-height: 1;
}
.favorite-bank {
  grid-template-rows: repeat(6, minmax(clamp(64px, 8.8vw, 88px), 1fr));
  gap: clamp(8px, 1.4vw, 10px);
}
.favorite-bank button,
.numpad button {
  border-radius: clamp(14px, 2.1vw, 18px);
  border: 1px solid rgba(205, 232, 255, .22);
  background:
    radial-gradient(circle at 50% 8%, rgba(255,255,255,.96), rgba(255,255,255,.10) 45%, rgba(255,255,255,0) 62%),
    linear-gradient(180deg, #dff1ff 0%, #b9dcff 43%, #7ab3f2 100%);
  color: #0c2949;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.82), 0 12px 24px rgba(0,0,0,.28);
}
.favorite-bank button {
  min-height: clamp(64px, 8.8vw, 88px);
  padding: 0 8px;
  font-size: clamp(.95rem, 2vw, 1.08rem);
}
.numpad {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(clamp(78px, 10.2vw, 96px), 1fr));
  gap: clamp(10px, 1.8vw, 14px);
}
.numpad button {
  min-height: clamp(78px, 10.2vw, 96px);
  padding: 0;
  font-size: clamp(1.45rem, 3.4vw, 1.9rem);
}
.numpad button.ok,
.numpad button.danger,
.numpad button.utility {
  color: #f7fff9;
  background: linear-gradient(180deg, #41c982 0%, #24975c 100%);
  border-color: rgba(94, 236, 154, .28);
  font-size: clamp(.82rem, 1.7vw, .98rem);
  letter-spacing: .02em;
}
.numpad button.ok {
  font-size: clamp(.88rem, 1.7vw, 1rem);
}
.numpad-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(10px, 1.8vw, 14px);
  min-height: clamp(78px, 10.2vw, 96px);
}
.numpad-split button {
  min-width: 0;
  min-height: 100%;
}
.keypad-footer {
  display: grid;
  min-height: clamp(36px, 5.2vw, 44px);
}
.keypad-back-button {
  width: 100%;
  min-height: clamp(36px, 5.2vw, 44px);
  border-radius: 12px;
  border: 1px solid rgba(76, 115, 170, .14);
  background: linear-gradient(180deg, rgba(8, 18, 34, .78), rgba(5, 12, 24, .92));
  color: rgba(226, 235, 250, .42);
  font-size: clamp(.7rem, 1.35vw, .8rem);
  font-weight: 900;
  letter-spacing: .05em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.keypad-back-button:disabled {
  cursor: not-allowed;
  opacity: .72;
}

.history-card {
  grid-area: history;
  border-radius: var(--radius-xl);
  padding: clamp(14px, 2vw, 22px);
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.history-head { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-weight: 800; }
.history-head strong { color: var(--accent-2); }
ol { list-style: none; margin: 16px 0 0; padding: 0; overflow: auto; display: grid; align-content: start; gap: 10px; scrollbar-width: thin; }
li { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 10px; padding: 12px; border-radius: 18px; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.06); }
li strong { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 1.45rem; }
li small { color: var(--muted); }
li.is-bust strong { color: var(--danger); }
li.empty { grid-template-columns: 1fr; color: var(--muted); }
.toast { position: fixed; z-index: 30; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 14px 18px; border-radius: 999px; background: #f7f8ff; color: #10131f; font-weight: 900; transition: .2s ease; box-shadow: 0 20px 70px rgba(0,0,0,.38); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.fireworks-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, rgba(255,255,255,.10), transparent 34%);
}
.fireworks-layer i {
  position: absolute;
  width: clamp(8px, 1.3vw, 16px);
  height: clamp(8px, 1.3vw, 16px);
  border-radius: 999px;
  background: var(--c);
  box-shadow: 0 0 18px var(--c), 0 0 34px var(--c);
  animation: fireworkFly var(--dur) cubic-bezier(.08,.7,.15,1) var(--delay) forwards;
  opacity: 0;
}
.win-banner {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%) scale(.9);
  padding: clamp(18px, 4vw, 34px) clamp(24px, 6vw, 62px);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.28);
  color: #06120e;
  background: linear-gradient(135deg, #35f2b8, #b7ff67 58%, #fff2a8);
  font-weight: 1000;
  font-size: clamp(1.35rem, 6vw, 4.4rem);
  letter-spacing: -.06em;
  text-align: center;
  box-shadow: 0 0 70px rgba(53,242,184,.5), 0 30px 100px rgba(0,0,0,.55);
  animation: bannerPop 2.8s ease forwards;
}
@keyframes fireworkFly {
  0% { opacity: 0; transform: translate(0, 0) scale(.4); }
  12% { opacity: 1; }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) scale(.08); }
}
@keyframes bannerPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.72) rotate(-2deg); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.05) rotate(1deg); }
  78% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(.94) rotate(1deg); }
}

.match-dialog { border: 0; border-radius: 28px; padding: 0; background: #111522; color: var(--text); box-shadow: 0 30px 90px rgba(0,0,0,.65); }
.match-dialog::backdrop { background: rgba(0,0,0,.68); backdrop-filter: blur(8px); }
.match-dialog form { width: min(92vw, 520px); padding: 26px; display: grid; gap: 14px; }
.match-dialog h2 { margin: 0; font-size: 2rem; }
.match-dialog label { display: grid; gap: 6px; color: var(--muted); }
.match-dialog input, .match-dialog select { width: 100%; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.08); color: var(--text); border-radius: 14px; padding: 12px 14px; }
.match-dialog menu { display: flex; justify-content: flex-end; gap: 10px; margin: 8px 0 0; padding: 0; }
.match-dialog .primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #05060a; font-weight: 900; }

@media (max-width: 980px) {
  body { overflow-y: auto; }
  .tablet-stage { min-height: 100dvh; }
  .scoreboard {
    min-height: calc(100dvh - 20px);
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    grid-template-areas: "top" "players" "entry" "history";
  }
  .players { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player-card { min-height: clamp(150px, 24dvh, 240px); }
  .big-score { font-size: clamp(4.4rem, 18vw, 9rem); }
  .history-card { max-height: 220px; }
}

@media (max-width: 640px) {
  .game-menu { align-content: start; padding-top: 8px; gap: 12px; }
  .menu-hero { border-radius: 22px; padding: 20px; }
  .game-grid { grid-template-columns: 1fr; gap: 8px; }
  .game-card { min-height: 82px; border-radius: 20px; padding: 16px 18px; }

  html, body { min-height: 100dvh; overflow: hidden; }
  .tablet-stage { min-height: 100dvh; padding: max(7px, env(safe-area-inset-top)) 7px max(9px, env(safe-area-inset-bottom)); }
  .scoreboard {
    gap: 8px;
    min-height: calc(100dvh - max(7px, env(safe-area-inset-top)) - max(9px, env(safe-area-inset-bottom)));
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "top" "players" "entry";
  }
  .entry-panel { align-self: end; }
  .topbar { border-radius: 20px; padding: 10px 11px; align-items: start; }
  .top-actions { gap: 6px; }
  .ghost-btn { min-height: 40px; border-radius: 12px; padding: 0 10px; font-size: .82rem; }
  .kicker { font-size: .58rem; letter-spacing: .13em; }
  h1 { font-size: clamp(1.15rem, 7vw, 1.8rem); }
  .player-card { border-radius: 20px; padding: 10px; min-height: 142px; }
  .player-card h2 { font-size: clamp(.9rem, 4.5vw, 1.25rem); margin-top: 4px; }
  .player-label { font-size: .56rem; letter-spacing: .10em; }
  .finish-arrow-actions { gap: 5px; margin-left: 6px; }
  .finish-arrow-btn { min-width: 34px; height: 32px; padding: 0 6px; font-size: .74rem; }
  .big-score { font-size: clamp(3.4rem, 18vw, 5.2rem); letter-spacing: -.13em; text-shadow: 0 0 24px rgba(121,124,255,.42); }
  .leg-line { font-size: .72rem; align-items: start; flex-direction: column; gap: 4px; }
  .leg-line strong { font-size: 1.15em; }
  .entry-panel { border-radius: 22px; padding: 8px; }
  .quick-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "display display"
      "left right";
    gap: 8px;
  }
  .entry-display { min-height: 78px; padding: 12px 14px; border-radius: 18px; gap: 8px; }
  .entry-display-label,
  .entry-display-status { font-size: .66rem; }
  .entry-display-head { align-items: start; }
  .entry-display strong { font-size: clamp(3.2rem, 18vw, 5.2rem); }
  .favorite-bank { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(48px, 1fr)); gap: 6px; }
  .favorite-bank button { min-height: 48px; border-radius: 14px; font-size: clamp(.95rem, 5vw, 1.25rem); }
  .numpad { gap: 6px; grid-template-rows: repeat(4, minmax(58px, 1fr)); }
  .numpad button { min-height: 58px; border-radius: 15px; font-size: clamp(1.35rem, 8vw, 1.9rem); }
  .numpad-split { gap: 6px; }
  .history-card { display: none; }
  li { padding: 9px; grid-template-columns: 34px 1fr auto; }
  li strong { font-size: 1.2rem; }
}

@media (orientation: landscape) and (max-height: 620px) {
  .game-menu { align-content: start; }
  .game-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .game-card { min-height: 112px; padding: 14px; }

  .scoreboard {
    height: calc(100dvh - 20px);
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(360px, .78fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "players entry";
  }
  .history-card { display: none; }
  .players { grid-template-columns: 1fr; }
  .player-card { min-height: 0; padding: 12px 16px; border-radius: 24px; }
  .finish-arrow-actions { gap: 6px; margin-left: 8px; }
  .finish-arrow-btn { min-width: 40px; height: 34px; }
  .big-score { font-size: clamp(4.4rem, 17vh, 7.8rem); }
  .quick-row { grid-template-columns: 72px minmax(0, 1fr) 72px; grid-template-areas: "left display right"; }
  .favorite-bank { grid-template-columns: 1fr; grid-template-rows: repeat(6, minmax(0, 1fr)); }
  .favorite-bank button { min-height: 0; }
  .numpad { grid-template-rows: repeat(4, minmax(42px, 1fr)); }
  .numpad button { min-height: 42px; }
}
