:root {
  --ink: #0c1220;
  --paper: #e8f3ff;
  --ice: #b9d9f5;
  --accent: #ff3b5c;
  --accent-2: #1ad1a5;
  --panel: rgba(12, 18, 32, 0.82);
  --line: rgba(255, 255, 255, 0.14);
  --muted: #9eb3c9;
  --glow: rgba(26, 209, 165, 0.35);
  --font-display: "Bebas Neue", Impact, sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--paper);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1f4d7a 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #6b1f3a 0%, transparent 50%),
    linear-gradient(160deg, #071018 0%, #12263a 45%, #0a1624 100%);
  overflow-x: hidden;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.05;
  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");
  z-index: 0;
}

.top, main, footer { position: relative; z-index: 1; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand { display: flex; gap: 0.8rem; align-items: center; }
.brand-mark {
  width: 2.2rem; height: 2.2rem; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff, var(--accent));
  box-shadow: 0 0 24px var(--glow);
  color: transparent; font-size: 0.5rem;
}
.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: 0.06em;
  line-height: 1;
}
.brand-tag { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.82rem; }

.user-chip {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.45rem 0.7rem 0.45rem 0.9rem;
  border-radius: 999px;
}
.user-chip strong { font-size: 0.95rem; }

main { padding: 1.5rem 1.25rem 3rem; max-width: 1100px; margin: 0 auto; }

.arena-head h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
  margin: 0 0 0.45rem;
}
.lede { color: var(--muted); font-size: 1rem; max-width: 40rem; line-height: 1.5; margin: 0 0 0.4rem; }

.auth-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
  margin-top: 2.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
}
.auth-copy h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 0.04em;
  margin: 0 0 0.5rem;
}
.auth-copy p { margin: 0; color: var(--muted); line-height: 1.5; }

.auth-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: 1.25rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  animation: rise 0.7s ease both;
}
.top-actions .btn { text-decoration: none; display: inline-block; }
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.tab {
  flex: 1;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0.65rem;
  border-radius: 0.7rem;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.tab.active {
  color: var(--ink);
  background: linear-gradient(120deg, var(--accent-2), #7dffd4);
  border-color: transparent;
}

.auth-form { display: grid; gap: 0.75rem; }
.auth-form.hidden, .hidden { display: none !important; }
label {
  display: grid; gap: 0.35rem;
  font-size: 0.85rem; color: var(--muted);
}
input[type="text"], input[type="email"], input[type="password"], input:not([type]) {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--paper);
  border-radius: 0.65rem;
  padding: 0.75rem 0.85rem;
  font: inherit;
}
input:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.check {
  display: flex; align-items: center; gap: 0.55rem;
  grid-template-columns: none;
}
.check input { width: auto; }

.btn {
  border: none;
  border-radius: 0.75rem;
  padding: 0.8rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(120deg, var(--accent), #ff7a3d);
  color: white;
  box-shadow: 0 10px 30px rgba(255, 59, 92, 0.35);
}
.btn.ghost {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
}
.hint { margin: 0; color: var(--muted); font-size: 0.82rem; }
.hint code {
  background: rgba(255,255,255,0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 0.3rem;
}
.auth-msg {
  min-height: 1.2rem;
  margin: 0.8rem 0 0;
  color: var(--accent-2);
  font-size: 0.9rem;
}
.auth-msg.error { color: #ff8fa3; }

.arena { display: grid; gap: 0.9rem; animation: rise 0.5s ease both; }
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 1rem;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}
.scoreboard strong { font-size: 2.6rem; display: block; line-height: 1; }
.scoreboard .who { color: var(--muted); font-family: var(--font-body); font-size: 0.85rem; letter-spacing: 0; }
.scoreboard > div:last-child { text-align: right; }
.period {
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

#table {
  width: 100%;
  max-width: 900px;
  height: auto;
  margin: 0 auto;
  display: block;
  border-radius: 1rem;
  background: linear-gradient(180deg, #d7ebff, #9fc4e8);
  box-shadow:
    inset 0 0 0 6px #1a3350,
    0 20px 50px rgba(0,0,0,0.4);
  touch-action: none;
  cursor: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.controls-btns { display: flex; gap: 0.5rem; }
.toast {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.8rem;
  letter-spacing: 0.05em;
  color: var(--accent-2);
  text-shadow: 0 0 20px var(--glow);
  animation: pop 0.45s ease;
}
@keyframes pop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: none; opacity: 1; }
}

footer {
  padding: 1rem 1.4rem 2rem;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
  text-align: center;
}

@media (max-width: 820px) {
  .auth-section { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; }
}
