/* ================================================================
   QuizApp – Design System
   Aesthetic: Broadcast precision — sharp, high-contrast, data-forward
   Fonts: Bricolage Grotesque (display) · Plus Jakarta Sans (body) · JetBrains Mono (data)
   ================================================================ */

:root {
  --bg:        #0a0a0a;
  --bg2:       #131313;
  --bg3:       #1c1c1c;
  --border:    #252525;
  --text:      #f2f2ee;
  --muted:     #585852;
  --accent:    #c5ff00;    /* electric lime — primary */
  --accent-fg: #0a0a0a;   /* text on lime bg */
  --accent2:   #3d7fff;   /* electric blue — secondary */
  --accent3:   #ff6830;   /* warm orange — highlight */
  --danger:    #ff3535;
  --success:   #00de88;

  --radius:    5px;
  --radius-lg: 8px;

  --font-display: 'Bricolage Grotesque', sans-serif;
  --font-body:    'Plus Jakarta Sans', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Typography ──────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.1;
  font-weight: 800;
}
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.2rem; }

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ─────────────────────────────────────────────── */
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 52px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.nav-logo img { height: 1.4rem; width: auto; }
.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.nav-links a { color: var(--muted); font-size: 0.875rem; text-decoration: none; }
.nav-links a:hover { color: var(--text); }
.nav-user {
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg3);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.nav-user i { color: var(--accent); font-size: 1rem; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.3rem;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: opacity 0.12s, transform 0.12s;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); opacity: 1; }
.btn i { font-size: 1em; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}

.btn-cyan {
  background: var(--accent2);
  color: #fff;
}

.btn-amber {
  background: var(--accent3);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: #404040; opacity: 1; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm  { padding: 0.35rem 0.85rem; font-size: 0.8rem; }
.btn-lg  { padding: 0.8rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1.1rem; }
label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-family: var(--font-body);
}

input[type=text], input[type=email], input[type=password],
input[type=number], textarea, select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.95rem;
  width: 100%;
  transition: border-color 0.12s;
  outline: none;
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

/* ── Containers ──────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.page-wrap { padding: 2.5rem 0; }

/* ── Flash messages ──────────────────────────────────────────── */
.flash {
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.1rem;
  font-size: 0.875rem;
  border-left: 3px solid;
}
.flash-error   { background: rgba(255,53,53,0.08);  border-color: var(--danger);  color: #ff9494; }
.flash-success { background: rgba(0,222,136,0.08);  border-color: var(--success); color: #5ef5b8; }
.flash-info    { background: rgba(61,127,255,0.08); border-color: var(--accent2); color: #80aaff; }

/* ── Badge ───────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.55rem;
  border-radius: 3px;
  font-family: var(--font-body);
}
.badge-purple { background: rgba(197,255,0,0.1);   color: var(--accent);  border: 1px solid rgba(197,255,0,0.2); }
.badge-cyan   { background: rgba(61,127,255,0.12); color: #80aaff; border: 1px solid rgba(61,127,255,0.2); }
.badge-amber  { background: rgba(255,104,48,0.12); color: #ffab87; border: 1px solid rgba(255,104,48,0.2); }
.badge-green  { background: rgba(0,222,136,0.1);   color: #5ef5b8; border: 1px solid rgba(0,222,136,0.2); }
.badge-orange { background: rgba(255,160,0,0.12);  color: #ffcc60; border: 1px solid rgba(255,160,0,0.25); }

/* ── Grid helpers ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.2rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media(max-width:768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── Landing / Auth ──────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.auth-bg {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 50% 0%, rgba(197,255,0,0.06) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg) 100%);
  /* Subtle dot grid */
  background-size: auto, 28px 28px;
}
.auth-bg::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 28px 28px;
}
.auth-box {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-top: 2px solid var(--accent);
}
.auth-logo {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.auth-logo img { height: 2rem; width: auto; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 2rem; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.auth-tab {
  flex: 1; padding: 0.6rem; text-align: center;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: 0.85rem;
  color: var(--muted); transition: all 0.12s;
}
.auth-tab + .auth-tab { border-left: 1px solid var(--border); }
.auth-tab.active { background: var(--accent); color: var(--accent-fg); }

/* ── Dashboard ───────────────────────────────────────────────── */
.dashboard-hero {
  background: var(--bg2);
  border: 3px dotted var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem;
  margin-bottom: 2rem;
}
.quiz-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: border-color 0.15s, transform 0.15s;
  cursor: pointer;
}
.quiz-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.quiz-card-title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; margin-bottom: 0.4rem; }
.quiz-card-meta { font-size: 0.8rem; color: var(--muted); font-family: var(--font-mono); }
.quiz-card-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* ── Creator ─────────────────────────────────────────────────── */
.creator-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  min-height: calc(100vh - 120px);
}
@media(max-width:900px) { .creator-layout { grid-template-columns: 1fr; } }

.question-list { display: flex; flex-direction: column; gap: 0.4rem; }
.question-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.84rem;
  transition: all 0.12s;
}
.question-item:hover { border-color: #383838; }
.question-item.active { border-color: var(--accent); background: rgba(197,255,0,0.05); }
.question-item-num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--muted);
  min-width: 20px;
}
.question-item-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.answer-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.5rem;
}
.answer-label {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 5px;
  font-family: var(--font-mono); font-weight: 700; font-size: 0.8rem;
  flex-shrink: 0;
}
.label-a { background: rgba(255,53,53,0.15);   color: #ff8080; }
.label-b { background: rgba(0,222,136,0.15);   color: #5ef5b8; }
.label-c { background: rgba(61,127,255,0.15);  color: #80aaff; }
.label-d { background: rgba(255,104,48,0.15);  color: #ffab87; }

.correct-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 5px;
  background: var(--bg3); border: 1px solid var(--border);
  cursor: pointer; font-size: 0.95rem; transition: all 0.12s; flex-shrink: 0;
  color: var(--muted);
}
.correct-toggle.active {
  background: rgba(0,222,136,0.15);
  border-color: var(--success);
  color: var(--success);
}

/* ── Lobby join page ─────────────────────────────────────────── */
.lobby-join-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.lobby-code {
  font-family: var(--font-mono);
  font-size: 3.5rem; font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-align: center; display: block;
}
.avatar-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; margin: 0.75rem 0; }
.avatar-btn {
  width: 52px; height: 52px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.12s;
  color: var(--muted); font-size: 1.4rem;
}
.avatar-btn i { font-size: 1.3rem; }
.avatar-btn:hover { border-color: #383838; color: var(--text); }
.avatar-btn.selected { border-color: var(--accent); color: var(--accent); background: rgba(197,255,0,0.08); }

/* ── Host UI ─────────────────────────────────────────────────── */
.host-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1rem;
  padding: 1rem;
  height: calc(100vh - 52px);
}
@media(max-width:1000px) { .host-layout { grid-template-columns: 1fr; height: auto; } }

.host-sidebar {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.1rem;
  display: flex; flex-direction: column; gap: 0.9rem;
  overflow-y: auto;
}
.host-main {
  display: flex; flex-direction: column; gap: 1rem; overflow-y: auto;
}
.host-question-preview {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem; flex: 1;
}

.players-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.players-table th {
  text-align: left; padding: 0.45rem 0.5rem;
  color: var(--muted); font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-body);
}
.players-table td { padding: 0.5rem; border-top: 1px solid var(--border); transition: background 0.3s; }
.rank-num { font-family: var(--font-mono); font-weight: 700; color: var(--muted); font-size: 0.8rem; }
.player-row-answered td { background: color-mix(in srgb, var(--success) 10%, transparent); }
.player-row-answered .rank-num { color: var(--success); }
.answered-badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  background: var(--success); color: #000;
  font-size: 0.65rem; font-weight: 700; font-family: var(--font-mono);
  padding: 0.15rem 0.45rem; border-radius: 99px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.waiting-badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  background: var(--bg3); color: var(--muted);
  font-size: 0.65rem; font-weight: 600; font-family: var(--font-mono);
  padding: 0.15rem 0.45rem; border-radius: 99px;
  text-transform: uppercase; letter-spacing: 0.04em;
}

.score-edit { display: flex; align-items: center; gap: 0.4rem; }
.score-edit input { width: 65px; text-align: center; font-family: var(--font-mono); }

/* ── Display screen (TV) ─────────────────────────────────────── */
.display-screen {
  background: var(--bg);
  min-height: 100vh;
  display: flex; flex-direction: column;
  padding: 2vw 3vw;
  position: relative;
  overflow: hidden;
}
.display-screen::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.display-lobby-code {
  font-family: var(--font-mono);
  font-size: 10vw; font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--accent);
}
.display-question-text {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 800;
  text-align: center;
  line-height: 1.15;
  margin-bottom: 2rem;
}
.display-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.display-answer {
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  display: flex; align-items: center; gap: 1rem;
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  border: 1px solid transparent;
  transition: all 0.3s;
}
.display-answer.a { background: rgba(255,53,53,0.12);  border-color: rgba(255,53,53,0.3); }
.display-answer.b { background: rgba(0,222,136,0.12);  border-color: rgba(0,222,136,0.3); }
.display-answer.c { background: rgba(61,127,255,0.12); border-color: rgba(61,127,255,0.3); }
.display-answer.d { background: rgba(255,104,48,0.12); border-color: rgba(255,104,48,0.3); }
.display-answer.correct { transform: scale(1.02); background: rgba(0,222,136,0.2); border-color: var(--success); }
.display-answer-label {
  font-family: var(--font-mono);
  font-size: 1.8rem; font-weight: 700;
  opacity: 0.7;
}

.scoreboard-list { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.scoreboard-item {
  display: flex; align-items: center; gap: 1rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 0.9rem 1.25rem;
  font-family: var(--font-display); font-size: 1.2rem; font-weight: 700;
  animation: slideIn 0.4s ease both;
}
.scoreboard-item:nth-child(1) { border-color: var(--accent); background: rgba(197,255,0,0.06); font-size: 1.4rem; }
.scoreboard-item:nth-child(2) { border-color: #94a3b8; }
.scoreboard-item:nth-child(3) { border-color: #92400e; }
.scoreboard-rank { color: var(--muted); min-width: 2rem; font-size: 0.9rem; font-family: var(--font-mono); }
.scoreboard-pts  { margin-left: auto; color: var(--accent); font-family: var(--font-mono); font-size: 1rem; }

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

.timer-bar-wrap {
  height: 5px; background: var(--bg3); border-radius: 99px; overflow: hidden;
  margin-bottom: 1.5rem;
}
.timer-bar {
  height: 100%;
  background: var(--accent);
  transition: width 1s linear;
}

/* ── Player UI (mobile-first) ────────────────────────────────── */
.player-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg);
  padding: 1rem;
}
.player-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem;
}
.player-nick {
  font-family: var(--font-display); font-weight: 700;
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.9rem;
}
.player-nick i { color: var(--accent); font-size: 1.1rem; }
.player-score-badge {
  font-family: var(--font-mono); font-weight: 700;
  color: var(--accent); font-size: 1.05rem;
}
.player-phase { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }

.abcd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; width: 100%; max-width: 400px; }
.abcd-btn {
  aspect-ratio: 1.6;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.25rem;
  font-family: var(--font-display); font-weight: 800;
  cursor: pointer; transition: all 0.12s;
  font-size: 0.875rem;
  padding: 0.5rem;
  text-align: center;
}
.abcd-btn:active { transform: scale(0.96); }
.abcd-btn.a { background: rgba(255,53,53,0.15);  border-color: rgba(255,53,53,0.35);  color: #ff8080; }
.abcd-btn.b { background: rgba(0,222,136,0.15);  border-color: rgba(0,222,136,0.35);  color: #5ef5b8; }
.abcd-btn.c { background: rgba(61,127,255,0.15); border-color: rgba(61,127,255,0.35); color: #80aaff; }
.abcd-btn.d { background: rgba(255,104,48,0.15); border-color: rgba(255,104,48,0.35); color: #ffab87; }
.abcd-btn:hover:not(.answered) { filter: brightness(1.25); transform: scale(1.03); }
.abcd-btn.answered { opacity: 0.35; pointer-events: none; }
.abcd-btn.selected {
  opacity: 1 !important;
  border-width: 3px;
  transform: scale(1.08);
  filter: brightness(1.6) saturate(1.4);
  box-shadow: 0 0 24px rgba(255,255,255,0.15);
  z-index: 1;
  position: relative;
}
.abcd-btn-letter { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 700; }
.abcd-btn-text { font-size: 0.72rem; line-height: 1.2; font-family: var(--font-body); font-weight: 500; }

.waiting-pulse {
  display: flex; flex-direction: column; align-items: center; gap: 1.5rem;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.open-answer-form { width: 100%; max-width: 400px; }
.open-answer-form textarea { min-height: 120px; text-align: center; font-size: 1.05rem; }

/* ── Media preview ───────────────────────────────────────────── */
.media-preview {
  max-width: 100%; max-height: 300px; border-radius: var(--radius);
  object-fit: contain; display: block; margin: 0 auto;
}
audio { width: 100%; }

/* ── Drag handle ─────────────────────────────────────────────── */
.drag-handle { cursor: grab; color: var(--muted); font-size: 0.9rem; }
.drag-handle:active { cursor: grabbing; }

/* ── Utility ─────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted   { color: var(--muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
