/* ═══════════════════════════════════════════════════════
   BLOCK BLAST — NEON ARCADE
   ═══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:     #060c14;
  --bg2:    #0b1420;
  --bg3:    #111d2e;
  --panel:  rgba(11,20,32,0.92);
  --edge:   rgba(0,210,255,0.12);
  --edge2:  rgba(0,210,255,0.45);
  --cyan:   #00d4ff;
  --pink:   #ff3472;
  --gold:   #ffd600;
  --lime:   #7fff00;
  --text:   #c8e8ff;
  --muted:  #3d6480;
  --cs:     46px;
  --gap:    3px;
  --mini:   13px;
  --r:      5px;
}

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Rajdhani', system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── BACKGROUND ─────────────────────── */
#bg {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ── SCREENS ────────────────────────── */
.screen {
  display: none;
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.screen.active {
  display: flex;
  animation: screenIn 0.35s cubic-bezier(.16,1,.3,1);
}
@keyframes screenIn {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── CARDS ──────────────────────────── */
.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 32px 28px;
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.6;
}

.nick-card, .over-card { max-width: 380px; }
.lb-card { max-width: 440px; }

/* ── LOGO ───────────────────────────── */
.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 6px;
  user-select: none;
}
.logo-row {
  display: flex;
  gap: 3px;
}
.logo-row span {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Orbitron', monospace;
  font-size: 22px;
  font-weight: 900;
  border-radius: 8px;
  color: #fff;
  position: relative;
  opacity: 0;
  animation: letterDrop 0.45s cubic-bezier(.34,1.56,.64,1) forwards;
}
.logo-row span::after {
  content: '';
  position: absolute;
  top: 2px; left: 4px; right: 4px;
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}
/* BLOCK */
.logo-row:first-child span:nth-child(1) { background: #ff3472; box-shadow: 0 4px 18px #ff347255; animation-delay:.05s }
.logo-row:first-child span:nth-child(2) { background: #ff7420; box-shadow: 0 4px 18px #ff742055; animation-delay:.10s }
.logo-row:first-child span:nth-child(3) { background: #ffd600; box-shadow: 0 4px 18px #ffd60055; animation-delay:.15s; color:#111 }
.logo-row:first-child span:nth-child(4) { background: #00e09a; box-shadow: 0 4px 18px #00e09a55; animation-delay:.20s }
.logo-row:first-child span:nth-child(5) { background: #00d4ff; box-shadow: 0 4px 18px #00d4ff55; animation-delay:.25s }
/* BLAST */
.logo-row.r2 span:nth-child(1) { background: #a655ff; box-shadow: 0 4px 18px #a655ff55; animation-delay:.35s }
.logo-row.r2 span:nth-child(2) { background: #4488ff; box-shadow: 0 4px 18px #4488ff55; animation-delay:.40s }
.logo-row.r2 span:nth-child(3) { background: #ff40c0; box-shadow: 0 4px 18px #ff40c055; animation-delay:.45s }
.logo-row.r2 span:nth-child(4) { background: #80ff40; box-shadow: 0 4px 18px #80ff4055; animation-delay:.50s; color:#111 }
.logo-row.r2 span:nth-child(5) { background: #ff3472; box-shadow: 0 4px 18px #ff347255; animation-delay:.55s }

@keyframes letterDrop {
  from { opacity:0; transform:translateY(-24px) scale(0.7); }
  to   { opacity:1; transform:translateY(0) scale(1); }
}

/* ── INPUT ──────────────────────────── */
.field-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 3px;
  color: var(--cyan);
}
.field-inner {
  display: flex;
  align-items: center;
  background: var(--bg3);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  padding: 0 14px;
  gap: 10px;
  transition: border-color .2s, box-shadow .2s;
}
.field-inner:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 18px rgba(0,212,255,.18);
}
.field-cursor {
  font-size: 10px;
  color: var(--cyan);
  animation: blink .9s step-end infinite;
}
@keyframes blink { 50% { opacity:0 } }

input[type=text] {
  flex: 1;
  padding: 13px 0;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: 'Orbitron', monospace;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 2px;
  -webkit-appearance: none;
}
input[type=text]::placeholder { color: var(--muted); font-weight:400; letter-spacing:1px; }
.field-inner.err {
  border-color: var(--pink);
  box-shadow: 0 0 0 1px var(--pink), 0 0 18px rgba(255,52,114,.2);
  animation: shake .35s ease;
}
@keyframes shake {
  0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)}
  40%{transform:translateX(6px)} 60%{transform:translateX(-3px)} 80%{transform:translateX(3px)}
}

/* ── BUTTONS ────────────────────────── */
.btn-primary {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px;
  border-radius: var(--r);
  border: 1.5px solid var(--cyan);
  background: transparent;
  color: var(--cyan);
  font-family: 'Orbitron', monospace;
  font-size: .9rem;
  font-weight: 900;
  letter-spacing: 3px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: color .15s, box-shadow .2s;
  box-shadow: 0 0 16px rgba(0,212,255,.1), inset 0 0 16px rgba(0,212,255,.04);
}
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--cyan);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .15s ease;
}
.btn-primary:hover { color: #000; box-shadow: 0 0 28px rgba(0,212,255,.35); }
.btn-primary:hover::before { transform: scaleX(1); }
.btn-primary:active { transform: scale(.98); }
.btn-primary svg { position: relative; z-index:1; }
.btn-primary span, .btn-primary > * { position: relative; z-index:1; }

.btn-ghost {
  width: 100%;
  padding: 12px;
  border-radius: var(--r);
  border: 1px solid var(--edge);
  background: transparent;
  color: var(--muted);
  font-family: 'Rajdhani', sans-serif;
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all .2s;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 14px rgba(255,214,0,.12); }

.btn-quit {
  background: transparent; border: none;
  color: var(--muted);
  font-family: 'Share Tech Mono', monospace;
  font-size: .65rem;
  letter-spacing: 2px;
  cursor: pointer;
  padding: 6px 12px;
  transition: color .2s;
  margin-top: -4px;
}
.btn-quit:hover { color: var(--pink); }

.btn-back {
  background: transparent;
  border: 1px solid var(--edge);
  border-radius: var(--r);
  color: var(--muted);
  font-family: 'Share Tech Mono', monospace;
  font-size: .65rem;
  letter-spacing: 1px;
  padding: 7px 13px;
  cursor: pointer;
  transition: all .2s;
}
.btn-back:hover { border-color: var(--cyan); color: var(--cyan); }

.hint {
  font-family: 'Share Tech Mono', monospace;
  font-size: .58rem;
  color: var(--muted);
  letter-spacing: .5px;
  text-align: center;
  opacity: .7;
}

/* ── GAME SHELL ──────────────────────── */
.game-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: calc(var(--cs)*9 + var(--gap)*8 + 24px);
}

/* ── HEADER ─────────────────────────── */
.hdr {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  padding: 9px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 90px;
  backdrop-filter: blur(12px);
}
.stat.right { align-items: flex-end; }
.stat-lbl {
  font-family: 'Share Tech Mono', monospace;
  font-size: .52rem;
  color: var(--cyan);
  letter-spacing: 3px;
}
.stat-num {
  font-family: 'Orbitron', monospace;
  font-size: 1.45rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  transition: color .1s, transform .1s;
}
.stat-num.bump { color: var(--cyan); transform: scale(1.12); }

.hdr-logo {
  font-family: 'Orbitron', monospace;
  font-size: .65rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
  flex: 1;
}

/* ── GRID ───────────────────────────── */
.grid-frame {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 0 0 1px rgba(0,212,255,.05), 0 12px 50px rgba(0,0,0,.8);
}
.grid-frame::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: .4;
}

.scanlines {
  position: absolute;
  inset: 10px;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,.08) 3px,
    rgba(0,0,0,.08) 4px
  );
  pointer-events: none;
  z-index: 3;
  border-radius: 4px;
}

#gc {
  display: block;
  border-radius: 4px;
  cursor: crosshair;
  position: relative;
  z-index: 2;
}

/* combo popup */
.combo-pop {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Orbitron', monospace;
  font-size: 1.6rem;
  font-weight: 900;
  pointer-events: none;
  z-index: 10;
  text-shadow: 0 0 20px currentColor, 0 0 40px currentColor;
  opacity: 0;
  transition: none;
}
.combo-pop.show {
  animation: comboPop .75s cubic-bezier(.16,1,.3,1) forwards;
}
@keyframes comboPop {
  0%   { opacity:0; transform:scale(.4); }
  25%  { opacity:1; transform:scale(1.15); }
  60%  { opacity:1; transform:scale(1); }
  100% { opacity:0; transform:scale(.85) translateY(-24px); }
}

/* ── TRAY ───────────────────────────── */
.tray {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 14px 10px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 10px;
  min-height: 92px;
  gap: 6px;
  backdrop-filter: blur(12px);
}

.ps {
  flex: 1;
  min-height: 68px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1.5px solid transparent;
  cursor: pointer;
  padding: 8px;
  transition: all .15s;
  position: relative;
}
.ps:hover:not(.used) { background: rgba(0,212,255,.05); border-color: rgba(0,212,255,.2); }
.ps.sel {
  border-color: var(--cyan);
  background: rgba(0,212,255,.07);
  box-shadow: 0 0 18px rgba(0,212,255,.18), inset 0 0 12px rgba(0,212,255,.05);
}
.ps.used { opacity: .1; pointer-events: none; }
.ps.used-anim { animation: pieceOut .2s ease forwards; }
@keyframes pieceOut {
  to { opacity: .1; transform: scale(.9); }
}

.mini-grid { display: grid; gap: 2px; }
.mc {
  width: var(--mini); height: var(--mini);
  border-radius: 2px;
}
.mc.f {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 1px 3px rgba(0,0,0,.5);
}

/* ── GAME OVER ───────────────────────── */
.over-title {
  font-family: 'Orbitron', monospace;
  font-size: 2.8rem;
  font-weight: 900;
  line-height: .95;
  text-align: center;
  letter-spacing: 4px;
  color: var(--pink);
  text-shadow: 0 0 24px rgba(255,52,114,.6), 0 0 50px rgba(255,52,114,.3);
}

.result-box {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 22px;
  text-align: center;
  display: flex; flex-direction: column; gap: 4px;
}
.result-lbl {
  font-family: 'Share Tech Mono', monospace;
  font-size: .58rem;
  letter-spacing: 4px;
  color: var(--cyan);
}
.result-num {
  font-family: 'Orbitron', monospace;
  font-size: 3.2rem;
  font-weight: 900;
  color: #fff;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.result-rank {
  font-family: 'Rajdhani', sans-serif;
  font-size: .95rem;
  font-weight: 600;
  color: var(--muted);
}

.new-rec {
  font-family: 'Orbitron', monospace;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255,214,0,.5);
  animation: recPulse .7s ease-in-out infinite alternate;
  text-align: center;
}
@keyframes recPulse { from { opacity:.7 } to { opacity:1; transform:scale(1.04); } }

/* ── LEADERBOARD ─────────────────────── */
.lb-head {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.lb-title {
  font-family: 'Orbitron', monospace;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255,214,0,.35);
}

#lb-rows {
  width: 100%;
  display: flex; flex-direction: column; gap: 5px;
  max-height: 55dvh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--edge) transparent;
}

.lb-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  background: var(--bg3);
  border: 1px solid var(--edge);
  border-radius: 6px;
  transition: border-color .15s;
  animation: rowIn .3s ease backwards;
}
.lb-row:hover { border-color: var(--edge2); }
@keyframes rowIn {
  from { opacity:0; transform:translateX(-10px); }
  to   { opacity:1; transform:translateX(0); }
}
.lb-row.r1 { border-color: rgba(255,214,0,.3); }
.lb-row.r2 { border-color: rgba(192,192,192,.2); }
.lb-row.r3 { border-color: rgba(205,127,50,.2); }

.lb-pos {
  font-family: 'Orbitron', monospace;
  font-size: 1rem; font-weight:700;
  text-align: center;
}
.lb-name {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600; font-size: .95rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb-right { text-align: right; }
.lb-sc-val {
  font-family: 'Orbitron', monospace;
  font-size: .85rem; font-weight:700;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}
.lb-ip {
  font-family: 'Share Tech Mono', monospace;
  font-size: .58rem;
  color: var(--muted);
  margin-top: 2px;
}

.hidden { display: none !important; }

/* ── MOBILE ──────────────────────────── */
@media (max-width: 500px) {
  :root { --cs:37px; --mini:11px; --gap:2px; }
  .stat-num  { font-size:1.1rem; }
  .stat      { min-width:72px; padding:8px 10px; }
  .result-num{ font-size:2.4rem; }
  .logo-row span { width:38px; height:38px; font-size:18px; }
}
@media (max-width: 390px) {
  :root { --cs:33px; --mini:10px; }
}
