/* Nightshade Academy: midnight blue, candle gold, parchment. */
:root {
  --night: #120d24; --night-2: #1c1538; --night-3: #2a2150; --line: #3d3170;
  --gold: #e6c36a; --gold-dim: #9b8446; --parchment: #f1e6c8; --ink: #2b2113;
  --text: #ece6f6; --muted: #a79fc0; --good: #6fd08c; --bad: #ef6f7a;
  --serif: 'EB Garamond', Georgia, serif; --title: 'Cinzel', 'Trajan Pro', Georgia, serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--night); font: 19px/1.5 var(--serif); }
.sky { position: fixed; inset: 0; z-index: -1; background:
  radial-gradient(1px 1px at 12% 18%, #fff8, transparent 60%), radial-gradient(1px 1px at 72% 12%, #fff9, transparent 60%),
  radial-gradient(1.5px 1.5px at 38% 34%, #fffa, transparent 60%), radial-gradient(1px 1px at 88% 44%, #fff7, transparent 60%),
  radial-gradient(1px 1px at 22% 72%, #fff6, transparent 60%), radial-gradient(1.5px 1.5px at 62% 82%, #fff8, transparent 60%),
  radial-gradient(120% 70% at 50% -10%, #3b2a7a 0%, var(--night-2) 45%, var(--night) 100%); }
a { color: var(--gold); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--title); font-weight: 700; letter-spacing: 0.02em; line-height: 1.2; }
h1 { margin: 4px 0 10px; font-size: clamp(26px, 7vw, 38px); color: var(--gold); }
h2 { margin: 28px 0 10px; font-size: 20px; }
h2 small, .small { font-family: var(--serif); font-size: 15px; font-weight: 400; letter-spacing: 0; }
h3 { margin: 0 0 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; }
.muted { color: var(--muted); }
.center { text-align: center; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; max-width: 760px; margin: 0 auto; padding: 16px 16px 6px; }
.crest { font-family: var(--title); font-weight: 700; font-size: 20px; color: var(--gold); text-decoration: none; letter-spacing: 0.04em; }
.house-badge { padding: 3px 12px; border: 1px solid var(--house); border-radius: 999px; font-size: 15px; color: var(--text); background: color-mix(in srgb, var(--house) 22%, transparent); }
.tabs { display: flex; gap: 6px; max-width: 760px; margin: 0 auto; padding: 6px 16px; overflow-x: auto; }
.tabs button { flex: 1; white-space: nowrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font: 600 15px var(--serif); cursor: pointer; }
.tabs button[aria-selected='true'] { background: var(--gold); border-color: var(--gold); color: var(--night); }
main { max-width: 760px; margin: 0 auto; padding: 6px 16px 30px; }
.kicker { margin: 16px 0 0; font-size: 15px; color: var(--gold-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.story { font-style: italic; font-size: 20px; }

.cast { display: grid; gap: 16px; margin: 18px 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #1c153899; }
@media (min-width: 640px) { .cast { grid-template-columns: 1.3fr 1fr; } }
.cast ul { margin: 0 0 12px; padding: 0; list-style: none; }
.cast li { display: grid; grid-template-columns: 34px 1fr; column-gap: 8px; margin-bottom: 8px; }
.cast li .em { grid-row: 1 / 3; font-size: 26px; }
.cast li small { color: var(--muted); font-size: 15px; }
.cast .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cast .chips li { display: block; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 16px; margin: 0; }

.clues { margin: 0; padding: 14px 16px 14px 40px; background: var(--parchment); color: var(--ink); border-radius: 6px; box-shadow: 0 12px 30px -16px #000; }
.clues li { padding: 6px 0; border-bottom: 1px dashed #c8b98f; cursor: pointer; }
.clues li:last-child { border-bottom: 0; }
.clues li.struck { opacity: 0.45; text-decoration: line-through; }

.grid-wrap { overflow-x: auto; }
.grid { border-collapse: collapse; margin: 0 auto; font-size: 15px; }
.grid th { padding: 4px; font-weight: 600; vertical-align: bottom; }
.grid thead th { width: 52px; text-align: center; }
.grid thead th span { display: block; font-size: 22px; }
.grid thead th small { display: block; font-size: 11px; line-height: 1.15; color: var(--muted); font-weight: 400; }
.grid tbody th { text-align: left; white-space: nowrap; padding-right: 8px; }
.grid td { padding: 2px; }
.grid .gap { width: 10px; }
.cell { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 6px; background: var(--night-2); color: var(--text); font-size: 20px; cursor: pointer; }
.cell.m1 { color: var(--bad); background: #3a1a2a; }
.cell.m2 { color: var(--good); background: #173a28; border-color: var(--good); }

.accuse, .result { margin-top: 26px; padding: 18px 16px; border: 1px solid var(--gold-dim); border-radius: 12px; background: #1c1538cc; }
.accuse h2, .result h2 { margin-top: 0; }
.selects { display: grid; gap: 10px; }
@media (min-width: 640px) { .selects { grid-template-columns: repeat(3, 1fr); } }
.selects label { display: grid; gap: 4px; font-size: 15px; color: var(--muted); }
select { width: 100%; padding: 12px; border: 1px solid var(--gold-dim); border-radius: 8px; background: var(--parchment); color: var(--ink); font: 17px var(--serif); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 10px 18px; margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--night-3); color: var(--text); font: 600 17px var(--serif); cursor: pointer; text-decoration: none; }
.btn.gold { width: 100%; background: var(--gold); border-color: var(--gold); color: var(--night); }
.btn small { font-weight: 400; }
.link { background: none; border: 0; color: var(--gold); font: 16px var(--serif); text-decoration: underline; cursor: pointer; margin-top: 20px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row .btn { flex: 1; }
.tries { margin: 14px 0 4px; padding: 0; list-style: none; font-size: 18px; }
.tries li { margin: 4px 0; }
.tries .muted { font-size: 14px; }

.result.won { border-color: var(--good); }
.result.lost { border-color: var(--bad); }
.share-preview { margin: 12px 0 0; padding: 12px; border-radius: 8px; background: var(--night); font: 15px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; }
.truth { width: 100%; margin-top: 18px; border-collapse: collapse; font-size: 16px; }
.truth th, .truth td { padding: 6px; border-bottom: 1px solid var(--line); text-align: left; }
.truth tr.guilty td { color: var(--gold); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 16px; text-align: center; font-size: 13px; color: var(--muted); }
.stats b { display: block; font-size: 26px; color: var(--text); font-family: var(--title); }
.cta { margin-top: 18px; padding: 12px 14px; border: 1px dashed var(--gold-dim); border-radius: 10px; font-size: 17px; }

.bar { height: 6px; margin: 10px 0 18px; border-radius: 999px; background: var(--night-3); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--gold); transition: width 0.3s; }
.q { font-size: clamp(22px, 6vw, 30px); color: var(--text); }
.answers { display: grid; gap: 10px; margin-top: 16px; }
.answer { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #1c1538cc; color: var(--text); font: 18px var(--serif); text-align: left; cursor: pointer; }
.answer:hover, .answer:focus-visible { border-color: var(--gold); }
.house-card { margin-top: 20px; padding: 24px 18px; text-align: center; border: 2px solid var(--house); border-radius: 16px; background: radial-gradient(90% 70% at 50% 0%, color-mix(in srgb, var(--house) 35%, transparent), #1c1538ee); }
.house-card h1 { color: var(--house); font-size: clamp(34px, 10vw, 52px); }
.house-emoji { font-size: 72px; line-height: 1; margin-top: 8px; }
.motto { font-style: italic; font-size: 21px; color: var(--gold); }
.how li { margin-bottom: 10px; }
.tip { padding: 12px 14px; border-left: 3px solid var(--gold); background: #1c153899; }

.foot { max-width: 760px; margin: 0 auto; padding: 10px 16px 40px; text-align: center; font-size: 15px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: 90vw; padding: 12px 18px; border: 1px solid var(--gold-dim); border-radius: 10px; background: var(--night-2); box-shadow: 0 10px 30px #000a; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (max-width: 520px) {
  .grid thead th { width: 36px; }
  .grid thead th small { font-size: 9.5px; }
  .grid tbody th { white-space: normal; max-width: 92px; font-size: 13px; line-height: 1.15; }
  .cell { width: 34px; height: 34px; font-size: 16px; }
  .grid .gap { width: 4px; }
}

/* ---------- motion: stars, sparkles, reveals (off for people who ask for less motion) ---------- */
.top-right { display: inline-flex; align-items: center; gap: 8px; }
.sound-btn { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: #1c1538cc; color: var(--text); font-size: 18px; cursor: pointer; }
.sound-btn[aria-pressed='true'] { border-color: var(--gold); box-shadow: 0 0 12px #e6c36a66; }
.sky .stars { position: absolute; inset: -20%; background-repeat: repeat; }
.sky .s1 { background-image: radial-gradient(1.4px 1.4px at 20px 30px, #fff, transparent), radial-gradient(1px 1px at 140px 90px, #fffc, transparent), radial-gradient(1.2px 1.2px at 260px 160px, #fff, transparent), radial-gradient(1px 1px at 80px 220px, #fffa, transparent); background-size: 320px 260px; animation: twinkle 5s ease-in-out infinite alternate; }
.sky .s2 { background-image: radial-gradient(1px 1px at 60px 60px, #fff, transparent), radial-gradient(1.6px 1.6px at 200px 20px, #ffeebb, transparent), radial-gradient(1px 1px at 300px 200px, #fff, transparent); background-size: 380px 300px; animation: twinkle 7s ease-in-out -3s infinite alternate, drift 180s linear infinite; }
.sky .moon { position: absolute; top: 40px; right: 8%; width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff7d6, #e6c36a 60%, transparent 62%); box-shadow: 0 0 60px 20px #e6c36a22; opacity: 0.55; animation: glow 6s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: 0.35; } to { opacity: 1; } }
@keyframes drift { from { transform: translateY(0); } to { transform: translateY(-300px); } }
@keyframes glow { from { box-shadow: 0 0 40px 10px #e6c36a1a; } to { box-shadow: 0 0 80px 26px #e6c36a33; } }
.motes { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.motes i { position: absolute; bottom: -20px; width: 4px; height: 4px; border-radius: 50%; background: #ffe9a8; box-shadow: 0 0 8px 2px #e6c36a88; opacity: 0; animation: rise 16s linear infinite; }
.motes i:nth-child(1) { left: 8%; animation-delay: 0s; } .motes i:nth-child(2) { left: 22%; animation-delay: 4s; animation-duration: 19s; }
.motes i:nth-child(3) { left: 37%; animation-delay: 9s; } .motes i:nth-child(4) { left: 51%; animation-delay: 2s; animation-duration: 21s; }
.motes i:nth-child(5) { left: 64%; animation-delay: 12s; } .motes i:nth-child(6) { left: 76%; animation-delay: 6s; animation-duration: 18s; }
.motes i:nth-child(7) { left: 88%; animation-delay: 10s; } .motes i:nth-child(8) { left: 95%; animation-delay: 1s; animation-duration: 23s; }
@keyframes rise { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: 0.8; } 50% { transform: translate(18px, -50vh); } 90% { opacity: 0.6; } 100% { transform: translate(-12px, -105vh); opacity: 0; } }

.panel > * { animation: rise-in 0.5s ease both; }
.panel > *:nth-child(2) { animation-delay: 0.05s; } .panel > *:nth-child(3) { animation-delay: 0.1s; } .panel > *:nth-child(4) { animation-delay: 0.15s; } .panel > *:nth-child(5) { animation-delay: 0.2s; }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.clues li { transition: opacity 0.25s, background 0.25s; }
.cell { transition: transform 0.12s, background 0.2s; }
.cell:active { transform: scale(0.9); }
.shake { animation: shake 0.45s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.result.won { animation: won-glow 2.4s ease-in-out 2; }
@keyframes won-glow { 50% { box-shadow: 0 0 40px 4px #6fd08c55; } }
.house-card { animation: reveal 0.7s cubic-bezier(.2,.9,.3,1.3) both; }
.house-emoji { display: inline-block; animation: float 3.5s ease-in-out infinite; }
@keyframes reveal { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: none; } }
@keyframes float { 50% { transform: translateY(-8px) rotate(-4deg); } }
.answer { transition: transform 0.15s, border-color 0.15s, background 0.15s; }
.answer:active { transform: scale(0.98); background: #2a2150; }
.burst { position: fixed; z-index: 50; width: 0; height: 0; pointer-events: none; }
.burst span { position: absolute; left: 0; top: 0; color: #ffe39a; font-size: 18px; text-shadow: 0 0 8px #e6c36a; animation: spark 1.1s ease-out forwards; }
@keyframes spark { from { transform: translate(-50%, -50%) scale(0.4); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1) rotate(160deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .motes { display: none; }
}
.sky { overflow: hidden; }
