:root {
  --ink: #0b1020;
  --navy: #141b2e;
  --panel: #1b2438;
  --line: rgba(243, 234, 215, 0.12);
  --cream: #f3ead7;
  --muted: #8d97ad;
  --paper: #e3d3b0;
  --paper-deep: #cbb892;
  --jade: #1fd27a;
  --jade-deep: #0f2a1c;
  --cyan: #3ee0ff;
  --cyan-deep: #123445;
  --amber: #ffb020;
  --magenta: #ff4f8b;
  --danger: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url("fonts/bricolage-latinext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url("fonts/bricolage-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/jetbrains-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/jetbrains-latinext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/jetbrains-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: var(--ink);
  color: var(--cream);
  font-family: "Bricolage Grotesque", "Segoe UI", sans-serif;
}

body {
  background-color: var(--ink);
}

.icon {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
}

.icon-lg { width: 22px; height: 22px; }

.shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 20px 64px;
  padding-top: max(28px, calc(env(safe-area-inset-top, 0px) + 16px));
  padding-bottom: max(64px, calc(env(safe-area-inset-bottom, 0px) + 28px));
  padding-left: max(20px, calc(env(safe-area-inset-left, 0px) + 12px));
  padding-right: max(20px, calc(env(safe-area-inset-right, 0px) + 12px));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: block;
  object-fit: cover;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.seat .token {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.cell-token {
  width: 82%;
  height: 82%;
  object-fit: contain;
  pointer-events: none;
  position: relative;
  z-index: 1;
}

.tier-showcase {
  position: relative;
  margin: 4px 0 14px;
  padding: 18px 8px 6px;
  overflow: visible;
}

.tier-showcase__rail {
  position: absolute;
  top: 52px;
  left: 12%;
  right: 12%;
  display: flex;
  align-items: center;
  gap: 0;
  pointer-events: none;
  z-index: 0;
}

.tier-showcase__rail i {
  flex: 1;
  height: 2px;
  background: rgba(243, 234, 215, 0.08);
  border-radius: 1px;
}

.tier-showcase__rail span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(243, 234, 215, 0.14);
}

.tier-showcase__row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tier-medal {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 118px;
  overflow: visible;
}

.tier-medal__halo {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 88px;
  height: 88px;
  transform: translateX(-50%);
  border-radius: 50%;
  filter: blur(10px);
  opacity: 0.85;
  pointer-events: none;
}

.tier-medal--bronze .tier-medal__halo { background: rgba(205, 127, 50, 0.32); }
.tier-medal--silver .tier-medal__halo { background: rgba(192, 199, 209, 0.28); }
.tier-medal--gold .tier-medal__halo { background: rgba(255, 176, 32, 0.34); }

.tier-medal__disc {
  position: relative;
  width: 52px;
  height: 52px;
  margin-top: 10px;
  border-radius: 50%;
  border: 2.5px solid;
  display: grid;
  place-items: center;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.tier-medal__disc::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 8px;
  width: 42%;
  height: 22%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  transform: rotate(-18deg);
}

.tier-medal__disc span {
  position: relative;
  z-index: 1;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.tier-medal--bronze .tier-medal__disc {
  border-color: #cd7f32;
  background: linear-gradient(145deg, #d9954a, #8f4f1c);
  color: #ffe0b5;
}

.tier-medal--silver .tier-medal__disc {
  border-color: #c0c7d1;
  background: linear-gradient(145deg, #e8edf4, #8a93a3);
  color: #ffffff;
}

.tier-medal--gold .tier-medal__disc {
  width: 58px;
  height: 58px;
  border-color: #ffb020;
  background: linear-gradient(145deg, #ffd56a, #c47e00);
  color: #fff4c8;
}

.tier-medal--gold .tier-medal__disc span { font-size: 22px; }

.tier-medal strong {
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.tier-medal--bronze strong { color: #cd7f32; }
.tier-medal--silver strong { color: #c0c7d1; }
.tier-medal--gold strong { color: #ffb020; }

.tier-medal small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.tier-showcase__caption {
  margin: 8px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.brand h1 {
  font-size: 28px;
  letter-spacing: 0.18em;
  font-weight: 800;
  line-height: 1;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: "JetBrains Mono", monospace;
}

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--cream);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.04em;
}

.chip.jade { color: var(--jade); border-color: rgba(31, 210, 122, 0.35); }
.chip.cyan { color: var(--cyan); border-color: rgba(62, 224, 255, 0.35); }

.status {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  margin-bottom: 18px;
  font-size: 15px;
}

.status .pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 6px rgba(255, 176, 32, 0.12);
}

.tip {
  background: var(--panel);
  border: 1px solid rgba(62, 224, 255, 0.28);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

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

.tip strong {
  display: block;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.tip ol {
  margin: 0 0 12px 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.tip .icon-btn { margin-top: 4px; }

.status.playing .pulse { background: var(--jade); box-shadow: 0 0 0 6px rgba(31, 210, 122, 0.12); }
.status.won .pulse { background: var(--cyan); }
.status.draw .pulse { background: var(--magenta); }
.status.paused .pulse { background: var(--muted); }

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  margin-bottom: 18px;
  align-items: stretch;
}

.seat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.seat.active { outline: 1px solid rgba(62, 224, 255, 0.45); }
.seat.player.active { outline-color: rgba(31, 210, 122, 0.55); }

.token {
  width: 36px;
  height: 36px;
}

.seat h2 {
  font-size: 16px;
  font-weight: 700;
}

.seat .meta {
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  margin-top: 2px;
}

.clock {
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: #0e1424;
  border: 1px solid var(--line);
  font-family: "JetBrains Mono", monospace;
}

.clock strong {
  font-size: 22px;
  letter-spacing: 0.08em;
}

.clock span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.stage {
  position: relative;
  background:
    radial-gradient(ellipse 70% 55% at 82% 12%, rgba(255, 79, 139, 0.08), transparent 55%),
    radial-gradient(ellipse 65% 50% at 12% 88%, rgba(255, 176, 32, 0.1), transparent 55%),
    linear-gradient(165deg, #1a2238 0%, #12182a 55%, #0e1424 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.stage-label {
  display: none;
}

.stage-label.start { top: 10px; right: 18px; color: var(--magenta); }
.stage-label.goal { bottom: 12px; left: 18px; color: var(--amber); }

.board {
  --tile-a: transparent;
  --tile-b: transparent;
  --tile-edge-a: transparent;
  --tile-edge-b: transparent;
  position: relative;
  display: block;
  width: min(100%, 640px);
  aspect-ratio: 1;
  margin: 10px auto 0;
  padding: 10px;
  background:
    linear-gradient(155deg, #3d454c 0%, #2a3038 45%, #1a1f24 100%);
  border-radius: 14px;
  box-shadow:
    0 0 0 1px #525a62,
    inset 0 1px 0 rgba(210, 218, 228, 0.1),
    inset 0 -2px 0 rgba(0, 0, 0, 0.5),
    0 12px 28px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.board-surface {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
}

.board-surface.simple-board .board-pcb-pattern,
.board-surface.simple-board .board-pcb-decor {
  opacity: 0.08;
}

.board-surface.simple-board {
  background: rgba(12, 28, 22, 0.95);
}


.board-cells {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(22, minmax(0, 1fr));
  grid-template-rows: repeat(22, minmax(0, 1fr));
  gap: 0;
}

.board::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 4px;
  box-shadow:
    inset 0 0 0 1px rgba(198, 134, 66, 0.28),
    inset 0 0 40px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 1;
}

.board::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 4px;
  background:
    radial-gradient(ellipse 70% 55% at 50% 45%, rgba(94, 196, 232, 0.06), transparent 70%),
    radial-gradient(ellipse 40% 35% at 12% 88%, rgba(198, 134, 66, 0.14), transparent 65%),
    radial-gradient(ellipse 85% 75% at 50% 50%, transparent 35%, rgba(0, 0, 0, 0.32) 100%);
  pointer-events: none;
  z-index: 1;
}

.board-pcb-pattern {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  opacity: 0.92;
}

.board-pcb-decor {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.board-pcb-decor .pcb-trace-pulse {
  stroke-dasharray: 0.45 1.1;
  animation: pcb-data-flow 3.8s linear infinite;
}

@keyframes pcb-data-flow {
  to {
    stroke-dashoffset: -5.5;
  }
}

.board-pcb-decor .pcb-trace-powered-you {
  filter: drop-shadow(0 0 0.06rem rgba(31, 210, 122, 0.28));
}

.board-pcb-decor .pcb-trace-powered-ai {
  filter: drop-shadow(0 0 0.06rem rgba(62, 224, 255, 0.28));
}

@media (prefers-reduced-motion: reduce) {
  .board-pcb-decor .pcb-trace-pulse {
    animation: none;
    stroke-dasharray: none;
  }
}

.trail-paths {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.trail-paths .trail-move-joint-you {
  filter: drop-shadow(0 0 0.05rem rgba(31, 210, 122, 0.35));
}

.trail-paths .trail-move-joint-ai {
  filter: drop-shadow(0 0 0.05rem rgba(62, 224, 255, 0.35));
}

@keyframes landmark-capture-flash {
  0% { opacity: 0.15; transform: scale(0.85); }
  45% { opacity: 0.95; }
  100% { opacity: 0; transform: scale(1.15); }
}

.board-decor-gems .landmark-capture-flash {
  animation: landmark-capture-flash 0.68s ease-out forwards;
  transform-origin: center;
  transform-box: fill-box;
}

.board-surface::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  border-radius: 4px;
  box-shadow: inset 0 0 18% 8% rgba(0, 0, 0, 0.28);
}

.board-decor {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cell {
  aspect-ratio: 1;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  z-index: 1;
  transition: background 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.cell.dark,
.cell.light,
.cell.edge.light,
.cell.edge.dark {
  background: transparent;
}

.cell.grid-v,
.cell.grid-h,
.cell.grid-v.grid-h {
  box-shadow: none;
}

.cell svg,
.cell-token { width: 78%; height: 78%; pointer-events: none; position: relative; z-index: 1; }
.cell.player .cell-token,
.cell.ai .cell-token,
.cell.player svg,
.cell.ai svg { animation: token-in 0.28s ease; }

.floating-token {
  position: absolute;
  z-index: 6;
  width: calc(100% / 22 * 0.82);
  height: calc(100% / 22 * 0.82);
  left: calc(100% / 22 * var(--tx, 0) + 100% / 22 * 0.09);
  top: calc(100% / 22 * var(--ty, 0) + 100% / 22 * 0.09);
  transition:
    left 0.22s cubic-bezier(0.45, 0, 0.55, 1),
    top 0.22s cubic-bezier(0.45, 0, 0.55, 1);
  pointer-events: none;
}

.floating-token.no-transition {
  transition: none;
}

@keyframes token-in {
  from { transform: scale(0.45); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes goal-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.18); }
}

.cell:hover { filter: brightness(1.08); }
.cell.player {
  background: #0f2a1c !important;
  box-shadow: inset 0 0 0 2px var(--jade), inset 0 0 12px rgba(31, 210, 122, 0.35);
}
.cell.ai {
  background: #123445 !important;
  box-shadow: inset 0 0 0 2px var(--cyan);
}
.cell.target {
  background: rgba(255, 79, 139, 0.16) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 79, 139, 0.65);
  animation: goal-glow 2.4s ease-in-out infinite;
}
.cell.placement {
  background: rgba(255, 176, 32, 0.14) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 176, 32, 0.55), inset 0 0 10px rgba(255, 176, 32, 0.2);
}

.landmark-gem {
  position: absolute;
  width: 22%;
  height: 22%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 2px;
  pointer-events: none;
  z-index: 1;
  border: 1px solid;
}

.landmark-gem.open {
  background: rgba(255, 176, 32, 0.55);
  border-color: rgba(255, 176, 32, 0.85);
}

.landmark-gem.you {
  background: var(--jade-deep);
  border-color: var(--jade);
}

.landmark-gem.ai {
  background: var(--cyan-deep);
  border-color: var(--cyan);
}

.gem-toast-slot {
  position: relative;
  height: 0;
  margin: 0;
  z-index: 40;
  pointer-events: none;
}

.gem-toast {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0;
  padding: 8px 14px;
  min-height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(255, 176, 32, 0.5);
  background: rgba(18, 22, 34, 0.94);
  color: var(--amber);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  animation: gem-toast-in 0.22s ease;
}

.gem-toast[hidden] {
  display: none !important;
}

@keyframes gem-toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#board-decor-gems {
  z-index: 6;
}

#board-connectors {
  z-index: 7;
}

.board-decor-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.board-decor-goal-svg {
  position: absolute;
  inset: 10px;
  z-index: 0;
}

.board-decor__goal-halo {
  position: absolute;
  border-radius: 4px;
  border: 2px solid rgba(255, 79, 139, 0.55);
  background: rgba(255, 79, 139, 0.12);
  box-sizing: border-box;
}

.board-decor__goal-star {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.board-decor__gem {
  position: absolute;
  transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 2px;
  border: 1.5px solid;
  box-sizing: border-box;
}

.board-decor__gem.open {
  background: rgba(255, 176, 32, 0.62);
  border-color: rgba(255, 224, 138, 0.95);
}

.board-decor__gem.you {
  background: var(--jade-deep);
  border-color: var(--jade);
}

.board-decor__gem.ai {
  background: var(--cyan-deep);
  border-color: var(--cyan);
}

/* Soft wash — no blink; checker still readable */
.cell.legal {
  cursor: pointer;
  z-index: 2;
}
.cell.light.legal {
  background: rgba(198, 134, 66, 0.32) !important;
}
.cell.dark.legal {
  background: rgba(198, 134, 66, 0.36) !important;
}
.cell.edge.light.legal,
.cell.edge.dark.legal {
  background: rgba(198, 134, 66, 0.32) !important;
}
.cell.legal::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(15, 42, 28, 0.85);
  box-shadow: 0 0 0 1.5px rgba(31, 210, 122, 0.95);
  pointer-events: none;
}
.cell.target.legal,
.cell.target.legal-dir,
.cell.target.legal-pick {
  background:
    linear-gradient(rgba(31, 210, 122, 0.35), rgba(31, 210, 122, 0.35)),
    #2a1f0c !important;
}
.cell.target.legal::after {
  background: var(--magenta);
  box-shadow: 0 0 0 1.5px rgba(255, 79, 139, 0.9);
}
.cell.player:hover,
.cell.ai:hover { filter: none; }

.dock {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  margin-bottom: 16px;
}

.dock-title {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  font-family: "JetBrains Mono", monospace;
}

.move-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.move-btn,
.confirm-btn,
.icon-btn,
.ghost-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #12192b;
  color: var(--cream);
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.icon-btn[hidden],
.ghost-btn[hidden],
.pwa-install__actions [hidden] {
  display: none !important;
}

.move-btn {
  min-height: 52px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.55;
}

.move-btn.is-on { opacity: 1; background: #1c2844; }
.left-btn.is-on { border-color: rgba(31, 210, 122, 0.5); color: var(--jade); }
.down-left-btn.is-on { border-color: rgba(62, 224, 255, 0.5); color: var(--cyan); }
.down-btn.is-on { border-color: rgba(255, 176, 32, 0.5); color: var(--amber); }

.distance-title {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  min-width: 120px;
}

.distance-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 14px 0 8px;
}

.step-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #12192b;
  color: var(--cream);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.step-btn:hover {
  border-color: rgba(31, 210, 122, 0.45);
}

.dock-hint {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 12px;
}

.distance-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.distance-btn {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #101726;
  color: var(--cream);
  font-family: "JetBrains Mono", monospace;
  cursor: pointer;
  opacity: 0.45;
}

.distance-btn:not(:disabled) {
  opacity: 1;
}

.distance-btn.is-on,
.distance-btn.selected {
  background: rgba(31, 210, 122, 0.16);
  color: var(--jade);
  border-color: var(--jade);
  opacity: 1;
}

.distance-btn-bonus:not(:disabled).is-on,
.distance-btn-bonus:not(:disabled).selected {
  background: rgba(255, 176, 32, 0.2);
  color: var(--amber);
  border-color: var(--amber);
}

.confirm-btn {
  width: 100%;
  min-height: 48px;
  background: var(--cream);
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.icon-btn {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.icon-btn.primary { background: var(--jade); color: #062213; border-color: transparent; }
.icon-btn.warn { color: var(--amber); }

.rules-toggle {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 8px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.5px;
  cursor: pointer;
  text-align: center;
}

.rules-toggle:hover {
  color: var(--cream);
}

.rules {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

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

.rules li {
  list-style: none;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 16, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 20px;
}

.modal.is-open {
  display: flex;
}

.modal-content {
  width: min(480px, 100%);
  max-height: 82vh;
  overflow: auto;
  background: var(--navy);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h3 { font-size: 18px; }

.close-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #101726;
  color: var(--cream);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.setting-group { margin-bottom: 14px; }
.setting-group label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.setting-group select,
.setting-group input[type="range"] {
  width: 100%;
  background: #101726;
  color: var(--cream);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.modal-footer { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.ghost-btn { padding: 10px 14px; }

.result-card {
  text-align: center;
}

.result-token {
  width: 56px;
  height: 56px;
  margin: 4px auto 12px;
  display: block;
}

.result-card h3 {
  font-size: 26px;
  margin: 0 0 8px;
}

.result-meta {
  color: var(--cream);
  font-size: 13px;
  margin: 10px 0 0;
}

.result-award {
  color: var(--amber);
  font-size: 13px;
  margin: 8px 0 0;
}

.result-actions {
  justify-content: center;
  margin-top: 18px;
}

.achievement {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: #101726;
  border: 1px solid var(--line);
  margin-bottom: 8px;
}

.achievement.unlocked { border-color: rgba(31, 210, 122, 0.4); }
.achievement-icon { width: 28px; height: 28px; color: var(--amber); flex-shrink: 0; }
.achievement-info { flex: 1; min-width: 0; }
.achievement-name { font-weight: 700; }
.achievement-description { color: var(--muted); font-size: 13px; margin-top: 2px; }

.tier-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tier-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid;
  opacity: 0.55;
}

.tier-chip.bronze { color: #cd7f32; border-color: #cd7f32; }
.tier-chip.silver { color: #c0c7d1; border-color: #c0c7d1; }
.tier-chip.gold { color: #ffb020; border-color: #ffb020; }

.tier-chip.on {
  opacity: 1;
  color: #0b1020 !important;
}
.tier-chip.bronze.on { background: #cd7f32; }
.tier-chip.silver.on { background: #c0c7d1; }
.tier-chip.gold.on { background: #ffb020; }

@media (max-width: 720px) {
  .shell {
    padding: 10px 12px 28px;
    padding-top: max(12px, calc(env(safe-area-inset-top, 0px) + 10px));
    padding-bottom: max(28px, calc(env(safe-area-inset-bottom, 0px) + 16px));
    padding-left: max(12px, calc(env(safe-area-inset-left, 0px) + 8px));
    padding-right: max(12px, calc(env(safe-area-inset-right, 0px) + 8px));
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }

  .brand {
    gap: 8px;
    min-width: 0;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    box-shadow: none;
  }

  .brand h1 {
    font-size: 18px;
    letter-spacing: 0.12em;
  }

  .brand p {
    display: none;
  }

  .chip-row {
    gap: 6px;
    justify-content: flex-end;
    flex-shrink: 0;
  }

  .chip {
    padding: 4px 8px;
    font-size: 10px;
  }

  .status {
    min-height: 0;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 12px;
    font-size: 13px;
  }

  .status .pulse {
    box-shadow: 0 0 0 4px rgba(255, 176, 32, 0.12);
  }

  .hud {
    grid-template-columns: 1fr auto 1fr;
    gap: 6px;
    margin-bottom: 8px;
  }

  .seat {
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
  }

  .seat .token,
  .token {
    width: 26px;
    height: 26px;
  }

  .seat h2 {
    font-size: 13px;
  }

  .seat .meta {
    font-size: 9px;
    line-height: 1.25;
  }

  .clock {
    min-width: 68px;
    min-height: auto;
    padding: 6px 8px;
    border-radius: 12px;
    flex-direction: column;
    gap: 0;
  }

  .clock strong {
    font-size: 15px;
  }

  .clock span {
    font-size: 9px;
    letter-spacing: 0.1em;
  }

  .gem-toast {
    left: 8px;
    right: 8px;
    top: 6px;
    font-size: 12px;
    padding: 7px 10px;
    min-height: 0;
  }

  .stage {
    padding: 10px 8px;
    margin-bottom: 8px;
    border-radius: 14px;
    overflow: hidden;
  }

  .stage-label {
    display: none;
  }

  .board {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border-radius: 6px;
    box-shadow: none;
    background: #1a1f24;
    overflow: visible;
  }

  .board-surface {
    border-radius: 6px;
    overflow: hidden;
  }

  .board::before,
  .board::after {
    inset: 0;
    border-radius: 6px;
  }

  .board::before {
    box-shadow: inset 0 0 0 1px rgba(198, 134, 66, 0.22);
  }

  .dock {
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 14px;
  }

  .dock-title {
    display: none;
  }

  .move-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .move-btn {
    min-height: 48px;
    height: 48px;
    padding: 0;
    border-radius: 12px;
    gap: 0;
    font-size: 0;
  }

  .move-btn .btn-label {
    display: none;
  }

  .move-btn .icon {
    width: 22px;
    height: 22px;
  }

  .distance-row {
    gap: 8px;
    margin: 10px 0 6px;
  }

  .distance-title {
    min-width: 0;
    font-size: 12px;
  }

  .step-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 18px;
  }

  .dock-hint {
    margin: 8px 0;
    font-size: 11px;
  }

  .distance-buttons {
    justify-content: center;
    margin-bottom: 0;
  }

  .distance-btn {
    width: 40px;
    height: 40px;
  }

  .toolbar {
    gap: 6px;
    margin-bottom: 12px;
    justify-content: center;
  }

  .toolbar .icon-btn {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    padding: 0;
    border-radius: 12px;
    font-size: 0;
    gap: 0;
  }

  .toolbar .btn-label {
    display: none;
  }

  .toolbar .icon {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 720px) and (max-height: 780px) {
  .shell {
    padding: 6px 10px 20px;
    padding-top: max(10px, calc(env(safe-area-inset-top, 0px) + 8px));
    padding-bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px));
    padding-left: max(10px, calc(env(safe-area-inset-left, 0px) + 6px));
    padding-right: max(10px, calc(env(safe-area-inset-right, 0px) + 6px));
  }

  .topbar {
    margin-bottom: 6px;
  }

  .status {
    padding: 6px 10px;
    margin-bottom: 6px;
    font-size: 12px;
  }

  .hud {
    margin-bottom: 6px;
  }

  .seat .meta {
    display: none;
  }

  .stage {
    padding: 8px 6px;
    margin-bottom: 6px;
  }

  .dock-title,
  .dock-hint {
    display: none;
  }

  .move-btn {
    min-height: 44px;
    height: 44px;
  }
}

.pwa-install {
  position: sticky;
  bottom: 12px;
  z-index: 50;
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(62, 224, 255, 0.35);
  background: rgba(16, 22, 38, 0.96);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.pwa-install[hidden] {
  display: none !important;
}

.pwa-install p {
  margin: 0 0 10px;
  color: var(--cream);
  font-size: 13px;
  line-height: 1.4;
}

.pwa-install__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (display-mode: standalone) {
  .pwa-install {
    display: none !important;
  }
}
