:root {
  --bg: #0f1c17;
  --card: #f5eddf;
  --text: #201b15;
  --accent: #b84a34;
  --accent-strong: #8e3425;
  --cool: #295b75;
  --ok: #4e8d53;
  --muted: #6a5e4f;
  --ring: rgba(183, 70, 49, 0.26);
  --radius: 10px;
  --cut: 12px;
  --shadow: 0 16px 28px rgba(10, 7, 5, 0.28);
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background-color: #12251d;
  background-image:
    radial-gradient(circle at center, rgba(227, 206, 173, 0.12) 0.5px, transparent 0.6px),
    radial-gradient(circle at center, rgba(227, 206, 173, 0.08) 0.5px, transparent 0.6px);
  background-size: 8px 8px, 8px 8px;
  background-position: 0 0, 4px 4px;
  color: var(--text);
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
}

.game-page {
  overflow-x: clip;
  overflow-y: auto;
  overscroll-behavior-x: none;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(28px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.34;
}

.orb-1 {
  width: 34vw;
  height: 34vw;
  max-width: 260px;
  max-height: 260px;
  left: -10vw;
  top: 34vh;
  background: #8e3e2d;
}

.orb-2 {
  width: 38vw;
  height: 38vw;
  max-width: 290px;
  max-height: 290px;
  right: -14vw;
  top: 8vh;
  background: #3e6650;
}

.app-shell {
  position: relative;
  z-index: 1;
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.game-shell > section {
  max-width: 100%;
}

.setup-shell {
  max-width: 500px;
}

.game-shell {
  height: 100dvh;
  max-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 6px;
  overflow: hidden;
}

.hero {
  padding: 14px 12px 10px;
  animation: rise-in 280ms ease-out;
  position: relative;
  background:
    linear-gradient(180deg, rgba(193, 154, 94, 0.18) 0 3px, transparent 3px 100%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.12)),
    #f1e5cf;
  border: 1px solid #c3a273;
  box-shadow: 0 10px 20px rgba(15, 10, 7, 0.24);
  clip-path: polygon(
    0 var(--cut),
    var(--cut) 0,
    calc(100% - var(--cut)) 0,
    100% var(--cut),
    100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%,
    var(--cut) 100%,
    0 calc(100% - var(--cut))
  );
}

.hero::before {
  content: "";
  position: absolute;
  inset: 8px 9px;
  border: 1px solid rgba(175, 136, 78, 0.45);
  clip-path: polygon(
    0 10px,
    10px 0,
    calc(100% - 10px) 0,
    100% 10px,
    100% calc(100% - 10px),
    calc(100% - 10px) 100%,
    10px 100%,
    0 calc(100% - 10px)
  );
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 10px;
  bottom: 10px;
  background:
    linear-gradient(90deg, transparent 0 8%, rgba(182, 142, 84, 0.45) 18%, rgba(214, 184, 124, 0.7) 50%,
      rgba(182, 142, 84, 0.45) 82%, transparent 92%) top center / 100% 1px no-repeat,
    radial-gradient(16px 8px at 10px 11px, transparent 58%, rgba(181, 141, 82, 0.38) 60%, transparent 63%)
      left top / 72px 28px no-repeat,
    radial-gradient(16px 8px at calc(100% - 10px) 11px, transparent 58%, rgba(181, 141, 82, 0.38) 60%, transparent 63%)
      right top / 72px 28px no-repeat,
    radial-gradient(10px 6px at 24px 16px, transparent 54%, rgba(181, 141, 82, 0.24) 56%, transparent 60%)
      left top / 72px 28px no-repeat,
    radial-gradient(10px 6px at calc(100% - 24px) 16px, transparent 54%, rgba(181, 141, 82, 0.24) 56%, transparent 60%)
      right top / 72px 28px no-repeat;
  pointer-events: none;
}

.eyebrow {
  margin: 0;
  color: #7c5b33;
  font-size: 0.7rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  font-weight: 600;
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid rgba(167, 125, 69, 0.5);
  background: rgba(248, 238, 220, 0.82);
  clip-path: polygon(0 6px, 6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px),
      calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px));
}

.hero h1 {
  margin: 6px 0 0;
  font-family: "IBM Plex Mono", "Courier New", monospace;
  letter-spacing: 0.02em;
  font-size: clamp(2rem, 8vw, 2.7rem);
  line-height: 1.02;
  text-transform: uppercase;
  color: #2c2117;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  display: inline-block;
  padding: 2px 12px 4px;
  border: 1px solid rgba(141, 108, 65, 0.42);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0.16)),
    linear-gradient(90deg, rgba(171, 131, 76, 0.05), rgba(171, 131, 76, 0.02));
  clip-path: polygon(0 7px, 7px 0, calc(100% - 7px) 0, 100% 7px, 100% calc(100% - 7px),
      calc(100% - 7px) 100%, 7px 100%, 0 calc(100% - 7px));
}

.sub {
  margin: 5px 0 0;
  color: #6e5538;
  font-size: 0.82rem;
  font-weight: 600;
}

section {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.06)),
    var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(85, 56, 33, 0.25);
  clip-path: polygon(
    0 var(--cut),
    var(--cut) 0,
    calc(100% - var(--cut)) 0,
    100% var(--cut),
    100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%,
    var(--cut) 100%,
    0 calc(100% - var(--cut))
  );
  position: relative;
  overflow: hidden;
}

.game-shell section::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(197, 151, 89, 0.55), rgba(224, 194, 148, 0.76), rgba(197, 151, 89, 0.55));
  pointer-events: none;
}

.setup,
.scoreboard,
.entry,
.history {
  margin-top: 10px;
}

.game-shell .scoreboard,
.game-shell .entry,
.game-shell .history,
.game-shell .checkout {
  margin-top: 0;
}

.setup {
  overflow: hidden;
}

.setup-static {
  margin-top: 10px;
}

.setup-toggle {
  width: 100%;
  border: 0;
  background: linear-gradient(135deg, #3c2a1f, #5a3f2d);
  color: #fff;
  font-weight: 700;
  font-size: 0.94rem;
  padding: 12px 14px;
  text-align: left;
}

.setup-panel {
  padding: 11px;
  display: grid;
  gap: 9px;
}

.rules-note {
  margin: 0;
  background: #efe2ca;
  border: 1px solid #d2b88f;
  border-radius: 10px;
  padding: 9px;
  color: #5c422b;
  font-size: 0.85rem;
}

.starter-picker {
  border: 1px solid #d2b88f;
  border-radius: 10px;
  background: #efe4cf;
  padding: 8px;
}

.starter-picker p {
  margin: 0 0 6px;
  color: #6a5034;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.starter-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.starter-btn {
  min-height: 40px;
  background: #f6ebd8;
  border: 1px solid #d0b893;
  color: #5a422b;
  font-weight: 700;
}

.starter-btn.active {
  background: #6b2f27;
  border-color: #6b2f27;
  color: #fff;
}

.setup-panel h2 {
  margin: 0;
  font-size: 1rem;
}

label {
  display: grid;
  gap: 5px;
  font-size: 0.84rem;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  background: #fbf4e6;
  border: 1px solid #d2bb99;
  border-radius: 8px;
  color: var(--text);
  padding: 9px 10px;
  min-height: 42px;
}

button {
  border-radius: 8px;
  border: 0;
  min-height: 42px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 1px;
}

.primary {
  background: linear-gradient(135deg, #a93d2a, #c85a3d);
  color: #fff;
  font-weight: 700;
}

.ghost {
  background: #e8dcc5;
  color: #493523;
  font-weight: 700;
  min-height: 38px;
  padding: 0 11px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 38px;
  border: 1px solid #be9a6a;
  background:
    linear-gradient(180deg, rgba(248, 239, 224, 0.92), rgba(227, 210, 180, 0.88));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34);
}

.ghost:disabled {
  opacity: 0.5;
}

#undoBtn {
  border: 1px solid #be9a6a;
  background:
    linear-gradient(180deg, rgba(248, 239, 224, 0.92), rgba(227, 210, 180, 0.88));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.34),
    0 1px 0 rgba(120, 85, 46, 0.22);
}

#undoBtn:disabled {
  opacity: 0.62;
}

.scoreboard {
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.checkout {
  padding: 9px 10px;
  height: 168px;
  display: flex;
  flex-direction: column;
}

.checkout-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.checkout h2 {
  margin: 0;
  font-size: 1.03rem;
  font-family: "Barlow Condensed", "Impact", sans-serif;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.checkout-live {
  margin: 0;
  font-size: 0.78rem;
  color: #6f5740;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 54%;
}

.checkout-routes {
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.checkout-routes li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: #efe2cb;
  border: 1px solid #d3b591;
  border-radius: 8px;
  padding: 6px 8px;
}

.checkout-routes li.route-empty {
  border-style: dashed;
  background: #f3e8d5;
}

.checkout-routes span {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #806246;
}

.checkout-routes strong {
  font-size: 0.88rem;
  color: #2d2014;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.checkout-routes li.route-empty strong {
  color: #8b7357;
  letter-spacing: 0.06em;
}

.checkout-note {
  margin: 7px 0 0;
  font-size: 0.8rem;
  color: #624a35;
  line-height: 1.3;
  min-height: 2.1em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.entry h2,
.history h2,
.setup-panel h2 {
  font-family: "Barlow Condensed", "Impact", sans-serif;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.player-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  background: #f9f2e4;
  border: 1px solid #d5c1a0;
  border-radius: 8px;
  padding: 8px;
  transition: transform 150ms ease, border-color 150ms ease;
  cursor: pointer;
  min-width: 0;
}

.player-card.active {
  border-color: #b25b34;
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(179, 77, 42, 0.55), 0 7px 14px rgba(34, 19, 11, 0.18);
}

.player-meta {
  display: grid;
  gap: 1px;
}

.player-name {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-status {
  color: #755f48;
  font-size: 0.74rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.turn-flag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.63rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #8a2e24, #bb5134);
}

.player-score {
  font-family: "Barlow Condensed", "Impact", sans-serif;
  font-size: clamp(1.8rem, 8vw, 2.2rem);
  font-weight: 800;
  line-height: 1;
  color: #f5ead3;
  background: linear-gradient(180deg, #3b2a1d, #2a1d14);
  border: 1px solid #4c3626;
  border-radius: 7px;
  padding: 3px 8px 2px;
  min-width: 72px;
  text-align: right;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.progress-wrap {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: #eadcc6;
  overflow: hidden;
}

.progress {
  height: 100%;
  background: linear-gradient(90deg, #5e8b4b, #88ad6c);
}

.entry {
  padding: 9px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.entry h2 {
  margin: 0;
  font-size: 0.98rem;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.mode {
  background: #e8d8bc;
  color: #624a35;
  border: 1px solid #cfb590;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.mode.active {
  background: #6b2f27;
  color: #fff;
  border-color: #6b2f27;
}

.active-player {
  margin: 6px 0 4px;
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  background: linear-gradient(135deg, #6f2f27, #8f3f2f);
  border: 1px solid #ab6b4c;
  border-radius: 8px;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.active-player::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #f3d8a1;
  box-shadow: 0 0 0 3px rgba(243, 216, 161, 0.18);
  animation: pulse-turn 1.2s ease-in-out infinite;
}

.turn-display {
  margin-bottom: 8px;
}

.turn-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.turn-value {
  font-family: "Barlow Condensed", "Impact", sans-serif;
  font-size: clamp(2.4rem, 11vw, 3rem);
  font-weight: 800;
  line-height: 1;
  margin: 0;
  color: #2d2015;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.28);
}

.turn-remaining {
  margin: 0;
  padding: 6px 11px;
  min-width: clamp(72px, 24vw, 96px);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  border-radius: 999px;
  background: #e8dac3;
  border: 2px solid #c69f6e;
  color: #5b3b24;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.mode-switch > button,
.multi-buttons > button,
.segment-grid > button,
.keypad > button {
  min-width: 0;
}

.turn-meta {
  margin: 2px 0 0;
  min-height: 1.2em;
  color: #503925;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.keypad button {
  background: #f6ecda;
  color: #4f3824;
  border: 1px solid #cfb796;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -1px 0 rgba(160, 124, 77, 0.28);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 7px;
}

.keypad button {
  min-height: 46px;
  font-size: 0.98rem;
}

.keypad button.muted {
  background: #e8d8c2;
  color: #6c5a49;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  background: #f4ead8;
  border: 1px solid #d4be9f;
  border-radius: 8px;
  padding: 7px 9px;
  color: #5a422d;
}

.inline-check input {
  min-height: auto;
}

#dartEntryPanel {
  min-height: 0;
}

.dart-compose {
  margin-top: 7px;
  border: 1px solid #d0b48d;
  border-radius: 9px;
  background: #f8efde;
  padding: 8px;
}

.dart-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.dart-preview {
  font-family: "Barlow Condensed", "Impact", sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  margin-top: 2px;
}

.multi-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.mult {
  background: #eadcc5;
  border: 1px solid #cfb691;
  color: #573f2b;
  font-weight: 700;
}

.mult.active {
  background: #6b2f27;
  color: #fff;
  border-color: #6b2f27;
}

.mult:disabled {
  opacity: 0.45;
}

.segment-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.segment-grid button {
  min-height: 40px;
  background: #f6ebd8;
  color: #563f2b;
  border: 1px solid #d0b893;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -1px 0 rgba(160, 124, 77, 0.24);
}

.segment-grid button.active {
  background: #7b3428;
  color: #fff;
  border-color: #7b3428;
}

.submit {
  width: 100%;
  margin-top: 8px;
  font-size: 0.98rem;
}

.feedback {
  min-height: 1.1em;
  margin: 6px 2px 0;
  color: var(--accent-strong);
  font-size: 0.84rem;
}

.history {
  padding: 8px;
}

.history h2 {
  margin: 0 0 5px;
  font-size: 0.9rem;
}

.history ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
  max-height: 58px;
  overflow: auto;
}

.history li {
  background: #f7efde;
  border: 1px solid #d8c3a4;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.76rem;
}

.history-back {
  width: 100%;
  margin-top: 6px;
  min-height: 34px;
  font-size: 0.8rem;
}

.quick-setup-link {
  position: fixed;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 9px;
  font-family: "IBM Plex Mono", "Courier New", monospace;
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: #5a422b;
  border: 1px solid rgba(177, 139, 84, 0.72);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(193, 154, 94, 0.2) 0 1px, transparent 1px 100%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0.14)),
    #efe3cc;
  box-shadow: 0 5px 10px rgba(15, 10, 7, 0.2);
  clip-path: polygon(0 6px, 6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px));
  opacity: 0.86;
}

.quick-setup-link::before {
  content: "<";
  font-size: 0.76em;
  line-height: 1;
}

.quick-setup-link:hover,
.quick-setup-link:focus-visible {
  opacity: 1;
  box-shadow: 0 6px 12px rgba(15, 10, 7, 0.25);
}

.game-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.win {
  color: var(--ok);
  font-weight: 700;
}

@keyframes pulse-turn {
  0% {
    transform: scale(0.86);
    opacity: 0.72;
  }

  50% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(0.86);
    opacity: 0.72;
  }
}

@keyframes rise-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (min-width: 720px) {
  .app-shell {
    padding-top: 14px;
  }

  .game-shell {
    height: auto;
    max-height: none;
    overflow: visible;
    display: block;
  }

  .setup-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .setup-panel h2,
  .setup-panel .primary,
  .setup-panel .ghost,
  .rules-note {
    grid-column: 1 / -1;
  }
}

@media (max-height: 760px) {
  .hero h1 {
    font-size: clamp(1.7rem, 7vw, 2.2rem);
  }

  .app-shell {
    padding-top: max(6px, env(safe-area-inset-top));
  }

  .scoreboard {
    gap: 4px;
    padding: 6px;
  }

  .player-card {
    padding: 6px;
  }

  .entry {
    padding: 7px;
  }

  .active-player {
    margin: 5px 0 4px;
    padding: 4px 8px;
    font-size: 0.86rem;
  }

  .turn-display {
    margin-bottom: 6px;
  }

  .keypad button {
    min-height: 42px;
  }

  .checkout,
  .history {
    display: none;
  }

  .segment-grid button {
    min-height: 36px;
  }
}

@media (max-width: 430px) {
  .app-shell {
    padding: max(4px, env(safe-area-inset-top)) 4px max(4px, env(safe-area-inset-bottom));
  }

  .game-shell {
    display: block;
    height: auto;
    max-height: none;
    overflow: visible;
    gap: 5px;
  }

  .checkout {
    display: block;
    padding: 6px 7px;
    height: 138px;
  }

  .checkout h2 {
    font-size: 0.86rem;
  }

  .checkout-live {
    font-size: 0.68rem;
  }

  .checkout-routes {
    margin-top: 5px;
    gap: 4px;
  }

  .checkout-routes li {
    padding: 4px 6px;
    border-radius: 7px;
  }

  .checkout-routes span {
    font-size: 0.62rem;
  }

  .checkout-routes strong {
    font-size: 0.74rem;
  }

  .checkout-note {
    margin-top: 5px;
    font-size: 0.69rem;
    line-height: 1.2;
    min-height: 2.3em;
  }

  .scoreboard {
    padding: 5px;
    gap: 4px;
  }

  .player-card {
    padding: 6px;
    gap: 4px;
  }

  .player-name {
    font-size: 0.8rem;
  }

  .player-status {
    font-size: 0.62rem;
  }

  .turn-flag {
    margin-left: 4px;
    padding: 1px 5px;
    font-size: 0.54rem;
  }

  .player-score {
    font-size: clamp(1.45rem, 8vw, 1.82rem);
    min-width: 56px;
    padding: 2px 6px 1px;
  }

  .progress-wrap {
    height: 7px;
  }

  .entry {
    padding: 6px;
    overflow: visible;
  }

  .entry h2 {
    font-size: 0.82rem;
  }

  .entry-head .ghost {
    min-height: 34px;
    padding: 0 9px;
  }

  .active-player {
    margin: 4px 0 3px;
    padding: 3px 7px;
    font-size: 0.78rem;
    gap: 5px;
  }

  .active-player::before {
    width: 7px;
    height: 7px;
  }

  .mode-switch {
    gap: 5px;
    margin-top: 4px;
  }

  .mode {
    min-height: 34px;
  }

  .turn-display {
    margin-bottom: 4px;
  }

  .turn-value {
    font-size: clamp(1.7rem, 9vw, 2.1rem);
  }

  .turn-remaining {
    font-size: 0.86rem;
    min-width: 84px;
    padding: 4px 8px;
  }

  .turn-meta {
    font-size: 0.8rem;
    min-height: 1.1em;
  }

  .keypad {
    gap: 4px;
    margin-top: 4px;
  }

  .keypad button {
    min-height: 36px;
    font-size: 0.84rem;
  }

  .inline-check {
    margin-top: 5px;
    padding: 5px 7px;
    font-size: 0.72rem;
    gap: 7px;
  }

  .dart-compose {
    margin-top: 4px;
    padding: 6px;
  }

  .dart-label {
    font-size: 0.72rem;
  }

  .dart-preview {
    font-size: 1.35rem;
    margin-top: 1px;
  }

  .multi-buttons,
  .segment-grid {
    gap: 4px;
    margin-top: 4px;
  }

  .mult {
    min-height: 34px;
    font-size: 0.82rem;
  }

  .segment-grid button {
    min-height: 30px;
    font-size: 0.78rem;
  }

  .submit {
    margin-top: 5px;
    min-height: 36px;
    font-size: 0.88rem;
  }

  .history {
    padding: 6px;
  }

  .history h2 {
    font-size: 0.8rem;
  }

  .history li {
    font-size: 0.7rem;
    padding: 5px 7px;
  }

  .history-back {
    min-height: 30px;
    margin-top: 5px;
    font-size: 0.72rem;
  }

  .quick-setup-link {
    right: 7px;
    bottom: max(7px, env(safe-area-inset-bottom));
    min-height: 28px;
    padding: 0 8px;
    font-size: 0.6rem;
    gap: 3px;
  }
}

@media (max-width: 390px) and (max-height: 700px) {
  .game-page {
    --cut: 8px;
  }

  .app-shell {
    padding: max(4px, env(safe-area-inset-top)) 4px max(4px, env(safe-area-inset-bottom));
  }

  .game-shell {
    display: block;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .history {
    display: none !important;
  }

  .quick-setup-link {
    right: 6px;
    bottom: max(6px, env(safe-area-inset-bottom));
    min-height: 26px;
    padding: 0 7px;
    font-size: 0.56rem;
    gap: 2px;
  }

  .checkout {
    display: block;
    padding: 5px 6px;
    height: 122px;
  }

  .checkout h2 {
    font-size: 0.78rem;
  }

  .checkout-live {
    font-size: 0.62rem;
  }

  .checkout-routes {
    margin-top: 4px;
    gap: 3px;
  }

  .checkout-routes li {
    padding: 3px 5px;
  }

  .checkout-routes span {
    font-size: 0.56rem;
  }

  .checkout-routes strong {
    font-size: 0.66rem;
  }

  .checkout-note {
    margin-top: 4px;
    font-size: 0.62rem;
    min-height: 2.2em;
  }

  .scoreboard {
    padding: 4px;
    gap: 3px;
  }

  .player-card {
    padding: 5px;
    gap: 3px;
  }

  .player-name {
    font-size: 0.74rem;
  }

  .player-status {
    font-size: 0.56rem;
  }

  .turn-flag {
    margin-left: 3px;
    padding: 1px 4px;
    font-size: 0.5rem;
  }

  .player-score {
    font-size: clamp(1.2rem, 7vw, 1.55rem);
    min-width: 48px;
    padding: 2px 5px 1px;
  }

  .progress-wrap {
    height: 6px;
  }

  .entry {
    padding: 5px;
    overflow: visible;
  }

  .entry-head .ghost {
    min-height: 30px;
    padding: 0 7px;
    font-size: 0.76rem;
  }

  .entry h2 {
    font-size: 0.74rem;
  }

  .active-player {
    margin: 3px 0;
    padding: 3px 6px;
    font-size: 0.72rem;
    gap: 4px;
  }

  .active-player::before {
    width: 6px;
    height: 6px;
  }

  .mode-switch {
    gap: 4px;
    margin-top: 3px;
  }

  .mode {
    min-height: 30px;
    font-size: 0.72rem;
  }

  .turn-display {
    margin-bottom: 3px;
  }

  .turn-value {
    font-size: clamp(1.35rem, 8vw, 1.75rem);
  }

  .turn-remaining {
    font-size: 0.8rem;
    min-width: 78px;
    padding: 3px 7px;
  }

  .turn-meta {
    font-size: 0.72rem;
    min-height: 1em;
  }

  .keypad,
  .multi-buttons,
  .segment-grid {
    gap: 3px;
    margin-top: 3px;
  }

  .keypad button,
  .mult,
  .segment-grid button {
    min-height: 28px;
    font-size: 0.72rem;
  }

  .inline-check {
    margin-top: 4px;
    padding: 4px 6px;
    font-size: 0.66rem;
    gap: 6px;
  }

  .dart-compose {
    margin-top: 3px;
    padding: 5px;
  }

  .dart-label {
    font-size: 0.66rem;
  }

  .dart-preview {
    font-size: 1.15rem;
    margin-top: 1px;
  }

  .submit {
    margin-top: 4px;
    min-height: 32px;
    font-size: 0.8rem;
    position: static;
    z-index: auto;
  }

  .feedback {
    margin-top: 4px;
    font-size: 0.72rem;
  }
}

@media (max-width: 340px) {
  .app-shell {
    padding-left: 3px;
    padding-right: 3px;
  }

  .scoreboard {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .turn-main {
    flex-wrap: wrap;
    gap: 4px;
  }

  .turn-remaining {
    min-width: 0;
    width: max-content;
  }

  .checkout-head {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 4px;
  }

  .checkout-live {
    max-width: 100%;
  }
}
