/* ===== Tokens ===== */
:root {
  --bg: #05060d;
  --ink: #eeeaff;
  --muted: #a3a8cc;
  --dim: #6e7397;
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .16);
  --glass: rgba(16, 19, 42, .62);
  --glass-2: rgba(20, 23, 52, .86);
  --accent: #9b87f5;
  --accent-rgb: 155, 135, 245;
  --accent2: #f5d27a;
  --on-accent: #120c26;
  --good: #3ddc97;
  --bad: #ff5d73;
  --r: 20px;
  --top: 64px;
  --display: 'Cinzel', 'Times New Roman', serif;
  --body: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}
body[data-house="gryffindor"] { --accent: #e5484d; --accent-rgb: 229, 72, 77; --accent2: #f2c14e; --on-accent: #fff; }
body[data-house="slytherin"]  { --accent: #2fbf7a; --accent-rgb: 47, 191, 122; --accent2: #d6dde4; --on-accent: #03140b; }
body[data-house="ravenclaw"]  { --accent: #5b8cff; --accent-rgb: 91, 140, 255; --accent2: #e0a86c; --on-accent: #fff; }
body[data-house="hufflepuff"] { --accent: #f4c430; --accent-rgb: 244, 196, 48; --accent2: #fff1c1; --on-accent: #1a1400; }

/* ===== Base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 620px at 50% -12%, rgba(var(--accent-rgb), .22), transparent 62%),
    radial-gradient(800px 600px at 100% 110%, rgba(90, 70, 220, .16), transparent 60%),
    radial-gradient(700px 500px at -10% 80%, rgba(40, 120, 200, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color .6s;
}
button { font: inherit; color: inherit; }
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .72em; padding: 1px 6px; border-radius: 6px;
  border: 1px solid var(--line-2); background: rgba(255, 255, 255, .06); color: var(--muted);
}
:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: .02em; line-height: 1.15; }
.eyebrow { font-size: 12px; letter-spacing: .28em; text-transform: uppercase; color: var(--accent2); font-weight: 600; }
.muted { color: var(--muted); }
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

/* floating candles */
.candles { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.candle {
  position: absolute; width: 8px; height: 34px; border-radius: 2px;
  background: linear-gradient(90deg, #d9cfb4, #fbf4e2 40%, #cfc3a3);
  opacity: .5; animation: floaty var(--dur, 7s) ease-in-out infinite; animation-delay: var(--delay, 0s);
}
.candle::before {
  content: ''; position: absolute; left: 50%; top: -14px; width: 8px; height: 14px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 70%, #fff8d0, #ffb347 55%, rgba(255, 120, 40, 0) 75%);
  transform: translateX(-50%); animation: flicker .16s infinite alternate;
}
.candle::after {
  content: ''; position: absolute; left: 50%; top: -34px; width: 70px; height: 70px; transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 190, 90, .32), transparent 65%);
}
@keyframes floaty { 0%, 100% { transform: translateY(0) scale(var(--s, 1)); } 50% { transform: translateY(-16px) scale(var(--s, 1)); } }
@keyframes flicker { from { transform: translateX(-50%) scale(1, 1); } to { transform: translateX(-50%) scale(.82, 1.12); } }
body.playing .candles { display: none; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 clamp(16px, 4vw, 40px);
  background: linear-gradient(180deg, rgba(5, 6, 13, .9), rgba(5, 6, 13, .55));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer;
  font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: .06em;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 20px -6px rgba(var(--accent-rgb), .8);
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.pill[hidden] { display: none; }
.points-pill span { color: var(--accent2); }
.points-pill strong { font-variant-numeric: tabular-nums; }
.house-pill { border-color: rgba(var(--accent-rgb), .5); background: rgba(var(--accent-rgb), .14); }
.icon-btn {
  width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .05); cursor: pointer; font-size: 15px;
  transition: background .2s, border-color .2s, transform .2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .1); border-color: var(--line-2); }
.icon-btn.on { background: rgba(var(--accent-rgb), .28); border-color: rgba(var(--accent-rgb), .8); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), .5); } 50% { box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0); } }
@media (max-width: 520px) { .brand-text, .hp-name { display: none; } }

/* ===== Screens ===== */
main { position: relative; z-index: 1; }
.screen { display: none; max-width: 1180px; margin: 0 auto; padding: clamp(16px, 4vw, 40px); }
.screen.active { display: block; animation: screenIn .5s cubic-bezier(.2, .8, .2, 1); }
@keyframes screenIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--line-2); background: rgba(255, 255, 255, .05);
  font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap;
  transition: background .2s, transform .2s, box-shadow .2s, border-color .2s;
}
.btn:hover { background: rgba(255, 255, 255, .1); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary {
  border-color: transparent; color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--accent2)));
  box-shadow: 0 10px 30px -10px rgba(var(--accent-rgb), .9), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn.primary:hover { box-shadow: 0 14px 36px -10px rgba(var(--accent-rgb), 1), inset 0 1px 0 rgba(255, 255, 255, .3); transform: translateY(-1px); }
.btn.lg { min-height: 52px; padding: 0 28px; font-size: 16px; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn[hidden] { display: none; }

/* ===== Home ===== */
.hero { text-align: center; padding: clamp(24px, 7vh, 72px) 0 clamp(20px, 5vh, 48px); }
.hero h1 {
  font-size: clamp(52px, 11vw, 120px); font-weight: 900; line-height: .95; margin: 14px 0 18px;
  background: linear-gradient(180deg, #fff 25%, var(--accent2) 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 34px rgba(var(--accent-rgb), .45));
}
.lede { max-width: 580px; margin: 0 auto; color: var(--muted); font-size: clamp(15px, 2vw, 18px); }
.lede b { color: var(--ink); }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }

.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.mode-card {
  position: relative; overflow: hidden; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 8px; padding: 26px;
  border-radius: var(--r); border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .015));
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), border-color .3s, box-shadow .3s;
}
.mode-card::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(380px 200px at var(--mx, 50%) var(--my, 0%), rgba(var(--accent-rgb), .28), transparent 65%);
}
.mode-card:hover { transform: translateY(-5px); border-color: rgba(var(--accent-rgb), .55); box-shadow: 0 24px 50px -24px rgba(var(--accent-rgb), .8); }
.mode-card:hover::before { opacity: 1; }
.mode-card > * { position: relative; }
.mode-icon { font-size: 42px; line-height: 1; filter: drop-shadow(0 8px 18px rgba(var(--accent-rgb), .5)); }
.mode-card h3 { font-size: 23px; margin-top: 8px; }
.mode-card p { color: var(--muted); font-size: 14px; }
.mode-card .tag {
  position: absolute; top: 20px; right: 20px; font-size: 11px; font-weight: 600; color: var(--accent2);
  padding: 3px 10px; border-radius: 999px; border: 1px solid rgba(245, 210, 122, .3); background: rgba(245, 210, 122, .08);
}
.mode-card .go { margin-top: auto; padding-top: 10px; font-weight: 600; font-size: 14px; color: var(--accent2); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 22px 0 10px; }
.stat {
  padding: 16px 20px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03);
  display: flex; flex-direction: column; gap: 2px;
}
.stat span { font-size: 12px; color: var(--muted); }
.stat strong { font-family: var(--display); font-size: 26px; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .stats { grid-template-columns: 1fr; } .stat { flex-direction: row; justify-content: space-between; align-items: center; } .stat strong { font-size: 20px; } }

/* ===== Levels ===== */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 18px; }
.section-head h2 { font-size: clamp(26px, 4vw, 36px); margin-top: 4px; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin-bottom: 48px; }
.level-card {
  position: relative; overflow: hidden; text-align: left; cursor: pointer; min-height: 230px;
  display: flex; flex-direction: column; gap: 6px; padding: 20px;
  border-radius: var(--r); border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .015));
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), border-color .3s, box-shadow .3s;
}
.level-card:hover:not(:disabled) { transform: translateY(-5px); border-color: rgba(var(--accent-rgb), .55); box-shadow: 0 20px 44px -20px rgba(var(--accent-rgb), .8); }
.level-num { font-family: var(--display); font-size: 13px; color: var(--accent2); letter-spacing: .2em; }
.level-emoji { font-size: 46px; line-height: 1; margin: 6px 0 4px; filter: drop-shadow(0 8px 18px rgba(var(--accent-rgb), .55)); }
.level-card h3 { font-size: 20px; }
.level-card p { font-size: 13px; color: var(--muted); }
.level-foot { margin-top: auto; padding-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 10%, transparent);
}
.stars { color: rgba(255, 255, 255, .16); letter-spacing: 2px; font-size: 17px; white-space: nowrap; }
.stars .on { color: var(--accent2); text-shadow: 0 0 10px rgba(245, 210, 122, .6); }
.level-card:disabled { cursor: not-allowed; }
.lock {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center;
  background: rgba(5, 6, 13, .86); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  font-size: 13px; color: var(--muted);
}
.lock b { display: block; font-size: 28px; margin-bottom: 6px; }

.spellbook { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 14px; margin-bottom: 40px; }
.spell-card { padding: 18px; border-radius: var(--r); border: 1px solid var(--line); background: rgba(255, 255, 255, .03); display: flex; flex-direction: column; gap: 6px; }
.spell-card .gwrap {
  height: 96px; display: grid; place-items: center; border-radius: 14px; margin-bottom: 6px;
  background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--c) 16%, transparent), transparent 70%);
}
.spell-card h3 { font-size: 17px; color: var(--c); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.spell-card .how { font-size: 13px; font-weight: 600; }
.spell-card p { font-size: 12.5px; color: var(--muted); }

/* gesture svg */
.gsvg { display: block; overflow: visible; flex: none; }
.gsvg path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.gsvg .g-ghost { stroke: rgba(255, 255, 255, .13); stroke-width: 3; }
.gsvg .g-path { stroke: var(--c, var(--accent2)); stroke-width: 3; filter: drop-shadow(0 0 4px var(--c, var(--accent2))); }
.gsvg .g-start { fill: var(--c, var(--accent2)); }
.gsvg.anim .g-path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: gdraw 2.4s ease-in-out infinite; }
@keyframes gdraw { 0% { stroke-dashoffset: 1; opacity: 1; } 55%, 82% { stroke-dashoffset: 0; opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 0; } }

/* ===== Play stage ===== */
#screen-play { max-width: none; padding: 10px clamp(8px, 1.6vw, 20px) 12px; }
#screen-play.active { animation: none; }
.stage {
  position: relative; overflow: hidden; height: calc(100vh - var(--top) - 22px); height: calc(100dvh - var(--top) - 22px); min-height: 480px;
  border-radius: 22px; border: 1px solid var(--line); background: #07081a;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .9), inset 0 0 0 1px rgba(var(--accent-rgb), .08);
  user-select: none; -webkit-user-select: none;
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: none; }
.hud { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.hud-row { width: 100%; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hud-row > * { pointer-events: auto; }
.hud .pill, .hud .icon-btn, .hud-title { background: rgba(8, 10, 26, .72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.hud-title { display: flex; flex-direction: column; justify-content: center; line-height: 1.1; padding: 4px 14px; height: 38px; border-radius: 12px; border: 1px solid var(--line); }
.hud-title small { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--accent2); }
.hud-title strong { font-family: var(--display); font-size: 15px; white-space: nowrap; }
.hud-obj { font-weight: 500; color: var(--muted); }
.hud-obj b { color: var(--ink); margin-left: 4px; font-variant-numeric: tabular-nums; }
.hud-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
#hud-timer { font-variant-numeric: tabular-nums; min-width: 72px; justify-content: center; }
#hud-timer.warn { color: var(--bad); border-color: rgba(255, 93, 115, .55); }
.hud-hp { letter-spacing: 1px; font-size: 13px; }
.hud-hp.warn { border-color: rgba(255, 93, 115, .55); }
.status-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.status-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: rgba(8, 10, 26, .78); border: 1px solid color-mix(in srgb, var(--c) 60%, transparent);
  box-shadow: 0 0 20px -6px var(--c); animation: chipIn .3s cubic-bezier(.2, .9, .3, 1.4);
}
.status-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
.status-chip b { color: var(--c); font-variant-numeric: tabular-nums; }
@keyframes chipIn { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

.cast-text {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); pointer-events: none; opacity: 0;
  font-family: var(--display); font-weight: 900; font-size: clamp(26px, 6vw, 64px); color: #fff; white-space: nowrap; text-align: center;
  text-shadow: 0 0 18px var(--c), 0 0 44px var(--c);
}
.cast-text.show { animation: cast 1.5s ease-out forwards; }
.cast-text.fail { font-size: clamp(18px, 3vw, 28px); font-weight: 700; color: var(--muted); text-shadow: none; }
@keyframes cast {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); letter-spacing: .35em; filter: blur(6px); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); letter-spacing: .04em; filter: blur(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -64%) scale(1.04); }
}

.hint {
  position: absolute; left: 50%; top: 112px; transform: translateX(-50%); pointer-events: none;
  max-width: calc(100% - 32px); text-align: center; padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: rgba(8, 10, 26, .8); border: 1px solid rgba(var(--accent-rgb), .45); box-shadow: 0 0 30px -8px rgba(var(--accent-rgb), .7);
  transition: opacity .4s, transform .4s;
}
.hint.hide { opacity: 0; transform: translate(-50%, -10px); }

.spellbar {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 7px; border-radius: 20px; max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none;
  background: rgba(8, 10, 26, .78); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.spell-chip {
  position: relative; flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 78px; padding: 7px 10px 6px; border-radius: 14px; cursor: pointer;
  border: 1px solid transparent; background: rgba(255, 255, 255, .03); color: var(--muted);
  transition: background .2s, border-color .2s, box-shadow .2s, color .2s;
}
.spell-chip:hover { background: rgba(255, 255, 255, .08); color: var(--ink); }
.spell-chip.need { color: var(--ink); }
.spell-chip.need::after { content: ''; position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.spell-chip.active { color: #fff; border-color: var(--c); background: color-mix(in srgb, var(--c) 20%, transparent); box-shadow: 0 0 22px -4px var(--c); }
.spell-chip .sc-name { font-size: 11px; font-weight: 600; }
.spell-chip kbd { position: absolute; top: 4px; left: 5px; font-size: 9px; padding: 0 3px; border: 0; background: none; }

@media (max-width: 640px) {
  .hud-obj { order: 5; }
  .hud-title strong { font-size: 13px; }
  #hud-timer { min-width: 0; }
  .spell-chip { min-width: 60px; padding: 6px 6px 4px; }
  .spell-chip kbd { display: none; }
  .hint { top: 150px; font-size: 13px; }
}

/* ===== Sorting ===== */
.sorting-card, .quiz-card { max-width: 720px; margin: clamp(4px, 4vh, 40px) auto; padding: clamp(20px, 4vw, 40px); position: relative; }
.hat-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 18px; }
.hat { width: 150px; height: auto; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .6)); animation: hatbob 3.2s ease-in-out infinite; transform-origin: 50% 90%; }
.hat.small { width: 104px; }
.hat.think { animation: hatthink .55s ease-in-out infinite; }
.hat .mouth { transform-box: fill-box; transform-origin: center; animation: talk .32s ease-in-out infinite alternate; }
@keyframes hatbob { 0%, 100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(3deg) translateY(-6px); } }
@keyframes hatthink { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg) scale(1.04); } }
@keyframes talk { from { transform: scaleY(1); } to { transform: scaleY(1.9); } }
.bubble {
  position: relative; padding: 10px 18px; border-radius: 14px; text-align: center; max-width: 440px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line-2);
  font-family: var(--display); color: var(--accent2); font-size: 15px;
}
.bubble::before { content: ''; position: absolute; top: -7px; left: 50%; width: 12px; height: 12px; transform: translateX(-50%) rotate(45deg); background: inherit; border-left: 1px solid var(--line-2); border-top: 1px solid var(--line-2); }
.sort-title { text-align: center; font-size: clamp(24px, 4vw, 34px); margin-bottom: 6px; }
.sort-sub { text-align: center; color: var(--muted); margin-bottom: 4px; }
.sort-q { font-size: clamp(19px, 3vw, 25px); text-align: center; margin: 4px 0 20px; }
.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 56px; border-radius: 14px; cursor: pointer; text-align: left; font-size: 15px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .03);
  transition: transform .2s, background .2s, border-color .2s;
  animation: optIn .4s both; animation-delay: var(--d, 0s);
}
.option:hover { border-color: rgba(var(--accent-rgb), .6); background: rgba(var(--accent-rgb), .1); transform: translateX(4px); }
.option kbd { flex: none; }
@keyframes optIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; }
.dots i { width: 22px; height: 4px; border-radius: 4px; background: var(--line-2); }
.dots i.on { background: var(--accent2); }
.name-form { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 20px; }
.input {
  flex: 1 1 220px; max-width: 340px; height: 52px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line-2); background: rgba(0, 0, 0, .25); color: var(--ink); font: 500 16px var(--body);
}
.input::placeholder { color: var(--dim); }
.input:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 4px rgba(245, 210, 122, .15); }
.reveal { text-align: center; }
.crest-wrap { width: 150px; margin: 0 auto 20px; filter: drop-shadow(0 0 40px var(--hc)); animation: crestIn 1s cubic-bezier(.2, .9, .3, 1.35) both; }
.crest {
  height: 172px; display: grid; place-items: center; font-size: 76px; padding-bottom: 20px;
  clip-path: polygon(50% 100%, 0 70%, 0 0, 100% 0, 100% 70%);
  background: linear-gradient(160deg, var(--hc), color-mix(in srgb, var(--hc) 60%, #000)),
              radial-gradient(circle at 50% 30%, rgba(255, 255, 255, .25), transparent 60%);
  background-blend-mode: overlay;
  box-shadow: inset 0 0 0 6px var(--hc2);
}
@keyframes crestIn { from { transform: scale(.2) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.house-shout { font-size: clamp(38px, 9vw, 70px); font-weight: 900; color: var(--hc); text-shadow: 0 0 32px color-mix(in srgb, var(--hc) 70%, transparent); animation: shout .8s .25s both; }
@keyframes shout { from { letter-spacing: .5em; opacity: 0; filter: blur(8px); } to { letter-spacing: .04em; opacity: 1; filter: none; } }
.reveal .trait { font-size: 18px; margin: 6px 0 4px; }
.reveal .modal-actions, .quiz-result .modal-actions { justify-content: center; margin-top: 24px; }

/* ===== Quiz ===== */
.quiz-top { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.quiz-progress { flex: 1; }
.bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .5s; }
.quiz-progress small { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.quiz-score { text-align: right; line-height: 1.15; }
.quiz-score small { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; }
.quiz-score strong { font-family: var(--display); font-size: 24px; font-variant-numeric: tabular-nums; }
.quiz-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.timer-ring { position: relative; width: 54px; height: 54px; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 4; }
.timer-ring .track { stroke: rgba(255, 255, 255, .08); }
.timer-ring .prog { stroke: var(--accent2); stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; transition: stroke .3s; }
.timer-ring.low .prog { stroke: var(--bad); }
.timer-ring span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-ring.low span { color: var(--bad); }
.streak { font-weight: 700; font-size: 14px; color: var(--dim); transition: .3s; }
.streak.on { color: #ffb347; text-shadow: 0 0 14px rgba(255, 140, 40, .6); transform: scale(1.08); }
.q-text { font-size: clamp(20px, 3.2vw, 28px); line-height: 1.3; margin-bottom: 22px; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .answers { grid-template-columns: 1fr; } }
.answer {
  display: flex; align-items: center; gap: 12px; min-height: 62px; padding: 12px 16px; border-radius: 14px; cursor: pointer; text-align: left;
  font-size: 15px; font-weight: 500; border: 1px solid var(--line); background: rgba(255, 255, 255, .035);
  transition: transform .15s, background .2s, border-color .2s, opacity .3s;
  animation: optIn .4s both; animation-delay: var(--d, 0s);
}
.answer:hover:not(:disabled) { border-color: rgba(var(--accent-rgb), .6); background: rgba(var(--accent-rgb), .12); transform: translateY(-2px); }
.answer:disabled { cursor: default; }
.answer.correct { border-color: var(--good); background: rgba(61, 220, 151, .14); box-shadow: inset 0 0 0 1px var(--good), 0 10px 30px -12px rgba(61, 220, 151, .7); }
.answer.wrong { border-color: var(--bad); background: rgba(255, 93, 115, .14); }
.answer.faded { opacity: .38; }
.answer.gone { visibility: hidden; }
.q-foot { display: flex; align-items: center; gap: 14px; margin-top: 20px; min-height: 48px; flex-wrap: wrap; }
.feedback { flex: 1 1 260px; font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.feedback .good { color: var(--good); }
.feedback .bad { color: var(--bad); }
.shake { animation: shake .4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
.quiz-result { text-align: center; }
.grade {
  font-family: var(--display); font-size: clamp(96px, 20vw, 150px); line-height: 1; font-weight: 900; margin: 8px 0 4px;
  background: linear-gradient(180deg, #fff, var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 30px rgba(var(--accent-rgb), .6)); animation: crestIn .9s cubic-bezier(.2, .9, .3, 1.4) both;
}
.quiz-result h2 { font-size: clamp(24px, 4vw, 32px); }
.new-best { display: inline-block; margin-top: 10px; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--on-accent); background: var(--accent2); }

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(3, 4, 10, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .25s;
}
.modal[hidden] { display: none; }
.modal.open { opacity: 1; }
.modal-card {
  width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: clamp(20px, 4vw, 32px);
  background: var(--glass-2); box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .9), 0 0 0 1px rgba(var(--accent-rgb), .15);
  transform: translateY(16px) scale(.97); transition: transform .35s cubic-bezier(.2, .9, .3, 1.25);
}
.modal.open .modal-card { transform: none; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.intro-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.intro-emoji {
  flex: none; width: 72px; height: 72px; display: grid; place-items: center; font-size: 42px; border-radius: 20px;
  background: radial-gradient(circle, rgba(var(--accent-rgb), .3), rgba(var(--accent-rgb), .05)); border: 1px solid rgba(var(--accent-rgb), .4);
}
.intro h2 { font-size: clamp(24px, 4vw, 30px); margin-top: 2px; }
.story { color: var(--muted); margin-bottom: 14px; }
.goal {
  display: flex; gap: 10px; align-items: center; padding: 10px 14px; margin-bottom: 14px; border-radius: 12px; font-weight: 600;
  background: rgba(245, 210, 122, .08); border: 1px solid rgba(245, 210, 122, .25);
}
.howto { display: grid; gap: 10px; margin-bottom: 14px; }
.howto-item { display: flex; align-items: center; gap: 14px; padding: 8px 14px 8px 8px; border-radius: 14px; background: rgba(255, 255, 255, .035); border: 1px solid var(--line); }
.howto-item .gsvg { border-radius: 12px; background: radial-gradient(circle, color-mix(in srgb, var(--c) 18%, transparent), transparent 70%); }
.howto-item > div { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.howto-item strong { color: var(--c); font-family: var(--display); }
.howto-item span { font-size: 14px; font-weight: 600; }
.howto-item small { font-size: 12.5px; color: var(--muted); }
.tip { font-size: 13px; color: var(--dim); margin-bottom: 18px; }
.result { text-align: center; }
.result .modal-actions { justify-content: center; margin-top: 22px; }
.result h2 { font-size: clamp(26px, 5vw, 34px); margin-top: 4px; }
.result-emoji { font-size: 64px; line-height: 1.1; animation: pop .6s cubic-bezier(.2, .9, .3, 1.5) both; }
.stars-big { display: flex; justify-content: center; gap: 10px; font-size: 54px; line-height: 1.1; margin: 10px 0 4px; }
.stars-big span { color: rgba(255, 255, 255, .12); animation: starIn .55s var(--d) cubic-bezier(.2, .9, .3, 1.6) both; }
.stars-big span.on { color: var(--accent2); text-shadow: 0 0 26px rgba(245, 210, 122, .85); }
@keyframes starIn { from { transform: scale(0) rotate(-70deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
.result-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 20px 0 0; }
.result-stats div { padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.result-stats span { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.result-stats strong { font-size: 20px; font-variant-numeric: tabular-nums; }

/* ===== Register ===== */
.register-card { max-width: 520px; margin: clamp(8px, 6vh, 64px) auto; padding: clamp(24px, 5vw, 44px); text-align: center; }
.register-card h2 { font-size: clamp(26px, 4.5vw, 34px); margin: 6px 0 10px; }
.letter-seal {
  width: 76px; height: 76px; margin: 0 auto 16px; display: grid; place-items: center; font-size: 38px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d9534f, #7a1d1b); box-shadow: 0 10px 30px -8px rgba(217, 83, 79, .7), inset 0 2px 0 rgba(255, 255, 255, .25);
  animation: hatbob 4s ease-in-out infinite;
}
.register-form { display: grid; gap: 14px; margin-top: 22px; text-align: left; }
.field { display: grid; gap: 6px; }
.field span { font-size: 13px; font-weight: 600; color: var(--muted); padding-left: 4px; }
.field .input { max-width: none; width: 100%; border-radius: 14px; }
.register-form .btn { margin-top: 4px; width: 100%; }
.form-error { min-height: 20px; color: var(--bad); font-size: 14px; font-weight: 500; }
.form-error:empty { min-height: 0; }
.fine { font-size: 12.5px; color: var(--dim); text-align: center; }
.account-line { margin: 4px 0 20px; font-size: 13px; color: var(--dim); text-align: center; }
.account-line b { color: var(--muted); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent2); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ===== Leaderboard ===== */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.house-cup { padding: 18px; border-radius: var(--r); border: 1px solid var(--line); background: rgba(255, 255, 255, .03); margin-bottom: 18px; }
.cup-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cup-head > span { font-size: 28px; }
.cup-head strong { font-family: var(--display); font-size: 18px; display: block; }
.cup-head small { color: var(--muted); font-size: 12.5px; }
.cup-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 760px) { .cup-grid { grid-template-columns: repeat(2, 1fr); } }
.cup-item {
  position: relative; padding: 14px; border-radius: 14px; display: flex; flex-direction: column; gap: 4px;
  border: 1px solid color-mix(in srgb, var(--hc) 30%, transparent); background: color-mix(in srgb, var(--hc) 8%, transparent);
}
.cup-item.lead { border-color: var(--hc); box-shadow: 0 0 30px -10px var(--hc); }
.cup-top { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
.cup-icon { font-size: 18px; }
.crown { margin-left: auto; }
.cup-item > strong { font-family: var(--display); font-size: 24px; font-variant-numeric: tabular-nums; }
.cup-item small { color: var(--muted); font-size: 12px; }
.cup-bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.cup-bar span { display: block; height: 100%; border-radius: inherit; background: var(--hc); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.lb-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 18px; scrollbar-width: none; }
.lb-tab {
  flex: none; height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03);
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; transition: .2s;
}
.lb-tab:hover { color: var(--ink); background: rgba(255, 255, 255, .07); }
.lb-tab.on { color: var(--on-accent); background: var(--accent); border-color: transparent; }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, var(--hc), color-mix(in srgb, var(--hc) 45%, #000)); box-shadow: 0 0 0 2px rgba(255, 255, 255, .08);
}
.avatar.big { width: 64px; height: 64px; font-size: 22px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--hc) 70%, transparent), 0 10px 30px -8px var(--hc); }
.lb-me { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 18px; border-color: rgba(var(--accent-rgb), .5); }
.lb-me div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lb-me small { color: var(--muted); font-size: 12.5px; }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; margin-bottom: 18px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; min-width: 0; }
.pod.empty { visibility: hidden; }
.medal { font-size: 30px; line-height: 1; }
.pod.p1 .medal { font-size: 40px; animation: pop .6s cubic-bezier(.2, .9, .3, 1.5) both; }
.pod-name { font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod small { color: var(--muted); font-size: 12px; }
.pod-block {
  width: 100%; margin-top: 6px; border-radius: 14px 14px 6px 6px; display: flex; flex-direction: column; justify-content: center; align-items: center;
  border: 1px solid color-mix(in srgb, var(--hc) 40%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--hc) 26%, transparent), color-mix(in srgb, var(--hc) 6%, transparent));
}
.pod-block span { font-family: var(--display); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pod.p1 .pod-block { height: 120px; }
.pod.p2 .pod-block { height: 92px; }
.pod.p3 .pod-block { height: 70px; }
.pod.me .pod-name { color: var(--accent2); }
.lb-list { padding: 6px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; transition: background .2s; }
.lb-row + .lb-row { border-top: 1px solid var(--line); }
.lb-row:hover { background: rgba(255, 255, 255, .03); }
.lb-row.me { background: rgba(var(--accent-rgb), .14); border-color: transparent; }
.rank { width: 38px; flex: none; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who em { font-style: normal; color: var(--accent2); font-weight: 500; }
.who small { color: var(--muted); font-size: 12px; }
.lb-meta { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.lb-pts { font-family: var(--display); font-size: 18px; min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .lb-meta { display: none; } .avatar.big { width: 52px; height: 52px; font-size: 18px; } .pod-block span { font-size: 18px; } }
.lb-foot { margin: 14px 0 30px; text-align: center; font-size: 13px; color: var(--dim); }
.lb-empty { padding: 40px 20px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.lb-empty span { font-size: 40px; }
.lb-empty p { color: var(--muted); }
.lb-loading { display: grid; gap: 10px; }
.sk { height: 60px; border-radius: 14px; background: linear-gradient(90deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .08), rgba(255, 255, 255, .03)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* canon notes */
.spell-card .lore, .howto-item .lore { font-size: 12px; color: var(--muted); border-left: 2px solid color-mix(in srgb, var(--c) 60%, transparent); padding-left: 8px; margin-top: 4px; }
.spell-card .lore b { color: var(--ink); font-weight: 600; }
.move-tag { align-self: flex-start; margin-top: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: var(--dim); border: 1px solid var(--line-2); }
.move-tag.canon { color: var(--accent2); border-color: rgba(245, 210, 122, .4); background: rgba(245, 210, 122, .08); }

/* ===== Arena ===== */
.arcade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; margin-bottom: 40px; }
.arcade-card {
  position: relative; overflow: hidden; text-align: left; cursor: pointer; display: flex; flex-direction: column;
  border-radius: var(--r); border: 1px solid var(--line); background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .015));
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), border-color .3s, box-shadow .3s;
}
.arcade-card:hover { transform: translateY(-5px); border-color: color-mix(in srgb, var(--gc) 70%, transparent); box-shadow: 0 24px 50px -24px var(--gc); }
.arcade-art {
  height: 150px; display: grid; place-items: center; font-size: 72px;
  background: radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--gc) 40%, transparent), transparent 65%),
              linear-gradient(180deg, color-mix(in srgb, var(--gc) 14%, #0b0d22), #0b0d22);
  border-bottom: 1px solid var(--line);
}
.arcade-art span { filter: drop-shadow(0 10px 24px color-mix(in srgb, var(--gc) 80%, transparent)); transition: transform .4s cubic-bezier(.2, .9, .3, 1.4); }
.arcade-card:hover .arcade-art span { transform: scale(1.12) rotate(-6deg); }
.arcade-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.arcade-tag { align-self: flex-start; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gc); }
.arcade-body h3 { font-size: 21px; }
.arcade-body p { font-size: 13.5px; color: var(--muted); }
.arcade-body .lore { font-size: 12.5px; border-left: 2px solid color-mix(in srgb, var(--gc) 60%, transparent); padding-left: 8px; }
.arcade-foot { margin-top: auto; padding-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.arcade-foot .go { color: var(--gc); font-weight: 700; white-space: nowrap; }

#screen-minigame { max-width: none; padding: 10px clamp(8px, 1.6vw, 20px) 12px; }
#screen-minigame.active { animation: none; }
#mg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.mg-hud { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill.warn { border-color: rgba(255, 93, 115, .55); color: #ffb3bf; }
.mg-ui { position: absolute; inset: 0; pointer-events: none; }
.mg-ui > * { pointer-events: auto; }
.lore-box { display: flex; gap: 8px; font-size: 13px; color: var(--muted); padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); margin-bottom: 14px; }
.controls { list-style: none; display: grid; gap: 6px; margin: 0 0 18px; font-size: 13.5px; color: var(--muted); }
.controls b { color: var(--ink); }

/* quidditch */
.qd-score { gap: 10px; font-size: 15px; }
.qd-score b { color: var(--ink); font-variant-numeric: tabular-nums; }
.qd-score .sep { color: var(--dim); }
.qd-stamina .bar { display: block; width: 70px; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.qd-stamina .bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffd166, #fff3b0); border-radius: inherit; }
.mg-boost {
  position: absolute; right: 16px; bottom: 16px; min-width: 120px; height: 56px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 15px;
  border: 1px solid rgba(255, 209, 102, .6); background: rgba(8, 10, 26, .75); color: #ffd166; backdrop-filter: blur(8px);
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.mg-boost:active { background: rgba(255, 209, 102, .25); }
@media (hover: hover) and (pointer: fine) { .mg-boost { display: none; } }

/* duel */
.duel-hp { min-width: 150px; padding: 6px 12px; border-radius: 12px; background: rgba(8, 10, 26, .75); border: 1px solid color-mix(in srgb, var(--hc) 45%, transparent); }
.duel-hp-top { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.duel-hp-top span { font-variant-numeric: tabular-nums; color: var(--muted); }
.duel-hp .bar { margin-top: 4px; height: 7px; }
.duel-hp .bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--hc), color-mix(in srgb, var(--hc) 50%, #fff)); transition: width .3s; }
.duel-vs { font-family: var(--display); font-weight: 900; color: var(--accent2); }
.duel-bar {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 8px; padding: 8px; border-radius: 20px;
  background: rgba(8, 10, 26, .8); border: 1px solid var(--line); backdrop-filter: blur(10px); max-width: calc(100% - 16px);
}
.duel-btn {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 96px; padding: 8px 10px; border-radius: 14px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); background: rgba(255, 255, 255, .04); touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: transform .1s, border-color .2s, box-shadow .2s;
}
.duel-btn:active { transform: scale(.95); }
.duel-btn.ready { border-color: var(--c); box-shadow: 0 0 18px -6px var(--c); }
.duel-btn.blocked { opacity: .4; }
.duel-ico { font-size: 22px; line-height: 1; }
.duel-name { font-size: 12px; font-weight: 700; }
.duel-btn kbd { position: absolute; top: 4px; left: 6px; font-size: 9px; border: 0; background: none; padding: 0; }
.duel-btn .cd { position: absolute; inset: 0; pointer-events: none; background: conic-gradient(rgba(5, 6, 13, .72) calc(var(--cdp, 0) * 360deg), transparent 0); }
@media (max-width: 560px) { .duel-btn { min-width: 0; flex: 1; padding: 8px 4px; } .duel-name { font-size: 10px; } .duel-btn kbd { display: none; } .duel-hp { min-width: 0; flex: 1; } }
.foe-pick { display: grid; gap: 8px; margin-bottom: 14px; }
.foe { display: flex; flex-direction: column; text-align: left; gap: 2px; padding: 10px 14px; border-radius: 12px; cursor: pointer; border: 1px solid var(--line); background: rgba(255, 255, 255, .03); }
.foe.on { border-color: var(--fc); background: color-mix(in srgb, var(--fc) 14%, transparent); }
.foe:disabled { opacity: .45; cursor: not-allowed; }
.foe small { color: var(--muted); font-size: 12px; }

/* potion */
.prince { font-family: 'Caveat', cursive; font-size: 18px; line-height: 1.15; color: #f0d9a8; font-style: normal; }
.pt-book {
  position: absolute; left: 12px; top: 64px; width: 300px; max-height: calc(100% - 170px); overflow: auto; padding: 16px 18px; border-radius: 16px;
  background: linear-gradient(180deg, #2b2216, #1e180f); border: 1px solid #5b4626; box-shadow: 0 20px 40px -20px rgba(0, 0, 0, .8); color: #f2e6cc;
}
.pt-book .eyebrow { color: #d9b56a; }
.pt-book h4 { font-family: var(--display); font-size: 18px; margin: 2px 0 10px; }
.pt-steps { display: grid; gap: 8px; padding-left: 18px; font-size: 13.5px; }
.pt-steps li { color: rgba(242, 230, 204, .55); }
.pt-steps li.now { color: #fff; font-weight: 600; }
.pt-steps li.done { color: rgba(242, 230, 204, .45); text-decoration: line-through; }
.pt-steps li.done .prince, .pt-steps li.done .book-line { text-decoration: none; }
.book-line { display: block; font-size: 12px; font-weight: 400; color: rgba(242, 230, 204, .6); text-decoration: line-through; }
.pt-steps .prince { display: block; margin-top: 2px; transform: rotate(-1.5deg); }
.stir-count { margin-top: 6px; padding: 6px 10px; border-radius: 10px; background: rgba(0, 0, 0, .3); font-variant-numeric: tabular-nums; font-size: 13px; }
.pt-shelf {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 6px; padding: 8px; border-radius: 20px; max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none;
  background: rgba(8, 10, 26, .8); border: 1px solid var(--line); backdrop-filter: blur(10px);
}
.pt-ing { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 84px; padding: 8px 4px; border-radius: 14px; cursor: pointer; border: 1px solid transparent; background: rgba(255, 255, 255, .04); transition: background .2s, transform .15s; }
.pt-ing:hover { background: rgba(255, 255, 255, .1); transform: translateY(-2px); }
.pt-ing span { font-size: 26px; line-height: 1.1; }
.pt-ing small { font-size: 10.5px; line-height: 1.2; color: var(--muted); text-align: center; }
.pt-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(3, 4, 10, .55); backdrop-filter: blur(4px); padding: 16px; }
.pt-overlay[hidden] { display: none; }
.pt-card { width: min(440px, 100%); padding: 22px; border-radius: 18px; background: var(--glass-2); border: 1px solid var(--line-2); text-align: center; }
.pt-card h4 { font-family: var(--display); font-size: 20px; margin: 4px 0 14px; }
.chop-board {
  position: relative; height: 150px; margin: 12px 0; border-radius: 16px; cursor: pointer; display: grid; place-items: center; overflow: hidden; touch-action: manipulation;
  background: repeating-linear-gradient(90deg, #7a5532 0 18px, #6e4b2b 18px 36px); border: 3px solid #4b321b;
}
.chop-item { font-size: 60px; }
.knife { position: absolute; right: 22%; top: 8px; font-size: 44px; transform-origin: 80% 20%; }
.chop-board.chop .knife { animation: chop .2s ease-in; }
@keyframes chop { 50% { transform: translateY(40px) rotate(-20deg); } }
.piece { position: absolute; bottom: 18px; left: 50%; width: 12px; height: 8px; border-radius: 3px; background: #c9b27a; transform: translateX(var(--x)) rotate(var(--r)); }
.chop-count { font-weight: 600; }
.pt-choices { display: grid; gap: 10px; }
.pt-choice { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 14px 16px; border-radius: 14px; cursor: pointer; border: 1px solid var(--line-2); background: rgba(255, 255, 255, .04); transition: border-color .2s, background .2s; }
.pt-choice:hover { border-color: rgba(var(--accent-rgb), .6); background: rgba(var(--accent-rgb), .1); }
.pt-choice small { color: var(--muted); font-size: 12.5px; }
.prince-way { background: linear-gradient(180deg, rgba(240, 217, 168, .08), rgba(240, 217, 168, .02)); }
@media (max-width: 759px) {
  .pt-book { left: 8px; right: 8px; width: auto; top: 112px; max-height: 30%; padding: 10px 14px; }
  .pt-steps li:not(.now) { display: none; }
  .pt-book h4 { font-size: 15px; margin-bottom: 4px; }
  .pt-ing { width: 70px; }
}

/* ===== Toast & fx ===== */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 999px; text-align: center; font-size: 14px;
  background: rgba(18, 20, 44, .94); border: 1px solid var(--line-2); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .8);
  transition: opacity .3s, transform .3s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.playing .toast { bottom: 140px; }
.fx-spark {
  position: fixed; z-index: 70; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; pointer-events: none;
  background: var(--c); box-shadow: 0 0 10px var(--c); animation: fxspark var(--t, .9s) cubic-bezier(.1, .7, .3, 1) forwards;
}
@keyframes fxspark { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .cast-text.show { animation: none; opacity: 1; }
}
