/* ==========================================================================
   Squadro — a duel of momentum
   Palette: olive-black stage, alabaster board, ochre + oxblood wedges, brass.
   ========================================================================== */

:root {
  --ink: #10120e;
  --ink-2: #161912;
  --ink-3: #1c2018;
  --cream: #f4eedf;
  --cream-soft: #ddd6c5;
  --muted: #a9a492;
  --muted-2: #817d6d;
  --line: rgba(244, 238, 223, 0.13);
  --line-strong: rgba(244, 238, 223, 0.26);

  --ochre: #d8a94f;
  --ochre-bright: #efcb80;
  --ochre-deep: #8d6428;
  --oxblood: #a54751;
  --oxblood-bright: #cf7480;
  --oxblood-deep: #57161f;
  --brass: #c6a468;
  --brass-bright: #e8cd9a;

  --board: #e8e1d1;
  --board-deep: #b9ad96;
  --board-line: #a99b83;

  --serif: "Fraunces", "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: "Archivo", "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  --mono: "IBM Plex Mono", "Zen Kaku Gothic New", ui-monospace, SFMono-Regular, Menlo, monospace;

  --ease: cubic-bezier(0.22, 0.8, 0.2, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: "palt" 1;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:disabled { cursor: default; }

::selection { background: rgba(216, 169, 79, 0.28); color: #fffaf0; }

:focus-visible {
  outline: 1px solid var(--brass-bright);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Atmosphere
   -------------------------------------------------------------------------- */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.ambient-glow {
  position: absolute;
  top: 44%;
  left: 46%;
  width: min(1500px, 130vw);
  aspect-ratio: 1.35;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side,
      rgba(210, 180, 118, 0.17),
      rgba(180, 154, 98, 0.07) 46%,
      rgba(20, 22, 16, 0) 72%);
  filter: blur(10px);
}

.ambient-glow::after {
  content: "";
  position: absolute;
  inset: 18% 22% 30% 18%;
  background: radial-gradient(closest-side, rgba(231, 205, 154, 0.08), transparent 70%);
  transform: rotate(-14deg);
}

.ambient-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 95% at 52% 42%, transparent 42%, rgba(6, 7, 5, 0.62) 100%),
    linear-gradient(180deg, rgba(7, 8, 6, 0.28), transparent 22%, transparent 76%, rgba(7, 8, 6, 0.45));
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.055;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: clamp(360px, 27vw, 430px) minmax(0, 1fr);
  min-height: 100svh;
  max-width: 1720px;
  margin: 0 auto;
}

.panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  min-height: 100svh;
  max-height: 100svh;
  padding: 46px clamp(28px, 2.9vw, 46px) 26px;
  border-right: 1px solid var(--line);
  position: relative;
  overflow-y: auto;
  scrollbar-width: none;
  transition: padding 0.5s var(--ease);
}

.panel::-webkit-scrollbar { display: none; }

.panel::after {
  content: "";
  position: absolute;
  top: 7%;
  bottom: 7%;
  right: -1px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(198, 164, 104, 0.32) 22%, rgba(198, 164, 104, 0.32) 78%, transparent);
  pointer-events: none;
}

.brand {
  position: relative;
  flex: 0 0 auto;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--muted-2);
  animation: fadeUp 0.8s 0.08s both;
}

.eyebrow-rule {
  width: 26px;
  height: 1px;
  background: linear-gradient(90deg, var(--brass), rgba(198, 164, 104, 0.15));
}

.wordmark {
  margin: 20px 0 10px;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(54px, 4.9vw, 76px);
  line-height: 0.86;
  letter-spacing: -0.052em;
  color: var(--cream);
  white-space: nowrap;
  font-variation-settings: "opsz" 120;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: fadeUp 0.9s 0.14s both;
  transition: font-size 0.55s var(--ease), margin 0.55s var(--ease);
}

.wordmark .period {
  color: var(--ochre);
  margin-left: 0.035em;
  display: inline-block;
  transform: translateY(-0.01em);
}

.tagline {
  margin: 0;
  font-family: var(--serif);
  font-style: normal;
  font-weight: 400;
  font-size: 20px;
  letter-spacing: 0.06em;
  line-height: 1.55;
  color: var(--muted);
  animation: fadeUp 0.9s 0.22s both;
  transition: opacity 0.35s, max-height 0.45s var(--ease);
}

.app.in-game .wordmark {
  font-size: 44px;
  margin: 16px 0 4px;
  animation: none;
}

.app.in-game .tagline {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
}

.app.in-game .panel {
  padding-top: 36px;
}

/* --------------------------------------------------------------------------
   Mobile actions
   -------------------------------------------------------------------------- */

.mobile-actions { display: none; }

/* --------------------------------------------------------------------------
   Lobby
   -------------------------------------------------------------------------- */

.panel-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
  padding-top: 26px;
}

.lobby > * {
  animation: fadeUp 0.75s both;
}

.lobby > :nth-child(1) { animation-delay: 0.28s; }
.lobby > :nth-child(2) { animation-delay: 0.36s; }
.lobby > :nth-child(3) { animation-delay: 0.44s; }
.lobby > :nth-child(4) { animation-delay: 0.52s; }
.lobby > :nth-child(5) { animation-delay: 0.6s; }

.lede {
  margin: 0 0 24px;
  max-width: 35ch;
  color: #b7b1a0;
  font-size: 14px;
  line-height: 1.9;
  letter-spacing: 0.015em;
  text-wrap: pretty;
}

.field { margin-bottom: 26px; }

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.micro {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.09em;
  color: var(--muted-2);
}

.micro.dim { color: rgba(129, 125, 109, 0.72); }

.rivals {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.rival {
  position: relative;
  min-height: 78px;
  padding: 10px 11px 11px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(244, 238, 223, 0.022), rgba(244, 238, 223, 0.006));
  color: var(--muted);
  transition:
    border-color 0.25s var(--ease-soft),
    background 0.25s var(--ease-soft),
    transform 0.25s var(--ease-soft),
    color 0.25s;
}

@media (hover: hover) {
  .rival:hover {
    border-color: var(--line-strong);
    transform: translateY(-1px);
    color: var(--cream-soft);
  }
}

.rival-mark {
  display: block;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  color: var(--muted-2);
  transition: color 0.25s;
}

.rival-name {
  display: block;
  margin-top: 7px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--cream-soft);
}

.rival-dots {
  display: flex;
  gap: 4px;
  margin-top: 9px;
}

.rival-dots i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(244, 238, 223, 0.18);
  transition: background 0.25s, box-shadow 0.25s;
}

.rival[data-level="initiate"] .rival-dots i:nth-child(1),
.rival[data-level="adept"] .rival-dots i:nth-child(-n + 2),
.rival[data-level="master"] .rival-dots i:nth-child(-n + 3),
.rival[data-level="grandmaster"] .rival-dots i:nth-child(-n + 4) {
  background: var(--brass-bright);
}

.rival[aria-checked="true"] {
  border-color: rgba(198, 164, 104, 0.58);
  background:
    linear-gradient(180deg, rgba(198, 164, 104, 0.13), rgba(198, 164, 104, 0.025));
  color: var(--cream);
}

.rival[aria-checked="true"] .rival-mark { color: var(--brass); }

.rival[aria-checked="true"]::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--brass-bright);
  box-shadow: 0 0 10px rgba(232, 205, 154, 0.7);
}

.rival-desc {
  margin: 10px 0 0;
  min-height: 36px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted-2);
}

.rival-desc.is-swapping { animation: softFade 0.32s var(--ease-soft); }

.side-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.side {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  background: rgba(244, 238, 223, 0.012);
  transition: border-color 0.25s, background 0.25s, color 0.25s, box-shadow 0.25s;
}

.side-piece {
  width: 9px;
  height: 15px;
  flex: 0 0 auto;
  clip-path: polygon(50% 0, 100% 38%, 100% 100%, 0 100%, 0 38%);
  opacity: 0.75;
  transition: opacity 0.25s, transform 0.25s;
}

.side-piece.ochre { background: linear-gradient(180deg, var(--ochre-bright), var(--ochre-deep)); }
.side-piece.oxblood { background: linear-gradient(180deg, var(--oxblood-bright), var(--oxblood-deep)); }

.side-name {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
}

.side em {
  margin-left: auto;
  font-family: var(--mono);
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--muted-2);
}

.side[aria-checked="true"] {
  color: var(--cream);
  border-color: var(--line-strong);
  background: rgba(244, 238, 223, 0.04);
}

.side[data-side="0"][aria-checked="true"] {
  box-shadow: inset 2px 0 0 var(--ochre);
  border-color: rgba(216, 169, 79, 0.4);
}

.side[data-side="1"][aria-checked="true"] {
  box-shadow: inset 2px 0 0 var(--oxblood);
  border-color: rgba(165, 71, 81, 0.48);
}

.side[aria-checked="true"] .side-piece { opacity: 1; transform: translateY(-1px); }

.cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  height: 58px;
  margin-top: 4px;
  padding: 0 20px;
  overflow: hidden;
  border-radius: 3px;
  background:
    linear-gradient(180deg, #e6c98f 0%, #cba96c 56%, #bd9a5c 100%);
  color: #1a1710;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  box-shadow:
    0 12px 34px rgba(198, 164, 104, 0.17),
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -1px 0 rgba(94, 68, 25, 0.24);
  transition: transform 0.25s var(--ease), box-shadow 0.25s, filter 0.25s;
}

.cta::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.4) 46%, transparent 66%);
  transform: translateX(-120%);
  transition: transform 0.65s var(--ease);
}

@media (hover: hover) {
  .cta:hover {
    transform: translateY(-1px);
    filter: brightness(1.035);
    box-shadow:
      0 16px 44px rgba(198, 164, 104, 0.26),
      inset 0 1px 0 rgba(255, 255, 255, 0.5);
  }
  .cta:hover::before { transform: translateX(120%); }
  .cta:hover .cta-arrow { transform: translateX(4px); }
}

.cta:active { transform: translateY(0) scale(0.995); }

.cta-arrow {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1;
  transition: transform 0.3s var(--ease);
}

.cta.small {
  width: auto;
  height: 46px;
  min-width: 210px;
  margin: 0;
  padding: 0 18px;
}

.fineprint {
  margin: 12px 0 0;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: rgba(129, 125, 109, 0.75);
  text-align: center;
}

/* --------------------------------------------------------------------------
   In-game panel
   -------------------------------------------------------------------------- */

.game {
  padding-top: 20px;
  animation: fadeUp 0.6s var(--ease) both;
}

.match-tags {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.turn-block {
  padding: 24px 0 22px;
  border-bottom: 1px solid var(--line);
}

.turn-kicker {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.turn-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ochre);
  box-shadow: 0 0 0 3px rgba(216, 169, 79, 0.12);
  transition: background 0.3s, box-shadow 0.3s;
}

.turn-dot.oxblood {
  background: var(--oxblood);
  box-shadow: 0 0 0 3px rgba(165, 71, 81, 0.14);
}

.turn-dot.thinking { animation: pulseDot 1.6s infinite; }

.turn-title {
  margin: 10px 0 6px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--cream);
}

.turn-note {
  margin: 0;
  min-height: 19px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted-2);
}

.scoreboard {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 28px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.score-name {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 82px;
  color: var(--cream-soft);
}

.score-name .pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ochre);
}

.score-row.oxblood .pip { background: var(--oxblood); }

.score-track {
  display: flex;
  gap: 5px;
}

.score-slot {
  width: 15px;
  height: 8px;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: rgba(244, 238, 223, 0.13);
  transition: background 0.35s, transform 0.35s var(--ease);
}

.score-row.ochre .score-slot.on {
  background: var(--ochre);
  filter: drop-shadow(0 0 5px rgba(216, 169, 79, 0.5));
  animation: slotPop 0.5s var(--ease);
}

.score-row.oxblood .score-slot.on {
  background: var(--oxblood);
  filter: drop-shadow(0 0 5px rgba(165, 71, 81, 0.55));
  animation: slotPop 0.5s var(--ease);
}

.score-count {
  margin-left: auto;
  font-size: 8.5px;
  color: var(--muted-2);
}

.log-block {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  padding-top: 17px;
}

.log-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.log {
  position: relative;
  flex: 1 1 auto;
  min-height: 96px;
  max-height: 210px;
  margin: 0;
  padding: 0 6px 0 0;
  list-style: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(244, 238, 223, 0.16) transparent;
  mask-image: linear-gradient(180deg, transparent 0, #000 12px, #000 100%);
}

.log::-webkit-scrollbar { width: 3px; }
.log::-webkit-scrollbar-thumb { background: rgba(244, 238, 223, 0.15); border-radius: 3px; }

.log:empty::after {
  content: "最初の一手から記録されます。";
  display: block;
  padding: 8px 0;
  font-size: 11.5px;
  line-height: 1.7;
  color: rgba(129, 125, 109, 0.7);
}

.log li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.01em;
  color: var(--muted);
  border-bottom: 1px solid rgba(244, 238, 223, 0.045);
  animation: logIn 0.35s var(--ease-soft) both;
}

.log li:last-child { border-bottom: 0; }

.log-idx {
  width: 17px;
  flex: 0 0 auto;
  font-size: 8px;
  color: rgba(129, 125, 109, 0.55);
}

.log-dot {
  width: 4px;
  height: 4px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ochre);
}

.log-dot.oxblood { background: var(--oxblood); }

.log-main {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-jump {
  margin-left: auto;
  padding: 1px 5px;
  border-radius: 2px;
  background: rgba(165, 71, 81, 0.16);
  color: var(--oxblood-bright);
  font-size: 7.5px;
  letter-spacing: 0.04em;
}

.log-home {
  margin-left: auto;
  color: var(--ochre-bright);
  font-size: 7.5px;
  letter-spacing: 0.08em;
}

.game-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  color: var(--muted);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

@media (hover: hover) {
  .ghost:hover:not(:disabled) {
    border-color: var(--line-strong);
    color: var(--cream);
    background: rgba(244, 238, 223, 0.03);
  }
}

.ghost:disabled { opacity: 0.35; }

.ghost.wide {
  width: 100%;
  height: 48px;
  margin-top: 8px;
}

kbd {
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 7.5px;
  color: var(--muted-2);
}

.panel-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.foot-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--muted-2);
  transition: color 0.2s;
}

@media (hover: hover) {
  .text-link:hover { color: var(--cream); }
}

.sound-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 8px;
}

.sound-bars i {
  display: block;
  width: 2px;
  background: currentColor;
  border-radius: 1px;
}

.sound-bars i:nth-child(1) { height: 3px; }
.sound-bars i:nth-child(2) { height: 7px; }
.sound-bars i:nth-child(3) { height: 5px; }

#soundToggle[aria-pressed="false"] .sound-bars i { height: 2px; }
#soundToggle[aria-pressed="false"] { opacity: 0.65; }

/* --------------------------------------------------------------------------
   Stage
   -------------------------------------------------------------------------- */

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: 30px clamp(24px, 4vw, 64px) 26px;
}

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(100%, calc(100svh - 220px), 740px);
  margin-bottom: 16px;
}

.match-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.07em;
  color: var(--muted-2);
  white-space: nowrap;
}

.meta-mark {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  border: 1px solid rgba(198, 164, 104, 0.7);
  background: rgba(198, 164, 104, 0.25);
}

.turn-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(244, 238, 223, 0.018);
  white-space: nowrap;
  transition: border-color 0.3s, color 0.3s, background 0.3s;
}

.pill-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted-2);
  transition: background 0.3s, box-shadow 0.3s;
}

.turn-pill[data-state="human"] {
  color: var(--cream-soft);
  border-color: rgba(244, 238, 223, 0.24);
  background: rgba(244, 238, 223, 0.04);
}

.turn-pill[data-state="human"] .pill-dot { background: var(--ochre); box-shadow: 0 0 0 3px rgba(216, 169, 79, 0.13); }

.turn-pill[data-state="human"][data-player="1"] .pill-dot {
  background: var(--oxblood);
  box-shadow: 0 0 0 3px rgba(165, 71, 81, 0.14);
}

.turn-pill[data-state="cpu"] .pill-dot { background: var(--oxblood); animation: pulseDot 1.5s infinite; }
.turn-pill[data-state="cpu"][data-player="0"] .pill-dot { background: var(--ochre); }

.turn-pill[data-state="over"] {
  color: var(--brass-bright);
  border-color: rgba(198, 164, 104, 0.4);
}

.board-zone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, calc(100svh - 220px), 740px);
  aspect-ratio: 1;
}

.board-halo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 132%;
  aspect-ratio: 1;
  transform: translate(-50%, -52%);
  border-radius: 50%;
  background: radial-gradient(circle,
      rgba(224, 190, 126, 0.105) 0%,
      rgba(224, 190, 126, 0.04) 38%,
      transparent 66%);
  pointer-events: none;
}

.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  animation: boardIn 1.15s 0.12s var(--ease) both;
}

.board-wrap::before {
  content: "";
  position: absolute;
  left: 9%;
  right: 9%;
  bottom: 2%;
  height: 9%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.72), transparent 68%);
  filter: blur(18px);
  z-index: -1;
}

.board-wrap svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter:
    drop-shadow(0 26px 34px rgba(0, 0, 0, 0.42))
    drop-shadow(0 4px 6px rgba(0, 0, 0, 0.22));
}

.zone-mark {
  position: absolute;
  width: 13px;
  height: 13px;
  border-color: rgba(198, 164, 104, 0.5);
  border-style: solid;
  pointer-events: none;
}

.zone-mark-a {
  left: -13px;
  top: 13px;
  border-width: 1px 0 0 1px;
}

.zone-mark-b {
  right: -13px;
  bottom: 13px;
  border-width: 0 1px 1px 0;
}

.stage-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  width: min(100%, calc(100svh - 220px), 740px);
  margin-top: 18px;
}

.stage-scores {
  display: flex;
  align-items: center;
  gap: 18px;
}

.stage-score {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--muted-2);
}

.stage-score i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ochre);
  align-self: center;
  margin-right: 1px;
}

.stage-score.oxblood i { background: var(--oxblood); }

.stage-score b {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--cream-soft);
  letter-spacing: 0;
}

.stage-score em {
  font-style: normal;
  font-size: 8px;
  color: rgba(129, 125, 109, 0.65);
}

.pace-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 8.8px;
  letter-spacing: 0.03em;
  color: var(--muted-2);
  white-space: nowrap;
}

.pace-set {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(244, 238, 223, 0.55);
}

.dot-set {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

.dot-set i {
  width: 2.5px;
  height: 2.5px;
  border-radius: 50%;
  background: var(--brass);
}

/* --------------------------------------------------------------------------
   SVG board
   -------------------------------------------------------------------------- */

#board text { user-select: none; }
.board-mark {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.34em;
  fill: #8d7e63;
  opacity: 0.5;
}

.board-corner {
  stroke: #b08d52;
  stroke-width: 1.4;
  fill: none;
  opacity: 0.5;
}

.groove {
  stroke: #b3a58d;
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.55;
}

.groove-light {
  stroke: #fff9ea;
  stroke-width: 1;
  stroke-linecap: round;
  opacity: 0.42;
}

.socket {
  fill: url(#socketGrad);
  stroke: #b4a68e;
  stroke-width: 0.8;
}

.socket-rim {
  fill: none;
  stroke: #fffaf0;
  stroke-width: 1;
  opacity: 0.32;
}

.trough {
  fill: url(#troughGrad);
  stroke: #b4a68e;
  stroke-width: 0.8;
}

.trough-rim {
  fill: none;
  stroke: #fffaf0;
  stroke-width: 0.9;
  opacity: 0.3;
}

.pace-dots circle {
  fill: #8d7e63;
  opacity: 0.7;
  transition: fill 0.2s, opacity 0.2s, r 0.2s;
}

.pace-dots.is-live circle {
  fill: var(--brass-bright);
  opacity: 1;
  filter: drop-shadow(0 0 3px rgba(232, 205, 154, 0.55));
}

/* pieces --------------------------------------------------------------- */

.piece {
  cursor: default;
}

.piece .visual {
  animation: pieceDrop 0.82s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 48ms + 260ms);
  transform-box: fill-box;
  transform-origin: center;
}

.piece .body {
  transition: transform 0.24s var(--ease-soft), filter 0.24s;
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

.piece.playable { cursor: pointer; }

@media (hover: hover) {
  .piece.playable:hover .body {
    transform: translateY(-5px);
    filter: brightness(1.06);
  }
}

.piece.selected .body {
  transform: translateY(-6px);
  filter: brightness(1.08);
}

.piece .piece-shadow {
  fill: url(#shadowGrad);
  transition: opacity 0.25s;
}

.piece.playable:hover .piece-shadow,
.piece.selected .piece-shadow { opacity: 0.55; }

.piece .shape {
  stroke: rgba(63, 42, 15, 0.42);
  stroke-width: 1;
}

.piece.oxblood .shape { stroke: rgba(43, 8, 14, 0.55); }

.piece .bevel {
  fill: none;
  stroke: rgba(255, 247, 226, 0.3);
  stroke-width: 0.9;
}

.piece.oxblood .bevel { stroke: rgba(255, 216, 218, 0.22); }

.piece .ridge {
  fill: none;
  stroke: rgba(54, 35, 10, 0.22);
  stroke-width: 1;
}

.piece.oxblood .ridge { stroke: rgba(38, 4, 10, 0.3); }

.piece .grip {
  fill: rgba(79, 53, 16, 0.24);
}

.piece.oxblood .grip { fill: rgba(43, 6, 12, 0.32); }

.piece .hit {
  fill: transparent;
  pointer-events: all;
}

.piece.is-hidden { opacity: 0; pointer-events: none; }

.piece.is-finished .visual { animation: none; }

.select-ring {
  fill: none;
  stroke: var(--ochre-bright);
  stroke-width: 1.4;
  stroke-dasharray: 2 5;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 0.2s;
}

.piece.oxblood .select-ring { stroke: var(--oxblood-bright); }

.piece.selected .select-ring {
  opacity: 0.9;
  animation: ringSpin 12s linear infinite;
}

/* pill colour (set from JS) ------------------------------------------- */

.turn-pill[data-state="human"][data-color="ochre"] .pill-dot,
.turn-pill[data-state="cpu"][data-color="ochre"] .pill-dot {
  background: var(--ochre);
  box-shadow: 0 0 0 3px rgba(216, 169, 79, 0.13);
}

.turn-pill[data-state="human"][data-color="oxblood"] .pill-dot,
.turn-pill[data-state="cpu"][data-color="oxblood"] .pill-dot {
  background: var(--oxblood);
  box-shadow: 0 0 0 3px rgba(165, 71, 81, 0.14);
}

/* preview -------------------------------------------------------------- */

.preview-lane {
  stroke: var(--preview-accent, var(--ochre-bright));
  stroke-width: 1;
  opacity: 0.18;
}

.preview-line {
  fill: none;
  stroke: var(--preview-accent, var(--ochre-bright));
  stroke-width: 1.6;
  stroke-dasharray: 2 7;
  stroke-linecap: round;
  opacity: 0.8;
  animation: dashFlow 1.2s linear infinite;
}

.preview-pip {
  fill: var(--preview-accent, var(--ochre-bright));
  opacity: 0.95;
}

.preview-target {
  fill: none;
  stroke: var(--preview-accent, var(--ochre-bright));
  stroke-width: 2;
  opacity: 0.95;
}

.preview-halo {
  fill: none;
  stroke: var(--preview-accent, var(--ochre-bright));
  stroke-width: 1.2;
  opacity: 0.5;
  transform-box: fill-box;
  transform-origin: center;
  animation: targetPulse 1.8s var(--ease-soft) infinite;
}

.preview-ghost > path:first-child {
  fill: var(--preview-accent, var(--ochre-bright));
  fill-opacity: 0.26;
  stroke: var(--preview-accent, var(--ochre-bright));
  stroke-width: 1.8;
  stroke-dasharray: 5 3;
  opacity: 1;
}

.preview-ghost-inner {
  fill: none;
  stroke: var(--preview-accent, var(--ochre-bright));
  stroke-width: 0.8;
  opacity: 0.45;
}

.preview-home-mark {
  fill: var(--preview-accent, var(--ochre-bright));
  opacity: 0.85;
}

.preview-victim {
  fill: none;
  stroke: var(--oxblood-bright);
  stroke-width: 1.2;
  stroke-dasharray: 2 4;
  opacity: 0.9;
}

.preview-victim-mark {
  fill: none;
  stroke: var(--oxblood-bright);
  stroke-width: 1.6;
  stroke-linecap: round;
  opacity: 0.9;
}

.impact {
  fill: none;
  stroke: var(--brass-bright);
  stroke-width: 1.5;
  animation: impact 0.6s var(--ease-soft) forwards;
  pointer-events: none;
}

.impact.oxblood { stroke: var(--oxblood-bright); }

/* tooltip -------------------------------------------------------------- */

.tooltip {
  position: absolute;
  z-index: 5;
  min-width: 84px;
  padding: 8px 10px 7px;
  border: 1px solid rgba(244, 238, 223, 0.18);
  border-radius: 3px;
  background: rgba(15, 17, 13, 0.93);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transform: translate(-50%, -100%);
  animation: tooltipIn 0.18s var(--ease-soft) both;
}

.tooltip-main {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--cream);
  white-space: nowrap;
}

.tooltip-sub {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.02em;
  color: var(--muted-2);
  white-space: nowrap;
}

.tooltip-sub.danger { color: var(--oxblood-bright); }

.tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 6px;
  height: 6px;
  background: rgba(15, 17, 13, 0.93);
  border-right: 1px solid rgba(244, 238, 223, 0.18);
  border-bottom: 1px solid rgba(244, 238, 223, 0.18);
  transform: translateX(-50%) rotate(45deg);
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 28px;
  max-width: calc(100vw - 32px);
  text-align: center;
  transform: translate(-50%, -12px);
  padding: 9px 16px;
  border: 1px solid rgba(198, 164, 104, 0.34);
  border-radius: 999px;
  background: rgba(16, 18, 14, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--cream-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s, transform 0.28s var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */

.modal,
.result {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(7, 8, 6, 0.72);
  backdrop-filter: blur(10px) saturate(0.85);
  animation: softFade 0.4s var(--ease-soft) both;
}

.sheet {
  position: relative;
  z-index: 1;
  width: min(800px, 100%);
  max-height: 91svh;
  padding: 26px 36px 28px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 18%),
    #161912;
  border: 1px solid rgba(244, 238, 223, 0.17);
  border-radius: 4px;
  box-shadow: 0 50px 120px rgba(0, 0, 0, 0.64);
  scrollbar-width: thin;
  scrollbar-color: rgba(244, 238, 223, 0.16) transparent;
  animation: sheetIn 0.5s var(--ease) both;
}

.sheet::before {
  content: "";
  position: absolute;
  top: 0;
  left: 38px;
  right: 38px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(198, 164, 104, 0.65), transparent);
}

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 17px;
  line-height: 1;
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}

@media (hover: hover) {
  .icon-btn:hover { color: var(--cream); border-color: var(--line-strong); transform: rotate(90deg); }
}

.sheet-title {
  margin: 20px 0 8px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(34px, 4.2vw, 50px);
  line-height: 1.25;
  letter-spacing: 0.015em;
}

.sheet-lede {
  max-width: 56ch;
  margin: 0 0 23px;
  font-size: 13px;
  line-height: 1.85;
  color: var(--muted);
  text-wrap: pretty;
}

.rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 28px;
  padding: 21px 0 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.rule-card { position: relative; }

.rule-index {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.14em;
  color: var(--brass);
}

.rule-card h3 {
  margin: 7px 0 7px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 19px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--cream);
}

.rule-card p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--muted-2);
}

.rules-figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 20px 0;
}

.figure {
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(244, 238, 223, 0.018);
}

.figure svg { display: block; width: 100%; height: auto; }

.fig-cell,
.fig-slot {
  fill: rgba(244, 238, 223, 0.045);
  stroke: rgba(244, 238, 223, 0.16);
  stroke-width: 0.8;
}

.fig-slot { fill: rgba(198, 164, 104, 0.08); stroke: rgba(198, 164, 104, 0.26); }

.fig-dots circle { fill: var(--brass); opacity: 0.8; }

.fig-arrow {
  fill: none;
  stroke: rgba(244, 238, 223, 0.32);
  stroke-width: 1.1;
  stroke-dasharray: 1 5;
  stroke-linecap: round;
}

.fig-arrow.strike { stroke: rgba(216, 169, 79, 0.65); }

.fig-arrow.oxblood-arrow { stroke: rgba(207, 116, 128, 0.65); }

.fig-arrow-head { fill: none; stroke: rgba(244, 238, 223, 0.4); stroke-width: 1.1; }
.fig-arrow-head.strike { stroke: rgba(216, 169, 79, 0.7); }

.fig-gold { fill: var(--ochre); stroke: rgba(255, 247, 226, 0.35); stroke-width: 0.7; }
.fig-gold.ghost { opacity: 0.28; }
.fig-oxblood { fill: var(--oxblood); stroke: rgba(255, 216, 218, 0.25); stroke-width: 0.7; }

.figure figcaption {
  margin-top: 6px;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--muted-2);
}

.figure figcaption b { color: var(--cream-soft); font-weight: 500; }

.rules-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  padding-top: 2px;
}

.rules-foot p {
  flex: 1;
  max-width: none;
  margin: 0;
  padding-right: 18px;
  font-family: var(--mono);
  font-size: 8.5px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  color: rgba(129, 125, 109, 0.75);
}

/* --------------------------------------------------------------------------
   Result
   -------------------------------------------------------------------------- */

.result { z-index: 70; }

.result-card {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  padding: 34px 38px 30px;
  text-align: center;
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(198, 164, 104, 0.09), transparent 55%),
    #161912;
  border: 1px solid rgba(244, 238, 223, 0.17);
  border-radius: 4px;
  box-shadow: 0 50px 120px rgba(0, 0, 0, 0.7);
  animation: sheetIn 0.6s 0.08s var(--ease) both;
}

.result-seal {
  position: relative;
  width: 62px;
  height: 62px;
  margin: 22px auto 18px;
  display: grid;
  place-items: center;
}

.seal-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(216, 169, 79, 0.55);
  animation: sealPulse 3s var(--ease-soft) infinite;
}

.seal-core {
  width: 22px;
  height: 38px;
  clip-path: polygon(50% 0, 100% 38%, 100% 100%, 0 100%, 0 38%);
  background: linear-gradient(180deg, var(--ochre-bright), var(--ochre-deep));
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.result-seal.oxblood .seal-core { background: linear-gradient(180deg, var(--oxblood-bright), var(--oxblood-deep)); }
.result-seal.oxblood .seal-ring { border-color: rgba(207, 116, 128, 0.5); }
.result-seal.draw .seal-core { background: rgba(244, 238, 223, 0.28); }
.result-seal.draw .seal-ring { border-color: rgba(244, 238, 223, 0.3); }

.result-title {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 40px;
  line-height: 1.25;
  letter-spacing: 0.015em;
  text-wrap: balance;
}

.result-note {
  margin: 0 auto 22px;
  max-width: 30em;
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
  text-wrap: pretty;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 14px 0 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.04em;
  color: var(--muted-2);
}

.result-stats span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.result-stats span + span::before {
  content: "";
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--muted-2);
}

.result-actions { padding-top: 20px; }

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes softFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes boardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.975); }
  to { opacity: 1; transform: none; }
}

@keyframes pieceDrop {
  0% { opacity: 0; transform: translateY(-26px) scale(0.9); }
  65% { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 3px rgba(165, 71, 81, 0.14); }
  50% { opacity: 0.55; box-shadow: 0 0 0 6px rgba(165, 71, 81, 0); }
}

@keyframes slotPop {
  0% { transform: scale(0.5); }
  55% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes logIn {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: none; }
}

@keyframes dashFlow {
  to { stroke-dashoffset: -18; }
}

@keyframes targetPulse {
  0%, 100% { transform: scale(1); opacity: 0.38; }
  50% { transform: scale(1.28); opacity: 0.1; }
}

@keyframes ringSpin {
  to { transform: rotate(360deg); }
}

@keyframes impact {
  from { r: 12; opacity: 0.75; }
  to { r: 48; opacity: 0; }
}

@keyframes homeOut {
  0% { transform: none; opacity: 1; }
  30% { transform: translateY(-9px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-20px) scale(0.25); opacity: 0; }
}

.piece.just-homed .visual {
  animation: homeOut 0.66s var(--ease) forwards !important;
}

.piece.just-homed .piece-shadow {
  opacity: 0;
  transition: opacity 0.3s;
}

.piece:focus { outline: none; }
.piece:focus-visible .select-ring {
  opacity: 1;
  stroke-width: 2;
  animation: none;
}

@keyframes tooltipIn {
  from { opacity: 0; transform: translate(-50%, calc(-100% + 4px)); }
  to { opacity: 1; transform: translate(-50%, -100%); }
}

@keyframes sheetIn {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes sealPulse {
  0%, 100% { transform: scale(1); opacity: 0.55; }
  50% { transform: scale(1.08); opacity: 0.9; }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .app { grid-template-columns: 344px minmax(0, 1fr); }
  .panel { padding-left: 30px; padding-right: 30px; }
  .wordmark { font-size: clamp(50px, 4.6vw, 64px); }
  .app.in-game .wordmark { font-size: 40px; }
  .stage { padding-left: 26px; padding-right: 26px; }
  .stage-head,
  .stage-foot { width: min(100%, calc(100svh - 214px), 660px); }
  .board-zone { width: min(100%, calc(100svh - 214px), 660px); }
}

@media (max-width: 900px) {
  .app {
    display: flex;
    flex-direction: column;
    min-height: 100svh;
  }

  .app:not(.in-game) .stage-head,
  .app:not(.in-game) .stage-foot { display: none; }

  .app.in-game .brand { display: none; }
  .app.in-game .match-tags { display: none; }
  .app.in-game .panel { padding-top: 22px; padding-bottom: 96px; }
  .app.in-game .panel-body.game { padding-top: 0; }
  .app.in-game .turn-block { padding-top: 4px; }
  .app.in-game .game-actions { display: none; }

  .mobile-actions {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 14px;
    z-index: 35;
    display: none;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 5px;
    padding: 5px;
    border: 1px solid rgba(244, 238, 223, 0.16);
    border-radius: 5px;
    background: rgba(16, 18, 14, 0.9);
    backdrop-filter: blur(14px);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  }

  .app.in-game .mobile-actions { display: grid; }

  .mobile-actions button {
    height: 40px;
    border: 1px solid transparent;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: rgba(244, 238, 223, 0.02);
    transition: border-color 0.2s, color 0.2s;
  }

  .mobile-actions button:active { background: rgba(244, 238, 223, 0.06); }
  .mobile-actions button:disabled { opacity: 0.32; }

  .panel {
    order: 2;
    min-height: 0;
    max-height: none;
    overflow: visible;
    width: 100%;
    padding: 30px 22px 26px;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .panel::after { display: none; }

  .stage { order: 1; min-height: 0; padding: 22px 18px 20px; }

  .app:not(.in-game) .panel { order: 1; border-top: 0; padding-top: 32px; }
  .app:not(.in-game) .stage { order: 2; padding-top: 0; }

  .brand { display: flex; flex-direction: column; align-items: flex-start; }
  .wordmark { font-size: clamp(48px, 11vw, 66px); }
  .app:not(.in-game) .tagline { opacity: 1; max-height: none; }

  .panel-body { padding-top: 22px; }
  .lobby { max-width: 540px; margin: 0 auto; width: 100%; }
  .game { max-width: 560px; margin: 0 auto; width: 100%; }

  .stage-head,
  .stage-foot,
  .board-zone {
    width: min(100%, 600px);
  }

  .stage-head { margin-bottom: 12px; }
  .stage-foot { margin-top: 14px; flex-wrap: wrap; gap: 12px; }

  .panel-foot { max-width: 540px; margin: 0 auto; width: 100%; }

  .log { max-height: 180px; }
  .app.in-game .panel { padding-top: 24px; }
  .app.in-game .wordmark { font-size: 38px; margin-top: 0; }
}

@media (max-width: 620px) {
  .stage { padding: 16px 10px 16px; }
  .board-zone { width: 100%; }
  .board-halo { width: 100%; }
  .board-wrap::before { filter: blur(12px); }
  .zone-mark { display: none; }
  .stage-head { padding: 0 4px; }
  .stage-foot { padding: 0 4px; }
  .pace-legend { display: none; }
  .stage-scores { gap: 14px; }
  .panel { padding: 26px 18px 24px; }

  .rules-grid,
  .rules-figures { grid-template-columns: 1fr; }
  .sheet { padding: 24px 22px 26px; max-height: 92svh; }
  .sheet::before { left: 22px; right: 22px; }
  .sheet-title { font-size: 38px; }
  .rules-foot { flex-direction: column; align-items: stretch; gap: 16px; }
  .rules-foot .cta.small { width: 100%; }
  .result-card { padding: 28px 24px 24px; }
  .result-title { font-size: 32px; }
  .result-actions .cta { height: 52px; }
  .modal, .result { padding: 12px; }
}

@media (max-height: 760px) and (min-width: 901px) {
  .panel { padding-top: 30px; }
  .wordmark { font-size: 58px; }
  .app.in-game .wordmark { font-size: 38px; }
  .lede { margin-bottom: 20px; }
  .field { margin-bottom: 18px; }
  .panel-body { padding-top: 16px; }
  .rival { min-height: 70px; }
  .rival-name { margin-top: 8px; font-size: 15px; }
  .rival-dots { margin-top: 9px; }
  .cta { height: 52px; }
  .turn-block { padding: 16px 0 14px; }
  .turn-title { font-size: 26px; }
  .scoreboard { padding: 12px 0; }
  .log { max-height: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
  .grain { display: none; }
}
