/* =========================================================
   Quiz Battle — Design System v2
   Catatan: CSP memblokir atribut style="" inline, jadi semua
   styling wajib lewat class di file ini.
   ========================================================= */

:root {
  /* Token tema (bisa di-override lewat .env -> /api/info) */
  --bg: #1b1340;
  --panel: #2a1f66;
  --panel-alt: #3b2f86;
  --accent: #ffcc00;
  --text: #ffffff;
  --muted: #c9c2ee;
  --ok: #26890c;
  --no: #a3122a;

  /* Warna opsi jawaban (warna = ID opsi mod 4) */
  --c0: #e21b3c;
  --c1: #1368ce;
  --c2: #ffcc00;
  --c3: #26890c;

  /* Turunan */
  --on-accent: #1b1340;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.2);
  --well: rgba(8, 4, 28, 0.38);
  --grid: rgba(255, 255, 255, 0.04);
  --good-text: #7ee787;
  --bad-text: #ff9aac;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 26px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Latar: glow lembut di atas + grid tipis yang memudar */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(70% 50% at 50% -5%, color-mix(in srgb, var(--panel-alt) 85%, transparent), transparent 70%),
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 44px 44px;
  mask-image: radial-gradient(90% 70% at 50% 0%, #000 35%, transparent 90%);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2 {
  letter-spacing: -0.02em;
  line-height: 1.15;
}

img {
  max-width: 100%;
}

.hide {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- Tipografi utilitas ---------- */
.kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.hint {
  font-size: 13px;
  color: var(--muted);
}

.num {
  font-variant-numeric: tabular-nums;
}

.err {
  min-height: 1.4em;
  font-size: 14px;
  font-weight: 600;
  color: var(--bad-text);
}

/* ---------- Brand ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.brand-mark i {
  border-radius: 3px;
}
.brand-mark i:nth-child(1) {
  background: var(--c0);
}
.brand-mark i:nth-child(2) {
  background: var(--c1);
}
.brand-mark i:nth-child(3) {
  background: var(--c2);
}
.brand-mark i:nth-child(4) {
  background: var(--c3);
}

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--panel-alt);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition:
    background-color 150ms ease-out,
    border-color 150ms ease-out,
    box-shadow 150ms ease-out,
    transform 120ms ease-out;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn:hover:not(:disabled) {
  border-color: var(--line-strong);
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 10px 28px -12px color-mix(in srgb, var(--accent) 80%, transparent);
}

.btn-primary:hover:not(:disabled) {
  border-color: transparent;
  box-shadow: 0 14px 34px -12px color-mix(in srgb, var(--accent) 95%, transparent);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
}

.btn-danger {
  background: var(--no);
}

.btn-success {
  background: var(--ok);
  color: #ffffff;
  box-shadow: 0 10px 28px -12px color-mix(in srgb, var(--ok) 85%, transparent);
}

.btn-info {
  background: color-mix(in srgb, var(--c1) 24%, transparent);
  border-color: color-mix(in srgb, var(--c1) 55%, transparent);
  color: #9ecbff;
}

.btn-info:hover:not(:disabled) {
  background: color-mix(in srgb, var(--c1) 36%, transparent);
}

.btn-danger-ghost {
  background: color-mix(in srgb, var(--c0) 14%, transparent);
  border-color: color-mix(in srgb, var(--c0) 40%, transparent);
  color: var(--bad-text);
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--no);
  border-color: transparent;
  color: #ffffff;
}

.btn-lg {
  min-height: 56px;
  padding: 14px 28px;
  border-radius: var(--r-lg);
  font-size: 18px;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* ---------- Form ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

input:where([type="text"], [type="password"], [type="number"], [type="url"]),
select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--well);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition:
    border-color 150ms ease-out,
    box-shadow 150ms ease-out;
}

input::placeholder {
  color: color-mix(in srgb, var(--muted) 55%, transparent);
}

input:where([type="text"], [type="password"], [type="number"], [type="url"]):focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}

select option {
  background: var(--panel);
  color: var(--text);
}

.input-code {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.input-suffix {
  position: relative;
}

.input-suffix input {
  padding-right: 72px;
}

.input-suffix span {
  position: absolute;
  right: 14px;
  top: 50%;
  translate: 0 -50%;
  font-size: 14px;
  color: var(--muted);
  pointer-events: none;
}

/* Switch dari checkbox native (role="switch") */
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.switch input {
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 28px;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel-alt);
  cursor: pointer;
  transition: background-color 150ms ease-out;
}

.switch input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text);
  transition: translate 180ms var(--ease);
}

.switch input:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.switch input:checked::before {
  translate: 18px 0;
  background: var(--on-accent);
}

.option-row {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--well);
}

input[type="file"] {
  max-width: 100%;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--panel-alt);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- Surface ---------- */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-alt) 45%, var(--panel)) 0%, var(--panel) 55%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 30px 60px -30px rgba(0, 0, 0, 0.65);
}

/* Native <dialog> modal */
dialog.modal-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 28px;
  color: var(--text);
  margin: auto;
}

dialog.modal-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(8, 4, 28, 0.72);
  backdrop-filter: blur(6px);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.pill.ok {
  color: var(--good-text);
  border-color: color-mix(in srgb, var(--c3) 45%, transparent);
  background: color-mix(in srgb, var(--c3) 14%, transparent);
}

.pill.warn {
  color: var(--bad-text);
  border-color: color-mix(in srgb, var(--c0) 45%, transparent);
  background: color-mix(in srgb, var(--c0) 14%, transparent);
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--well);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.meta-tag strong {
  color: var(--text);
  font-weight: 700;
}

/* =========================================================
   HOST
   ========================================================= */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--line);
}

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

.view {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px;
}

/* Login */
.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(420px, 100%);
  padding: 32px;
}

/* Setup */
.setup {
  display: grid;
  justify-items: center;
  padding-top: 48px;
}

.setup-card {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: min(620px, 100%);
  padding: 32px;
}

.dash {
  width: min(1040px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.quiz-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.quiz-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  transition: border-color 150ms ease-out, transform 150ms ease-out;
}

.quiz-card:hover {
  border-color: var(--line-strong);
}

.quiz-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.btn-icon {
  min-height: 36px;
  width: 36px;
  padding: 0;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}

.btn-icon:hover:not(:disabled) {
  background: color-mix(in srgb, var(--c0) 18%, transparent);
  border-color: color-mix(in srgb, var(--c0) 40%, transparent);
  color: var(--bad-text);
}

.quiz-card h3 {
  font-size: 20px;
  line-height: 1.25;
}

.quiz-card-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.meta-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--well);
}

.meta-box .label {
  font-size: 11px;
}

.meta-box strong {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.quiz-card-actions {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.title-xl {
  margin: 6px 0 8px;
  font-size: 32px;
}

.quiz-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 20px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--well);
}

.quiz-summary strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Editor */
.editor {
  width: min(1040px, 100%);
  margin: 0 auto;
  overflow: clip;
}

.editor-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(10px);
}

.editor-head h2 {
  font-size: 20px;
}

.editor-head .group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.editor-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.import-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
}

.import-box .label {
  flex-basis: 100%;
}

.msg {
  min-height: 1.4em;
  font-size: 14px;
  font-weight: 600;
}

.msg.ok {
  color: var(--good-text);
}

.msg.err {
  color: var(--bad-text);
}

.msg.warn {
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.q-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.q-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--well);
}

.q-card.incomplete {
  border-color: var(--accent);
}

.q-warn-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.q-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.q-num {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.opt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.opt-input {
  position: relative;
  display: flex;
  align-items: center;
}

.opt-badge {
  position: absolute;
  left: 10px;
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--dot);
  color: #ffffff;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.opt-input[data-c="2"] .opt-badge {
  color: var(--on-accent);
}

.opt-input input {
  height: 48px;
  padding-left: 48px;
  padding-right: 40px;
}

.opt-check {
  position: absolute;
  right: 12px;
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--dot);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease-out;
}

.opt-input[data-c="2"] .opt-check {
  color: var(--on-accent);
}

.opt-input.is-correct input {
  border-color: var(--dot);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--dot) 30%, transparent);
}

.opt-input.is-correct .opt-check {
  opacity: 1;
}

.opt-input[data-c="0"] {
  --dot: var(--c0);
}
.opt-input[data-c="1"] {
  --dot: var(--c1);
}
.opt-input[data-c="2"] {
  --dot: var(--c2);
}
.opt-input[data-c="3"] {
  --dot: var(--c3);
}

.q-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.q-meta-right {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.q-meta .field .label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.q-meta input {
  height: 48px;
}

.ans-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.ans-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  min-height: 48px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--well);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 150ms ease-out, background-color 150ms ease-out, color 150ms ease-out;
}

.ans-btn .ans-dot {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 3px;
  background: var(--dot);
}

.ans-btn[data-c="0"] {
  --dot: var(--c0);
}
.ans-btn[data-c="1"] {
  --dot: var(--c1);
}
.ans-btn[data-c="2"] {
  --dot: var(--c2);
}
.ans-btn[data-c="3"] {
  --dot: var(--c3);
}

.ans-btn[aria-pressed="true"] {
  border-color: transparent;
  background: var(--dot);
  color: #ffffff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.ans-btn[aria-pressed="true"] .ans-dot {
  background: currentColor;
}

.ans-btn[data-c="2"][aria-pressed="true"] {
  color: var(--on-accent);
  box-shadow: inset 0 0 0 2px rgba(27, 19, 64, 0.5);
}

/* Preview Quiz */
.preview-panel {
  width: min(1040px, 100%);
  margin: 0 auto;
  overflow: clip;
}

.preview-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px;
}

.preview-phone {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(390px, 100%);
  min-height: 540px;
  padding: 16px;
  border: 2px solid var(--line-strong);
  border-radius: 28px;
  background: var(--bg);
  box-shadow: 0 24px 48px -20px rgba(0, 0, 0, 0.75);
}

.preview-phone .opts {
  min-height: 220px;
}

.bar-static {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.preview-fb {
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.preview-fb.ok {
  background: var(--ok);
}

.preview-fb.no {
  background: var(--no);
}

.preview-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(390px, 100%);
}

/* ---------- Lobby (proyektor) ---------- */
.lobby {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
  min-height: calc(100dvh - 73px);
  font-size: 24px;
}

.lobby-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 48px;
  padding: 36px 44px;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.step {
  display: flex;
  align-items: center;
  gap: 16px;
}

.step-n {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel-alt);
  font-size: 18px;
  font-weight: 800;
}

.step .label {
  font-size: 14px;
}

.url {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.01em;
  word-break: break-all;
}

.code {
  display: flex;
  gap: 12px;
}

.code span {
  display: grid;
  place-items: center;
  width: clamp(64px, 7vw, 108px);
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--well);
  box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
  font-size: clamp(48px, 6vw, 92px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 16px 16px 12px;
  border-radius: 24px;
  background: #ffffff;
  color: var(--on-accent);
}

.qr img {
  display: block;
  width: 260px;
  height: 260px;
}

.qr figcaption {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h2 {
  font-size: 32px;
}

.section-head .accent {
  color: var(--accent);
}

.section-head p {
  font-size: 18px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.chip {
  padding: 10px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  font-size: 24px;
  font-weight: 700;
}

.chip:nth-child(4n + 1) {
  border-color: color-mix(in srgb, var(--c0) 60%, transparent);
  background: color-mix(in srgb, var(--c0) 16%, var(--panel));
}
.chip:nth-child(4n + 2) {
  border-color: color-mix(in srgb, var(--c1) 60%, transparent);
  background: color-mix(in srgb, var(--c1) 16%, var(--panel));
}
.chip:nth-child(4n + 3) {
  border-color: color-mix(in srgb, var(--c2) 60%, transparent);
  background: color-mix(in srgb, var(--c2) 14%, var(--panel));
}
.chip:nth-child(4n + 4) {
  border-color: color-mix(in srgb, var(--c3) 60%, transparent);
  background: color-mix(in srgb, var(--c3) 16%, var(--panel));
}

.chip small {
  margin-left: 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--muted);
}

.empty {
  color: var(--muted);
}

.lobby-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px;
  font-size: 16px;
}

.lobby-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 24px;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 12px;
}

.inline-field input[type="number"] {
  width: 96px;
}

.inline-field input[type="text"] {
  width: 320px;
}

.lobby-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---------- Game / ranking (proyektor) ---------- */
.game {
  font-size: 24px;
}

.game-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.game-head h1 {
  margin-top: 4px;
  font-size: 44px;
}

.game-stats {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 150px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--well);
}

.stat strong {
  font-size: 32px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--well);
}

.tab {
  min-height: 44px;
  padding: 8px 22px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

.board-head,
.r {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 84px 190px 150px 150px;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
}

.board-head {
  padding-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.board-head .right {
  text-align: right;
}

.board {
  position: relative;
}

.r {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  font-size: 24px;
  font-weight: 700;
  transition:
    opacity 400ms ease-out,
    background-color 400ms ease-out;
}

@media (prefers-reduced-motion: no-preference) {
  .r {
    transition:
      transform 800ms var(--ease),
      opacity 400ms ease-out,
      background-color 400ms ease-out;
  }
}

.r.first {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 16px 36px -16px color-mix(in srgb, var(--accent) 80%, transparent);
}

.rk {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.first .rk {
  color: var(--on-accent);
}

.nm {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nm small {
  margin-left: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}

.first .nm small {
  color: var(--on-accent);
  opacity: 0.75;
}

.mv {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.mv.up {
  color: var(--good-text);
}

.mv.down {
  color: var(--bad-text);
}

.first .mv.up {
  color: #0b5d1e;
}

.first .mv.down {
  color: #8a0f20;
}

.ct {
  font-size: 20px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.first .ct {
  color: var(--on-accent);
}

.pg {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
}

.pg i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--c1), var(--c3), var(--accent));
  transition: width 600ms ease-out;
}

.first .pg {
  background: rgba(27, 19, 64, 0.2);
}

.first .pg i {
  background: var(--on-accent);
}

.sc {
  font-weight: 900;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Ranking tim */
.team-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.team-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 220px 170px;
  align-items: center;
  gap: 20px;
  min-height: 64px;
  padding: 0 24px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  font-weight: 700;
}

.team-row.first {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
}

.team-row .ct {
  text-align: right;
}

/* Podium */
.podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 20px;
  max-width: 960px;
  margin: 8px auto 40px;
}

.pod {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  text-align: center;
}

.pod-name {
  max-width: 100%;
  overflow: hidden;
  font-size: 28px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pod-score {
  font-size: 20px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pod-block {
  display: grid;
  place-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 20px 20px 8px 8px;
  font-size: 56px;
  font-weight: 900;
}

.p1 .pod-block {
  height: 200px;
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
}

.p2 .pod-block {
  height: 150px;
  background: var(--panel-alt);
}

.p3 .pod-block {
  height: 110px;
  background: var(--panel);
}

@media (prefers-reduced-motion: no-preference) {
  .pod {
    animation: rise 600ms var(--ease) both;
  }
  .pod.p1 {
    animation-delay: 300ms;
  }
  .pod.p2 {
    animation-delay: 150ms;
  }
  .chip {
    animation: pop 250ms var(--ease);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(32px);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
}

.export-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

/* =========================================================
   PESERTA (mobile-first, 390px)
   ========================================================= */
body.play {
  height: 100dvh;
  overflow: hidden;
}

.screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.screen-center {
  justify-content: center;
  gap: 20px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.join-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
}

.join-card h1 {
  margin: 6px 0 8px;
  font-size: 26px;
}

.join-card .lead {
  margin-top: 0;
  color: var(--muted);
}

.host-link {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.host-link a {
  color: var(--text);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
  transition: color 150ms ease-out, text-decoration-color 150ms ease-out;
}

.host-link a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* Menunggu */
.wait {
  align-items: center;
  text-align: center;
}

.wait-orb {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, var(--panel-alt), var(--panel));
  box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  font-size: 48px;
  font-weight: 900;
}

.wait h1 {
  font-size: 26px;
}

.player-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  font-weight: 700;
}

.player-tag span {
  color: var(--muted);
  font-weight: 600;
}

/* Soal */
.screen-q {
  gap: 10px;
}

.hud {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 14px;
  padding: 8px 8px 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
}

.hud-chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--panel-alt);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.hud-stat .label {
  font-size: 10px;
}

.hud-stat strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.streak {
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.timer {
  display: grid;
  place-items: center;
  min-width: 52px;
  height: 40px;
  margin-left: auto;
  padding: 0 8px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  transition: background-color 200ms ease-out;
}

.timer.low {
  background: var(--c0);
  color: #ffffff;
}

.timebar {
  flex-shrink: 0;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel);
}

#bar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left center;
}

.q-box {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  text-align: center;
}

#qtext {
  font-size: clamp(18px, 5vw, 22px);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.qimg {
  max-height: 22dvh;
  object-fit: contain;
  border-radius: 12px;
}

.powerups {
  display: grid;
  flex-shrink: 0;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pu {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.pu[data-pu="double"] {
  border-color: color-mix(in srgb, var(--c2) 55%, transparent);
  background: color-mix(in srgb, var(--c2) 12%, transparent);
  color: var(--accent);
}

.pu[data-pu="fifty"] {
  border-color: color-mix(in srgb, var(--c1) 60%, transparent);
  background: color-mix(in srgb, var(--c1) 16%, transparent);
  color: #9ecbff;
}

.pu[data-pu="extraTime"] {
  border-color: color-mix(in srgb, var(--c3) 60%, transparent);
  background: color-mix(in srgb, var(--c3) 16%, transparent);
  color: var(--good-text);
}

.pu-n {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--panel-alt);
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.pu[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

.pu:disabled {
  opacity: 0.4;
  cursor: default;
}

.opts {
  display: grid;
  flex: 1;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 10px;
  min-height: 0;
}

.opts.one {
  grid-template-columns: 1fr;
}

.opt {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 28px 12px 16px;
  border: 0;
  border-radius: var(--r-lg);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.22);
  color: #ffffff;
  font: inherit;
  font-size: clamp(16px, 4.4vw, 20px);
  font-weight: 800;
  line-height: 1.25;
  word-break: break-word;
  cursor: pointer;
  transition:
    transform 120ms ease-out,
    opacity 200ms ease-out;
}

.opt:active:not(:disabled) {
  transform: scale(0.98);
}

.opt-shape {
  position: absolute;
  top: 10px;
  left: 12px;
  font-size: 14px;
  opacity: 0.9;
}

.o0 {
  background: var(--c0);
}
.o1 {
  background: var(--c1);
}
.o2 {
  background: var(--c2);
  color: var(--on-accent);
}
.o3 {
  background: var(--c3);
}

.opt:disabled {
  opacity: 0.3;
  cursor: default;
}

.opt.pick {
  opacity: 1;
  box-shadow:
    inset 0 0 0 4px #ffffff,
    inset 0 -5px 0 rgba(0, 0, 0, 0.22);
}

/* Feedback (overlay layar penuh) */
.feedback {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.feedback.ok {
  background: var(--ok);
}

.feedback.no {
  background: var(--no);
}

.fb-icon {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  font-size: 48px;
  font-weight: 900;
}

.fb-title {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.fb-detail {
  max-width: 30ch;
  font-size: 17px;
}

.fb-rank {
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: no-preference) {
  .feedback:not(.hide) .fb-icon {
    animation: pop 300ms var(--ease);
  }
}

/* Selesai / hasil akhir */
.screen-fin {
  gap: 20px;
  padding-top: 32px;
  overflow-y: auto;
}

.fin-head {
  text-align: center;
}

.fin-head h1 {
  margin: 6px 0 4px;
  font-size: 28px;
}

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

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  text-align: center;
}

.stat-card strong {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.stat-card.hl {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
}

.stat-card.hl .label {
  color: var(--on-accent);
  opacity: 0.8;
}

.section-title {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.top-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.top-list li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  font-weight: 700;
}

.top-list li.me {
  border-color: var(--accent);
}

.top-list .tr {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.top-list .tn {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-list .tn small {
  margin-left: 6px;
  color: var(--muted);
  font-weight: 600;
}

.top-list .ts {
  font-variant-numeric: tabular-nums;
}

/* ---------- Responsif ---------- */
@media (max-width: 960px) {
  .view {
    padding: 20px;
  }
  .topbar {
    padding: 12px 20px;
  }
  .lobby-hero {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 24px;
    text-align: center;
  }
  .board-head,
  .r {
    grid-template-columns: 44px minmax(0, 1fr) 70px 150px 110px;
  }
  .board-head .col-pg,
  .r .pg {
    display: none;
  }
  .grid-2,
  .q-meta,
  .opt-grid,
  .quiz-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .hud {
    gap: 10px;
  }
  .opt {
    padding-top: 24px;
  }
}
