:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-glow: #0d2035;
  --panel: rgba(8, 18, 34, 0.78);
  --panel-strong: rgba(10, 24, 44, 0.94);
  --line: rgba(164, 205, 255, 0.16);
  --text: #edf6ff;
  --muted: #91a9c6;
  --accent: #9be564;
  --danger: #ff6b6b;
  --neutral: #9dc6ff;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(91, 149, 255, 0.24), transparent 34%),
    radial-gradient(circle at right, rgba(155, 229, 100, 0.16), transparent 28%),
    linear-gradient(180deg, #0a1628 0%, #050b15 100%);
}

input,
button {
  border: 0;
  border-radius: 14px;
  font: inherit;
}

button {
  padding: 12px 16px;
  color: #041014;
  background: linear-gradient(135deg, #9be564, #6ddccf);
  font-weight: 700;
  cursor: pointer;
}

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

input {
  width: 100%;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

h1,
h2,
p {
  margin: 0;
}

.shell {
  min-height: 100vh;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

.top-note {
  margin-top: 8px;
  color: var(--muted);
}

h1 {
  font-size: clamp(2rem, 4vw, 3.1rem);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.board,
.card,
.status-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.board {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  min-height: 74vh;
}

.start-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, rgba(4, 9, 18, 0.3), rgba(4, 9, 18, 0.72));
  backdrop-filter: blur(6px);
}

.start-overlay.hidden {
  display: none;
}

.start-card {
  width: min(100%, 520px);
  padding: 26px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(7, 16, 30, 0.92);
  box-shadow: var(--shadow);
}

.start-card h2 {
  margin-bottom: 10px;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
}

#start-status {
  color: var(--muted);
  line-height: 1.5;
}

#game {
  width: 100%;
  height: 74vh;
  display: block;
  background:
    radial-gradient(circle at center, rgba(16, 34, 62, 0.5), rgba(5, 11, 21, 0.92)),
    linear-gradient(180deg, rgba(8, 17, 31, 0.92), rgba(4, 8, 16, 0.98));
  touch-action: none;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
}

.panel,
.controls,
.mobile-controls,
.joystick {
  pointer-events: auto;
}

.panel {
  width: min(520px, calc(100% - 24px));
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.stack-panel {
  display: grid;
  gap: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}

.name-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.mobile-controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.joystick-wrap {
  display: none;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.joystick {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(3, 8, 18, 0.45);
  box-shadow: inset 0 0 0 1px rgba(157, 198, 255, 0.06);
  touch-action: none;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin-left: -27px;
  margin-top: -27px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(155, 229, 100, 0.95), rgba(109, 220, 207, 0.9));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.controls {
  display: flex;
  justify-content: flex-end;
}

#boost-button {
  min-width: 132px;
  min-height: 56px;
  touch-action: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card,
.status-card {
  padding: 18px;
  border-radius: 24px;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  padding: 8px 12px;
  border-radius: 999px;
  color: #08121f;
  font-size: 0.82rem;
  font-weight: 700;
}

.online {
  background: var(--accent);
}

.offline {
  background: var(--danger);
}

.neutral {
  background: var(--neutral);
}

.leaderboard,
.progress-list,
.stack {
  margin-top: 14px;
}

.leaderboard,
.progress-list,
.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.entry small,
.card p,
#players-count,
.joystick-wrap small {
  color: var(--muted);
}

.entry strong {
  display: block;
}

.auth-grid {
  margin-bottom: 12px;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.start-actions {
  margin-top: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .board {
    min-height: 68vh;
  }

  #game {
    height: 68vh;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
  }

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

  .name-row,
  .button-row,
  .start-actions {
    grid-template-columns: 1fr;
    display: grid;
  }

  .controls {
    justify-content: stretch;
  }

  #boost-button {
    width: 100%;
  }
}

@media (pointer: coarse) {
  .shell {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .joystick-wrap {
    display: flex;
  }

  #boost-button {
    min-width: 112px;
    min-height: 112px;
    border-radius: 999px;
    padding: 0;
  }

  .mobile-controls {
    align-items: end;
  }

  .start-overlay {
    align-items: end;
    padding: 14px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .start-card {
    padding: 20px;
  }
}
