/* Overclock Worlds — base styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --bg2:       #161b27;
  --bg3:       #1d2333;
  --border:    rgba(255,255,255,.08);
  --accent:    #ef4444;
  --accent2:   #dc2626;
  --green:     #34d399;
  --yellow:    #fbbf24;
  --red:       #f87171;
  --text:      #e4e5e9;
  --text-dim:  #6b7280;
  --text-mid:  #9ca3af;
  --radius:    12px;
  --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;
  --blue:      #3b82f6;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  padding: .65rem 1.5rem;
  transition: opacity .15s, transform .1s;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent2);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent); }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg2); }

.btn-danger {
  background: var(--red);
  color: #fff;
}

input[type="text"], input[type="number"], input[type="password"] {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: .6rem 1rem;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input:focus { border-color: var(--accent); }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

/* ── Layout helpers ──────────────────────────── */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.flex  { display: flex; }
.wrap  { flex-wrap: wrap; }

/* ── Logo / header ───────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 2rem;
}
.site-header .logo-badge {
  width: 44px; height: 44px;
  background: rgba(239,68,68,.15);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.site-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.site-header .sub {
  font-size: .8rem;
  color: var(--text-dim);
}

/* ── QR section ──────────────────────────────── */
.qr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  max-width: 600px;
  width: 100%;
}
.qr-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.qr-card canvas, .qr-card img { margin: 0 auto .75rem; display: block; }
.qr-card .platform {
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: .25rem;
}
.qr-card .handle {
  font-size: .75rem;
  color: var(--text-dim);
  word-break: break-all;
}
.qr-card .ig-color  { color: #e1306c; }
.qr-card .yt-color  { color: #ff0000; }

/* ── Verify overlay ──────────────────────────── */
#verify-overlay {
  position: fixed; inset: 0;
  background: rgba(15,17,23,.95);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
  padding: 2rem;
}
#verify-overlay h2 { font-size: 2rem; color: var(--accent); }
#verify-overlay p  { color: var(--text-mid); font-size: 1.1rem; }
.pulse {
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ── Mode select ─────────────────────────────── */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: 500px;
  width: 100%;
  margin-top: 1.5rem;
}
.mode-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, transform .1s;
  text-decoration: none;
  color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
}
.mode-card:hover { border-color: var(--accent); color: var(--text); }
.mode-card:active { transform: scale(.97); }
.mode-card .icon { font-size: 2.5rem; }
.mode-card .title { font-weight: 700; font-size: 1.1rem; }
.mode-card .desc  { font-size: .8rem; color: var(--text-dim); }

/* ── Typing engine ───────────────────────────── */
.typing-area {
  max-width: 760px;
  width: 100%;
}

.stats-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
  align-items: baseline;
}
.stat-box { text-align: center; }
.stat-box .val {
  font-size: 2.2rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--accent);
  line-height: 1;
}
.stat-box.timer .val { color: var(--yellow); }
.stat-box .lbl {
  font-size: .7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.prompt-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 1.2rem;
  line-height: 2;
  user-select: none;
  position: relative;
  min-height: 120px;
}
.prompt-wrap .char { position: relative; }
.char.correct   { color: var(--green); }
.char.incorrect { color: var(--red); background: rgba(248,113,113,.12); border-radius: 2px; }
.char.cursor {
  border-left: 2px solid var(--accent);
  margin-left: -1px;
  animation: blink .8s step-end infinite;
}
@keyframes blink { 50% { border-color: transparent; } }

.typing-input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  left: 0; top: 0;
}

/* sub-stats shared between play result and VS result */
.sub-stats {
  display: flex; gap: 1.5rem; justify-content: center; margin: .75rem 0 1.5rem;
  color: var(--text-mid);
}

.countdown-overlay {
  position: absolute; inset: 0;
  background: rgba(15,17,23,.9);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 5rem;
  font-weight: 900;
  color: var(--accent);
  z-index: 10;
}

/* ── Result card ─────────────────────────────── */
.result-card {
  max-width: 440px;
  width: 100%;
  text-align: center;
}
.result-card .big-wpm {
  font-size: 5rem;
  font-weight: 900;
  color: var(--accent);
  font-family: var(--font-mono);
  line-height: 1;
  margin: .5rem 0;
}
.result-card .sub-stats {
  display: flex; gap: 1.5rem; justify-content: center; margin: .75rem 0 1.5rem;
  color: var(--text-mid);
}
.result-card .rank-badge {
  background: rgba(239,68,68,.15);
  border: 1px solid var(--accent2);
  border-radius: 999px;
  padding: .3rem 1rem;
  font-size: .85rem;
  color: var(--accent);
  display: inline-block;
  margin-bottom: 1.25rem;
}

/* ── Leaderboard ─────────────────────────────── */
.lb-table {
  width: 100%;
  max-width: 640px;
  border-collapse: collapse;
}
.lb-table th {
  text-align: left;
  color: var(--text-dim);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .5rem 1rem .5rem 0;
  border-bottom: 1px solid var(--border);
}
.lb-table td {
  padding: .65rem 1rem .65rem 0;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.lb-table tr:last-child td { border-bottom: none; }
.lb-rank { color: var(--text-dim); font-family: var(--font-mono); width: 2rem; }
.lb-rank.gold   { color: #fbbf24; }
.lb-rank.silver { color: #d1d5db; }
.lb-rank.bronze { color: #cd7f32; }
.lb-handle { font-weight: 600; }
.lb-wpm   { font-family: var(--font-mono); font-size: 1.1rem; color: var(--accent); text-align: right; }
.lb-acc   { color: var(--text-dim); font-size: .85rem; text-align: right; }

/* Winner banners */
.winner-banner {
  width: 100%;
  max-width: 640px;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.winner-banner.random-draw {
  background: rgba(251,191,36,.07);
  border: 1px solid rgba(251,191,36,.3);
}
.winner-banner.highscore {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.3);
}
.winner-banner .trophy { font-size: 1.5rem; }
.winner-banner .wlabel { font-size: .75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.winner-banner .wname  { font-size: 1.1rem; font-weight: 700; }
.winner-banner.not-drawn .wname { color: var(--text-dim); font-weight: 400; font-style: italic; }

/* ── VS race ─────────────────────────────────── */
.vs-container {
  max-width: 780px;
  width: 100%;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: .75rem;
}
.player-row .pname {
  width: 130px;
  font-weight: 700;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-row .pname.you { color: var(--accent); }
.progress-bar-wrap {
  flex: 1;
  background: var(--bg3);
  border-radius: 999px;
  height: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-bar {
  height: 100%;
  border-radius: 999px;
  transition: width .4s ease;
  min-width: 4px;
}
.progress-bar.you { background: var(--accent2); }
.progress-bar.opp { background: var(--red); }
.player-row .pwpm {
  width: 70px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-mid);
}

/* VS lobby */
.room-code {
  font-size: 4rem;
  font-weight: 900;
  font-family: var(--font-mono);
  letter-spacing: .3em;
  color: var(--accent);
  text-align: center;
}

/* ── Admin panel ─────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .5rem;
}
.admin-tab {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: .9rem;
  padding: .4rem .9rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}
.admin-tab:hover  { background: var(--bg3); color: var(--text); }
.admin-tab.active { background: var(--bg3); color: var(--accent); }

.player-verify-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.player-verify-row:last-child { border-bottom: none; }

/* ── Admin live card grid ────────────────────── */
#live-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.live-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem;
  transition: opacity .3s;
}
.live-card-stale { opacity: .55; }
.live-card-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
  font-size: .82rem;
}
.live-game-badge {
  background: rgba(239,68,68,.12);
  color: var(--red);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.live-ago {
  color: var(--text-dim);
  font-size: .72rem;
  margin-left: auto;
  white-space: nowrap;
}
.live-card-body { font-size: .82rem; }
.live-tetris-canvas { display: block; border-radius: 4px; }
.live-big-nums {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: .4rem;
  font-size: 1.3rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text);
}
.live-big-nums small { font-size: .65rem; font-weight: 600; color: var(--text-dim); margin-left: 2px; }
.live-stat-row {
  color: var(--text-dim);
  font-size: .78rem;
  display: flex;
  gap: .8rem;
  margin-top: .3rem;
}
.live-stat-row b { color: var(--text); }
.live-prog-wrap {
  background: rgba(255,255,255,.08);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin: .25rem 0;
}
.live-prog-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width .4s;
}
.live-prog-label { font-size: .72rem; color: var(--text-dim); }
.live-tug-track {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: .4rem 0;
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-dim);
}
.live-tug-rope-wrap {
  flex: 1;
  position: relative;
  height: 12px;
  background: rgba(255,255,255,.08);
  border-radius: 6px;
}
.live-tug-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  transition: left .3s;
}
.live-lives { color: var(--red); letter-spacing: .1em; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 520px) {
  .qr-grid    { grid-template-columns: 1fr; }
  .mode-grid  { grid-template-columns: 1fr; }
  .stats-row  { gap: .75rem; }
  .stat-box .val { font-size: 1.6rem; }
  .prompt-wrap { font-size: 1rem; }
  .result-card .big-wpm { font-size: 3.5rem; }
}

/* ── Fullscreen watermark (used on game pages) ── */
.page-watermark {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(5rem, 18vw, 14rem);
  font-weight: 900; letter-spacing: -.04em;
  pointer-events: none; z-index: 0;
  user-select: none; white-space: nowrap;
  opacity: .12;
}
