/* ── ROOT VARS ── */
:root {
  --g1: #22c55e;   /* bright green */
  --g2: #4ade80;   /* light green  */
  --g3: #16a34a;   /* mid green    */
  --g4: #052e0f;   /* dark green   */
  --y1: #ffd700;   /* gold         */
  --y2: #fbbf24;   /* amber        */
  --y3: #fde68a;   /* pale yellow  */
  --scarlet: #e63946;
  --violet:  #9b8dff;
  --bg:  #040c04;
  --card: rgba(5, 18, 5, 0.88);
  --border: rgba(34,197,94,0.3);
  --text: #d1fae5;
}

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

body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  overflow-x: hidden;
}

/* ── CANVASES ── */
#bg-canvas {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  z-index: -1; pointer-events: none;
}
#effect-canvas {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  z-index: 200; pointer-events: none;
}
#confetti-canvas {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  z-index: 999; pointer-events: none; display: none;
}

.screen { width: 100%; display: flex; flex-direction: column; align-items: center; }

/* ── BUTTONS ── */
button {
  padding: 12px 22px; border: none; border-radius: 10px;
  font-size: 0.9rem; font-weight: 800; cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, opacity 0.15s;
  letter-spacing: 0.5px;
}
button:hover  { transform: translateY(-2px); opacity: 0.92; }
button:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--g1), var(--y2));
  color: #031a03;
  box-shadow: 0 4px 18px rgba(34,197,94,0.45);
  font-size: 1rem;
}
.btn-primary:hover { box-shadow: 0 6px 28px rgba(255,215,0,0.5); }

.btn-secondary {
  background: rgba(34,197,94,0.08);
  color: var(--g2);
  border: 1px solid rgba(34,197,94,0.35);
}
.btn-secondary:hover { background: rgba(34,197,94,0.15); }

/* ── AUTH SCREEN ── */
#auth-screen { min-height: 100vh; justify-content: center; }

.auth-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 48px;
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  box-shadow: 0 0 60px rgba(34,197,94,0.12), 0 0 120px rgba(255,215,0,0.06);
  animation: gameOverPop 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
}

.auth-logo { width: 120px; height: 120px; margin-bottom: -8px; }
.auth-title { font-size: 2.4rem; }

.auth-tabs {
  display: flex; gap: 0; width: 100%;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.auth-tab {
  flex: 1; padding: 10px 8px; border-radius: 0; border: none;
  background: transparent; color: #4a6a4a; font-size: 0.85rem; font-weight: 700;
  transition: background 0.2s, color 0.2s;
}
.auth-tab.active {
  background: rgba(34,197,94,0.18);
  color: var(--g2);
}
.auth-tab:hover:not(.active) { background: rgba(34,197,94,0.07); transform: none; }

.auth-form {
  width: 100%; display: flex; flex-direction: column; gap: 12px;
}
.auth-form input {
  width: 100%; padding: 13px 16px;
  background: rgba(34,197,94,0.06);
  border: 1px solid rgba(34,197,94,0.25);
  border-radius: 10px; color: var(--text);
  font-size: 0.95rem; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-form input:focus {
  border-color: var(--g1);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.15);
}
/* ── TEAM CUSTOMIZER ── */
.tc-card {
  background: rgba(34,197,94,0.06); border: 1px solid rgba(34,197,94,0.2);
  border-radius: 10px; padding: 6px 8px; text-align: center;
  cursor: pointer; transition: border-color 0.2s, background 0.2s; min-width: 72px;
}
.tc-card:hover { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.5); }
.tc-active { border-color: #ffd700 !important; background: rgba(255,215,0,0.12) !important; box-shadow: 0 0 10px rgba(255,215,0,0.3); }

.auth-divider {
  width: 100%; text-align: center; position: relative;
  color: #2a4a2a; font-size: 0.8rem; margin: 4px 0;
}
.auth-divider::before,.auth-divider::after {
  content:''; position:absolute; top:50%; width:42%; height:1px;
  background: rgba(34,197,94,0.2);
}
.auth-divider::before { left:0; }
.auth-divider::after  { right:0; }

.auth-error {
  background: rgba(230,57,70,0.15);
  border: 1px solid rgba(230,57,70,0.4);
  border-radius: 8px; padding: 10px 14px;
  color: #ff8a8a; font-size: 0.85rem; text-align: center;
}

/* ── LOGGED-IN BAR ── */
#logged-in-bar {
  display: flex; align-items: center; gap: 12px;
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: 10px; padding: 8px 16px;
}
#logged-in-name {
  color: var(--g2); font-weight: 700; font-size: 0.9rem;
}
#logged-in-name::before { content: '👤 '; }
.btn-logout {
  padding: 5px 12px; border-radius: 7px; font-size: 0.75rem; font-weight: 700;
  background: rgba(230,57,70,0.12); color: #ff8a8a;
  border: 1px solid rgba(230,57,70,0.3);
}
.btn-logout:hover { background: rgba(230,57,70,0.22); transform: none; }

#elo-record {
  font-size: 0.72rem; color: #4a7a4a; margin-top: 2px;
}

/* ── MENU ── */
#menu { padding: 30px 20px; gap: 0; min-height: 100vh; justify-content: center; }

.menu-mascots {
  display: flex; align-items: flex-start; gap: 28px;
  width: 100%; max-width: 1100px;
}

.mascot {
  flex-shrink: 0; width: 180px;
  display: flex; flex-direction: column; align-items: center;
  position: relative; margin-top: 60px;
}
.mascot img { width: 160px; height: 160px; object-fit: contain; filter: drop-shadow(0 0 20px rgba(34,197,94,0.4)); }
.mascot-left img  { animation: pikaBounce 1.4s ease-in-out infinite; }
.mascot-right img { animation: bulbaSway 2.2s ease-in-out infinite; }

@keyframes pikaBounce {
  0%,100% { transform: translateY(0) rotate(-2deg); }
  50%     { transform: translateY(-16px) rotate(2deg); }
}
@keyframes bulbaSway {
  0%,100% { transform: rotate(-3deg); }
  50%     { transform: rotate(3deg); }
}

.mascot-bolt {
  position: absolute; top: 0; right: 10px;
  font-size: 2rem; animation: boltFlash 1.8s ease-in-out infinite;
}
.mascot-leaf {
  position: absolute; top: 0; left: 10px;
  font-size: 2rem; animation: leafSpin 3s linear infinite;
}
@keyframes boltFlash {
  0%,100% { opacity: 0.5; transform: scale(1); }
  50%     { opacity: 1;   transform: scale(1.3) rotate(15deg); }
}
@keyframes leafSpin {
  0%   { transform: rotate(0deg) translateY(0); }
  50%  { transform: rotate(180deg) translateY(-8px); }
  100% { transform: rotate(360deg) translateY(0); }
}

.menu-center-col {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 18px;
}

.title {
  font-size: 4rem; font-weight: 900; letter-spacing: 3px;
  color: var(--g1);
  text-shadow: 0 0 30px rgba(34,197,94,0.6), 0 0 60px rgba(34,197,94,0.3);
  animation: titlePulse 3s ease-in-out infinite;
  line-height: 1;
}
.title-chess { color: var(--y1); text-shadow: 0 0 30px rgba(255,215,0,0.6), 0 0 60px rgba(255,215,0,0.3); }
@keyframes titlePulse {
  0%,100% { text-shadow: 0 0 30px rgba(34,197,94,0.6), 0 0 60px rgba(34,197,94,0.25); }
  50%     { text-shadow: 0 0 50px rgba(34,197,94,0.9), 0 0 100px rgba(34,197,94,0.4); }
}

.subtitle {
  color: var(--y2); font-size: 0.85rem; letter-spacing: 5px;
  text-transform: uppercase; margin-top: -12px;
}

#elo-badge {
  background: linear-gradient(135deg, rgba(5,18,5,0.9), rgba(10,30,10,0.9));
  border: 1px solid var(--g3); border-radius: 14px;
  padding: 14px 36px; text-align: center;
  box-shadow: 0 0 20px rgba(34,197,94,0.15);
}
#elo-rank-label { color: var(--g2); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 3px; }
#elo-num { font-size: 2.8rem; font-weight: 900; color: var(--y1); font-family: monospace; line-height: 1; }
.elo-sub { color: #555; font-size: 0.7rem; letter-spacing: 1px; }

.menu-options {
  display: flex; flex-direction: column; gap: 14px;
  width: 340px;
}

#username {
  padding: 12px 16px;
  background: rgba(5,18,5,0.8); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 1rem;
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
  text-align: center;
}
#username:focus { border-color: var(--g1); box-shadow: 0 0 12px rgba(34,197,94,0.3); }
#username::placeholder { color: #3a5a3a; }

.opt-label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 0.7rem; color: #4a7a4a; text-transform: uppercase; letter-spacing: 1.5px;
}
.opt-label select {
  padding: 10px 14px;
  background: rgba(5,18,5,0.85); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; font-size: 0.95rem; cursor: pointer;
}

.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--y1); cursor: pointer; }
.slider-row span { font-size: 1.2rem; font-weight: 900; color: var(--y1); width: 24px; text-align: center; }

#ai-elo-hint { font-size: 0.75rem; color: var(--g3); text-align: center; }

/* ── QUEUE SCREEN ── */
#queue-screen { min-height: 100vh; justify-content: center; }

.queue-content {
  display: flex; flex-direction: column; align-items: center; gap: 24px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 48px 60px;
  box-shadow: 0 0 60px rgba(34,197,94,0.2);
  backdrop-filter: blur(10px);
}

.queue-title {
  font-size: 1.8rem; font-weight: 900; color: var(--y1);
  animation: titlePulse 1.5s ease-in-out infinite;
}

.queue-arena { display: flex; align-items: center; gap: 48px; }

.queue-side { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 160px; }

.queue-pokemon-img { width: 130px; height: 130px; object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(255,215,0,0.5)); }

.bounce { animation: pikaBounce 1s ease-in-out infinite; }

.queue-silhouette {
  width: 130px; height: 130px; border-radius: 50%;
  background: rgba(34,197,94,0.08); border: 2px dashed var(--g3);
  display: flex; align-items: center; justify-content: center;
  font-size: 4rem; color: var(--g3);
  animation: silhouettePulse 1.5s ease-in-out infinite;
}
@keyframes silhouettePulse {
  0%,100% { box-shadow: 0 0 8px rgba(34,197,94,0.2); }
  50%     { box-shadow: 0 0 24px rgba(34,197,94,0.5); }
}

.queue-player-name { font-weight: 800; color: var(--g2); font-size: 0.95rem; text-align: center; }

.queue-vs-col { display: flex; flex-direction: column; align-items: center; gap: 8px; }

.queue-vs {
  font-size: 3rem; font-weight: 900;
  color: var(--y1); text-shadow: 0 0 20px rgba(255,215,0,0.6);
  animation: vsPulse 0.8s ease-in-out infinite;
}
@keyframes vsPulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.1); }
}

#queue-status-text { color: var(--g3); font-size: 0.82rem; text-align: center; }

#queue-pos { color: var(--g2); font-size: 0.9rem; }

#match-found-banner {
  font-size: 2rem; font-weight: 900; color: var(--y1);
  text-shadow: 0 0 30px rgba(255,215,0,0.8);
  animation: titlePulse 0.5s ease-in-out infinite;
}

#queue-countdown {
  font-size: 5rem; font-weight: 900; color: var(--g1);
  text-shadow: 0 0 40px rgba(34,197,94,0.8);
}

/* ── GAME ── */
#game { padding: 10px; gap: 10px; align-items: flex-start; min-height: 100vh; justify-content: center; }

#topBar {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; max-width: 1020px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 24px;
  backdrop-filter: blur(8px);
  box-shadow: 0 0 20px rgba(34,197,94,0.1);
}

.player-panel { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.player-name { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 2px; }
.scarlet-text { color: var(--scarlet); }
.violet-text  { color: var(--violet); }

.timer {
  font-size: 1.9rem; font-family: 'Courier New', monospace;
  font-weight: 900; color: #2a4a2a; transition: color 0.3s;
}
.player-panel.active .timer {
  color: var(--y1);
  text-shadow: 0 0 14px rgba(255,215,0,0.6);
  animation: timerTick 1s ease-in-out infinite;
}
@keyframes timerTick { 0%,100%{opacity:1} 50%{opacity:0.7} }

#status-bar { text-align: center; }
#turn-display {
  font-size: 1rem; font-weight: 900; text-transform: uppercase; letter-spacing: 2px;
}
#turn-display.scarlet { color: var(--scarlet); }
#turn-display.violet  { color: var(--violet); }
#phase-display { font-size: 0.7rem; color: #3a5a3a; margin-top: 2px; }

#main-area { display: flex; gap: 14px; align-items: flex-start; max-width: 1020px; width: 100%; }

/* ── BOARD ── */
#board-wrap { flex-shrink: 0; position: relative; }

#board {
  display: grid;
  grid-template-columns: repeat(8, 88px);
  grid-template-rows: repeat(8, 88px);
  border: 2px solid rgba(34,197,94,0.4);
  border-radius: 6px; overflow: hidden;
  box-shadow: 0 0 40px rgba(34,197,94,0.12), 0 0 80px rgba(34,197,94,0.06);
}

.cell {
  width: 88px; height: 88px;
  cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center;
  transition: filter 0.12s;
}
.cell.light { background: #1a2e1a; }
.cell.dark  { background: #0f1e0f; }
.cell:hover { filter: brightness(1.3); }

/* Highlights */
.cell.sel { background: #5a4200 !important; box-shadow: inset 0 0 0 3px var(--y1); }

.cell.movable { background: #0d2e0d !important; }
.cell.movable::after {
  content: ''; position: absolute;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(34,197,94,0.55); pointer-events: none;
  box-shadow: 0 0 12px rgba(34,197,94,0.6);
}
.cell.movable:has(.piece)::after { display: none; }
.cell.movable:has(.piece) { box-shadow: inset 0 0 0 3px var(--g1); }

.cell.attackable { background: #2e0a0a !important; }
.cell.attackable::after {
  content: ''; position: absolute; inset: 3px;
  border: 2px solid var(--scarlet); border-radius: 6px;
  pointer-events: none; animation: atkPulse 0.8s ease-in-out infinite;
}
@keyframes atkPulse { 0%,100%{opacity:1;box-shadow:0 0 6px var(--scarlet)} 50%{opacity:0.4;box-shadow:0 0 14px var(--scarlet)} }

.cell.bike-tgt { background: #2e2200 !important; }
.cell.bike-tgt::after {
  content: ''; position: absolute; inset: 3px;
  border: 2px solid var(--y1); border-radius: 6px;
  pointer-events: none; animation: bikePulse 0.5s ease-in-out infinite;
}
@keyframes bikePulse { 0%,100%{box-shadow:0 0 8px var(--y1)} 50%{box-shadow:0 0 20px var(--y1)} }

.cell.spec-tgt { background: #1a0a2e !important; }
.cell.spec-tgt::after {
  content: ''; position: absolute; inset: 3px;
  border: 2px solid var(--violet); border-radius: 6px;
  pointer-events: none; animation: specPulse 0.7s ease-in-out infinite;
}
@keyframes specPulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── PIECE ANIMATIONS ── */
@keyframes arrive {
  from { transform: scale(0.7) translateY(-8px); opacity: 0.4; filter: brightness(2); }
  to   { transform: scale(1) translateY(0); opacity: 1; filter: brightness(1); }
}
@keyframes hurt {
  0%  { transform: translateX(0); filter: brightness(1); }
  15% { transform: translateX(-6px); filter: brightness(3) saturate(0) sepia(1) hue-rotate(-30deg); }
  35% { transform: translateX(6px); }
  55% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
  100%{ transform: translateX(0); filter: brightness(1); }
}
@keyframes attacking {
  0%  { transform: scale(1); }
  40% { transform: scale(1.2) rotate(-4deg); filter: brightness(1.8); }
  100%{ transform: scale(1); }
}
@keyframes promotionPop {
  0%  { transform: scale(1); filter: brightness(1); }
  30% { transform: scale(1.35); filter: brightness(3) sepia(1) hue-rotate(30deg) saturate(4); }
  60% { transform: scale(0.9); }
  100%{ transform: scale(1); filter: brightness(1); }
}
@keyframes stunAnim {
  0%,100%{ filter: brightness(1); }
  30%    { filter: brightness(3) sepia(1) hue-rotate(40deg); transform: scale(1.05); }
}
@keyframes bikeTransAnim {
  0%  { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.12); filter: brightness(3) saturate(4) hue-rotate(50deg); box-shadow:0 0 30px var(--y1); }
  100%{ transform: scale(1); filter: brightness(1); }
}
@keyframes bikeGlowPulse {
  0%,100%{ box-shadow: 0 0 10px var(--y1), 0 3px 10px rgba(0,0,0,0.7); }
  50%    { box-shadow: 0 0 26px var(--y1), 0 3px 10px rgba(0,0,0,0.7); }
}
@keyframes hpLowBlink { 0%,100%{opacity:1} 50%{opacity:0.5} }

.cell.anim-arrive .piece  { animation: arrive 0.32s cubic-bezier(0.2,0.8,0.3,1.1); }
.cell.anim-hurt .piece    { animation: hurt 0.36s ease; }
.cell.anim-attack .piece  { animation: attacking 0.3s ease; }
.cell.anim-promo .piece   { animation: promotionPop 0.55s ease; }
.cell.anim-stun .piece    { animation: stunAnim 0.45s ease; }
.cell.anim-bike .piece    { animation: bikeTransAnim 0.55s ease; }

/* ── PIECES ── */
.piece {
  width: 82px; height: 82px; border-radius: 8px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  padding-bottom: 5px; position: relative;
  box-shadow: 0 3px 10px rgba(0,0,0,0.8);
  overflow: hidden; pointer-events: none; user-select: none;
  transition: box-shadow 0.25s;
}

.piece.scarlet {
  background: linear-gradient(160deg, #1a080e, #320d1c);
  border: 1px solid var(--scarlet);
}
.piece.violet {
  background: linear-gradient(160deg, #080814, #10103a);
  border: 1px solid var(--violet);
}
.piece.bike-mode {
  border-color: var(--y1) !important;
  animation: bikeGlowPulse 1s ease-in-out infinite;
}
.piece.st-stunned { border-color: #faff00 !important; box-shadow: 0 0 12px rgba(250,255,0,0.5) !important; }
.piece.st-frozen  { border-color: #00d4ff !important; box-shadow: 0 0 12px rgba(0,212,255,0.5) !important; }

.piece img {
  position: absolute; top: -2px; left: 50%;
  transform: translateX(-50%);
  width: 68px; height: 68px; object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,0.9));
}
.plabel {
  font-size: 0.6rem; font-weight: 800; letter-spacing: 1px;
  color: #fff; position: absolute; top: 2px; left: 0; right: 0;
  text-align: center; opacity: 0;
}

.hpbar {
  width: 68px; height: 5px;
  background: rgba(0,0,0,0.6); border-radius: 3px; overflow: hidden;
  position: relative; z-index: 1; border: 1px solid rgba(255,255,255,0.08);
}
.hpfill {
  height: 100%; border-radius: 3px;
  background: var(--g1); transition: width 0.3s;
}
.hpfill.mid { background: var(--y2); }
.hpfill.low { background: #e63946; animation: hpLowBlink 1s ease-in-out infinite; }

.hptext {
  font-size: 0.5rem; color: rgba(255,255,255,0.6);
  font-family: monospace; line-height: 1; position: relative; z-index: 1;
}

.sticon  { position: absolute; top: 2px; right: 3px; font-size: 0.7rem; z-index: 2; }
.bikeicon { position: absolute; top: 2px; left: 3px; font-size: 0.7rem; z-index: 2; }

/* ── SIDEBAR ── */
#sidebar {
  flex: 1; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; display: flex; flex-direction: column;
  gap: 10px; max-width: 240px; min-height: 704px;
  backdrop-filter: blur(8px);
}

#sel-info {
  background: rgba(2,8,2,0.8); border-radius: 8px; padding: 12px;
  font-size: 0.82rem; min-height: 110px; border: 1px solid rgba(34,197,94,0.1);
}
.hint { color: #2a4a2a; font-size: 0.78rem; }
.pname { font-size: 1rem; font-weight: 800; margin-bottom: 6px; }
.pname.scarlet { color: var(--scarlet); }
.pname.violet  { color: var(--violet); }
.pstats { display: flex; gap: 10px; color: #4a7a4a; font-size: 0.78rem; margin-bottom: 4px; }
.pstats b { color: var(--g2); }
.pstatus {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 4px;
  display: inline-block; margin-top: 4px; margin-right: 4px;
}
.pstatus.stunned     { background: #1a1a00; color: #faff00; }
.pstatus.frozen      { background: #001a2a; color: #00d4ff; }
.pstatus.bike        { background: #1a1400; color: var(--y1); }
.pstatus.transforming{ background: #100e00; color: #ffaa00; }
.pcd { font-size: 0.7rem; color: #2a4a2a; margin-top: 4px; }

#actions { display: flex; flex-direction: column; gap: 6px; }

#special-btn { background: #100a20; color: #c084fc; border: 1px solid #6030b0; padding: 9px; font-size: 0.82rem; }
#bike-btn    { background: #1a1200; color: var(--y1); border: 1px solid var(--y2); padding: 9px; font-size: 0.82rem; }
#cancel-btn  { background: rgba(5,18,5,0.6); color: #2a4a2a; border: 1px solid rgba(34,197,94,0.15); padding: 9px; font-size: 0.82rem; }

.log-title {
  font-size: 0.65rem; color: #1a3a1a; text-transform: uppercase; letter-spacing: 1.5px;
  border-top: 1px solid rgba(34,197,94,0.12); padding-top: 10px;
}
#log {
  font-size: 0.68rem; color: #3a6a3a;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto; max-height: 280px;
}
#log div { padding: 3px 0; border-bottom: 1px solid rgba(34,197,94,0.06); line-height: 1.4; }

/* ── LEADERBOARD MODAL ── */
#lb-modal {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
.lb-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 36px 44px;
  max-width: 520px; width: 90%;
  box-shadow: 0 0 60px rgba(34,197,94,0.2);
  backdrop-filter: blur(10px);
  max-height: 80vh; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.lb-title {
  font-size: 1.5rem; font-weight: 900; color: var(--y1);
  text-shadow: 0 0 20px rgba(255,215,0,0.5);
}
#lb-list { width: 100%; display: flex; flex-direction: column; gap: 6px; }

.lb-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; border-radius: 8px;
  font-size: 0.85rem; border: 1px solid rgba(34,197,94,0.1);
  transition: background 0.2s;
}
.lb-row:hover { background: rgba(34,197,94,0.06); }
.lb-row.top1 { background: rgba(255,215,0,0.12); border-color: rgba(255,215,0,0.4); }
.lb-row.top2 { background: rgba(200,200,200,0.08); border-color: rgba(200,200,200,0.3); }
.lb-row.top3 { background: rgba(205,127,50,0.1); border-color: rgba(205,127,50,0.3); }
.lb-row.is-me { border-color: var(--g1); background: rgba(34,197,94,0.08); }

.lb-rank  { width: 28px; font-weight: 900; color: var(--g3); text-align: center; font-size: 1rem; }
.lb-name  { flex: 1; font-weight: 700; color: var(--g2); }
.lb-elo   { font-family: monospace; font-weight: 900; color: var(--y1); font-size: 1rem; }
.lb-record{ color: #3a5a3a; font-size: 0.72rem; }

/* ── GAME OVER ── */
#game-over { min-height: 100vh; justify-content: center; }

.gameover-box {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 64px 80px; text-align: center;
  display: flex; flex-direction: column; gap: 22px;
  box-shadow: 0 0 80px rgba(34,197,94,0.2);
  backdrop-filter: blur(12px);
  animation: gameOverPop 0.65s cubic-bezier(0.2,0.8,0.3,1.2);
}
@keyframes gameOverPop {
  from { transform: scale(0.65) rotate(-5deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

.winner-emoji { font-size: 5rem; animation: emojiSpin 0.8s cubic-bezier(0.2,0.8,0.3,1.4) 0.3s both; }
@keyframes emojiSpin {
  from { transform: scale(0) rotate(-180deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

#winner-text { font-size: 3rem; font-weight: 900; letter-spacing: 2px; }
#winner-text.scarlet { color: var(--scarlet); text-shadow: 0 0 40px rgba(230,57,70,0.5); }
#winner-text.violet  { color: var(--violet);  text-shadow: 0 0 40px rgba(155,141,255,0.5); }

.elo-change-box {
  font-size: 1rem; font-family: monospace;
  color: var(--y1); background: rgba(5,18,5,0.9);
  border: 1px solid rgba(255,215,0,0.3); border-radius: 10px;
  padding: 12px 24px;
}

/* ── SCREEN SHAKE ── */
@keyframes screenShake {
  0%,100%{ transform: translate(0,0) rotate(0); }
  20%    { transform: translate(-5px,2px) rotate(-0.5deg); }
  40%    { transform: translate(5px,-2px) rotate(0.5deg); }
  60%    { transform: translate(-3px,5px); }
  80%    { transform: translate(3px,-3px); }
}
.shake { animation: screenShake 0.35s ease; }
