/* =========================================================
   Base Theme Variables
   ========================================================= */
:root {
  /* App theme */
  --bg: #0b0b0c;
  --fg: #eaeaea;
  --muted: #b8b8b8;
  --card: #151517;
  --accent: #7dd3fc;

  /* Overlay */
  --overlay-bg: rgba(10, 10, 10, 0.35);
  --overlay-card: var(--card);

  /* Option tiles (player + host) */
  --tile-bg: #ffffff;              /* tile background (white card on dark UI) */
  --tile-fg: #111;                 /* strong default text inside tiles */
  --tile-fg-muted: #4b4b4b;        /* muted secondary line */
  --tile-border: #b9c3ca;          /* default border */
  --tile-hover-border: #2e7d32;    /* border on hover */
  --tile-hover-bg: #f1f8f2;        /* soft hover bg */
  --tile-sel-bg: #e8f5e9;          /* selected background */
  --tile-sel-border: #2e7d32;      /* selected border (thick rounded look) */
  --tile-sel-fg: #0b3d0b;          /* selected text */

  /* Layout */
  --opt-gap: clamp(6px, 1.2vw, 12px);
}

/* =========================================================
   Base Elements
   ========================================================= */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--fg);
  font: 16px/1.5 system-ui, Segoe UI, Roboto, Inter, sans-serif;
}
.container { max-width: 800px; margin: 8vh auto; padding: 24px; }
.card { background: var(--card); padding: 24px; border-radius: 12px; border: 1px solid #222; }

h1 { margin: 0 0 12px; }
label { display: block; margin: 12px 0 6px; color: var(--muted); }

input {
  width: 100%; padding: 10px 12px;
  border-radius: 8px; border: 1px solid #333;
  background: #101012; color: var(--fg);
}

button {
  margin-top: 12px; padding: 10px 14px;
  border: 0; border-radius: 8px; background: var(--accent);
  color: #0b0b0c;
  cursor: pointer;
}
a { color: var(--accent); text-decoration: none; }

.foot {
  position: fixed; bottom: 12px; left: 0; right: 0;
  text-align: center; color: var(--muted); font-size: 14px;
}

/* =========================================================
   Leaderboard Overlay
   ========================================================= */
html.modal-open, body.modal-open { overflow: hidden; }

.overlay {
  position: fixed; inset: 0; display: none; z-index: 1000;
}
.overlay.show { display: block; }

.overlay-backdrop {
  position: absolute; inset: 0;
  background: var(--overlay-bg); backdrop-filter: blur(6px);
}

.overlay-dialog {
  position: relative; z-index: 1;
  max-width: min(720px, 92vw);
  margin: 6vh auto;
  background: var(--overlay-card);
  border-radius: 12px;
  padding: clamp(16px, 2.5vw, 28px);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.overlay-close {
  position: absolute; top: 8px; right: 10px;
  border: 0; background: transparent;
  font-size: 1.75rem; line-height: 1; cursor: pointer;
}

.leaderboard-list { margin: 12px 0 0 24px; }

.player-bar { display: flex; align-items: center; gap: 12px; }

.btn-secondary {
  padding: .5rem .75rem; border-radius: 8px; border: 1px solid #ccc;
  background: #f5f5f5; color: #111; cursor: pointer;
}
.btn-secondary:hover { filter: brightness(0.98); }

/* =========================================================
   Option Tiles (Player + Host)
   ========================================================= */

/* Layouts */
.option-list {
  display: flex; flex-direction: column;
  gap: var(--opt-gap);
}
.option-grid {
  /* Kept for compatibility; currently you’re using option-list (vertical). */
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* Base tile */
.tile {
  width: 100%;
  border-radius: 12px;
  border: 2px solid var(--tile-border);
  background: var(--tile-bg);
  color: var(--tile-fg);
  padding: 0.75rem 1rem;
  cursor: pointer;
  user-select: none;
  outline: none;
  transition:
    border-color .18s ease,
    background-color .18s ease,
    box-shadow .18s ease,
    transform .05s ease;
}

/* Strong, legible primary line */
.tile .tile-title {
  color: inherit;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Secondary lines: readable but not dominant */
.tile .tile-meta,
.tile .tile-alt,
.tile .count,
.tile .muted {
  color: #6b6b6b;
  font-size: 0.9rem;
  margin-top: 2px;
}

/* Hover */
.tile:hover {
  background: var(--tile-hover-bg);
  border-color: var(--tile-hover-border);
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}

/* Pressed feedback */
.tile:active { transform: scale(.995); }

/* Focus outline (keyboard) */
.tile:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tile-hover-border) 45%, transparent);
}

/* Selected state */
.tile.is-selected {
  background: var(--tile-sel-bg);
  border-color: var(--tile-sel-border);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tile-sel-border) 30%, transparent);
  color: var(--tile-sel-fg);
}
.tile.is-selected .tile-title { color: var(--tile-sel-fg); }

/* Slightly smaller variant (used in host adjudication lists) */
.tile--compact { padding: .6rem .75rem; }

/* Keep tiles readable even when the panel is temporarily disabled
   (we only reduce interactivity there, not legibility). */
#adj[style*="pointer-events: none"] .tile,
#adj[style*="pointer-events: none"] .tile * {
  opacity: 1;
}

/* Host Trivia State UI */

.state-indicators {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.state-label {
  font-weight: 600;
  margin-right: 4px;
}

.status-pill {
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.status-live {
  background: #2f855a; /* green */
  color: #fff;
}

.status-not-live {
  background: #c53030; /* red */
  color: #fff;
}

.state-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

#resetGame:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Host Question section UI */

.question-indicators {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.question-status-pill {
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.question-status-open {
  background: #2f855a; /* green */
  color: #fff;
}

.question-status-closed {
  background: #c53030; /* red */
  color: #fff;
}

/* Host dropdowns: match button-ish height */
.host-select {
  padding: 6px 10px;
  min-height: 36px;
  line-height: 1.2;
  border-radius: 4px;
}

/* Question log area */
.question-log {
  margin-top: 8px;
  text-align: center;
}

.question-log-divider {
  width: 75%;
  margin: 0.5rem auto;
  border: 0;
  border-top: 1px solid #dddddd;
}

.question-log-message {
  color: #b8b8b8;
  font-size: 0.9rem;
  min-height: 1.2em; /* reserve space even when empty */
}

/* Base style for the little arrow buttons (optional, if you want them to match) */
.nav-arrow {
  min-width: 2.2rem;
  padding: 0.25rem 0.5rem;
}

/* Greyed-out look when they are disabled */
.nav-arrow:disabled {
  opacity: 0.4;
  cursor: default;
  filter: grayscale(0.4);
  box-shadow: none;
  transform: none;
}

/* Host Leaderboard table */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.95rem;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #333;
}

.leaderboard-table thead th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
}

.leaderboard-table .lb-rank {
  width: 3rem;
  text-align: right;
  color: var(--muted);
}

.leaderboard-table .lb-score {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Select box highlight (Questions + Scoring) */
#qpick.status-future,
#scoreQpick.status-future { background-color:#f5f5f5; color:#555; }

#qpick.status-open,
#scoreQpick.status-open { background-color:#e8f5e9; color:#1b5e20; }

#qpick.status-closed_unscored,
#scoreQpick.status-closed_unscored { background-color:#fff8e1; color:#7a5b00; }

#qpick.status-scored,
#scoreQpick.status-scored { background-color:#e3f2fd; color:#0d47a1; }

/* Question + Scoring dropdown option status colors */
#qpick option[data-status="future"],
#scoreQpick option[data-status="future"] {
  background-color: #f5f5f5;
  color: #555;
}

#qpick option[data-status="open"],
#scoreQpick option[data-status="open"] {
  background-color: #e8f5e9;
  color: #1b5e20;
}

#qpick option[data-status="closed_unscored"],
#scoreQpick option[data-status="closed_unscored"] {
  background-color: #fff8e1;
  color: #7a5b00;
}

#qpick option[data-status="scored"],
#scoreQpick option[data-status="scored"] {
  background-color: #e3f2fd;
  color: #0d47a1;
}

#qpick.status-none,
#scoreQpick.status-none {
  background-color: #fff;
  color: inherit;
}

.seo-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
