/* main.css
   global layout + the menu, lobby, leaderboard, result screens.
   game screen has its own file. reveal grid has its own file.
   try to keep it in that order or it gets messy fast. */

/* ---------- base ---------- */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* subtle radial tint behind everything. cheap depth. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 400px at 95% 5%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 60%);
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* ---------- header ---------- */
.hdr {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 17px;
}

.brand-logo {
  width: 22px;
  height: 22px;
}

.brand-name {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: 12px;
}

.navlink {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--fg-dim);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}

.navlink:hover {
  color: var(--fg);
  background: var(--bg-soft);
}

.hdr-r {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.rank-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-soft);
}

.rank-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rank-bronze);
  box-shadow: 0 0 8px currentColor;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 15px;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: var(--bg-soft);
}

/* ---------- screens ---------- */
.screen {
  display: none;
  padding-top: 40px;
  animation: fadeUp 0.28s ease;
}

.screen.is-active {
  display: block;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.screen-sub {
  color: var(--fg-dim);
  font-size: 15px;
  margin-bottom: 28px;
}

/* ---------- buttons ---------- */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: #0a0b10;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  transition: transform 0.12s, box-shadow 0.2s, filter 0.15s;
}

.primary-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: var(--shadow-glow);
}

.primary-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.primary-btn:disabled {
  opacity: 0.4;
  filter: grayscale(0.4);
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-dim);
  border: 1px solid var(--border);
  background: transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.ghost-btn:hover {
  color: var(--fg);
  border-color: var(--fg-faint);
  background: var(--bg-soft);
}

/* ---------- menu: hero ---------- */
.hero {
  text-align: center;
  margin-bottom: 44px;
}

.hero-title {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 14px;
}

.accent {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  color: var(--fg-dim);
  font-size: 16px;
  max-width: 520px;
  margin: 0 auto;
}

/* ---------- menu: mode grid ---------- */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 44px;
}

.mode-card {
  text-align: left;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
}

.mode-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(200px 120px at 100% 0%, var(--accent-soft), transparent 70%);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.mode-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.mode-card:hover::after {
  opacity: 1;
}

.mode-icon {
  display: block;
  font-size: 24px;
  margin-bottom: 12px;
  filter: saturate(0.9);
}

.mode-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.mode-card p {
  font-size: 13px;
  color: var(--fg-dim);
  line-height: 1.45;
}

/* ---------- menu: quick stats ---------- */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat-box {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
  font-weight: 600;
}

.val {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.val small {
  font-size: 12px;
  color: var(--fg-dim);
  font-weight: 500;
}

/* ---------- lobby ---------- */
.lobby-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.lobby-card {
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lobby-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  font-size: 12px;
  color: var(--fg-dim);
  font-weight: 500;
}

.field input,
.field select {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 14px;
  color: var(--fg);
  transition: border-color 0.15s, background 0.15s;
}

.field input::placeholder {
  color: var(--fg-faint);
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  background: var(--bg-elev);
}

/* the 4-char room code */
.code-input {
  text-transform: uppercase;
  letter-spacing: 0.4em;
  text-align: center;
  font-family: var(--mono);
  font-weight: 600;
}

/* ---------- lobby: room panel ---------- */
.room-panel {
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.room-code-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--fg-dim);
}

.room-code-row strong {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 0.3em;
  color: var(--accent);
  font-weight: 700;
}

.room-code-row button {
  margin-left: auto;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  font-size: 14px;
}

.player-list li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}

.player-list li.is-host::after {
  content: "host";
  margin-left: auto;
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

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

.room-actions .primary-btn {
  flex: 1;
}

/* ---------- leaderboard ---------- */
.board-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-soft);
}

.tab {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--fg-dim);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--fg);
}

.tab.is-active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.board-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
}

.board {
  width: 100%;
  font-size: 14px;
}

.board th {
  text-align: left;
  padding: 14px 18px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}

.board td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  font-variant-numeric: tabular-nums;
}

.board tr:last-child td {
  border-bottom: none;
}

.board tr:hover td {
  background: var(--bg-soft);
}

.board td:nth-child(1) {
  color: var(--fg-faint);
  font-weight: 600;
  width: 48px;
}

.board td:nth-child(3) {
  font-weight: 700;
  color: var(--accent);
}

.board-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--fg-dim);
}

.board-empty p {
  font-size: 15px;
  margin-bottom: 6px;
}

.board-empty small {
  font-size: 13px;
  color: var(--fg-faint);
}

.board-empty code {
  font-family: var(--mono);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--accent);
  font-size: 12px;
}

/* ---------- toasts ---------- */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toastIn 0.25s ease;
  max-width: 320px;
}

.toast.is-ok    { border-left: 3px solid var(--ok); }
.toast.is-warn  { border-left: 3px solid var(--warn); }
.toast.is-bad   { border-left: 3px solid var(--bad); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---------- scrollbar (webkit only, firefox uses theme) ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-soft);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
  border: 2px solid var(--bg-soft);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--fg-faint);
}

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .hdr {
    padding: 12px 16px;
    gap: 12px;
  }

  .nav {
    display: none;
  }

  .hero {
    margin-bottom: 32px;
  }

  .hero-title {
    font-size: 32px;
  }

  .brand-name {
    display: none;
  }

  .room-code-row strong {
    font-size: 18px;
  }

  .board th,
  .board td {
    padding: 12px 12px;
    font-size: 13px;
  }
}