/* ══════════════════════════════════════════
   MONOLITH — Magic Tetris Redesign
   Precision Dark × Surgical Neon
   Fonts: Bebas Neue · JetBrains Mono · DM Sans
══════════════════════════════════════════ */
:root {
  --bg:      #030308;
  --bg2:     #07070F;
  --panel:   rgba(8, 8, 18, 0.97);
  --glass:   rgba(255, 255, 255, 0.025);
  --glass2:  rgba(255, 255, 255, 0.05);

  --cyan:    #00F5D4;
  --cyan2:   #00BFA5;
  --coral:   #FF3A5C;
  --gold:    #FFC700;
  --violet:  #9B72FF;
  --white:   #EDEAF8;
  --muted:   #4A4868;

  --b0: rgba(0, 245, 212, 0.08);
  --b1: rgba(0, 245, 212, 0.18);
  --b2: rgba(0, 245, 212, 0.45);

  --r0: 3px;
  --r1: 6px;
  --r2: 10px;
}

*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'DM Sans', sans-serif;
  color: var(--white);
  background: var(--bg);
}

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


body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ── GRID LINES ── */
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 245, 212, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 245, 212, 0.018) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* ── CORNER GLOWS ── */
#aurora {
  position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden;
}
.au {
  position: absolute; border-radius: 50%; filter: blur(110px);
  animation: aupulse 14s ease-in-out infinite;
}
.au1 {
  width: 700px; height: 700px; left: -18%; top: -22%;
  background: radial-gradient(ellipse, rgba(0, 245, 212, 0.055), transparent 70%);
  animation-delay: 0s;
}
.au2 {
  width: 600px; height: 600px; right: -15%; bottom: -18%;
  background: radial-gradient(ellipse, rgba(155, 114, 255, 0.05), transparent 70%);
  animation-delay: 7s;
}
.au3 { display: none; }
@keyframes aupulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

/* ── STARS ── */
#stars { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.st { position: absolute; border-radius: 50%; background: #fff; }
@keyframes tw { 0%, 100% { opacity: 0.04; } 50% { opacity: 0.8; } }
#pts { display: none; }

/* ══ PAGE SYSTEM ══ */
.pg { display: none; position: relative; z-index: 10; min-height: 100vh; width: 100%; }
.pg.on { display: flex; }

/* ══ CARD ══ */
.gcard {
  position: relative;
  border: 1px solid var(--b1);
  border-radius: var(--r2);
  box-shadow:
    0 0 0 1px rgba(0, 245, 212, 0.04),
    0 24px 64px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(0, 245, 212, 0.06);
}
.gcard::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: calc(var(--r2) - 1px);
  background: linear-gradient(135deg,
    rgba(0, 245, 212, 0.035) 0%,
    transparent 40%,
    rgba(155, 114, 255, 0.02) 100%);
  pointer-events: none;
}
.gcard-inner {
  background: var(--panel);
  border-radius: calc(var(--r2) - 1px);
  position: relative; overflow: hidden;
}
.gcard-inner::after {
  content: '';
  position: absolute; top: 0; left: 15%; right: 15%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 245, 212, 0.22), transparent);
  pointer-events: none;
}
@keyframes fadeup {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: none; }
}

/* ══════════════════════════════════════════
   PAGE 1 — START
══════════════════════════════════════════ */
#pg-start {
  flex-direction: column;
  align-items: center; justify-content: center;
  padding: 28px 16px 36px; gap: 24px; overflow-y: auto;
}

.logo-anim { animation: bob 7s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.logo-anim img {
  width: 260px; max-width: 78vw;
  filter:
    drop-shadow(0 0 18px rgba(0, 245, 212, 0.55))
    drop-shadow(0 0 50px rgba(0, 245, 212, 0.18))
    brightness(1.05);
}

.start-card {
  width: 100%; max-width: 358px;
  animation: fadeup 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.start-card .gcard-inner { padding: 28px 28px 32px; }

.start-card h2 {
  font-family: 'Bebas Neue', cursive;
  font-size: 1.7rem; letter-spacing: 0.14em;
  text-align: center; margin-bottom: 4px;
  color: var(--cyan);
  text-shadow: 0 0 22px rgba(0, 245, 212, 0.45);
}
.start-card .sub {
  text-align: center; color: var(--muted);
  font-size: 0.65rem; letter-spacing: 0.14em;
  text-transform: uppercase; margin-bottom: 26px; font-weight: 500;
}

/* Avatar */
.av-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 22px; }
.av-ring {
  padding: 2px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
}
.av-ring:hover { transform: scale(1.06); box-shadow: 0 0 28px rgba(0, 245, 212, 0.4); }
.av-btn {
  width: 74px; height: 74px; border-radius: 50%;
  background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.av-ico { font-size: 1.9rem; user-select: none; }
.av-img { display: none; width: 100%; height: 100%; object-fit: cover; position: absolute; border-radius: 50%; }
.av-hint { font-size: 0.6rem; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500; }

/* Input */
.fld { margin-bottom: 18px; }
.fld label {
  display: block; font-size: 0.58rem; color: var(--cyan);
  font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 7px;
}
.fld input {
  width: 100%; padding: 12px 14px;
  border-radius: var(--r0);
  border: 1px solid rgba(0, 245, 212, 0.14);
  background: rgba(0, 0, 0, 0.5);
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem; font-weight: 600;
  outline: none; transition: all 0.22s; letter-spacing: 0.02em;
}
.fld input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(0, 245, 212, 0.15), 0 0 18px rgba(0, 245, 212, 0.07);
  background: rgba(0, 245, 212, 0.025);
}
.fld input::placeholder { color: rgba(255, 255, 255, 0.15); }

/* Buttons */
.btn-main {
  width: 100%; padding: 14px;
  border-radius: var(--r0);
  border: 1px solid var(--cyan); cursor: pointer;
  font-family: 'Bebas Neue', cursive;
  font-size: 1.15rem; letter-spacing: 0.18em;
  background: rgba(0, 245, 212, 0.1); color: var(--cyan);
  box-shadow: 0 0 28px rgba(0, 245, 212, 0.1), inset 0 1px 0 rgba(0, 245, 212, 0.08);
  transition: all 0.22s; position: relative; overflow: hidden; margin-bottom: 10px;
}
.btn-main::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(0, 245, 212, 0.12), transparent);
  transform: translateX(-120%); transition: 0.6s;
}
.btn-main:hover {
  background: rgba(0, 245, 212, 0.18);
  box-shadow: 0 0 40px rgba(0, 245, 212, 0.22);
  transform: translateY(-1px);
}
.btn-main:hover::before { transform: translateX(120%); }

.btn-sec {
  width: 100%; padding: 11px; border-radius: var(--r0);
  border: 1px solid rgba(255, 255, 255, 0.07); background: transparent;
  color: var(--muted); cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 0.8rem; font-weight: 600;
  transition: all 0.2s;
}
.btn-sec:hover { border-color: var(--b1); color: var(--white); background: var(--glass); }

/* ══════════════════════════════════════════
   PAGE 2 — GAME
══════════════════════════════════════════ */
#pg-game {
  flex-direction: column; align-items: center; justify-content: center;
  padding: 72px 14px 14px; gap: 10px; overflow: hidden;
}

/* Header */
.gh {
  position: absolute; top: 14px; left: 18px; right: 18px;
  z-index: 25;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none;
}
.gh-logo img { width: 72px; filter: drop-shadow(0 0 10px rgba(0, 245, 212, 0.45)) brightness(1.05); }
.gh-right { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.gh-av {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  border: 1.5px solid var(--cyan); box-shadow: 0 0 14px rgba(0, 245, 212, 0.3);
  background: var(--bg2);
}
.gh-nm {
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 0.7rem;
  color: var(--cyan); max-width: 110px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(0, 245, 212, 0.3);
}

.gbody {
  display: flex; gap: 10px; align-items: flex-start; justify-content: center;
  width: 100%; max-width: 920px; margin: 0 auto;
}

/* ── LEFT PANEL ── */
.lp {
  flex: 0 0 130px; max-width: 130px;
  display: flex; flex-direction: column; gap: 6px;
}

.lp-player {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(0,245,212,0.1);
  border-radius: var(--r1); padding: 14px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.lp-av {
  width: 52px; height: 52px; border-radius: 50%; object-fit: cover;
  border: 1.5px solid var(--cyan);
  box-shadow: 0 0 14px rgba(0,245,212,0.25);
  background: var(--bg2);
}
.lp-nm {
  font-family: 'JetBrains Mono', monospace; font-size: 0.62rem;
  font-weight: 700; color: var(--white); letter-spacing: 0.04em;
  max-width: 108px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: center;
}
.lp-status {
  font-size: 0.5rem; font-weight: 700; letter-spacing: 0.16em;
  color: var(--cyan); text-transform: uppercase;
  animation: blink-status 2.2s ease-in-out infinite;
}
@keyframes blink-status {
  0%, 80%, 100% { opacity: 1; }
  40% { opacity: 0.3; }
}

.lp-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,245,212,0.15), transparent);
  margin: 2px 0;
}

.lp-tip {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(0,245,212,0.07);
  border-radius: var(--r0); padding: 8px 9px;
}
.lp-tip-label {
  font-size: 0.45rem; font-weight: 700; letter-spacing: 0.2em;
  color: var(--cyan); text-transform: uppercase; margin-bottom: 4px;
}
.lp-tip-text {
  font-size: 0.58rem; color: var(--muted); line-height: 1.4;
  transition: opacity 0.2s ease;
}

/* ── COMBO ── */
.combo-display {
  position: absolute; top: 18%; left: 50%; transform: translateX(-50%);
  z-index: 20; pointer-events: none; white-space: nowrap;
  font-family: 'Bebas Neue', cursive;
  font-size: 1.6rem; letter-spacing: 0.18em;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255,199,0,0.9), 0 0 4px rgba(255,199,0,0.5);
  opacity: 0;
}
@keyframes combo-pop {
  0%   { transform: translateX(-50%) scale(1.5); opacity: 1; }
  55%  { transform: translateX(-50%) scale(1.05); opacity: 1; }
  100% { transform: translateX(-50%) scale(0.9); opacity: 0; }
}
.combo-display.show {
  animation: combo-pop 1s ease forwards;
}

/* hide left panel on mobile */
@media (max-width: 700px) {
  .lp { display: none; }
}

/* Board */
.bwrap {
  flex: 0 0 auto; position: relative;
  border-radius: var(--r1); overflow: hidden; padding: 1px;
  border: 1px solid var(--b2);
  box-shadow:
    0 0 0 1px rgba(0, 245, 212, 0.06),
    0 0 40px rgba(0, 245, 212, 0.08),
    0 0 80px rgba(0, 0, 0, 0.6);
}
.bwrap::before {
  content: ''; position: absolute; z-index: 3; pointer-events: none;
  top: -1px; left: -1px; right: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent); opacity: 0.8;
}
.bwrap::after {
  content: ''; position: absolute; z-index: 3; pointer-events: none;
  bottom: -1px; left: -1px; right: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--violet), transparent); opacity: 0.5;
}
.bwrap-in { border-radius: 5px; overflow: hidden; line-height: 0; position: relative; }
#gc { display: block; background: #020108; }

/* Scanlines */
.bwrap-in::after {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 3px,
    rgba(0, 0, 0, 0.05) 3px, rgba(0, 0, 0, 0.05) 4px
  );
}

/* Pause */
.pov {
  position: absolute; inset: 1px; z-index: 30;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: rgba(2, 1, 10, 0.92); backdrop-filter: blur(10px); border-radius: 5px;
}
.pov h2 {
  font-family: 'Bebas Neue', cursive; font-size: 2.4rem;
  color: var(--cyan); letter-spacing: 0.18em;
  text-shadow: 0 0 28px rgba(0, 245, 212, 0.55);
}
.pov p { font-size: 0.62rem; color: var(--muted); letter-spacing: 0.1em; }

/* Side panel */
.sp { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 122px; max-width: 145px; }

.sc {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 245, 212, 0.08);
  border-radius: var(--r0); padding: 8px 10px;
  position: relative; overflow: hidden; transition: border-color 0.25s;
}
.sc:hover { border-color: rgba(0, 245, 212, 0.2); }
.sc label {
  display: block; font-size: 0.48rem; color: var(--muted);
  letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 2px; font-weight: 700;
}
.sv {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.18rem; line-height: 1.1; font-weight: 700; color: var(--white);
}
.sv.gd { color: var(--gold); text-shadow: 0 0 14px rgba(255, 199, 0, 0.35); }
.sv.pk { color: var(--violet); }

.lbar { margin-top: 5px; height: 2px; background: rgba(255, 255, 255, 0.05); border-radius: 2px; overflow: hidden; }
.lbar-f {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 8px rgba(0, 245, 212, 0.6);
}

.nc-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 245, 212, 0.08);
  border-radius: var(--r0); padding: 8px 10px;
}
.nc-card label {
  display: block; font-size: 0.48rem; color: var(--muted);
  letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 6px; font-weight: 700;
}
#nc { display: block; margin: 0 auto; }

.kh {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 245, 212, 0.08);
  border-radius: var(--r0); padding: 8px 10px;
}
.kh label {
  display: block; font-size: 0.48rem; color: var(--muted);
  letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 6px; font-weight: 700;
}
.kh-row { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; font-size: 0.56rem; color: var(--muted); }
kbd {
  background: rgba(0, 245, 212, 0.07);
  border: 1px solid rgba(0, 245, 212, 0.18);
  border-radius: 3px; padding: 1px 5px;
  font-size: 0.52rem; color: var(--cyan);
  font-family: 'JetBrains Mono', monospace; font-weight: 700;
}

.sp-btns { display: flex; flex-direction: column; gap: 4px; }
.sb { width: 100%; padding: 7px 9px; border-radius: var(--r0); cursor: pointer; font-family: 'DM Sans', sans-serif; font-size: 0.64rem; font-weight: 700; letter-spacing: 0.04em; transition: all 0.18s; }
.sb-r { background: rgba(255, 199, 0, 0.05); color: var(--gold); border: 1px solid rgba(255, 199, 0, 0.2); }
.sb-r:hover { background: rgba(255, 199, 0, 0.1); box-shadow: 0 0 14px rgba(255, 199, 0, 0.15); }
.sb-b { background: transparent; color: var(--muted); border: 1px solid rgba(255, 255, 255, 0.06); }
.sb-b:hover { background: var(--glass); color: var(--white); }

/* D-pad */
.dpad { display: none; width: 100%; max-width: 660px; padding: 4px 0 6px; }
.dp-row { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; }
.mb {
  width: 54px; height: 54px; border-radius: var(--r1);
  border: 1px solid rgba(0, 245, 212, 0.18); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; background: rgba(0, 0, 0, 0.55); color: var(--white);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  user-select: none; -webkit-user-select: none; touch-action: manipulation; transition: all 0.1s;
}
.mb:active { transform: scale(0.85); background: rgba(0, 245, 212, 0.1); box-shadow: 0 0 16px rgba(0, 245, 212, 0.3); border-color: var(--cyan); }
.mb.wide { width: 126px; font-family: 'Bebas Neue', cursive; font-size: 0.88rem; letter-spacing: 0.1em; }
.mb.drp { background: rgba(255, 58, 92, 0.06); border-color: rgba(255, 58, 92, 0.28); color: var(--coral); }
.mb.drp:active { background: rgba(255, 58, 92, 0.18); box-shadow: 0 0 16px rgba(255, 58, 92, 0.3); }

/* ══════════════════════════════════════════
   PAGE 3 — GAME OVER
══════════════════════════════════════════ */
#pg-over { flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; overflow-y: auto; }
.oc { width: 100%; max-width: 338px; animation: fadeup 0.55s cubic-bezier(0.22, 1, 0.36, 1); }
.oc .gcard-inner { padding: 28px 26px; }
.oc h2 {
  font-family: 'Bebas Neue', cursive; font-size: 2.5rem; text-align: center;
  margin-bottom: 20px; letter-spacing: 0.12em; color: var(--coral);
  text-shadow: 0 0 30px rgba(255, 58, 92, 0.45);
}
.oc-av { width: 66px; height: 66px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto 10px; border: 2px solid var(--cyan); box-shadow: 0 0 22px rgba(0, 245, 212, 0.3); }
.oc-nm { font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; font-weight: 700; text-align: center; margin-bottom: 5px; color: var(--white); letter-spacing: 0.06em; }
.oc-rnk { display: block; text-align: center; margin-bottom: 20px; font-family: 'Bebas Neue', cursive; font-size: 1.05rem; letter-spacing: 0.14em; color: var(--gold); text-shadow: 0 0 16px rgba(255, 199, 0, 0.45); }
.oc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.oc-st { background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(0, 245, 212, 0.08); border-radius: var(--r0); padding: 11px 10px; text-align: center; }
.oc-st label { display: block; font-size: 0.46rem; color: var(--muted); letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 4px; font-weight: 700; }
.oc-st .v { font-family: 'JetBrains Mono', monospace; font-size: 1.1rem; color: var(--white); font-weight: 700; }
.oc-st .v.gd { color: var(--gold); text-shadow: 0 0 10px rgba(255, 199, 0, 0.35); }
.oc-btns { display: flex; gap: 8px; }
.btn-pa { flex: 1; padding: 12px 8px; border-radius: var(--r0); border: 1px solid var(--cyan); cursor: pointer; font-family: 'Bebas Neue', cursive; font-size: 0.92rem; letter-spacing: 0.12em; background: rgba(0, 245, 212, 0.1); color: var(--cyan); transition: all 0.2s; }
.btn-pa:hover { background: rgba(0, 245, 212, 0.2); box-shadow: 0 0 24px rgba(0, 245, 212, 0.2); transform: translateY(-1px); }
.btn-oa { flex: 1; padding: 12px 8px; border-radius: var(--r0); border: 1px solid rgba(255, 255, 255, 0.08); background: transparent; color: var(--muted); cursor: pointer; font-family: 'Bebas Neue', cursive; font-size: 0.92rem; letter-spacing: 0.12em; transition: all 0.2s; }
.btn-oa:hover { border-color: var(--b1); color: var(--white); }
.btn-dl { width: 100%; padding: 12px; border-radius: var(--r0); border: 1px solid rgba(155, 114, 255, 0.28); cursor: pointer; font-family: 'Bebas Neue', cursive; font-size: 0.92rem; letter-spacing: 0.12em; background: rgba(155, 114, 255, 0.06); color: var(--violet); transition: all 0.2s; margin-top: 8px; position: relative; overflow: hidden; }
.btn-dl::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(155, 114, 255, 0.15), transparent); transform: translateX(-120%); transition: 0.6s; }
.btn-dl:hover { background: rgba(155, 114, 255, 0.14); box-shadow: 0 0 24px rgba(155, 114, 255, 0.18); }
.btn-dl:hover::before { transform: translateX(120%); }

/* ══════════════════════════════════════════
   PAGE 4 — LEADERBOARD
══════════════════════════════════════════ */
#pg-lb { flex-direction: column; align-items: center; justify-content: flex-start; padding: 18px 12px 30px; gap: 0; overflow-y: auto; }
.lb-hd { width: 100%; max-width: 520px; display: flex; align-items: center; margin-bottom: 18px; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(0, 245, 212, 0.1); border-radius: var(--r1); padding: 10px 14px; backdrop-filter: blur(10px); }
.lb-hd h1 { flex: 1; text-align: center; font-family: 'Bebas Neue', cursive; font-size: 1.3rem; letter-spacing: 0.14em; color: var(--gold); text-shadow: 0 0 18px rgba(255, 199, 0, 0.35); }
.btn-bk { padding: 6px 12px; border-radius: var(--r0); border: 1px solid rgba(255, 255, 255, 0.07); background: transparent; color: var(--muted); cursor: pointer; font-family: 'DM Sans', sans-serif; font-size: 0.72rem; font-weight: 600; transition: all 0.18s; }
.btn-bk:hover { border-color: var(--b1); color: var(--white); }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; width: 100%; max-width: 520px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 5px; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(0, 245, 212, 0.08); border-radius: var(--r1); padding: 12px 10px; min-width: 98px; transition: transform 0.2s, border-color 0.2s; }
.pod:hover { transform: translateY(-3px); border-color: var(--b1); }
.pod1 { border-color: rgba(255, 199, 0, 0.3); box-shadow: 0 0 24px rgba(255, 199, 0, 0.07); }
.pod2 { order: -1; } .pod3 { order: 1; }
.pod-crown { font-size: 1.3rem; }
.pod-av { border-radius: 50%; object-fit: cover; }
.pod1 .pod-av { width: 46px; height: 46px; border: 2px solid var(--gold); }
.pod2 .pod-av, .pod3 .pod-av { width: 38px; height: 38px; border: 1.5px solid rgba(200, 200, 255, 0.25); }
.pod-nm { font-size: 0.62rem; font-weight: 700; max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; color: var(--white); }
.pod-sc { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; font-weight: 700; }
.pod1 .pod-sc { color: var(--gold); text-shadow: 0 0 10px rgba(255, 199, 0, 0.4); }
.pod2 .pod-sc { color: #C0C0C0; } .pod3 .pod-sc { color: #CD7F32; }
.lb-tbl { width: 100%; max-width: 520px; background: rgba(0, 0, 0, 0.25); border: 1px solid rgba(0, 245, 212, 0.07); border-radius: var(--r1); overflow: hidden; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.03); transition: background 0.12s; }
.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: rgba(255, 255, 255, 0.02); }
.lb-row.me { background: rgba(0, 245, 212, 0.04); border-left: 2px solid var(--cyan); padding-left: 12px; }
.lb-rk { width: 24px; font-size: 0.64rem; font-weight: 700; text-align: center; flex-shrink: 0; font-family: 'JetBrains Mono', monospace; }
.r1 { color: var(--gold); } .r2 { color: #C0C0C0; } .r3 { color: #CD7F32; } .rn { color: var(--muted); }
.lb-av { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(0, 245, 212, 0.15); flex-shrink: 0; }
.lb-nm { flex: 1; font-size: 0.72rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-sc { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: var(--gold); font-weight: 700; }
.lb-empty { text-align: center; padding: 30px; color: var(--muted); font-size: 0.78rem; }

/* ══ MODAL ══ */
.modal-bg { display: none; position: fixed; inset: 0; z-index: 999; background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(10px); align-items: center; justify-content: center; }
.modal-bg.open { display: flex; }
.modal-wrap { width: 90%; max-width: 256px; animation: fadeup 0.3s ease; }
.modal-wrap .gcard-inner { padding: 24px 22px; text-align: center; }
.modal-wrap h3 { font-family: 'Bebas Neue', cursive; font-size: 1.4rem; color: var(--white); margin-bottom: 8px; letter-spacing: 0.1em; }
.modal-wrap p { color: var(--muted); font-size: 0.76rem; margin-bottom: 20px; }
.modal-row { display: flex; gap: 8px; }
.m-y { flex: 1; padding: 10px; border-radius: var(--r0); border: 1px solid var(--coral); cursor: pointer; font-family: 'Bebas Neue', cursive; font-size: 0.92rem; letter-spacing: 0.1em; background: rgba(255, 58, 92, 0.1); color: var(--coral); transition: all 0.18s; }
.m-y:hover { background: rgba(255, 58, 92, 0.2); }
.m-n { flex: 1; padding: 10px; border-radius: var(--r0); border: 1px solid rgba(255, 255, 255, 0.08); background: transparent; color: var(--muted); cursor: pointer; font-family: 'Bebas Neue', cursive; font-size: 0.92rem; letter-spacing: 0.1em; transition: all 0.18s; }
.m-n:hover { border-color: var(--b1); color: var(--white); }

/* ══ RESPONSIVE ══ */
@media (max-width: 540px) {
  /* Page: top padding for header, bottom for fixed dpad */
  /* Layout props applied always; display is controlled by .pg / .pg.on rules */
  #pg-game {
    padding: 52px 0 152px;
    min-height: 100dvh;
    flex-direction: column; align-items: center;
    overflow-x: hidden; overflow-y: hidden;
  }

  /* Header — fixed at top */
  .gh {
    position: fixed; top: 0; left: 0; right: 0;
    height: 52px; padding: 0 12px;
    background: rgba(3,3,8,0.97);
    border-bottom: 1px solid rgba(0,245,212,0.08);
    z-index: 50; pointer-events: auto;
  }
  .gh-logo img { width: 56px; }
  .gh-av { width: 30px; height: 30px; }
  .gh-nm { max-width: 80px; font-size: 0.62rem; }
  .gh-right { gap: 6px; }

  /* Game body: column, canvas + compact stat strip */
  .gbody {
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
    padding: 6px 8px 0;
  }
  .lp { display: none; }

  /* Canvas stays centered */
  .bwrap { flex: 0 0 auto; }

  /* Stats + next + buttons all in one horizontal wrap row */
  .sp {
    flex-direction: row;
    flex-wrap: wrap;
    min-width: unset;
    max-width: 100%;
    width: 100%;
    gap: 4px;
  }
  .sc {
    flex: 1 1 60px;
    min-width: 60px;
    padding: 5px 7px;
  }
  .sc label { font-size: 0.4rem; margin-bottom: 1px; }
  .sv { font-size: 0.88rem; }
  .lbar { margin-top: 3px; }
  .nc-card {
    flex: 0 0 auto;
    padding: 5px 8px;
    display: flex; align-items: center; gap: 8px;
  }
  .nc-card label { margin-bottom: 0; }
  #nc { width: 64px !important; height: 50px !important; margin: 0; }
  .kh { display: none; }
  .sp-btns {
    flex: 1 1 120px;
    flex-direction: column;
    gap: 3px;
    min-width: 110px;
  }
  .sb { padding: 6px 8px; font-size: 0.58rem; width: 100%; }

  /* Game over page — account for fixed header */
  #pg-over { padding-top: 20px; }
  .oc { width: 92%; max-width: 360px; }

  /* D-pad — fixed at bottom, only when game is active */
  .dpad {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: 7px 0 max(8px, env(safe-area-inset-bottom));
    background: rgba(3,3,8,0.98);
    border-top: 1px solid rgba(0,245,212,0.1);
    z-index: 40;
  }
  #pg-game.on .dpad {
    display: block;
  }
  .dp-row { gap: 8px; margin-bottom: 5px; }
  .dp-row:last-child { margin-bottom: 0; }
  .mb { width: 58px; height: 46px; font-size: 1.2rem; border-radius: 6px; }
  .mb.wide { width: 144px; font-size: 0.82rem; }
}

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 245, 212, 0.2); border-radius: 2px; }

/* ══ IMAGE MODAL ══ */
#img-modal { display: none; position: fixed; inset: 0; z-index: 1100; background: rgba(0, 0, 0, 0.94); backdrop-filter: blur(18px); flex-direction: column; align-items: center; justify-content: center; padding: 16px; gap: 18px; }
#img-modal.open { display: flex; }
#img-modal img { max-width: min(420px, 92vw); max-height: 72vh; object-fit: contain; border-radius: var(--r1); box-shadow: 0 0 50px rgba(0, 245, 212, 0.18), 0 0 100px rgba(0, 0, 0, 0.6); border: 1px solid var(--b1); }
.img-modal-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; width: 100%; }
.img-modal-btns--single { margin-top: 4px; }
.img-modal-cl { min-width: 200px; padding: 12px 24px; border-radius: var(--r0); cursor: pointer; border: 1px solid rgba(255, 255, 255, 0.08); background: rgba(0, 0, 0, 0.5); color: var(--muted); font-family: 'Bebas Neue', cursive; font-size: 0.92rem; letter-spacing: 0.12em; transition: all 0.2s; }
.img-modal-cl:hover { border-color: var(--b1); color: var(--white); }
