:root {
  --bg: #0b1020;
  --panel: #151d34;
  --line: #273453;
  --text: #e8eefc;
  --muted: #95a3c4;
  --red: #ff6b6b;
  --blue: #4dd0e1;
  --accent: #ffd166;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1000px 600px at 50% -10%, #1d2a4d 0%, var(--bg) 70%);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 18px 16px 40px; }

.topbar, .scoreboard, .controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar { margin-bottom: 14px; }

.brand { font-weight: 800; letter-spacing: 2px; font-size: 18px; }
.brand em {
  color: var(--accent); font-style: normal;
  animation: title-glow 2.4s ease-in-out infinite;
}
.brand .dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); margin-right: 8px; box-shadow: 0 0 14px var(--accent);
  animation: neon-pulse 1.3s ease-in-out infinite;
}

.status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.status strong { color: var(--text); letter-spacing: 2px; }
#conn.ok { color: #5ee6a8; }
#conn.bad { color: var(--red); }
.divider { opacity: .3; }

.scoreboard { margin-bottom: 12px; }
.card {
  flex: 0 0 190px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 10px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: 10px;
}
.card.blue { border-top-color: var(--blue); }
.card .who { grid-column: 1 / -1; font-size: 10px; letter-spacing: 2px; color: var(--muted); }
.card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .score { font-size: 26px; font-weight: 800; line-height: 1; }
.card.red .score { color: var(--red); }
.card.blue .score { color: var(--blue); }

.middle { text-align: center; flex: 1; min-width: 0; }
.turn { display: block; font-weight: 700; font-size: 17px; }
.turn.active { color: var(--accent); }
.message { display: block; color: var(--muted); font-size: 13px; }

.arena-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #101a33;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  animation: arena-aura 4s ease-in-out infinite;
}
canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }

.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 13, 28, .78);
  backdrop-filter: blur(3px);
}
.overlay.login { position: fixed; z-index: 10; background: rgba(8, 13, 28, .94); }
.panel {
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 28px;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.panel.big { max-width: 440px; }
.panel h1 { margin: 0 0 6px; font-size: 34px; letter-spacing: 1px; }
.panel h1::first-letter { color: var(--accent); }
.panel h2 { margin: 8px 0; }
.panel p { color: var(--muted); margin: 8px 0 16px; }
.panel strong { color: var(--text); }
.panel .lead { text-align: left; }
.panel label { display: block; text-align: left; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.panel .small { font-size: 12px; margin: 14px 0 0; }

input {
  width: 100%; padding: 11px 13px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #0e1529; color: var(--text); font: inherit;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button { font: inherit; cursor: pointer; }
.primary {
  width: 100%; padding: 11px 18px; border: 0; border-radius: 8px;
  background: var(--accent); color: #1a1300; font-weight: 700;
}
.primary:hover { filter: brightness(1.08); }
.mini {
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 12px;
}
.mini:hover { color: var(--text); border-color: var(--accent); }
.mini.active { color: var(--accent); border-color: rgba(255,209,102,.55); }

.error { color: var(--red) !important; }
.spinner {
  width: 34px; height: 34px; margin: 0 auto;
  border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.controls { margin-top: 14px; flex-wrap: wrap; }
.keys { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 12px; }
kbd {
  display: inline-block; min-width: 20px; padding: 1px 5px; margin-right: 3px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  background: var(--panel); color: var(--text); font: 11px/1.6 monospace; text-align: center;
}
.hint { text-align: center; color: var(--accent); font-size: 13px; margin-top: 8px; }

@keyframes neon-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 10px var(--accent); }
  50% { transform: scale(1.35); box-shadow: 0 0 26px var(--accent), 0 0 44px var(--blue); }
}
@keyframes title-glow {
  0%, 100% { text-shadow: 0 0 4px rgba(255,209,102,.4); opacity: .85; }
  50% { text-shadow: 0 0 18px var(--accent), 0 0 34px rgba(255,107,107,.6); opacity: 1; }
}
@keyframes arena-aura {
  0%, 100% { box-shadow: 0 18px 50px rgba(0,0,0,.35), 0 0 18px rgba(77,208,225,.18); }
  50% { box-shadow: 0 18px 50px rgba(0,0,0,.35), 0 0 42px rgba(255,209,102,.32); }
}

@media (max-width: 680px) {
  .scoreboard { flex-wrap: wrap; }
  .card { flex: 1 1 40%; }
  .middle { flex: 1 1 100%; order: 3; }
  .brand { font-size: 15px; }
  .status { gap: 6px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .brand em, .brand .dot, .arena-wrap { animation: none; }
}
