:root {
  --bg: #0f1020;
  --panel: #181a30;
  --panel-2: #20223d;
  --line: #2e3155;
  --text: #ecebf5;
  --muted: #9a9bbd;
  --accent: #c9a8ff;
  --accent-2: #8f6cf0;
  --hit: #5fd3a4;
  --miss: #f08a8a;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #2a2160 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, sans-serif;
  min-height: 100vh;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 32px 20px 64px; }
header { text-align: center; margin-bottom: 28px; }
h1 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600; font-size: 52px; letter-spacing: 0.04em;
  margin: 0; line-height: 1;
  background: linear-gradient(180deg, #fff, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tag { color: var(--muted); margin-top: 8px; }
.card {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px;
}
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 0 0 14px; font-weight: 600; }
label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
input[type=text], select {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font: inherit;
}
input[type=text]:focus, select:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.row { display: grid; grid-template-columns: 1fr 160px; gap: 14px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } h1 { font-size: 42px; } }
button {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent;
  padding: 11px 18px; font-weight: 600;
}
.btn-primary { background: var(--accent-2); color: #fff; }
.btn-primary:hover { background: #9f80f5; }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }
.hash { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }

/* Game */
.status { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.status .who { font-weight: 600; }
.status .count { color: var(--muted); }
.progress { height: 4px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-bottom: 22px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); width: 0; transition: width .3s; }
.prompt { text-align: center; color: var(--muted); margin-bottom: 16px; min-height: 24px; }
.choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 560px) { .choices { grid-template-columns: repeat(2, 1fr); } }
.choice {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px;
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--text); transition: transform .12s, border-color .12s, background .12s; padding: 10px;
}
.choice:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); }
.choice:disabled { cursor: default; }
.choice svg { width: 56%; height: auto; }
.choice span { font-size: 13px; color: var(--muted); font-weight: 500; }
.choice.picked { border-color: var(--accent); }
.choice.target-hit { background: color-mix(in srgb, var(--hit) 22%, var(--panel-2)); border-color: var(--hit); }
.choice.target-miss { background: color-mix(in srgb, var(--miss) 18%, var(--panel-2)); border-color: var(--miss); }
.choice.dim { opacity: .35; }
.reveal { text-align: center; margin-top: 18px; min-height: 48px; }
.reveal .verdict { font-family: "Cormorant Garamond", Georgia, serif; font-size: 26px; font-weight: 600; }
.verdict.hit { color: var(--hit); }
.verdict.miss { color: var(--miss); }
.trail { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; justify-content: center; }
.pip { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); }
.pip svg { width: 14px; height: 14px; }
.pip.hit { border-color: var(--hit); background: color-mix(in srgb, var(--hit) 20%, var(--panel-2)); }
.pip.miss { border-color: color-mix(in srgb, var(--miss) 60%, var(--line)); }

/* Scramble */
.scramble-title { text-align: center; font-family: "Cormorant Garamond", Georgia, serif; font-size: 28px; font-weight: 600; color: var(--accent); margin-bottom: 22px; }
.slots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; max-width: 560px; margin: 0 auto; }
@media (max-width: 560px) { .slots { gap: 5px; } }
.slot {
  aspect-ratio: 3 / 4; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line);
  display: grid; place-items: center; position: relative; overflow: hidden;
  transition: transform .35s, border-color .35s, background .35s, box-shadow .35s;
}
.slot svg { width: 58%; height: auto; color: var(--muted); }
.slot.spinning svg { animation: flick .09s linear infinite alternate; }
@keyframes flick { from { opacity: .45; transform: scale(.9) rotate(-6deg); } to { opacity: 1; transform: scale(1.04) rotate(6deg); } }
.slot.locked {
  background: linear-gradient(160deg, #3a2a78, #1d1640); border-color: var(--accent);
  transform: rotateY(180deg); box-shadow: 0 0 18px -4px var(--accent-2);
}
.slot.locked::after {
  content: "?"; position: absolute; inset: 0; display: grid; place-items: center;
  font-family: "Cormorant Garamond", Georgia, serif; font-size: 30px; color: var(--accent);
  transform: rotateY(180deg);
}
.slot.locked svg { display: none; }
.scramble-sub { text-align: center; color: var(--muted); margin-top: 20px; min-height: 40px; font-size: 13px; }
.scramble-sub .hash { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .slot.spinning svg { animation: none; } .slot { transition: none; } }

/* Result */
.score { text-align: center; }
.score .big { font-family: "Cormorant Garamond", Georgia, serif; font-size: 84px; font-weight: 600; line-height: 1; color: var(--accent); font-variant-numeric: lining-nums; font-feature-settings: "lnum" 1; }
.score .big .of { font-size: .55em; color: var(--muted); margin-left: 2px; }
.score .bigrow { display: flex; justify-content: center; align-items: center; gap: 36px; margin-top: 6px; }
.score .bigrow .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; margin-top: 6px; }
.score .divider { width: 1px; align-self: stretch; background: var(--line); }
@media (max-width: 560px) { .score .big { font-size: 60px; } .score .bigrow { gap: 22px; } }
.score .sub { color: var(--muted); margin-top: 14px; }
.score .read { margin-top: 14px; font-size: 16px; }
.seq { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 4px 14px; font-size: 13px; margin-top: 18px; max-height: 280px; overflow: auto; }
.seq div { padding: 4px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 6px; }
.seq .h { color: var(--muted); font-weight: 600; }
.seq svg { width: 14px; height: 14px; }

/* Log */
.log-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.log-head h2 { margin: 0; }
.filter { display: flex; gap: 8px; align-items: center; }
.filter select { width: auto; padding: 7px 10px; font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--panel-2); border-radius: 10px; padding: 12px; }
.stat .v { font-size: 22px; font-weight: 600; }
.stat .l { font-size: 12px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
tr.detail td { background: var(--panel-2); padding: 10px 12px; }
.mini { display: flex; flex-wrap: wrap; gap: 4px; }
.empty { color: var(--muted); text-align: center; padding: 20px 0; }
.note { color: var(--muted); font-size: 12px; margin-top: 12px; }
.hidden { display: none !important; }
/* Nav */
.nav { display: flex; justify-content: center; gap: 6px; margin-top: 18px; }
.nav a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; padding: 7px 14px; border-radius: 999px; border: 1px solid transparent; }
.nav a:hover { color: var(--text); border-color: var(--line); }
.nav a.on { color: var(--text); background: var(--panel-2); border-color: var(--line); }
a.btn-ghost { display: inline-flex; align-items: center; text-decoration: none; border-radius: 10px; padding: 11px 18px; font-weight: 600; border: 1px solid var(--line); }


/* Hidden card during play */
.mystery-wrap { position: relative; display: flex; justify-content: center; align-items: center; height: 160px; margin-bottom: 8px; perspective: 800px; }
.mystery {
  position: relative; overflow: hidden;
  width: 104px; aspect-ratio: 3 / 4; border-radius: 14px;
  background:
    radial-gradient(circle at 50% 50%, transparent 38%, rgba(201,168,255,.08) 39%, transparent 41%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.03) 0 6px, transparent 6px 12px),
    linear-gradient(160deg, #3a2a78, #1d1640);
  border: 1px solid var(--accent);
  box-shadow: 0 0 22px -4px var(--accent-2), inset 0 0 0 4px rgba(201,168,255,.12);
  display: grid; place-items: center; user-select: none;
  font-family: "Cormorant Garamond", Georgia, serif; font-size: 64px; font-weight: 600; color: var(--accent);
  animation: hover-float 3s ease-in-out infinite;
  transform-style: preserve-3d;
}
.mystery .q { text-shadow: 0 0 18px rgba(201,168,255,.7); animation: q-glow 2.4s ease-in-out infinite; }
.mystery::after {
  content: ""; position: absolute; inset: -40%;
  background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.35) 50%, transparent 60%);
  transform: translateX(-120%); pointer-events: none;
}
.mystery.deal { animation: deal-in .7s cubic-bezier(.2,.9,.25,1.15), hover-float 3s ease-in-out .7s infinite; }
.mystery.deal::after { animation: shimmer .9s ease-out .45s; }
.mystery.sealed { animation: none; transform: scale(.92); box-shadow: 0 0 40px 0 var(--accent); transition: transform .18s, box-shadow .18s; }
.mystery.exit { animation: card-exit .4s ease-in forwards; }
@keyframes deal-in {
  0%   { opacity: 0; transform: translate(-160px, -60px) rotateY(-540deg) rotateZ(-25deg) scale(.35); filter: blur(3px); }
  60%  { opacity: 1; transform: translate(8px, 4px) rotateY(-20deg) rotateZ(3deg) scale(1.08); filter: blur(0); }
  100% { transform: none; }
}
@keyframes card-exit {
  0%   { transform: scale(.92); opacity: 1; }
  100% { transform: translate(140px, 40px) rotateZ(35deg) rotateY(80deg) scale(.4); opacity: 0; }
}
@keyframes shimmer { to { transform: translateX(120%); } }
@keyframes hover-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes q-glow { 0%, 100% { opacity: .85; } 50% { opacity: 1; text-shadow: 0 0 26px rgba(201,168,255,.95); } }

.spark {
  position: absolute; left: 50%; top: 50%; color: #e7d6ff; pointer-events: none;
  text-shadow: 0 0 8px var(--accent);
  animation: spark-out .85s ease-out forwards;
}
@keyframes spark-out {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.3); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(1); }
}
.ripple {
  position: absolute; left: 50%; top: 50%; width: 110px; height: 146px; border-radius: 16px;
  border: 2px solid var(--accent); pointer-events: none;
  animation: ripple-out .85s ease-out forwards;
}
@keyframes ripple-out {
  0%   { opacity: .9; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.7); }
}
@media (prefers-reduced-motion: reduce) {
  .mystery, .mystery.deal, .mystery .q, .mystery.deal::after { animation: none; }
}

/* Card reveal on results */
.reveal-row { margin: 22px auto 6px; perspective: 600px; }
.slot.hit { border-color: var(--hit); background: color-mix(in srgb, var(--hit) 18%, var(--panel-2)); }
.slot.hit svg { color: var(--hit); }
.slot.miss { border-color: color-mix(in srgb, var(--miss) 55%, var(--line)); }
.slot.miss svg { color: var(--text); }

/* Footer banner */
.site-foot {
  display: flex; align-items: center; gap: 12px;
  margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--line);
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 14px; color: var(--muted);
}
.site-foot img { width: 28px; height: 28px; border-radius: 6px; flex: none; }
.site-foot span { flex: 1; min-width: 0; line-height: 1.6; }
.site-foot a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.site-foot a:hover { color: #fff; }
@media (max-width: 560px) { .site-foot { font-size: 12px; } }
