:root {
  color-scheme: dark;
  --bg: #111111;
  --panel: #181818;
  --text: #f5f5f5;
  --muted: #a9a9a9;
  --blue: #6caaf0;
  --pink: #f18ff0;
  --border: #343434;
  --danger: #ff8d8d;
  --success: #8fe5b2;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; }

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
}

.panel {
  width: min(620px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: clamp(24px, 5vw, 42px);
  box-shadow: 0 18px 55px rgba(0,0,0,.28);
}

.eyebrow {
  color: var(--pink);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .78rem;
  font-weight: 800;
}

h1 { margin: 8px 0 10px; font-size: clamp(2rem, 6vw, 3.1rem); }
.muted { margin: 0 0 28px; color: var(--muted); line-height: 1.6; }
.form { display: grid; gap: 10px; }
label { margin-top: 8px; font-weight: 700; }

input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #101010;
  color: var(--text);
  padding: 14px 15px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

textarea { resize: vertical; min-height: 155px; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(108,170,240,.18); }

.button {
  border: 0;
  cursor: pointer;
  color: #111;
  font-weight: 800;
  transition: transform .12s ease, opacity .12s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.button-primary { margin-top: 12px; padding: 14px 18px; border-radius: 12px; background: var(--blue); }
.button-secondary { padding: 14px 18px; border-radius: 12px; background: #303030; color: #f5f5f5; }

.status { min-height: 1.25rem; margin: 8px 0 0; color: var(--muted); }
.status.success { color: var(--success); }
.status.error { color: var(--danger); }
.text-link { display: inline-block; margin-top: 22px; color: #c9c9c9; text-decoration: none; }
.text-link:hover { color: white; }

/* Name setup */
.setup-panel { width: min(680px, 100%); }
.name-entry label { display: block; margin-bottom: 9px; }
.name-entry-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: stretch; }
.add-name-button { margin-top: 0; min-width: 120px; }
.name-list-header { display: flex; justify-content: space-between; align-items: center; margin-top: 30px; margin-bottom: 10px; }
.name-count { display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 9px; border-radius: 999px; background: #2b2b2b; color: #ddd; font-weight: 700; }
.name-list { display: grid; gap: 8px; min-height: 54px; max-height: 280px; overflow-y: auto; }
.empty-list { margin: 0; padding: 16px; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); text-align: center; }
.name-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border-radius: 11px; background: #101010; border: 1px solid var(--border); }
.remove-name { border: 0; background: transparent; color: #ff9f9f; cursor: pointer; padding: 5px; }
.remove-name:hover { text-decoration: underline; }
.setup-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 22px; }
.setup-actions .button-primary { margin-top: 0; }

/* Random result page — based on the supplied reference image. */
.random-body { min-height: 100vh; overflow-x: hidden; }
.random-page { min-height: 100vh; position: relative; border: 1px solid #dedede; background: #111; }
.random-back-link { position: absolute; z-index: 3; top: 18px; left: 20px; color: #777; text-decoration: none; font-size: .86rem; }
.random-back-link:hover { color: #ddd; }
.random-stage {
  min-height: 100vh;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 80px 30px 58px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  align-items: start;
}
.reference-card {
  background: var(--blue);
  color: #101010;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px 24px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
  overflow-wrap: anywhere;
}
.reference-name { width: min(390px, 76vw); min-height: 72px; }
.reference-question { width: min(490px, 88vw); min-height: 105px; align-self: center; }
.reference-name span { font-size: clamp(1rem, 2.6vw, 1.35rem); }
.reference-question span { font-size: clamp(1rem, 2.6vw, 1.3rem); line-height: 1.45; }
.reference-actions { align-self: end; text-align: center; }
.reference-next { min-width: 120px; min-height: 61px; padding: 15px 23px; background: var(--pink); }
.random-status { max-width: 520px; margin-top: 12px; }

@media (max-width: 560px) {
  .panel { border-radius: 16px; }
  .name-entry-row, .setup-actions { grid-template-columns: 1fr; }
  .add-name-button { min-width: 0; }
  .random-stage { padding-inline: 16px; padding-top: 74px; }
  .reference-name { width: 86vw; }
  .reference-question { width: 92vw; }
  .random-back-link { top: 13px; left: 13px; }
}

@media (prefers-reduced-motion: no-preference) {
  .reference-card.reveal { animation: reveal .2s ease-out; }
  @keyframes reveal { from { opacity: .35; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
}

/* Admin */
.admin-page { align-items: start; }
.admin-panel { width: min(980px, 100%); }
.admin-header { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.admin-intro { margin-bottom: 0; }
.admin-back { margin-top: 4px; white-space: nowrap; }
.admin-login { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.admin-login label { display: block; margin-bottom: 9px; }
.admin-login-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.admin-login-row .button-primary { margin-top: 0; min-width: 120px; }
.admin-content { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.admin-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.admin-toolbar > div:first-child { display: flex; align-items: center; gap: 10px; }
.admin-toolbar-actions { display: flex; gap: 8px; }
.admin-add-form { padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: #141414; }
.admin-add-form label { display: block; margin: 0 0 9px; }
.admin-add-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: stretch; }
.admin-add-row textarea { min-height: 76px; }
.admin-add-row .button-primary { margin-top: 0; min-width: 110px; }
.admin-question-list { display: grid; gap: 12px; margin-top: 20px; }
.admin-question-row { display: grid; grid-template-columns: 1fr auto; gap: 9px 14px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: #101010; }
.admin-question-meta { grid-column: 1 / -1; color: var(--muted); font-size: .82rem; }
.admin-question-text { min-height: 88px; resize: vertical; }
.admin-question-actions { display: flex; flex-direction: column; gap: 8px; min-width: 92px; }
.button-danger { border: 1px solid rgba(255,141,141,.34); background: #3b1d1d; color: #ffd6d6; padding: 14px 18px; border-radius: 12px; }
.button-danger-small { padding: 11px 14px; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-top: 32px; padding: 18px; border: 1px solid rgba(255,141,141,.35); border-radius: 14px; background: rgba(100, 25, 25, .16); }
.danger-zone p { margin: 6px 0 0; color: var(--muted); }

@media (max-width: 700px) {
  .admin-header, .admin-toolbar, .danger-zone { align-items: stretch; flex-direction: column; }
  .admin-login-row, .admin-add-row, .admin-question-row { grid-template-columns: 1fr; }
  .admin-question-actions { flex-direction: row; }
  .admin-question-actions .button { flex: 1; }
  .admin-toolbar-actions { width: 100%; }
  .admin-toolbar-actions .button { flex: 1; }
}

/* ============================================================
   Random Draw v6 — presentation interface
   Deep navy + mint + warm ivory + coral.
   ============================================================ */
.random-body {
  --random-bg: #07111f;
  --random-surface: #0d1b2a;
  --random-surface-2: #102338;
  --random-line: rgba(175, 204, 230, .16);
  --random-muted: #93a9bd;
  --random-mint: #67e8c3;
  --random-mint-deep: #39caa5;
  --random-ivory: #fff7e8;
  --random-ink: #10202d;
  --random-coral: #ff7a66;
  --random-coral-light: #ff9a88;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% 0%, rgba(103, 232, 195, .10), transparent 35%),
    radial-gradient(circle at 88% 84%, rgba(255, 122, 102, .10), transparent 30%),
    var(--random-bg);
}

.random-shell {
  min-height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 clamp(18px, 4vw, 54px);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.random-topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--random-line);
}

.random-brand,
.random-edit-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.random-brand {
  color: #edf8ff;
  font-weight: 800;
  letter-spacing: -.02em;
}

.random-brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--random-ink);
  background: var(--random-mint);
  box-shadow: 0 8px 26px rgba(103, 232, 195, .18);
}

.random-edit-link {
  color: var(--random-muted);
  font-size: .9rem;
  font-weight: 650;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
}

.random-edit-link:hover {
  color: #fff;
  border-color: var(--random-line);
  background: rgba(255, 255, 255, .035);
}

.random-stage {
  min-height: auto;
  width: min(940px, 100%);
  margin: 0 auto;
  padding: clamp(28px, 5vh, 58px) 0 clamp(28px, 5vh, 52px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.random-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  color: var(--random-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .11em;
  font-weight: 750;
}

.random-meta-chip strong {
  color: #e9f5ff;
  font-size: .94rem;
}

.random-meta-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--random-mint);
  opacity: .8;
}

.draw-zone {
  width: 100%;
  display: grid;
  justify-items: center;
}

.draw-card {
  position: relative;
  width: 100%;
  border-radius: 24px;
  overflow: hidden;
  transition:
    transform .3s cubic-bezier(.2,.8,.2,1),
    box-shadow .3s ease,
    border-color .3s ease;
}

.draw-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, .09);
}

.draw-card-name {
  width: min(560px, 88vw);
  padding: 22px clamp(24px, 5vw, 48px) 28px;
  color: var(--random-ink);
  background: linear-gradient(135deg, #7af0ce, var(--random-mint));
  box-shadow: 0 20px 60px rgba(14, 30, 47, .34);
}

.draw-card-question {
  padding: clamp(24px, 4vw, 38px) clamp(24px, 5vw, 52px) clamp(30px, 5vw, 48px);
  color: var(--random-ink);
  background: var(--random-ivory);
  box-shadow: 0 26px 80px rgba(0, 0, 0, .34);
}

.draw-label {
  margin: 0 0 12px;
  font-size: .71rem;
  line-height: 1;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .58;
}

.slot-window {
  position: relative;
  overflow: hidden;
  display: grid;
  align-items: center;
}

.slot-window::before,
.slot-window::after {
  content: "";
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  height: 18%;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}

.draw-card-name .slot-window::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(103, 232, 195, .92), transparent);
}

.draw-card-name .slot-window::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(103, 232, 195, .92), transparent);
}

.draw-card-question .slot-window::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(255, 247, 232, .96), transparent);
}

.draw-card-question .slot-window::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(255, 247, 232, .96), transparent);
}

.draw-card.is-rolling .slot-window::before,
.draw-card.is-rolling .slot-window::after {
  opacity: 1;
}

.slot-window-name {
  min-height: 62px;
}

.slot-window-question {
  min-height: clamp(118px, 18vh, 180px);
}

.slot-value {
  position: relative;
  z-index: 1;
  overflow-wrap: anywhere;
}

#drawName {
  font-size: clamp(2.15rem, 7vw, 4.7rem);
  line-height: 1;
  letter-spacing: -.055em;
  font-weight: 900;
}

#drawQuestion {
  font-size: clamp(1.45rem, 4vw, 2.7rem);
  line-height: 1.22;
  letter-spacing: -.035em;
  font-weight: 820;
}

.draw-connector {
  width: 70px;
  height: 52px;
  display: grid;
  place-items: center;
}

.draw-connector span {
  width: 2px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(to bottom, var(--random-mint), var(--random-coral));
  opacity: .75;
}

.random-actions {
  margin-top: clamp(26px, 5vh, 46px);
  display: grid;
  justify-items: center;
  text-align: center;
}

.roll-button {
  min-width: 218px;
  min-height: 66px;
  border: 0;
  border-radius: 999px;
  padding: 0 30px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--random-coral-light), var(--random-coral));
  color: #21110d;
  font-weight: 950;
  font-size: 1rem;
  letter-spacing: .08em;
  box-shadow:
    0 16px 40px rgba(255, 122, 102, .22),
    inset 0 1px 0 rgba(255, 255, 255, .35);
  transition:
    transform .18s cubic-bezier(.2,.8,.2,1),
    box-shadow .18s ease,
    filter .18s ease;
}

.roll-button:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.015);
  box-shadow:
    0 20px 52px rgba(255, 122, 102, .30),
    inset 0 1px 0 rgba(255, 255, 255, .4);
}

.roll-button:active:not(:disabled) {
  transform: translateY(0) scale(.985);
}

.roll-button:disabled {
  cursor: wait;
  opacity: 1;
}

.roll-die {
  width: 25px;
  height: 25px;
  position: relative;
  display: block;
  border: 2px solid currentColor;
  border-radius: 7px;
}

.roll-die i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
}

.roll-die i:nth-child(1) { top: 5px; left: 5px; }
.roll-die i:nth-child(2) { top: 5px; right: 5px; }
.roll-die i:nth-child(3) { top: 10px; left: 10px; }
.roll-die i:nth-child(4) { bottom: 5px; left: 5px; }
.roll-die i:nth-child(5) { bottom: 5px; right: 5px; }

.random-shortcut {
  margin: 13px 0 0;
  color: var(--random-muted);
  font-size: .78rem;
}

.random-shortcut kbd {
  display: inline-block;
  margin: 0 3px;
  padding: 2px 7px;
  border: 1px solid var(--random-line);
  border-bottom-color: rgba(175, 204, 230, .28);
  border-radius: 6px;
  background: rgba(255,255,255,.04);
  color: #dbeaf6;
  font: inherit;
  font-weight: 750;
}

.random-status {
  min-height: 20px;
  max-width: 620px;
  margin-top: 10px;
}

.random-footer {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-top: 1px solid var(--random-line);
  color: #61768a;
  font-size: .72rem;
  letter-spacing: .04em;
}

.random-footer-separator {
  color: var(--random-mint);
}

@media (prefers-reduced-motion: no-preference) {
  .slot-value.is-rolling {
    animation: slot-roll .18s linear infinite;
  }

  .draw-card.is-rolling {
    transform: scale(.992);
  }

  .draw-card-name.is-rolling {
    box-shadow:
      0 20px 60px rgba(14, 30, 47, .34),
      0 0 0 4px rgba(103, 232, 195, .12);
  }

  .draw-card-question.is-rolling {
    box-shadow:
      0 26px 80px rgba(0, 0, 0, .34),
      0 0 0 4px rgba(255, 122, 102, .09);
  }

  .slot-value.slot-landed {
    animation: slot-land .48s cubic-bezier(.16, 1, .3, 1);
  }

  .draw-card.card-landed {
    animation: card-land .55s cubic-bezier(.16, 1, .3, 1);
  }

  .roll-button.is-rolling .roll-die {
    animation: die-roll .55s linear infinite;
  }

  @keyframes slot-roll {
    0% { transform: translateY(-12px); filter: blur(2.5px); opacity: .55; }
    50% { transform: translateY(12px); filter: blur(1px); opacity: .9; }
    100% { transform: translateY(-12px); filter: blur(2.5px); opacity: .55; }
  }

  @keyframes slot-land {
    0% { opacity: .1; transform: translateY(-24px) scale(.96); filter: blur(5px); }
    55% { opacity: 1; transform: translateY(4px) scale(1.015); filter: blur(0); }
    100% { transform: translateY(0) scale(1); }
  }

  @keyframes card-land {
    0% { transform: scale(.985); }
    55% { transform: scale(1.012); }
    100% { transform: scale(1); }
  }

  @keyframes die-roll {
    to { transform: rotate(360deg); }
  }
}

@media (max-width: 640px) {
  .random-shell {
    padding-inline: 14px;
  }

  .random-topbar {
    min-height: 66px;
  }

  .random-brand {
    font-size: .9rem;
  }

  .random-brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  .random-edit-link {
    padding-inline: 8px;
    font-size: .82rem;
  }

  .random-stage {
    padding-top: 24px;
  }

  .random-meta {
    margin-bottom: 18px;
    font-size: .7rem;
  }

  .draw-card {
    border-radius: 19px;
  }

  .draw-card-name {
    width: 94%;
    padding: 18px 20px 22px;
  }

  .draw-card-question {
    padding: 22px 22px 28px;
  }

  .slot-window-name {
    min-height: 50px;
  }

  .slot-window-question {
    min-height: 132px;
  }

  .draw-connector {
    height: 38px;
  }

  .draw-connector span {
    height: 23px;
  }

  .roll-button {
    min-width: 200px;
    min-height: 60px;
  }

  .random-shortcut {
    display: none;
  }
}

