/* ============ TETRIS — neon dark theme ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0a14;
  --panel: rgba(20, 22, 40, 0.85);
  --panel-border: rgba(120, 130, 255, 0.22);
  --text: #e8e9ff;
  --dim: #8a8db8;
  --accent: #00e5ff;
}

html, body { height: 100%; }

body {
  background: radial-gradient(ellipse at 50% -20%, #1a1c3a 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* faint animated starfield */
#stars {
  position: fixed; inset: 0; pointer-events: none; opacity: 0.5;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff8, transparent 100%),
    radial-gradient(1px 1px at 70% 12%, #fff6, transparent 100%),
    radial-gradient(1.5px 1.5px at 84% 68%, #fff7, transparent 100%),
    radial-gradient(1px 1px at 40% 80%, #fff5, transparent 100%),
    radial-gradient(1px 1px at 8% 62%, #fff6, transparent 100%),
    radial-gradient(1.5px 1.5px at 55% 45%, #fff4, transparent 100%),
    radial-gradient(1px 1px at 92% 35%, #fff6, transparent 100%),
    radial-gradient(1px 1px at 30% 8%, #fff5, transparent 100%);
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.35; } to { opacity: 0.65; } }

#layout {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 16px;
}

.side { display: flex; flex-direction: column; gap: 14px; width: 172px; }
.side.left { align-items: stretch; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px 14px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

.panel h2 {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 6px;
  font-weight: 600;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.55);
  margin-bottom: 10px;
}
.stat-value.small { font-size: 19px; }
.stat-row { display: flex; gap: 18px; }
.stats h2:last-of-type { margin-top: 2px; }

.keys table { width: 100%; border-collapse: collapse; font-size: 11.5px; color: var(--dim); }
.keys td { padding: 2.5px 0; }
.keys td:first-child { color: var(--text); font-weight: 600; white-space: nowrap; padding-right: 10px; }

canvas { display: block; }
#hold, #next { margin: 0 auto; }

/* ---- playfield ---- */
#board-wrap {
  position: relative;
  border-radius: 8px;
  padding: 6px;
  background: linear-gradient(180deg, rgba(80, 90, 220, 0.25), rgba(30, 34, 80, 0.25));
  box-shadow:
    0 0 0 1px rgba(130, 140, 255, 0.35),
    0 0 45px rgba(60, 80, 255, 0.28),
    0 12px 48px rgba(0, 0, 0, 0.6);
}
#board { background: #0d0e1c; border-radius: 4px; }
#fx { position: absolute; top: 6px; left: 6px; pointer-events: none; }

/* action callout ("TETRIS!", "T-SPIN DOUBLE!") */
#callout {
  position: absolute; top: 34%; left: 0; right: 0;
  text-align: center;
  font-size: 24px; font-weight: 800; letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 0 0 18px var(--accent), 0 0 40px var(--accent);
  opacity: 0;
  pointer-events: none;
  white-space: pre-line;
}
#callout.show { animation: callout 1.1s ease-out forwards; }
@keyframes callout {
  0%   { opacity: 0; transform: scale(0.6); }
  12%  { opacity: 1; transform: scale(1.08); }
  22%  { transform: scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-26px); }
}

/* ---- overlay (menu / pause / game over) ---- */
#overlay {
  position: absolute; inset: 6px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 9, 20, 0.82);
  backdrop-filter: blur(3px);
  border-radius: 4px;
  text-align: center;
  transition: opacity 0.25s;
}
#overlay.hidden { opacity: 0; pointer-events: none; }

.logo { font-size: 44px; font-weight: 900; letter-spacing: 0.06em; margin-bottom: 18px; }
.logo span { display: inline-block; animation: bob 2.2s ease-in-out infinite; }
.logo span:nth-child(1) { color: #00e5ff; animation-delay: 0s; }
.logo span:nth-child(2) { color: #ffd500; animation-delay: 0.12s; }
.logo span:nth-child(3) { color: #b968ff; animation-delay: 0.24s; }
.logo span:nth-child(4) { color: #52e788; animation-delay: 0.36s; }
.logo span:nth-child(5) { color: #ff4d6d; animation-delay: 0.48s; }
.logo span:nth-child(6) { color: #ff9430; animation-delay: 0.6s; }
.logo span { text-shadow: 0 0 22px currentColor; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

#overlay-msg { font-size: 17px; color: var(--text); }
#overlay-msg b { color: var(--accent); }
.overlay-sub { margin-top: 10px; font-size: 13px; color: var(--dim); white-space: pre-line; line-height: 1.7; }

.toggle {
  width: 100%;
  background: rgba(0, 229, 255, 0.12);
  color: var(--accent);
  border: 1px solid rgba(0, 229, 255, 0.4);
  border-radius: 6px;
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 0;
  cursor: pointer;
}
.toggle.off { color: var(--dim); border-color: #444a6e; background: rgba(255,255,255,0.04); }

/* ---- touch controls ---- */
#touch-bar {
  display: none;
  position: fixed; bottom: 10px; left: 0; right: 0;
  justify-content: center; gap: 10px;
  padding: 0 12px;
}
#touch-bar button {
  flex: 1; max-width: 76px; height: 58px;
  font-size: 22px; color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
}
@media (pointer: coarse) {
  #touch-bar { display: flex; }
  .keys { display: none; }
}

@media (max-height: 760px) {
  .keys { display: none; }
}
@media (max-width: 860px) {
  #layout { gap: 10px; }
  .side { width: 128px; }
  .panel { padding: 8px 10px; }
  .stat-value { font-size: 20px; }
}
