:root {
  --bg: #07111f;
  --bg-soft: #122238;
  --panel: rgba(6, 17, 31, 0.86);
  --line: rgba(148, 163, 184, 0.24);
  --text: #f8fafc;
  --muted: #a5b4c8;
  --accent: #3ddc97;
  --accent-2: #58b7ff;
  --accent-soft: rgba(61, 220, 151, 0.15);
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(24, 71, 114, 0.5), transparent 35%),
    linear-gradient(180deg, #0a1526 0%, #06101d 100%);
}

.page-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}

.grid.single {
  grid-template-columns: 1fr;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

.hero {
  padding: 28px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(88, 183, 255, 0.22), transparent 26%),
    radial-gradient(circle at left bottom, rgba(61, 220, 151, 0.12), transparent 30%),
    var(--panel);
}

.auth-shell {
  max-width: 760px;
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 16px;
}

.auth-hero,
.auth-page-card {
  padding: 28px;
}

.brand-block {
  display: grid;
  gap: 14px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.brand-puck {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, rgba(255,255,255,0.24), transparent 30%),
    linear-gradient(180deg, #162236 0%, #05080d 100%);
  border: 3px solid rgba(255,255,255,0.16);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.brand-subtitle {
  color: var(--muted);
  font-size: 14px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 680px;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 0.96;
}

.hero-copy {
  max-width: 620px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 16px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, 1fr));
  gap: 12px;
  min-width: 310px;
}

.status-strip div,
.score-pill {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.status-strip span,
.message.small {
  color: var(--muted);
}

.status-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
}

.auth-panel,
.lobby-panel,
.game-panel,
.leaderboard-panel {
  padding: 22px;
}

.lobby-panel {
  background:
    linear-gradient(180deg, rgba(88, 183, 255, 0.06), transparent 42%),
    var(--panel);
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid rgba(61, 220, 151, 0.3);
}

.stack {
  display: grid;
  gap: 12px;
}

.row {
  display: flex;
  gap: 10px;
}

input,
button {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
}

input {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid transparent;
}

input:focus {
  outline: none;
  border-color: rgba(61, 220, 151, 0.4);
}

button {
  cursor: pointer;
  background: linear-gradient(135deg, #46ffb0 0%, #13b868 100%);
  color: #03110b;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(19, 184, 104, 0.24);
}

button.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

button.compact {
  width: auto;
  min-width: 110px;
}

button.dangerish {
  border: 1px solid rgba(255, 107, 107, 0.32);
  color: #ffd5d5;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.message {
  min-height: 22px;
  color: var(--muted);
}

.game-panel {
  position: relative;
}

#gameCanvas {
  width: 100%;
  aspect-ratio: 12 / 7;
  display: block;
  border-radius: 20px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 0 49.6%, rgba(255, 88, 88, 0.7) 49.6% 50.4%, rgba(255, 255, 255, 0.07) 50.4% 100%),
    linear-gradient(180deg, #d9f2ff 0%, #c8e9ff 100%);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.scoreboard {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: end;
}

.score-pill {
  font-weight: 700;
}

.leaderboard-list {
  display: grid;
  gap: 10px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 60px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.leaderboard-place {
  font-weight: 800;
  color: var(--accent);
}

.leaderboard-name {
  font-weight: 700;
}

.leaderboard-rank {
  color: var(--accent-2);
  font-weight: 700;
}

.leaderboard-elo {
  color: var(--muted);
  font-weight: 700;
}

.touch-stick {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(7, 17, 31, 0.1);
  border: 2px solid rgba(7, 17, 31, 0.08);
  backdrop-filter: blur(8px);
  display: none;
  touch-action: none;
  z-index: 3;
}

.stick-knob {
  position: absolute;
  left: 26px;
  top: 26px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(7, 17, 31, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

@media (max-width: 640px) {
  .game-panel {
    padding-bottom: 120px;
  }

  .hero-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 900px) {
  .grid,
  .hero {
    grid-template-columns: 1fr;
    display: grid;
  }

  .hero {
    align-items: start;
  }

  .status-strip {
    min-width: 0;
  }
}

@media (hover: none) and (pointer: coarse) {
  .touch-stick {
    display: block;
  }
}

.text-link {
  color: var(--accent);
  text-decoration: none;
}
