@font-face {
  font-family: "Bungee";
  src: url("/fonts/bungee-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Anton";
  src: url("/fonts/anton-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0b0912;
  --bg-2: #141020;
  --surface: #1a1527;
  --surface-2: #241d36;
  --surface-3: #2e2544;
  --border: #3b3054;
  --text: #f7f2e8;
  --muted: #b9afcb;
  --gold: #f5c542;
  --gold-deep: #b9861f;
  --red: #e63946;
  --red-deep: #8f0a14;
  --teal: #2ec4b6;
  --focus: #7fd1ff;
  --display: "Bungee", "Arial Black", Impact, sans-serif;
  --condensed: "Anton", Impact, "Arial Narrow", sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.5;
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(245, 197, 66, 0.22), transparent 70%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(230, 57, 70, 0.14), transparent 70%),
    repeating-linear-gradient(90deg, transparent 0 78px, rgba(255, 255, 255, 0.018) 78px 80px),
    var(--bg);
  background-attachment: fixed;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

a { color: var(--gold); }

button, .button {
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  border: 2px solid transparent;
  padding: 10px 20px;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-3);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
}

button:active:not(:disabled) { transform: translateY(1px) scale(0.98); }

button:disabled { opacity: 0.45; cursor: not-allowed; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.primary {
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  color: #1b1200;
  box-shadow: 0 4px 0 #6b4a0b;
}

.danger { background: transparent; border-color: var(--red); color: #ff8a92; }

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

.small { padding: 6px 14px; font-size: 0.9rem; }

input[type="text"], input[type="password"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  min-width: 0;
  width: 100%;
}

textarea { resize: vertical; min-height: 4.5em; }

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

.error { color: #ff8a92; font-weight: 700; min-height: 1.5em; margin: 8px 0 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.kicker {
  font-family: var(--condensed);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  font-size: 0.85rem;
}

/* ---------- Header ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.topbar-actions { display: flex; gap: 8px; }

.icon-btn { padding: 8px 14px; font-size: 0.95rem; white-space: nowrap; background: rgba(255, 255, 255, 0.06); border-color: var(--border); }

@media (max-width: 520px) {
  .topbar { justify-content: center; }
  .topbar > .kicker { display: none; }
  .icon-btn { padding: 7px 12px; font-size: 0.9rem; }
}

.masthead { text-align: center; margin: 8px 0 28px; }

.masthead h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 7.2vw, 4.4rem);
  line-height: 1.02;
  margin: 6px 0 10px;
  color: var(--gold);
  text-shadow: 0 2px 0 #c0392b, 0 4px 0 var(--red-deep), 0 8px 18px rgba(0, 0, 0, 0.6);
  text-wrap: balance;
}

.tagline {
  font-family: var(--condensed);
  font-size: clamp(1.2rem, 3.6vw, 1.7rem);
  letter-spacing: 0.06em;
  margin: 0;
  color: var(--text);
}

/* ---------- Stage ---------- */

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

@media (max-width: 880px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
}

.accused { margin-bottom: 18px; text-align: center; }

.accused .kicker { display: block; margin-bottom: 10px; }

.names { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.name-btn {
  font-family: var(--condensed);
  font-weight: 400;
  letter-spacing: 0.06em;
  font-size: 1.25rem;
  padding: 10px 26px;
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
}

.name-btn[aria-pressed="true"] {
  background: var(--red);
  border-color: #ff8a92;
  box-shadow: 0 0 0 4px rgba(230, 57, 70, 0.25), 0 0 24px rgba(230, 57, 70, 0.45);
}

.wheel-wrap {
  position: relative;
  width: min(100%, 540px);
  margin: 0 auto;
  aspect-ratio: 1;
  padding: 4.2%;
  border-radius: 50%;
  background: radial-gradient(circle, #3a2a10 60%, #1d1406 100%);
  box-shadow: 0 0 0 6px var(--gold-deep), 0 0 0 10px #4a3510, var(--shadow), 0 0 80px rgba(245, 197, 66, 0.18);
}

.wheel-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  will-change: transform;
}

.bulb {
  position: absolute;
  width: 2.3%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #ffe9a8;
  box-shadow: 0 0 6px 2px rgba(255, 220, 120, 0.7);
}

.wheel-wrap.spinning .bulb { animation: chase 0.5s steps(1) infinite; }
.wheel-wrap.spinning .bulb:nth-child(odd) { animation-delay: 0.25s; }
.wheel-wrap.landed .bulb { animation: blink 0.35s steps(1) 6; }

@keyframes chase {
  0% { background: #ffe9a8; box-shadow: 0 0 8px 3px rgba(255, 220, 120, 0.85); }
  50% { background: #6b5320; box-shadow: none; }
}

@keyframes blink { 50% { background: var(--red); box-shadow: 0 0 10px 3px rgba(230, 57, 70, 0.8); } }

.pointer {
  position: absolute;
  top: -4%;
  left: 50%;
  width: 9%;
  aspect-ratio: 0.8;
  transform: translateX(-50%);
  transform-origin: 50% 20%;
  z-index: 3;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.6));
}

.pointer svg { width: 100%; height: 100%; display: block; }

.hub {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 17%;
  aspect-ratio: 1;
  border-radius: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff1c0, var(--gold) 45%, var(--gold-deep));
  box-shadow: 0 0 0 4px #4a3510, 0 6px 14px rgba(0, 0, 0, 0.6);
  color: #3b2600;
  font-family: var(--display);
  font-size: clamp(0.55rem, 1.6vw, 0.85rem);
  line-height: 1;
  text-align: center;
}

.spin-row { text-align: center; margin-top: 26px; }

.spin-btn {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  letter-spacing: 0.06em;
  padding: 14px 54px;
  min-width: min(100%, 280px);
  background: linear-gradient(180deg, #ff5a66, var(--red) 55%, #b3202c);
  color: #fff;
  border-color: #ffb3b9;
  box-shadow: 0 6px 0 var(--red-deep), 0 10px 30px rgba(230, 57, 70, 0.45);
}

.spin-btn:not(:disabled):hover { box-shadow: 0 6px 0 var(--red-deep), 0 10px 40px rgba(230, 57, 70, 0.7); }

.spin-btn:disabled { background: var(--surface-3); border-color: var(--border); box-shadow: none; color: var(--muted); opacity: 1; }

.status {
  font-family: var(--condensed);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  min-height: 1.6em;
  margin: 14px 0 0;
}

.status.ominous { color: var(--gold); animation: flicker 1.1s ease-in-out infinite; }

@keyframes flicker { 50% { opacity: 0.55; } }

.practice-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: -8px 0 24px;
  padding: 12px 16px;
  border-radius: 14px;
  color: #d9fffb;
  border: 2px solid var(--teal);
  background: repeating-linear-gradient(135deg, rgba(46, 196, 182, 0.18) 0 16px, rgba(46, 196, 182, 0.08) 16px 32px);
}

.practice-bar[hidden] { display: none; }

.sealed {
  margin: 16px auto 0;
  max-width: 460px;
  padding: 10px 16px;
  border: 2px dashed var(--red);
  border-radius: 12px;
  color: #ffc2c7;
  font-weight: 700;
  text-align: center;
}

/* ---------- Case file (result card) ---------- */

.case {
  position: relative;
  overflow: hidden;
  min-height: 300px;
}

.case::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: repeating-linear-gradient(135deg, var(--gold) 0 14px, #1b1200 14px 28px);
}

.case-empty { text-align: center; padding: 36px 8px; }

.case-empty .seal {
  font-family: var(--display);
  font-size: 3.2rem;
  color: var(--surface-3);
  line-height: 1;
  margin-bottom: 12px;
}

.case-empty h2 { font-family: var(--condensed); font-weight: 400; letter-spacing: 0.06em; font-size: 1.6rem; margin: 0 0 6px; }

.case.revealed { animation: reveal 0.6s cubic-bezier(0.2, 1.3, 0.4, 1); border-color: var(--gold-deep); }

@keyframes reveal {
  from { transform: translateY(16px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.case-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 4px; }

.case-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.6rem, 4.4vw, 2.3rem);
  line-height: 1.08;
  color: var(--gold);
  margin: 10px 0 12px;
  overflow-wrap: anywhere;
}

.case-intro {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 14px;
  padding-left: 14px;
  border-left: 4px solid var(--red);
}

.case h3 {
  font-family: var(--condensed);
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-size: 0.95rem;
  margin: 18px 0 6px;
}

.case ul.reqs { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }

.case ul.reqs li { padding-left: 28px; position: relative; }

.case ul.reqs li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.32em;
  width: 15px;
  height: 15px;
  border: 2px solid var(--gold);
  border-radius: 4px;
}

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

.chip {
  background: rgba(245, 197, 66, 0.1);
  border: 1px solid rgba(245, 197, 66, 0.35);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.92rem;
}

.note {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(46, 196, 182, 0.12);
  border: 1px solid rgba(46, 196, 182, 0.4);
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 480px) { .facts { grid-template-columns: minmax(0, 1fr); } }

.fact { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }

.fact .kicker { display: block; font-size: 0.75rem; }

.outro {
  font-style: italic;
  font-size: 1.08rem;
  color: var(--muted);
  margin: 20px 0 0;
  text-align: center;
}

.accept-row { margin-top: 20px; text-align: center; }

.accept-btn { font-family: var(--condensed); font-weight: 400; letter-spacing: 0.1em; font-size: 1.3rem; padding: 12px 32px; }

.stamp {
  display: inline-block;
  font-family: var(--display);
  color: var(--red);
  border: 4px solid var(--red);
  border-radius: 10px;
  padding: 6px 16px;
  transform: rotate(-4deg);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  animation: stamp 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.stamp small { display: block; font-family: var(--body); font-size: 0.75rem; font-weight: 700; letter-spacing: 0; }

@keyframes stamp { from { transform: rotate(-4deg) scale(2.2); opacity: 0; } }

/* ---------- History ---------- */

.rulings { margin-top: 28px; }

.rulings h2 { font-family: var(--condensed); font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase; margin: 0 0 10px; }

.log-list { list-style: none; margin: 0; padding: 0; }

.log-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.log-list li:last-child { border-bottom: 0; }

.log-what { font-weight: 700; overflow-wrap: anywhere; }

.log-who { color: var(--gold); font-family: var(--condensed); letter-spacing: 0.06em; margin-right: 8px; }

.log-when { color: var(--muted); font-size: 0.88rem; text-align: right; white-space: nowrap; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 6px;
  vertical-align: 2px;
}

.badge.pending { background: rgba(230, 57, 70, 0.2); color: #ffb3b9; }
.badge.accepted { background: rgba(46, 196, 182, 0.18); color: #8cefe5; }

footer { text-align: center; margin-top: 36px; font-size: 0.95rem; color: var(--muted); }

/* ---------- Dialogs ---------- */

dialog {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 26px 22px 22px;
  width: min(460px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(5, 3, 10, 0.72); }

dialog h2 { font-family: var(--condensed); font-weight: 400; letter-spacing: 0.06em; font-size: 1.6rem; margin: 0 0 6px; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* ---------- Parent page ---------- */

.stack { display: grid; gap: 24px; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

.section-head h2 { margin: 0; font-family: var(--condensed); font-weight: 400; letter-spacing: 0.08em; text-transform: uppercase; }

.row-form { display: flex; gap: 10px; flex-wrap: wrap; }

.row-form input { flex: 1 1 200px; width: auto; }

.edit-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }

.edit-list li { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.edit-list input[type="text"] { flex: 1 1 180px; width: auto; }

.con-row {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.con-row.off { opacity: 0.55; }

.con-row .con-title { font-weight: 700; overflow-wrap: anywhere; }

.con-row .con-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 560px) {
  .con-row { grid-template-columns: auto minmax(0, 1fr); }
  .con-row .con-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

.switch { width: 22px; height: 22px; accent-color: var(--gold); }

.form-grid { display: grid; gap: 12px; }

.form-grid label { display: grid; gap: 4px; font-weight: 700; font-size: 0.95rem; }

.form-grid .hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }

.form-grid input, .form-grid textarea { font-weight: 400; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }

@media (max-width: 560px) { .two-col { grid-template-columns: minmax(0, 1fr); } }

dialog.wide { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }

th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }

th { color: var(--muted); font-weight: 700; }

td.wrap { overflow-wrap: anywhere; }

.login { max-width: 440px; margin: 40px auto; }

.saved { color: var(--muted); font-size: 0.9rem; }

.lock-status { font-weight: 700; }

.lock-status.sealed-text { color: #ffb3b9; }

.lock-status.open-text { color: #8cefe5; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
