@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Inter:wght@400;600;700&display=swap');

/* ─── DESIGN TOKENS ─── */
:root {
  --bg-void:        #050810;
  --bg-deep:        #080d1c;
  --bg-panel:       #0c1428;
  --bg-card:        #101830;
  --bg-hover:       #162040;
  --board-dark:     #1e3a6e;
  --board-light:    #6b9fd4;
  --accent-gold:    #2979ff;
  --accent-gold2:   #1565e0;
  --accent-cyan:    #00d4ff;
  --accent-green:   #00ff88;
  --accent-red:     #ff3b6b;
  --accent-purple:  #a855f7;
  --text-primary:   #e8f0ff;
  --text-secondary: #6880b0;
  --text-dim:       #2a3560;
  --font-pixel:     'Press Start 2P', monospace;
  --font-ui:        'Inter', sans-serif;
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-pixel);
  background: var(--bg-void);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Gradient ambient background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(41,121,255,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 90%,  rgba(0,212,255,0.08)  0%, transparent 50%),
    radial-gradient(ellipse 50% 60% at 0%   60%, rgba(41,121,255,0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* CRT scanlines + vignette */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent        0px 5px,
      rgba(0,0,0,0.04)   5px 6px
    ),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.40) 100%);
  pointer-events: none;
  z-index: 500;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar       { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--accent-gold); border-radius: 0; animation: none; }

/* ─── SCREENS ─── */
.screen        { display: none; min-height: 100vh; position: relative; z-index: 1; flex-direction: column; }
.screen.active { display: flex; }

/* ─── HEADER ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: rgba(4,5,13,0.92);
  border-bottom: 2px solid rgba(41,121,255,0.22);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  font-size: 20px;
  filter: drop-shadow(0 0 8px rgba(41,121,255,0.8));
  animation: float 3s ease-in-out infinite;
  display: inline-block;
}

@keyframes float {
  0%, 100% { transform: translateY(0);    }
  50%       { transform: translateY(-4px); }
}

.logo-text {
  font-size: 12px;
  color: var(--accent-gold);
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 #001a66, 0 0 12px rgba(41,121,255,0.5);
}

.logo-sub {
  font-size: 6px;
  color: var(--accent-cyan);
  letter-spacing: 1px;
  display: block;
  margin-top: 3px;
  opacity: 0.8;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── BUTTONS ─── */
.btn {
  font-family: var(--font-pixel);
  font-size: 8px;
  padding: 10px 18px;
  cursor: pointer;
  border: none;
  letter-spacing: 1px;
  transition: transform 0.1s, box-shadow 0.1s;
  outline: none;
  position: relative;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Blue 8-bit primary button */
.btn-gold {
  background: linear-gradient(180deg, #4d9fff 0%, #2979ff 45%, #1a5fd4 100%);
  color: #ffffff;
  border: none;
  box-shadow: 4px 4px 0 #001a66, 0 0 20px rgba(41,121,255,0.3);
}
.btn-gold::before {
  content: '';
  position: absolute;
  top: 1px; left: 1px; right: 3px;
  height: 40%;
  background: rgba(255,255,255,0.18);
  pointer-events: none;
}
.btn-gold:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 #001a66, 0 0 28px rgba(41,121,255,0.45);
}
.btn-gold:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #001a66;
}

/* Outline secondary button */
.btn-outline {
  background: rgba(41,121,255,0.06);
  color: var(--accent-cyan);
  border: 2px solid var(--accent-cyan);
  box-shadow: 3px 3px 0 rgba(0,26,102,0.8);
}
.btn-outline:hover:not(:disabled) {
  background: rgba(0,212,255,0.12);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 rgba(0,26,102,0.8);
}
.btn-outline:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(0,26,102,0.8);
}

/* Ghost nav button */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.08);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.2);
}

/* Small danger button (Resign) */
.btn-danger-sm {
  background: rgba(255,59,107,0.10);
  color: var(--accent-red);
  border: 1px solid rgba(255,59,107,0.35);
  font-size: 7px;
  padding: 7px 12px;
  box-shadow: 2px 2px 0 rgba(180,0,50,0.5);
}
.btn-danger-sm:hover:not(:disabled) {
  background: rgba(255,59,107,0.20);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 rgba(180,0,50,0.5);
}

.btn-lg   { font-size: 10px; padding: 13px 28px; }
.btn-full { width: 100%; display: block; text-align: center; }

/* ─── WALLET PILL ─── */
.wallet-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--text-dim);
  font-size: 7px;
  color: var(--text-secondary);
}
.wallet-pill.connected {
  border-color: rgba(0,255,136,0.4);
  color: var(--accent-green);
  background: rgba(0,255,136,0.05);
}
.wallet-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.wallet-pill.connected .wallet-dot {
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
  animation: blink-dot 1.5s ease-in-out infinite;
}
.wallet-status { display: flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 7px; }

.balance-chip {
  font-size: 7px;
  color: var(--accent-cyan);
  background: rgba(0,212,255,0.08);
  border: 1px solid rgba(0,212,255,0.2);
  padding: 6px 10px;
}

/* ─── PIXEL BACKGROUND FLOATERS ─── */
.pixel-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.floater {
  position: absolute;
  font-size: 28px;
  opacity: 0.04;
  animation: float-drift 20s linear infinite;
  color: var(--accent-gold);
}
.f1 { top: 10%; left:  5%; animation-duration: 22s; animation-delay:  0s;  font-size: 24px; }
.f2 { top: 25%; left: 85%; animation-duration: 18s; animation-delay: -5s;  font-size: 32px; }
.f3 { top: 60%; left: 15%; animation-duration: 25s; animation-delay: -3s;  font-size: 20px; }
.f4 { top: 75%; left: 70%; animation-duration: 20s; animation-delay: -8s;  font-size: 28px; }
.f5 { top: 40%; left: 50%; animation-duration: 30s; animation-delay:-12s;  font-size: 36px; }
.f6 { top: 85%; left: 30%; animation-duration: 16s; animation-delay: -2s;  font-size: 22px; }
.f7 { top:  5%; left: 60%; animation-duration: 24s; animation-delay: -7s;  font-size: 26px; }
.f8 { top: 50%; left: 90%; animation-duration: 19s; animation-delay: -4s;  font-size: 30px; }
@keyframes float-drift {
  0%   { transform: translateY(0)     rotate(0deg);  }
  50%  { transform: translateY(-30px) rotate(10deg); }
  100% { transform: translateY(0)     rotate(0deg);  }
}

/* ─── HERO TWO-COLUMN LAYOUT ─── */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 32px;
  padding: 44px 40px 36px;
  align-items: center;
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.hero-left  { display: flex; flex-direction: column; }
.hero-right { display: flex; justify-content: center; align-items: center; }

/* Live eyebrow */
.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.dot-green {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green), 0 0 16px var(--accent-green);
  animation: blink-dot 1.5s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes blink-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
.hero-eyebrow span { font-size: 7px; color: var(--accent-green); letter-spacing: 2px; }

/* Title */
.hero-title {
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: 4px;
  line-height: 1;
  margin-bottom: 14px;
}
.title-pixel { color: var(--text-primary); text-shadow: 3px 3px 0 rgba(255,255,255,0.06); }
.title-chess { color: var(--accent-gold); text-shadow: 3px 3px 0 #001a66, 0 0 24px rgba(245,197,24,0.35); }

.hero-tagline {
  font-size: 11px;
  color: var(--text-primary);
  letter-spacing: 2px;
  line-height: 2;
  margin-bottom: 12px;
}
.hero-desc {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 20px;
}

/* Badges */
.hero-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.badge { font-family: var(--font-pixel); font-size: 6px; padding: 4px 10px; letter-spacing: 1px; }
.hero-badges .badge:nth-child(1) { background: rgba(245,197,24,0.10); color: var(--accent-gold);   border: 1px solid rgba(245,197,24,0.30); }
.hero-badges .badge:nth-child(2) { background: rgba(0,212,255,0.08);  color: var(--accent-cyan);   border: 1px solid rgba(0,212,255,0.25);  }
.hero-badges .badge:nth-child(3) { background: rgba(0,255,136,0.08);  color: var(--accent-green);  border: 1px solid rgba(0,255,136,0.25);  }
.hero-badges .badge:nth-child(4) { background: rgba(168,85,247,0.08); color: var(--accent-purple); border: 1px solid rgba(168,85,247,0.25); }

/* CTA row */
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }

/* Stats bar */
.hero-stats {
  display: flex;
  border: 1px solid rgba(245,197,24,0.12);
  background: rgba(0,0,0,0.3);
}
.hstat { flex: 1; padding: 12px 8px; text-align: center; }
.hstat:not(:last-child) { border-right: 1px solid rgba(245,197,24,0.10); }
.hstat-val {
  font-size: 11px;
  color: var(--accent-gold);
  text-shadow: 0 0 8px rgba(245,197,24,0.35);
  display: block;
  margin-bottom: 5px;
}
.hstat-lbl { font-size: 5px; color: var(--text-dim); letter-spacing: 1px; }
.hstat-div { display: none; }

/* ─── BOARD PREVIEW (landing page right column) ─── */
.board-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.board-preview-label {
  font-size: 6px;
  color: var(--text-secondary);
  letter-spacing: 2px;
  border: 1px solid rgba(255,255,255,0.06);
  padding: 5px 12px;
  background: rgba(0,0,0,0.3);
}
.board-preview {
  display: grid;
  grid-template-columns: repeat(8, 40px);
  grid-template-rows: repeat(8, 40px);
  width: 320px;
  height: 320px;
  border: 2px solid rgba(41,121,255,0.4);
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.8),
    0 0 30px rgba(41,121,255,0.15),
    0 24px 48px rgba(0,0,0,0.6);
}
.prev-sq {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.prev-light { background: var(--board-light); }
.prev-dark  { background: var(--board-dark); }
.prev-piece { font-size: 22px; user-select: none; line-height: 1; }
.bp { color: #0a0f1e; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }
.wp { color: #e8f0ff; text-shadow: 0 1px 3px rgba(0,0,0,0.9); }

.board-preview-footer {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 6px;
  color: var(--accent-cyan);
  letter-spacing: 1px;
}
.thinking-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: think 1s ease-in-out infinite;
}
.thinking-dot.d2 { animation-delay: 0.2s; }
.thinking-dot.d3 { animation-delay: 0.4s; }
@keyframes think {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%       { opacity: 1;   transform: scale(1.2); }
}

/* ─── HOW IT WORKS ─── */
.how-section {
  padding: 40px 40px 36px;
  background: rgba(0,0,0,0.2);
  border-top: 1px solid rgba(245,197,24,0.07);
  position: relative;
  z-index: 1;
}
.how-title {
  font-size: 12px;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: 3px;
  margin-bottom: 28px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}
.how-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  max-width: 900px;
  margin: 0 auto;
}
.how-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 20px 14px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.how-card:hover {
  border-color: rgba(245,197,24,0.2);
  background: rgba(245,197,24,0.03);
}
.how-num  { font-size: 8px; color: var(--text-dim); margin-bottom: 10px; letter-spacing: 1px; }
.how-icon { font-size: 24px; margin-bottom: 10px; display: block; }
.how-head { font-size: 7px; color: var(--accent-gold); letter-spacing: 1px; margin-bottom: 8px; line-height: 1.6; }
.how-desc { font-family: var(--font-ui); font-size: 12px; color: var(--text-secondary); line-height: 1.7; }

/* ─── FOOTER ─── */
.footer {
  background: rgba(4,5,13,0.8);
  border-top: 1px solid rgba(255,255,255,0.04);
  padding: 14px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-dim);
  flex-wrap: wrap;
  gap: 8px;
  position: relative;
  z-index: 1;
}
.footer a { color: rgba(245,197,24,0.5); text-decoration: none; transition: color 0.2s; }
.footer a:hover { color: var(--accent-gold); }
.footer-links { display: flex; gap: 20px; }

/* ─── LOBBY SCREEN ─── */
#screen-lobby { padding: 0; }

.lobby-content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 860px;
  margin: 40px auto;
  width: 100%;
  padding: 0 24px;
  gap: 20px;
}
.lobby-section {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 24px;
  position: relative;
}
.lobby-section::before {
  content: '';
  position: absolute;
  top: -1px; left: 12px; right: 12px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(245,197,24,0.25), transparent);
}
.section-title {
  font-size: 8px;
  color: var(--accent-cyan);
  letter-spacing: 2px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.wager-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 18px; }
.wager-btn {
  font-family: var(--font-pixel);
  font-size: 7px;
  padding: 12px 6px;
  background: rgba(255,255,255,0.02);
  color: var(--text-secondary);
  border: 2px solid rgba(255,255,255,0.06);
  cursor: pointer;
  text-align: center;
  line-height: 1.8;
  transition: all 0.15s;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}
.wager-btn:hover:not(.active) { border-color: rgba(245,197,24,0.3); color: var(--text-primary); }
.wager-btn.active {
  border-color: var(--accent-gold);
  background: rgba(245,197,24,0.08);
  color: var(--accent-gold);
  box-shadow: 2px 2px 0 #001a66, 0 0 12px rgba(245,197,24,0.1);
}
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 18px; }
.color-btn {
  font-family: var(--font-pixel);
  font-size: 7px;
  padding: 14px 6px;
  background: rgba(255,255,255,0.02);
  border: 2px solid rgba(255,255,255,0.06);
  cursor: pointer;
  text-align: center;
  color: var(--text-secondary);
  line-height: 1.8;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
  transition: all 0.15s;
}
.color-btn[data-color="w"].active {
  border-color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.06);
  color: #fff;
  box-shadow: 2px 2px 0 rgba(180,180,180,0.3);
}
.color-btn[data-color="b"].active {
  border-color: var(--accent-cyan);
  background: rgba(0,212,255,0.06);
  color: var(--accent-cyan);
  box-shadow: 2px 2px 0 rgba(0,100,150,0.5);
}
.level-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.level-btn {
  font-family: var(--font-pixel);
  font-size: 6px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.4);
}
.level-btn span { margin-left: auto; color: var(--text-dim); }
.level-btn:hover:not(.active) { border-color: rgba(168,85,247,0.25); color: var(--text-primary); }
.level-btn.active {
  border-color: var(--accent-purple);
  background: rgba(168,85,247,0.08);
  color: var(--accent-purple);
  box-shadow: 2px 2px 0 rgba(100,0,200,0.4);
}
.level-btn.active span { color: var(--accent-purple); }
.summary-box {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.05);
  padding: 14px;
  margin-bottom: 14px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 6px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.summary-row:last-child { border-bottom: none; }
.summary-row span:first-child { color: var(--text-secondary); }
.val     { color: var(--accent-gold); }
.val.win { color: var(--accent-green); }
#btn-play { animation: btn-glow 2.5s ease-in-out infinite; }
@keyframes btn-glow {
  0%, 100% { box-shadow: 4px 4px 0 #001a66, 0 0 16px rgba(245,197,24,0.2); }
  50%       { box-shadow: 4px 4px 0 #001a66, 0 0 32px rgba(245,197,24,0.45); }
}
.lobby-note {
  font-size: 5px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 8px;
  letter-spacing: 1px;
}

/* ─── GAME SCREEN ─── */
#screen-game { padding: 0; }
.game-layout {
  display: grid;
  grid-template-columns: 190px 1fr 190px;
  gap: 16px;
  flex: 1;
  max-width: 1080px;
  margin: 16px auto;
  width: 100%;
  padding: 0 16px;
  align-items: start;
}
.side-panel {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
.side-panel::before {
  content: '';
  position: absolute;
  top: -1px; left: 10px; right: 10px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,212,255,0.2), transparent);
}
.panel-title {
  font-size: 7px;
  color: var(--accent-cyan);
  letter-spacing: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.info-row { font-size: 6px; display: flex; justify-content: space-between; align-items: center; }
.info-label { font-family: var(--font-ui); font-size: 10px; color: var(--text-secondary); }
.info-value { color: var(--accent-gold); }
.win-color  { color: var(--accent-green); }
.ai-thinking { display: none; align-items: center; gap: 6px; font-size: 6px; color: var(--accent-cyan); }
.ai-thinking.visible { display: flex; }
.think-label { letter-spacing: 1px; }
.think-bar { flex: 1; height: 3px; background: rgba(255,255,255,0.05); overflow: hidden; }
.think-fill {
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
  width: 40%;
  animation: think-slide 1.2s ease-in-out infinite;
}
@keyframes think-slide {
  0%   { transform: translateX(-200%); }
  100% { transform: translateX(400%); }
}
.status-text {
  font-size: 7px;
  text-align: center;
  padding: 8px;
  letter-spacing: 1px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
}
.status-player   { color: var(--accent-green); }
.status-opponent { color: var(--accent-cyan); }
.status-check  { color: var(--accent-red); animation: blink 0.5s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.wager-display {
  text-align: center;
  padding: 10px;
  background: rgba(245,197,24,0.05);
  border: 1px solid rgba(245,197,24,0.18);
}
.wager-amount { font-size: 10px; color: var(--accent-gold); }
.wager-sub    { font-family: var(--font-ui); font-size: 10px; color: var(--text-secondary); margin-top: 3px; }
#move-history {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.move-row {
  display: grid;
  grid-template-columns: 22px 1fr 1fr;
  gap: 4px;
  padding: 4px 5px;
  font-size: 6px;
}
.move-row:nth-child(odd) { background: rgba(255,255,255,0.02); }
.move-num { color: var(--text-dim); }
.move-w   { color: var(--text-primary); }
.move-b   { color: var(--text-secondary); }
.balance-bar {
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--text-secondary);
  text-align: center;
  padding: 5px;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.balance-bar span { color: var(--accent-gold); }
.board-container { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.board-wrapper {
  overflow: hidden;
  box-shadow:
    0 0 0 3px rgba(245,197,24,0.35),
    0 0 50px rgba(245,197,24,0.12),
    0 24px 50px rgba(0,0,0,0.6);
}
#chessboard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(520px, 86vw);
  height: min(520px, 86vw);
  image-rendering: pixelated;
}
.square { display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer; }
.square.light { background: var(--board-light); }
.square.dark  { background: var(--board-dark); }
.square.selected  { background: rgba(0,212,255,0.55) !important; }
.square.last-move { background: rgba(41,121,255,0.40) !important; }
.square.in-check  { background: rgba(255,51,102,0.65) !important; animation: check-pulse 0.4s ease infinite alternate; }
@keyframes check-pulse {
  from { background: rgba(255,51,102,0.40); }
  to   { background: rgba(255,51,102,0.85); }
}
.move-dot {
  width: 30%; height: 30%;
  border-radius: 50%;
  background: rgba(0,0,0,0.28);
  position: absolute; z-index: 2;
  pointer-events: none;
}
.capture-ring {
  position: absolute; inset: 3px;
  border-radius: 50%;
  border: 4px solid rgba(0,0,0,0.3);
  z-index: 2;
  pointer-events: none;
}
.piece {
  font-size: clamp(24px, 5.2vw, 44px);
  position: relative; z-index: 3;
  cursor: grab; user-select: none;
  line-height: 1;
  transition: transform 0.1s;
  image-rendering: pixelated;
}
.piece:active { cursor: grabbing; transform: scale(1.15); }
.piece:hover  { transform: scale(1.08); }
.piece-white {
  color: #fffde7;
  text-shadow: 1px 1px 0 #997700, -1px -1px 0 #cc9900;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}
.piece-black {
  color: #111;
  text-shadow: 1px 1px 0 #000;
  filter: drop-shadow(0 0 5px rgba(0,212,255,0.12));
}

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.82);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(6px);
}
.modal-overlay.active,
.modal.active { display: flex; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--bg-panel);
  border: 2px solid rgba(245,197,24,0.3);
  padding: 44px 36px;
  text-align: center;
  max-width: 420px; width: 90%;
  box-shadow: 4px 4px 0 #001a66, 0 0 50px rgba(245,197,24,0.12), 0 40px 80px rgba(0,0,0,0.5);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-win  .modal-box { border-color: rgba(0,255,136,0.35); box-shadow: 4px 4px 0 rgba(0,100,50,0.8),  0 0 50px rgba(0,255,136,0.10), 0 40px 80px rgba(0,0,0,0.5); }
.modal-lose .modal-box { border-color: rgba(255,59,107,0.35); box-shadow: 4px 4px 0 rgba(150,0,40,0.8), 0 0 50px rgba(255,59,107,0.10), 0 40px 80px rgba(0,0,0,0.5); }
.modal-icon  { font-size: 48px; margin-bottom: 18px; animation: float 2s ease-in-out infinite; }
.modal-title { font-size: 14px; color: var(--accent-gold); margin-bottom: 12px; line-height: 1.6; }
.modal-win  .modal-title { color: var(--accent-green); }
.modal-lose .modal-title { color: var(--accent-red); }
.modal-sub  { font-family: var(--font-ui); font-size: 14px; color: var(--text-secondary); margin-bottom: 28px; line-height: 1.6; }
.modal-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ─── TOAST ─── */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--bg-panel);
  border: 1px solid rgba(245,197,24,0.3);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 12px 24px;
  z-index: 9000;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
  box-shadow: 3px 3px 0 #001a66, 0 8px 24px rgba(0,0,0,0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  /* Header */
  .header         { padding: 10px 16px; }
  .logo-text      { font-size: 8px; }
  .logo-sub       { display: none; }
  .header-right   { gap: 8px; }
  .btn-ghost      { font-size: 6px; padding: 6px 8px; }
  .btn-outline    { font-size: 7px; padding: 8px 12px; }

  /* Hero */
  .hero           { grid-template-columns: 1fr; padding: 24px 16px; gap: 24px; }
  .hero-right     { display: none; }
  .hero-title     { font-size: 28px; }
  .hero-tagline   { font-size: 11px; }
  .hero-badges    { gap: 6px; }
  .badge          { font-size: 6px; padding: 4px 8px; }
  .hero-stats     { flex-wrap: wrap; gap: 8px; }
  .hstat          { min-width: 45%; }
  .hstat-div      { display: none; }

  /* How it works */
  .how-grid       { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .how-section    { padding: 40px 16px; }

  /* Lobby */
  .lobby-wrap     { padding: 0 16px; margin: 20px auto; }
  .lobby-tab-btn  { font-size: 7px; padding: 12px 6px; }
  .fm-layout      { grid-template-columns: 1fr; }
  .fm-right       { min-height: 160px; padding: 24px 16px; }
  .summary-box    { font-size: 7px; }

  /* Game */
  .game-layout    { grid-template-columns: 1fr; }
  .side-panel     { display: none; }
  .side-panel:first-child { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
  #chessboard     { width: 100% !important; }

  /* Waiting screen */
  .waiting-box    { padding: 24px 16px; margin: 16px; }
  .waiting-link-row { flex-direction: column; gap: 8px; }
  .waiting-link-input { width: 100%; }
}

@media (max-width: 480px) {
  .hero-title     { font-size: 22px; }
  .how-grid       { grid-template-columns: 1fr; }
  .wager-grid     { grid-template-columns: repeat(2, 1fr); }
  .hstat          { min-width: 40%; }
  .logo-text      { font-size: 7px; }
  .game-card      { grid-template-columns: 1fr auto; grid-template-rows: auto auto; }
  .gc-time        { display: none; }
}

/* ─── LOBBY WRAP ─── */
.lobby-wrap {
  max-width: 1000px;
  width: 100%;
  margin: 32px auto;
  padding: 0 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ─── LOBBY TABS ─── */
.lobby-tabs {
  display: flex;
  gap: 0;
  margin: 0 0 24px;
  border: 1px solid rgba(41,121,255,0.25);
  border-radius: 4px;
  overflow: hidden;
}
.lobby-tab-btn {
  flex: 1;
  font-family: var(--font-pixel);
  font-size: 9px;
  padding: 14px 10px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.lobby-tab-btn.active {
  background: rgba(41,121,255,0.18);
  color: var(--accent-gold);
}
.lobby-tab-btn:hover:not(.active) {
  background: rgba(41,121,255,0.08);
  color: var(--text-primary);
}

/* ─── LOBBY TAB CONTENT ─── */
.lobby-tab-content { padding-top: 24px; width: 100%; }

/* ─── FIND MATCH LAYOUT ─── */
.fm-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  align-items: stretch;
}
.fm-left  { display: flex; flex-direction: column; gap: 16px; }
.fm-right {
  background: var(--bg-card);
  border: 1px solid rgba(41,121,255,0.15);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
}
.fm-state { text-align: center; width: 100%; }

.fm-idle-icon  { font-size: 48px; margin-bottom: 16px; }
.fm-idle-title {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--accent-gold);
  margin-bottom: 12px;
  letter-spacing: 1px;
}
.fm-idle-desc {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.fm-search-icon { font-size: 24px; display: flex; justify-content: center; gap: 8px; margin-bottom: 20px; }
.fm-search-title {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--accent-cyan);
  margin-bottom: 12px;
  letter-spacing: 1px;
  animation: blink-dot 1s ease-in-out infinite;
}
.fm-search-desc { font-family: var(--font-ui); font-size: 13px; color: var(--text-secondary); }

.fm-wait-icon  { font-size: 40px; margin-bottom: 16px; animation: float 2s ease-in-out infinite; }
.fm-wait-title {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--accent-green);
  margin-bottom: 12px;
  letter-spacing: 1px;
}
.fm-wait-desc  { font-family: var(--font-ui); font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.fm-wager-highlight { color: var(--accent-cyan); font-weight: 700; }
.fm-wait-dots  { display: flex; justify-content: center; gap: 6px; margin: 12px 0; }
.fm-wait-note  { font-family: var(--font-ui); font-size: 11px; color: var(--text-dim); }

/* ─── BROWSE LOBBY ─── */
.browse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  width: 100%;
}
.open-games-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  min-height: 400px;
}
.games-empty, .games-loading {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  padding: 100px 24px;
  border: 1px dashed rgba(41,121,255,0.2);
  border-radius: 4px;
  line-height: 1.8;
  width: 100%;
}

/* ─── GAME CARD ─── */
.game-card {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid rgba(41,121,255,0.15);
  border-radius: 4px;
  transition: border-color 0.2s, background 0.2s;
  width: 100%;
}
.game-card:hover { border-color: rgba(41,121,255,0.4); background: var(--bg-hover); }

.gc-player { display: flex; align-items: center; gap: 8px; }
.gc-icon   { font-size: 18px; color: var(--text-secondary); }
.gc-addr   { font-family: var(--font-pixel); font-size: 7px; color: var(--text-secondary); }

.gc-wager  { text-align: right; }
.gc-eth    { display: block; font-family: var(--font-pixel); font-size: 9px; color: var(--accent-gold); }
.gc-win    { display: block; font-family: var(--font-ui); font-size: 11px; color: var(--accent-green); margin-top: 2px; }

.gc-time   { font-family: var(--font-ui); font-size: 11px; color: var(--text-dim); min-width: 60px; text-align: center; }
.gc-join-btn { font-size: 8px; padding: 8px 14px; white-space: nowrap; }

@media (max-width: 768px) {
  .fm-layout { grid-template-columns: 1fr; }
  .fm-right  { min-height: 200px; }
  .game-card { grid-template-columns: 1fr auto; grid-template-rows: auto auto; }
  .gc-time   { display: none; }
}

/* ─── JOIN INPUT ─── */
.join-input-wrap { margin-bottom: 14px; }
.join-label {
  display: block;
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.join-input {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 12px;
  background: var(--bg-deep);
  color: var(--text-primary);
  border: 1px solid rgba(41,121,255,0.3);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
}
.join-input:focus { border-color: var(--accent-gold); }
.join-input::placeholder { color: var(--text-dim); }

/* ─── PVP INFO CARD ─── */
.pvp-info-card {
  background: var(--bg-card);
  border: 1px solid rgba(41,121,255,0.2);
  padding: 20px;
  margin-bottom: 20px;
  text-align: center;
}
.pvp-info-icon  { font-size: 32px; margin-bottom: 10px; }
.pvp-info-title {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--accent-gold);
  margin-bottom: 10px;
  letter-spacing: 1px;
}
.pvp-info-desc {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ─── PVP FLOW STEPS ─── */
.pvp-flow { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.pvp-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px 10px;
  background: rgba(41,121,255,0.04);
  border-left: 2px solid rgba(41,121,255,0.3);
}
.pvp-num {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--accent-gold);
  min-width: 16px;
}
.pvp-timeout-note {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  padding: 8px;
}

/* ─── WAITING SCREEN ─── */
#screen-waiting { align-items: stretch; }
.waiting-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.waiting-box {
  background: var(--bg-panel);
  border: 2px solid rgba(41,121,255,0.3);
  padding: 40px 36px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 4px 4px 0 #001a66, 0 0 40px rgba(41,121,255,0.12);
}
.waiting-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: float 2s ease-in-out infinite;
}
.waiting-title {
  font-size: 14px;
  color: var(--accent-gold);
  margin-bottom: 16px;
  letter-spacing: 1px;
  line-height: 1.6;
}
.waiting-wager-row {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  letter-spacing: 1px;
}
.waiting-wager-val { color: var(--accent-cyan); }
.waiting-desc {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.waiting-link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.waiting-link-input {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 11px;
  background: var(--bg-deep);
  color: var(--text-secondary);
  border: 1px solid rgba(41,121,255,0.25);
  padding: 9px 12px;
  outline: none;
  min-width: 0;
}
.waiting-pulse {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 20px;
}
.waiting-note {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.6;
}
