:root {
  --blue: #2563eb;
  --blue-2: #3b82f6;
  --blue-soft: #eff6ff;
  --green: #10b981;
  --green-dark: #059669;
  --red: #ef4444;
  --red-dark: #dc2626;
  --amber: #f59e0b;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #fff;
  --shadow: 0 2px 16px rgba(0, 0, 0, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 16px 10px;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: #fff;
  box-shadow: 0 2px 12px rgba(37, 99, 235, .3);
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: .5px; }
.topbar p { margin: 2px 0 0; font-size: 11.5px; opacity: .8; }
.tabbar {
  position: sticky;
  top: 54px;
  z-index: 19;
  display: flex;
  overflow-x: auto;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1 0 auto;
  min-width: 0;
  padding: 11px 6px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: #fff;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  transition: all .2s;
}
.tab.on { color: var(--blue); border-bottom-color: var(--blue); }
.phone-shell { max-width: 600px; margin: 0 auto; padding: 14px; }
.card, .admin-panel, .login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.card { margin-bottom: 12px; }
.card h2, .admin-panel h2, .screen-section h2 {
  margin: 0 0 10px;
  font-size: 14.5px;
  font-weight: 800;
}
.card h3 { margin: 16px 0 8px; font-size: 13px; text-align: left; }
.muted { margin: 0 0 12px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
textarea, input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--ink);
  outline: none;
  background: #fff;
  line-height: 1.55;
}
textarea { resize: vertical; min-height: 92px; }
textarea:focus, input:focus { border-color: var(--blue); }
.char-row { text-align: right; color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.primary, .secondary, .danger, .card button, .admin-panel button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
}
.primary { width: 100%; margin-top: 10px; padding: 13px; background: var(--blue); color: #fff; font-size: 15px; }
.secondary { background: #f1f5f9; color: var(--muted); }
.danger { background: linear-gradient(135deg, #dc2626, #ef4444); color: #fff; }
.small { padding: 7px 10px; font-size: 12px; }
.speaker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.speaker-card {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fafafa;
  padding: 11px 9px;
}
.speaker-name {
  margin-bottom: 9px;
  padding: 4px 6px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12.5px;
  font-weight: 900;
  text-align: center;
}
.speaker-card[data-generation="host"] .speaker-name { background: #f5f3ff; color: #7c3aed; }
.speaker-card[data-generation="70"] .speaker-name { background: #fef2f2; color: var(--red-dark); }
.speaker-card[data-generation="80"] .speaker-name { background: #fffbeb; color: #d97706; }
.speaker-card[data-generation="90"] .speaker-name { background: #f0fdf4; color: var(--green-dark); }
.bar-row { margin: 0 0 7px; }
.bar-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 10.5px; margin-bottom: 2px; }
.bar-track { height: 16px; background: #e2e8f0; border-radius: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 8px; background: linear-gradient(90deg, #2563eb, #60a5fa); transition: width .6s cubic-bezier(.4,0,.2,1); }
.bar-fill.red { background: linear-gradient(90deg, #ef4444, #f87171); }
.vote-row { display: flex; gap: 6px; margin-top: 8px; }
.vote-row button {
  flex: 1;
  padding: 8px 4px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
}
.vote-row button.active-blue { color: var(--blue); background: var(--blue-soft); border-color: var(--blue); }
.vote-row button.active-red { color: var(--red-dark); background: #fef2f2; border-color: var(--red); }
.question-list { display: flex; flex-direction: column; gap: 9px; }
.question-item {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fafafa;
  transition: border-color .2s;
}
.question-item:hover { border-color: #93c5fd; }
.question-text { white-space: pre-wrap; line-height: 1.6; font-size: 13px; color: var(--ink); }
.question-meta { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; margin: 9px 0; color: var(--muted); font-size: 11.5px; }
.question-meta strong { padding: 3px 8px; border-radius: 20px; background: var(--bg); color: var(--muted); }
.tag { padding: 2px 8px; border-radius: 20px; background: var(--blue-soft); color: var(--blue-2); font-size: 10.5px; font-weight: 800; }
.tag.live { background: #f0fdf4; color: #16a34a; }
.question-item button { width: 100%; padding: 9px; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 13px; }
.question-item button.voted { background: var(--blue-soft); color: var(--blue); border-color: var(--blue); }
.stage-card { text-align: center; }
.stage-light {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  margin: 16px auto 14px;
  border: 6px solid #fecaca;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ff6b6b, #dc2626 60%, #991b1b);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.28;
  letter-spacing: 1px;
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
  box-shadow: 0 0 40px rgba(239,68,68,.6), 0 0 80px rgba(239,68,68,.3), inset 0 2px 4px rgba(255,255,255,.2);
  animation: lightPulse 1.8s ease-in-out infinite;
}
@keyframes lightPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 40px rgba(239,68,68,.6), 0 0 80px rgba(239,68,68,.3), inset 0 2px 4px rgba(255,255,255,.2); }
  50% { transform: scale(1.04); box-shadow: 0 0 60px rgba(239,68,68,.8), 0 0 120px rgba(239,68,68,.5), inset 0 2px 4px rgba(255,255,255,.25); }
}
.my-stage { margin: 0 0 12px; padding: 12px 14px; background: #fef2f2; border: 1.5px solid #fecaca; border-radius: 10px; color: var(--red-dark); font-size: 13px; font-weight: 800; }
.stage-list { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.stage-item, .queue-admin {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.rank {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  flex: 0 0 auto;
}
.stage-item strong { flex: 1; color: var(--ink); }
dialog { border: 0; border-radius: 16px; padding: 0; width: min(340px, calc(100vw - 48px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dialog-card { padding: 22px 20px 20px; text-align: center; }
.dialog-card h2 { margin: 0 0 6px; font-size: 17px; }
.dialog-actions { display: flex; gap: 10px; margin-top: 16px; }
.dialog-actions button { flex: 1; padding: 11px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  z-index: 100;
  transform: translateX(-50%) translateY(16px);
  background: rgba(15, 23, 42, .9);
  color: #fff;
  border-radius: 24px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: .3s;
  white-space: nowrap;
  max-width: 90vw;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.screen-body { min-height: 100vh; background: #0f172a; color: #e2e8f0; overflow: hidden; }
.screen-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px;
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
}
.screen-top h1 { margin: 0; color: #fff; font-size: 26px; font-weight: 900; letter-spacing: 2px; }
.screen-link { color: #fff; text-decoration: none; padding: 8px 20px; border-radius: 8px; background: rgba(255,255,255,.15); }
.screen-grid {
  display: grid;
  grid-template-columns: .72fr 1fr 1.15fr;
  gap: 16px;
  padding: 20px;
  height: calc(100vh - 65px);
}
.screen-qr { display: flex; flex-direction: column; align-items: center; gap: 16px; min-width: 0; overflow-y: auto; }
.qr-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 24px 24px 16px;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.qr-card img { width: min(260px, 100%); aspect-ratio: 1; }
.qr-card strong { color: var(--ink); font-size: 15px; }
.qr-card span { color: #94a3b8; font-size: 11px; text-align: center; word-break: break-all; line-height: 1.3; }
.screen-section {
  width: 100%;
  min-height: 0;
  overflow: auto;
  padding: 18px 22px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.05);
}
.screen-section h2 { color: #f1f5f9; font-size: 20px; margin-bottom: 14px; }
.screen-section .muted { color: #94a3b8; }
.screen-speakers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.screen-section .speaker-card { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.08); }
.screen-section .speaker-name { font-size: 17px; }
.screen-section .bar-label { color: #cbd5e1; font-size: 13px; }
.screen-section .bar-track { background: rgba(255,255,255,.08); }
.screen-row {
  display: grid;
  grid-template-columns: 34px 1fr auto 100px;
  gap: 10px;
  align-items: center;
  padding: 9px 14px;
  margin-bottom: 6px;
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 10px;
  background: rgba(255,255,255,.04);
}
.screen-row .question-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e2e8f0; }
.screen-row strong { color: #fbbf24; }
.screen-section .stage-item { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.06); }
.screen-section .stage-item strong { color: #e2e8f0; }
.screen-footer { position: fixed; left: 0; right: 0; bottom: 5px; text-align: center; color: rgba(255,255,255,.35); font-size: 11px; }
.admin-body { background: #eef2f7; }
.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.admin-top h1 { margin: 0; font-size: 20px; }
.admin-top nav { display: flex; align-items: center; gap: 12px; }
.admin-top a, .exports a { color: var(--blue); text-decoration: none; font-weight: 700; }
.admin-top form { margin: 0; }
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 1220px;
  margin: 0 auto;
  padding: 16px;
}
.wide { grid-column: 1 / -1; }
.row-form, .question-admin {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.question-admin { grid-template-columns: 1fr auto auto auto; }
.stack-form { display: grid; gap: 10px; }
.reset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.exports { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.login-card { width: min(360px, calc(100vw - 32px)); margin: 14vh auto 0; }
.login-card h1 { margin-top: 0; }
.login-card form { display: grid; gap: 10px; }
.error { padding: 9px 11px; border-radius: 8px; background: #fef2f2; color: var(--red-dark); margin-bottom: 10px; }
@media (max-width: 760px) {
  .speaker-grid, .screen-speakers, .admin-grid { grid-template-columns: 1fr; }
  .screen-body { overflow: auto; }
  .screen-grid { grid-template-columns: 1fr; height: auto; }
  .screen-top { padding: 12px 16px; }
  .screen-top h1 { font-size: 18px; letter-spacing: .5px; }
  .row-form, .question-admin { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
}
