/* =========================================================
   WISPBOUND — FIELD TEST 01
   styles.css — mobile-first app shell, dark sci-fi
   ========================================================= */

:root {
  --bg: #09100f;
  --panel: #101817;
  --panel-2: #14201e;
  --line: rgba(111, 255, 210, 0.10);
  --line-soft: rgba(111, 255, 210, 0.05);
  --pull: #6fffd2;
  --pull-dim: rgba(111, 255, 210, 0.16);
  --push: #ff715f;
  --push-dim: rgba(255, 113, 95, 0.16);
  --gold: #ffd166;
  --gold-dim: rgba(255, 209, 102, 0.15);
  --text: #f3f6ef;
  --muted: #86a096;
  --danger: #ff5f6e;
  --void: #04080a;
  --wall: #2b3c38;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(900px 420px at 80% -10%, rgba(111, 255, 210, 0.05), transparent 62%),
    radial-gradient(700px 400px at -10% 110%, rgba(255, 209, 102, 0.04), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

.noscript { padding: 40px 20px; text-align: center; }

:focus-visible {
  outline: 2px solid var(--pull);
  outline-offset: 3px;
  border-radius: 6px;
}

kbd {
  font-family: var(--mono);
  font-size: 0.68em;
  padding: 1px 6px;
  border: 1px solid rgba(243, 246, 239, 0.22);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.25);
}

/* Hide keyboard hints on touch-only devices */
@media (hover: none) {
  kbd { display: none; }
}

/* =========================================================
   Screens
   ========================================================= */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(var(--sat) + 10px) calc(var(--sar) + 14px) calc(var(--sab) + 12px) calc(var(--sal) + 14px);
  max-width: 520px;
  margin: 0 auto;
}

.screen[hidden] { display: none; }

.screen-home,
.screen-sectors { overflow-y: auto; }

/* ---------- small top bar (sectors + game) ---------- */
.topbar-sm {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0 10px;
  flex: none;
}

.topbar-title {
  margin: 0;
  flex: 1;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.3em;
  color: var(--muted);
  font-weight: 600;
}

.topbar-side {
  min-width: 44px;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--pull);
}

.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--text);
  background: rgba(111, 255, 210, 0.06);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.icon-btn:active { transform: scale(0.94); }

/* =========================================================
   Home
   ========================================================= */
.home-hero {
  text-align: center;
  padding: 8vh 0 4vh;
}

.logo-mark {
  display: block;
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #ffffff 0%, var(--pull) 42%, rgba(111, 255, 210, 0.1) 78%);
  box-shadow: 0 0 18px rgba(111, 255, 210, 0.75), 0 0 52px rgba(111, 255, 210, 0.3);
  animation: logo-breathe 3.2s ease-in-out infinite;
}

@keyframes logo-breathe {
  0%, 100% { box-shadow: 0 0 14px rgba(111, 255, 210, 0.65), 0 0 40px rgba(111, 255, 210, 0.25); }
  50%      { box-shadow: 0 0 22px rgba(111, 255, 210, 0.95), 0 0 62px rgba(111, 255, 210, 0.4); }
}

.logo-text {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: 0.24em;
}

.logo-text em { font-style: normal; color: var(--pull); }

.home-tag {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.34em;
  color: var(--gold);
}

.home-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  text-align: left;
  background: linear-gradient(170deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
}

.card-btn:active { transform: scale(0.98); }

.btn-sub {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.primary-btn {
  justify-content: center;
  text-align: center;
  color: #07110d;
  background: linear-gradient(170deg, #8dffde, var(--pull));
  border-color: var(--pull);
  box-shadow: 0 0 22px rgba(111, 255, 210, 0.28);
}

.daily-card {
  border-color: rgba(255, 209, 102, 0.35);
  background: linear-gradient(170deg, #1c2013, var(--panel));
}

.daily-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.daily-kicker {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.26em;
  color: var(--gold);
}

.daily-info {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.daily-badge {
  flex: none;
  font-size: 1.3rem;
  filter: drop-shadow(0 0 8px rgba(255, 209, 102, 0.6));
}

.daily-card.solved .daily-badge::after { content: " ✓"; font-size: 0.9rem; color: var(--pull); }

.ghost-btn {
  align-self: center;
  margin-top: 6px;
  padding: 12px 22px;
  min-height: 44px;
  font-size: 0.9rem;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
}

.home-foot {
  margin-top: auto;
  padding-top: 24px;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  color: rgba(134, 160, 150, 0.55);
}

/* =========================================================
   Sectors — world list
   ========================================================= */
.world-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 20px;
}

.world-card {
  background: linear-gradient(170deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.world-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-align: left;
  cursor: pointer;
}

.world-head .w-desc {
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-top: 2px;
}

.world-head .w-progress {
  flex: none;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--pull);
}

.world-card.locked .world-head { color: rgba(134, 160, 150, 0.5); cursor: not-allowed; }
.world-card.locked .w-progress { color: rgba(134, 160, 150, 0.45); }

.world-tiles {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 4px 14px 14px;
}

.tile {
  position: relative;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  cursor: pointer;
}

.tile:active { transform: scale(0.95); }

.tile .t-stars {
  font-size: 0.55rem;
  letter-spacing: 1px;
  color: var(--gold);
  min-height: 0.8em;
}

.tile.solved {
  border-color: rgba(111, 255, 210, 0.4);
  background: rgba(111, 255, 210, 0.08);
  color: var(--pull);
}

.tile.locked {
  color: rgba(134, 160, 150, 0.4);
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.12);
}

/* =========================================================
   Game screen — fixed viewport, no scroll
   ========================================================= */
.screen-game { overflow: hidden auto; }

.hud-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.hud-sector {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  color: var(--pull);
}

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

/* ---------- pulse counter ---------- */
.pulse-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  margin-bottom: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.pips { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }

.pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--pull);
  box-shadow: 0 0 8px rgba(111, 255, 210, 0.55);
  transition: background 220ms ease, box-shadow 220ms ease, transform 220ms ease;
}

.pip.spent {
  background: rgba(134, 160, 150, 0.22);
  box-shadow: none;
  transform: scale(0.75);
}

.pulse-count {
  font-family: var(--mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--pull);
  min-width: 2ch;
  text-align: right;
}

.pulse-count.low { color: var(--push); }

/* ---------- board ---------- */
.board-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board {
  --grid: 5;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  background-color: rgba(9, 16, 15, 0.6);
  background-image:
    linear-gradient(to right, var(--line-soft) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px);
  background-size: calc(100% / var(--grid)) calc(100% / var(--grid));
  transition: box-shadow 300ms ease;
}

.board.is-failed { box-shadow: 0 0 0 1px rgba(255, 95, 110, 0.5), 0 0 30px rgba(255, 95, 110, 0.18); }
.board.is-won    { box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.55), 0 0 34px rgba(255, 209, 102, 0.22); }

.piece {
  position: absolute;
  transform: translate(-50%, -50%);
}

/* ---------- barrier ---------- */
.wall {
  width: calc(100% / var(--grid) * 0.52);
  height: calc(100% / var(--grid) * 0.52);
  background: linear-gradient(150deg, #3a4f49, var(--wall) 55%, #1c2926);
  border: 1px solid rgba(111, 255, 210, 0.20);
  transform: translate(-50%, -50%) rotate(45deg);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.6), 0 0 6px rgba(0, 0, 0, 0.5);
  border-radius: 3px;
}

/* ---------- void ---------- */
.void {
  width: calc(100% / var(--grid) * 0.62);
  height: calc(100% / var(--grid) * 0.62);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #000 20%, var(--void) 58%, rgba(4, 8, 10, 0));
  box-shadow: inset 0 0 12px #000, 0 0 16px rgba(0, 0, 0, 0.9), 0 0 3px rgba(111, 255, 210, 0.12);
  animation: void-churn 5s ease-in-out infinite;
}

@keyframes void-churn {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -50%) scale(1.07); }
}

/* ---------- nexus ---------- */
.nexus {
  width: calc(100% / var(--grid) * 0.88);
  height: calc(100% / var(--grid) * 0.88);
}

.nexus-core {
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff3d0 0%, var(--gold) 45%, #b8862f 100%);
  box-shadow: 0 0 16px rgba(255, 209, 102, 0.8), 0 0 44px rgba(255, 209, 102, 0.28);
  animation: nexus-glow 2.6s ease-in-out infinite;
}

@keyframes nexus-glow {
  0%, 100% { box-shadow: 0 0 14px rgba(255, 209, 102, 0.7), 0 0 38px rgba(255, 209, 102, 0.22); }
  50%      { box-shadow: 0 0 22px rgba(255, 209, 102, 1), 0 0 58px rgba(255, 209, 102, 0.4); }
}

.nexus-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 209, 102, 0.75);
  animation: ring-spin 9s linear infinite;
}

.nexus-ring.inner {
  inset: 14%;
  border-style: dotted;
  border-color: rgba(255, 209, 102, 0.5);
  animation: ring-spin-reverse 6s linear infinite;
}

@keyframes ring-spin         { to { transform: rotate(360deg); } }
@keyframes ring-spin-reverse { to { transform: rotate(-360deg); } }

/* ---------- field nodes (full-cell touch target) ---------- */
.node {
  width: calc(100% / var(--grid));
  height: calc(100% / var(--grid));
  padding: 0;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: transparent;
  transition: transform 180ms ease;
  z-index: 2;
}

@media (hover: hover) {
  .node:hover:not(:disabled)  { transform: translate(-50%, -50%) scale(1.1); }
}

.node:active:not(:disabled) { transform: translate(-50%, -50%) scale(0.94); }
.node:disabled { cursor: not-allowed; opacity: 0.55; }

.node::before {
  content: "";
  position: absolute;
  inset: 19%;
  border-radius: 50%;
  transition: background 260ms ease, box-shadow 260ms ease;
}

.node::after {
  content: "";
  position: absolute;
  inset: 37%;
  border-radius: 50%;
  transition: background 260ms ease, border 260ms ease;
}

.node.pull::before {
  background: radial-gradient(circle at 36% 32%, rgba(255, 255, 255, 0.85), var(--pull) 55%, rgba(111, 255, 210, 0.25));
  box-shadow: 0 0 12px rgba(111, 255, 210, 0.8), 0 0 30px rgba(111, 255, 210, 0.3);
  animation: node-pulse-pull 2.4s ease-in-out infinite;
}

.node.pull::after { background: #0b3a2d; }

.node.push::before {
  background: radial-gradient(circle at 36% 32%, rgba(255, 255, 255, 0.8), var(--push) 55%, rgba(255, 113, 95, 0.25));
  box-shadow: 0 0 12px rgba(255, 113, 95, 0.8), 0 0 30px rgba(255, 113, 95, 0.3);
  animation: node-pulse-push 2.4s ease-in-out infinite;
}

.node.push::after {
  background: transparent;
  border: 2.5px solid #571812;
}

@keyframes node-pulse-pull {
  0%, 100% { box-shadow: 0 0 10px rgba(111, 255, 210, 0.7), 0 0 26px rgba(111, 255, 210, 0.24); }
  50%      { box-shadow: 0 0 16px rgba(111, 255, 210, 1),   0 0 40px rgba(111, 255, 210, 0.42); }
}

@keyframes node-pulse-push {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 113, 95, 0.7), 0 0 26px rgba(255, 113, 95, 0.24); }
  50%      { box-shadow: 0 0 16px rgba(255, 113, 95, 1),   0 0 40px rgba(255, 113, 95, 0.42); }
}

/* resonator */
.node.resonator::before {
  background: radial-gradient(circle at 36% 32%, #ffffff 0%, #dfe8e4 45%, rgba(243, 246, 239, 0.25) 100%);
  box-shadow: 0 0 12px rgba(243, 246, 239, 0.8), 0 0 30px rgba(243, 246, 239, 0.3);
  animation: node-pulse-resonator 2.4s ease-in-out infinite;
}

.node.resonator::after {
  background: transparent;
  border: 2px dashed rgba(9, 16, 15, 0.75);
  animation: ring-spin 7s linear infinite;
}

@keyframes node-pulse-resonator {
  0%, 100% { box-shadow: 0 0 10px rgba(243, 246, 239, 0.7), 0 0 26px rgba(243, 246, 239, 0.22); }
  50%      { box-shadow: 0 0 16px rgba(243, 246, 239, 1),   0 0 40px rgba(243, 246, 239, 0.4); }
}

/* anchored */
.node.anchored::before {
  border-radius: 8px;
  border: 2px solid rgba(243, 246, 239, 0.55);
}

.node.anchored::after { border-radius: 3px; }

/* burnout / burnt */
.node.burnout:not(.burnt)::before { border: 2px dotted rgba(255, 209, 102, 0.8); }

.node.burnt::before {
  background: radial-gradient(circle at 40% 35%, #24302d, #131c1a) !important;
  box-shadow: none !important;
  animation: none !important;
}

.node.burnt::after {
  background: transparent !important;
  border: 2px solid rgba(134, 160, 150, 0.25) !important;
  animation: none !important;
}

/* portals */
.portal {
  width: calc(100% / var(--grid) * 0.8);
  height: calc(100% / var(--grid) * 0.8);
  pointer-events: none;
}

.portal-ring {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  border: 2px dashed var(--portal-color, #b58cff);
  box-shadow: 0 0 14px var(--portal-glow, rgba(181, 140, 255, 0.45)),
              inset 0 0 12px var(--portal-glow, rgba(181, 140, 255, 0.35));
  animation: ring-spin 5s linear infinite;
}

.portal-0 { --portal-color: #b58cff; --portal-glow: rgba(181, 140, 255, 0.45); }
.portal-1 { --portal-color: #5fb8ff; --portal-glow: rgba(95, 184, 255, 0.45); }

/* currents */
.current {
  width: calc(100% / var(--grid) * 0.9);
  height: calc(100% / var(--grid) * 0.9);
  pointer-events: none;
  opacity: 0.85;
}

.current-arrow {
  position: absolute;
  inset: 0;
  transform: rotate(var(--angle, 0deg));
}

.current-arrow::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 58%;
  width: 26%;
  height: 26%;
  border-top: 3px solid rgba(111, 255, 210, 0.55);
  border-right: 3px solid rgba(111, 255, 210, 0.55);
  transform: translate(-50%, -50%) rotate(45deg);
  animation: current-flow 1.6s ease-in-out infinite;
}

@keyframes current-flow {
  0%, 100% { opacity: 0.45; margin-left: -4%; }
  50%      { opacity: 1; margin-left: 4%; }
}

/* cracked tiles */
.cracked {
  width: calc(100% / var(--grid) * 0.92);
  height: calc(100% / var(--grid) * 0.92);
  border-radius: 5px;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 46%, rgba(243, 246, 239, 0.22) 48%, transparent 52%),
    linear-gradient(35deg, transparent 55%, rgba(243, 246, 239, 0.16) 57%, transparent 61%),
    linear-gradient(75deg, transparent 30%, rgba(243, 246, 239, 0.12) 32%, transparent 36%),
    rgba(20, 32, 30, 0.55);
  border: 1px solid rgba(243, 246, 239, 0.14);
  transition: background 400ms ease, box-shadow 400ms ease;
}

.cracked.broken {
  background: radial-gradient(circle at 50% 45%, #000 25%, var(--void) 65%, rgba(4, 8, 10, 0.4));
  border-color: rgba(0, 0, 0, 0.8);
  box-shadow: inset 0 0 14px #000;
}

/* flip flash + hint */
.node.flipped { animation: node-flip 420ms ease; }

@keyframes node-flip {
  0%   { transform: translate(-50%, -50%) scale(1); }
  45%  { transform: translate(-50%, -50%) scale(1.3); filter: brightness(1.8); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.node.hinted { animation: hint-ping 900ms ease-in-out infinite; }

.node.hinted::before {
  box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.85), 0 0 26px rgba(255, 209, 102, 0.8) !important;
}

@keyframes hint-ping {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -50%) scale(1.18); }
}

/* ---------- sparks ---------- */
.spark {
  width: calc(100% / var(--grid) * 0.44);
  height: calc(100% / var(--grid) * 0.44);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffffff 0%, #eafff7 55%, rgba(214, 255, 240, 0.35) 100%);
  box-shadow:
    0 0 12px rgba(255, 255, 255, 0.95),
    0 0 30px rgba(214, 255, 240, 0.6),
    0 0 60px rgba(111, 255, 210, 0.35);
  pointer-events: none;
  z-index: 3;
  transition: left 260ms cubic-bezier(0.3, 0.9, 0.4, 1.1), top 260ms cubic-bezier(0.3, 0.9, 0.4, 1.1);
  animation: spark-breathe 2s ease-in-out infinite;
}

@keyframes spark-breathe {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.35); }
}

.spark-twin {
  background: radial-gradient(circle at 40% 35%, #ffffff 0%, #e4f4ff 55%, rgba(200, 235, 255, 0.35) 100%);
  box-shadow:
    0 0 12px rgba(255, 255, 255, 0.95),
    0 0 30px rgba(200, 235, 255, 0.6),
    0 0 60px rgba(95, 184, 255, 0.4);
}

.spark.blocked-bump { animation: spark-bump 340ms ease; }

@keyframes spark-bump {
  0%, 100% { margin-left: 0; margin-top: 0; }
  30%      { margin-left: 4px; margin-top: -4px; filter: brightness(1.6); }
  60%      { margin-left: -3px; margin-top: 3px; }
}

.spark.destroyed { animation: spark-die 620ms ease forwards; }

@keyframes spark-die {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: brightness(2); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.05); filter: brightness(0.2); }
}

.spark.fused { animation: spark-fuse 900ms ease forwards; }

@keyframes spark-fuse {
  0%   { filter: brightness(1); }
  40%  { filter: brightness(2.4); transform: translate(-50%, -50%) scale(1.5); }
  100% { filter: brightness(1.6) sepia(0.6) saturate(2); transform: translate(-50%, -50%) scale(0.8); }
}

/* ---------- status toast ---------- */
.status {
  flex: none;
  min-height: 2.2em;
  margin: 8px 2px 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line-soft);
  opacity: 0;
  transition: opacity 250ms ease;
}

.status.show { opacity: 1; }
.status.is-danger { color: var(--danger); border-color: rgba(255, 95, 110, 0.3); }
.status.is-win    { color: var(--gold); border-color: rgba(255, 209, 102, 0.3); }
.status.is-info   { color: var(--pull); }

/* ---------- bottom action bar ---------- */
.action-bar {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 6px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text);
  background: rgba(111, 255, 210, 0.06);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
}

.action-btn:active:not(:disabled) { transform: scale(0.96); }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.action-btn.gold {
  color: var(--gold);
  border-color: rgba(255, 209, 102, 0.35);
  background: var(--gold-dim);
}

/* =========================================================
   Sheets
   ========================================================= */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 10, 0.7);
  backdrop-filter: blur(2px);
  z-index: 20;
}

.scrim[hidden] { display: none; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(520px, 100%);
  max-height: 82dvh;
  overflow-y: auto;
  padding: 16px 20px calc(var(--sab) + 20px);
  background: linear-gradient(170deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  z-index: 21;
  animation: sheet-up 240ms ease;
}

.sheet[hidden] { display: none; }

@keyframes sheet-up {
  from { transform: translateX(-50%) translateY(30px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}

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

.sheet-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

.sheet-note {
  margin: 0 0 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--gold);
  background: var(--gold-dim);
  border: 1px solid rgba(255, 209, 102, 0.3);
  border-radius: 10px;
}

.sheet-text {
  margin: 0 0 14px;
  font-size: 0.9rem;
  color: var(--muted);
}

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.fact {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 9px 12px;
}

.fact dt {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.24em;
  color: var(--muted);
}

.fact dd {
  margin: 3px 0 0;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--text);
}

/* manual cards (how to play) */
.manual-card {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
}

.manual-card:first-of-type { border-top: 0; }

.manual-card h3 {
  margin: 0 0 3px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
}

.manual-card p { margin: 0; font-size: 0.86rem; color: var(--muted); }
.manual-card strong { color: var(--text); font-weight: 600; }

.manual-icon {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-top: 2px;
}

.icon-pull { background: radial-gradient(circle at 38% 32%, #fff, var(--pull) 60%); box-shadow: 0 0 12px rgba(111, 255, 210, 0.55); }
.icon-push { background: radial-gradient(circle at 38% 32%, #fff, var(--push) 60%); box-shadow: 0 0 12px rgba(255, 113, 95, 0.55); }
.icon-flip { background: linear-gradient(135deg, var(--pull) 0%, var(--pull) 48%, var(--push) 52%, var(--push) 100%); box-shadow: 0 0 12px rgba(255, 209, 102, 0.4); }
.icon-goal { background: radial-gradient(circle at 38% 32%, #fff3d0, var(--gold) 60%); box-shadow: 0 0 12px rgba(255, 209, 102, 0.55); }

/* settings */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 6px 2px;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 8px;
  cursor: pointer;
}

.toggle {
  appearance: none;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: rgba(134, 160, 150, 0.25);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  transition: background 200ms ease;
  flex: none;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 200ms ease, background 200ms ease;
}

.toggle:checked { background: rgba(111, 255, 210, 0.35); }
.toggle:checked::after { transform: translateX(22px); background: var(--pull); }

#sheet-settings .card-btn { margin-top: 10px; min-height: 52px; }

.card-btn.danger {
  color: var(--danger);
  border-color: rgba(255, 95, 110, 0.3);
}

.settings-foot {
  margin: 16px 0 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.24em;
  color: rgba(134, 160, 150, 0.5);
}

/* =========================================================
   Win sheet
   ========================================================= */
.win-sheet {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(400px, calc(100vw - 36px));
  padding: 26px 24px calc(var(--sab) + 22px);
  background: linear-gradient(170deg, var(--panel-2), var(--panel));
  border: 1px solid rgba(255, 209, 102, 0.35);
  border-radius: 20px;
  color: var(--text);
  text-align: center;
}

.win-sheet::backdrop {
  background: rgba(4, 8, 10, 0.78);
  backdrop-filter: blur(3px);
}

.win-kicker {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.34em;
  color: var(--gold);
}

.win-stars { font-size: 2rem; letter-spacing: 8px; margin-bottom: 4px; }

.win-stars .star { color: rgba(134, 160, 150, 0.3); transition: color 300ms ease, text-shadow 300ms ease; }

.win-stars .star.earned {
  color: var(--gold);
  text-shadow: 0 0 16px rgba(255, 209, 102, 0.7);
}

.win-sheet h2 { margin: 0 0 4px; font-size: 1.4rem; }

.win-sub { margin: 0 0 16px; color: var(--muted); font-size: 0.88rem; }

.win-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 18px;
}

.win-stats > div {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 10px 6px;
}

.win-stats dt {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.win-stats dd {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
}

.win-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}

/* =========================================================
   Desktop
   ========================================================= */
@media (min-width: 720px) {
  .screen { padding-top: 24px; }
  .board { max-width: 560px; max-height: 560px; }
  .sheet { bottom: auto; top: 50%; transform: translate(-50%, -50%); border-radius: 20px; border-bottom: 1px solid var(--line); }
  @keyframes sheet-up {
    from { transform: translate(-50%, -48%); opacity: 0; }
    to   { transform: translate(-50%, -50%); opacity: 1; }
  }
}

/* =========================================================
   Reduced motion (system preference or in-game toggle)
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .spark { transition: none; }
  .node.hinted::before { box-shadow: 0 0 0 5px rgba(255, 209, 102, 0.95) !important; }
}

html.no-motion *, html.no-motion *::before, html.no-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

html.no-motion .spark { transition: none; }
html.no-motion .node.hinted::before { box-shadow: 0 0 0 5px rgba(255, 209, 102, 0.95) !important; }
