:root { --ink:#edf2ff; --muted:#8995b2; --line:rgba(180,200,255,.14); --purple:#8d6cff; --cyan:#4ee4ff; --board-size:min(82vw, calc((100dvh - 360px) / 2)); }

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 15% 20%, #293471 0, transparent 29%), radial-gradient(circle at 85% 80%, #214b65 0, transparent 26%), #080b19;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: 0;
}

.game-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: .6rem;
  width: min(100vw, 420px);
  height: 100dvh;
  max-height: 100dvh;
  padding: 0.6rem;
  overflow: hidden;
  background: rgba(11, 15, 34, .8);
  border: 1px solid rgba(214,224,255,.1);
  box-shadow: 0 28px 80px rgba(0,0,0,.48), inset 0 1px rgba(255,255,255,.04);
}

.board-wrap {
  width: var(--board-size);
  height: calc(var(--board-size) * 2 + 18px);
  position: relative;
  padding: 27px 8px 25px;
  background: linear-gradient(145deg,#202a51,#0c1128 18%,#151a38 100%);
  border: 1px solid rgba(176,194,255,.28);
  border-radius: 16px;
  overflow: hidden;
  flex-shrink: 0;
  order: 2;
  box-shadow: 0 14px 30px rgba(0,0,0,.34), 0 0 40px rgba(90,104,255,.18), inset 0 0 0 3px rgba(4,7,20,.65);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #080c1c;
  touch-action: none;
}

.side-panel {
  width: 100%;
  display: grid;
  gap: .55rem;
  order: 1;
}

.brand { display:flex; align-items:center; justify-content:center; gap:.7rem; padding-top:.1rem; }
.brand-mark { display:grid; grid-template-columns:repeat(2, 8px); gap:2px; transform:rotate(-3deg); }
.brand-mark i { width:8px; height:8px; border-radius:2px; background:linear-gradient(135deg,#8d6cff,#4ee4ff); box-shadow:0 0 9px rgba(78,228,255,.8); }
.eyebrow { margin:0 0 .12rem; color:var(--cyan); font-size:.54rem; letter-spacing:.16em; font-weight:800; text-transform:uppercase; }
h1 { margin:0; letter-spacing:.12em; font-size:clamp(1.5rem,5vw,2rem); line-height:.9; font-weight:900; font-style:italic; text-shadow:0 3px 16px rgba(129,110,255,.6); }
h1 span { color:var(--cyan); font-size:.4em; vertical-align:top; margin-left:.1rem; }
.board-header, .board-footer { position:absolute; left:11px; right:11px; display:flex; justify-content:space-between; color:#a7b3d4; font-size:.52rem; font-weight:800; letter-spacing:.12em; text-transform:uppercase; z-index:1; }
.board-header { top:8px; }.board-footer { bottom:8px; color:#657196; letter-spacing:.05em; text-transform:none; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .25rem;
  background: linear-gradient(145deg,rgba(47,58,101,.42),rgba(22,27,55,.52));
  padding: .55rem .35rem;
  border:1px solid var(--line);
  border-radius: 9px;
  text-align: center;
}

.stat span {
  color: var(--muted);
  text-transform: uppercase;
  font-size: .58rem;
  letter-spacing: 0.08rem;
}

.stat strong {
  font-size: 1.12rem;
  letter-spacing:.03em;
}

.palette {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  align-items:center;
  min-height:.7rem;
}
.palette-label { color:var(--muted); font-size:.58rem; letter-spacing:.1em; text-transform:uppercase; margin-right:.15rem; }

.swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  box-shadow:0 0 0 2px rgba(255,255,255,.08), 0 0 10px currentColor;
}

.swatch-cyan {
  background: #4dd0ff;
}

.swatch-gold {
  background: #ffd166;
}

.swatch-violet {
  background: #c084fc;
}

.swatch-green {
  background: #4ade80;
}

button {
  width: 100%;
  border: none;
  border: 1px solid rgba(194,211,255,.4);
  border-radius: 9px;
  background: linear-gradient(100deg, #7458ed, #40bddc);
  color: white;
  font-size: 0.95rem;
  font-weight: 700;
  padding:.78rem .8rem;
  cursor: pointer;
  transition:transform .15s ease,filter .15s ease,box-shadow .15s ease;
  box-shadow:0 8px 20px rgba(76,104,255,.3),inset 0 1px rgba(255,255,255,.3);
  touch-action: manipulation;
}
button:hover { filter:brightness(1.12); box-shadow:0 10px 24px rgba(76,104,255,.45),inset 0 1px rgba(255,255,255,.3); }
#start-btn { display:flex; justify-content:space-between; align-items:center; text-align:left; letter-spacing:.05em; text-transform:uppercase; font-size:.78rem; }
#start-btn b { font-size:1.25rem; line-height:0; font-weight:500; }

button:active {
  transform: scale(0.98);
}

#status {
  min-height: 1.2rem;
  margin: 0;
  color: var(--muted);
  line-height: 1.3;
  font-size: 0.8rem;
  text-align: center;
}
.status-dot { display:inline-block; width:6px; height:6px; margin:0 .38rem .04rem 0; border-radius:50%; background:#4ee4ff; box-shadow:0 0 9px #4ee4ff; }

.controls {
  background:rgba(17,23,50,.56);
  border:1px solid var(--line);
  border-radius:9px;
  padding: 0.65rem 0.7rem;
}

.controls h2 {
  margin: 0 0 0.45rem;
  font-size: 0.75rem;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
  color: var(--cyan);
}

.controls ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.2rem;
  color: #c5cde4;
  font-size: 0.72rem;
}

.mobile-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
}

.mobile-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
}

.mobile-controls button {
  padding: 0.6rem 0.3rem;
  min-height: 40px;
}

@media (max-width: 640px) {
  .game-shell { gap: .45rem; padding: .45rem .6rem; }
  .side-panel { gap: .38rem; }
  .brand { gap: .48rem; }
  .brand-mark { grid-template-columns: repeat(2, 7px); gap: 2px; }
  .brand-mark i { width: 7px; height: 7px; }
  .eyebrow { font-size: .5rem; }
  h1 { font-size: 1.45rem; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; }
  .stat { padding: .38rem .25rem; gap: .12rem; }
  .stat span { font-size: .5rem; letter-spacing: .06rem; }
  .stat strong { font-size: .95rem; }
  .palette { gap: .35rem; }
  .palette-label { font-size: .5rem; }
  .swatch { width: .58rem; height: .58rem; }
  #start-btn { padding: .62rem .7rem; }
  #status { min-height: 1rem; font-size: .68rem; }
  .controls { display: none; }
  .mobile-controls { gap: .28rem; }
  .mobile-row { gap: .28rem; }
  .mobile-controls button { min-height: 35px; padding: .45rem .25rem; font-size: .78rem; }
  .board-wrap { border-radius: 13px; padding: 23px 7px 21px; }
  .board-header, .board-footer { left: 10px; right: 10px; font-size: .48rem; }
  .board-header { top: 6px; }
  .board-footer { bottom: 6px; }
}

@media (min-width: 641px) {
  :root {
    --board-size: min(82vw, 300px);
  }

  .game-shell {
    width:min(100%, 760px);
    height: auto;
    min-height: 100dvh;
    padding: 1.25rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap:2rem;
  }

  .side-panel {
    width:235px;
  }

  .controls {
    display: block;
  }

  .mobile-controls {
    display: none;
  }
  .board-wrap { padding:27px 8px 25px; }
}
