:root { --neon: #36e0ff; --neon-2: #ff3df0; --gold: #ffd23b; --bg: #0a0520; }
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(124,92,255,0.18), transparent 60%),
    linear-gradient(180deg, #160a36 0%, #0a0520 60%, #04010c 100%);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #eaf6ff; -webkit-tap-highlight-color: transparent; user-select: none;
}

#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; gap: 22px; padding: 12px 18px; justify-content: center;
  z-index: 5; text-shadow: 0 0 12px rgba(54,224,255,0.7);
}
.stat { display: flex; flex-direction: column; line-height: 1.1; text-align: center; }
.stat .label { font-size: 10px; letter-spacing: 2px; opacity: 0.65; }
.stat span:last-child { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

#game {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 18px; padding-top: 40px;
}
#board {
  border: 1px solid rgba(54,224,255,0.3);
  border-radius: 8px;
  background: rgba(4,2,14,0.55);
  box-shadow: 0 0 40px rgba(54,224,255,0.18);
  touch-action: none;
}
#side { display: flex; flex-direction: column; gap: 16px; }
.box { text-align: center; }
.box h4 { font-size: 11px; letter-spacing: 2px; opacity: 0.7; margin-bottom: 6px; }
.box canvas {
  border: 1px solid rgba(54,224,255,0.25);
  border-radius: 6px; background: rgba(4,2,14,0.5);
}

#touch {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: none; gap: 6px; padding: 8px; z-index: 6;
}
#touch button {
  flex: 1; padding: 14px 0; font-size: 18px; font-weight: 700;
  color: #eaf6ff; background: rgba(54,224,255,0.08);
  border: 1px solid rgba(54,224,255,0.3); border-radius: 12px;
}
#touch button:active { background: rgba(54,224,255,0.25); }
body.touch #touch { display: flex; }
body.touch #game { padding-bottom: 76px; }

/* overlay / help / buttons */
#overlay, #help {
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20,6,50,0.5), rgba(2,0,8,0.9));
  backdrop-filter: blur(3px); z-index: 10; padding: 20px;
}
#overlay.show, #help.open { display: flex; }
.panel, .help-card {
  text-align: center; padding: 32px 34px; max-width: min(94vw, 560px);
  border: 1px solid rgba(54,224,255,0.35); border-radius: 18px;
  background: rgba(10,5,30,0.8);
  box-shadow: 0 0 60px rgba(54,224,255,0.22);
}
h1 {
  font-size: clamp(22px,5vw,38px); letter-spacing: 3px; font-weight: 900; white-space: nowrap;
  background: linear-gradient(90deg, var(--neon), var(--neon-2));
  -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: 0.16em;
  filter: drop-shadow(0 0 16px rgba(54,224,255,0.5));
}
.tag { margin-top: 10px; opacity: 0.7; font-size: 13px; letter-spacing: 1px; }
.how { margin: 22px 0; display: flex; flex-direction: column; gap: 9px; font-size: 13px; opacity: 0.9; }
kbd {
  display: inline-block; min-width: 20px; padding: 2px 6px; margin: 0 1px;
  border: 1px solid rgba(54,224,255,0.5); border-radius: 5px;
  background: rgba(54,224,255,0.08); font-family: inherit; font-size: 12px;
}
button#startBtn, #helpClose {
  margin-top: 6px; padding: 13px 44px; font-size: 16px; font-weight: 800; letter-spacing: 2px;
  color: #06121a; background: linear-gradient(90deg, var(--neon), var(--neon-2));
  border: none; border-radius: 40px; cursor: pointer;
  box-shadow: 0 0 26px rgba(54,224,255,0.5);
}
#overMsg { margin-top: 18px; font-size: 15px; line-height: 1.6; color: var(--gold); }
.hidden { display: none !important; }
.help-card { text-align: left; }
.help-card h3 { text-align: center; color: var(--neon); letter-spacing: 3px; margin-bottom: 14px; font-size: 15px; }
.help-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.help-list li { font-size: 13.5px; line-height: 1.5; opacity: 0.9; }
.help-list b { color: var(--neon); }

#homeLink {
  position: fixed; bottom: 12px; left: 16px; z-index: 7;
  font-size: 13px; letter-spacing: 1px; color: rgba(234,246,255,0.6); text-decoration: none;
  padding: 6px 12px; border: 1px solid rgba(54,224,255,0.3); border-radius: 20px;
  background: rgba(10,5,30,0.5);
}
#homeLink:hover { color: var(--neon); border-color: var(--neon); }
#helpBtn {
  position: fixed; bottom: 12px; right: 16px; z-index: 7;
  width: 40px; height: 40px; font-size: 20px; font-weight: 800;
  color: rgba(234,246,255,0.7); background: rgba(10,5,30,0.5);
  border: 1px solid rgba(54,224,255,0.3); border-radius: 50%; cursor: pointer;
}
#helpBtn:hover { color: var(--neon); border-color: var(--neon); }
body.touch #homeLink, body.touch #helpBtn { bottom: 70px; }
