/* Hogwarts Math Academy — original art made only with CSS, emoji and simple SVG. */
:root {
  --night: #151033;
  --night2: #241a52;
  --ink: #2a1c0c;
  --parch: #f7ecd2;
  --parch2: #ecdcb6;
  --gold: #e8b923;
  --gold2: #b98a0c;
  --ok: #1d7a3c;
  --okbg: #dff5e4;
  --warm: #9a4b00;
  --warmbg: #fff0d9;
  --focus: #ffdf5e;
  --radius: 18px;
  --gryffindor: #8e1b1b; --gryffindor2: #e3a51a;
  --slytherin: #1d5a35; --slytherin2: #c0c6cc;
  --ravenclaw: #1f3c88; --ravenclaw2: #b07a3c;
  --hufflepuff: #c99a06; --hufflepuff2: #2a2a2a;
  --none: #5b4a8a; --none2: #c9b8ff;
  font-size: 20px;
}
body.big { font-size: 24px; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #fff; background: var(--night); line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
.sky {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1.5px 1.5px at 10% 20%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 70%, #fff9 50%, transparent 51%),
    radial-gradient(2px 2px at 55% 15%, #fffa 50%, transparent 51%),
    radial-gradient(1px 1px at 75% 45%, #fff8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 90% 80%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 20% 90%, #fff7 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 65% 85%, #fff8 50%, transparent 51%),
    radial-gradient(ellipse at 50% 120%, #3a2a7a 0%, transparent 60%),
    linear-gradient(180deg, var(--night) 0%, var(--night2) 100%);
  background-size: 300px 300px, 260px 260px, 420px 420px, 200px 200px, 350px 350px, 280px 280px, 380px 380px, 100% 100%, 100% 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.2; margin: .2em 0 .5em; }
h1 { font-size: 2.1rem; color: var(--gold); text-shadow: 0 2px 0 #0008; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
.muted { opacity: .8; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .6rem;
  padding: .45rem .8rem; background: #0d0a24ee; border-bottom: 2px solid #ffffff1a;
  backdrop-filter: blur(6px);
}
.brand { background: none; border: 0; color: var(--gold); font-family: Georgia, serif; font-size: 1.05rem; font-weight: bold; white-space: nowrap; padding: .4rem; min-height: 48px; }
.cupbar { flex: 1; display: flex; gap: .4rem; justify-content: center; overflow-x: auto; scrollbar-width: none; }
.cupbar .chip { display: flex; align-items: center; gap: .35rem; padding: .2rem .7rem; border-radius: 999px; background: #ffffff14; font-size: .8rem; white-space: nowrap; border: 2px solid transparent; }
.cupbar .chip.lead { border-color: var(--gold); }
.cupbar .chip b { color: var(--gold); }
.controls { display: flex; gap: .35rem; }
.icon-btn { min-width: 48px; min-height: 48px; border-radius: 14px; border: 2px solid #ffffff30; background: #ffffff12; font-weight: bold; font-size: .9rem; }
.icon-btn:hover { background: #ffffff25; }

main { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 4rem; outline: none; }

/* ---------- generic pieces ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 60px; padding: .6rem 1.4rem; border-radius: 16px; border: 0;
  background: linear-gradient(180deg, #ffd34d, var(--gold2)); color: #2a1a00; font-weight: bold; font-size: 1.05rem;
  box-shadow: 0 4px 0 #6d5008, 0 6px 14px #0006; transition: transform .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #6d5008; }
.btn.secondary { background: #ffffff1c; color: #fff; box-shadow: 0 4px 0 #0006; border: 2px solid #ffffff40; }
.btn.small { min-height: 48px; padding: .35rem 1rem; font-size: .9rem; }
.btn.danger { background: #b3261e; color: #fff; box-shadow: 0 4px 0 #5c120e; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.stack > * + * { margin-top: .8rem; }
.panel { background: #ffffff10; border: 2px solid #ffffff22; border-radius: var(--radius); padding: 1rem 1.2rem; }
.parch { background: linear-gradient(180deg, var(--parch), var(--parch2)); color: var(--ink); border-radius: var(--radius); padding: 1.2rem 1.4rem; box-shadow: 0 8px 24px #0008, inset 0 0 40px #c9a86a55; }
.tag { display: inline-block; font-size: .75rem; padding: .15rem .6rem; border-radius: 999px; background: #0002; font-weight: bold; }
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%) translateY(150%); background: var(--parch); color: var(--ink); padding: .8rem 1.3rem; border-radius: 14px; font-weight: bold; box-shadow: 0 6px 20px #000a; transition: transform .25s; z-index: 50; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- house colours ---------- */
.h-gryffindor { --h1: var(--gryffindor); --h2: var(--gryffindor2); }
.h-slytherin { --h1: var(--slytherin); --h2: var(--slytherin2); }
.h-ravenclaw { --h1: var(--ravenclaw); --h2: var(--ravenclaw2); }
.h-hufflepuff { --h1: var(--hufflepuff); --h2: var(--hufflepuff2); }
.h-none { --h1: var(--none); --h2: var(--none2); }

.crest {
  width: 4.2rem; height: 4.8rem; flex: none; display: grid; place-items: center; font-size: 2.2rem;
  background: linear-gradient(135deg, var(--h1) 0 50%, color-mix(in srgb, var(--h1) 75%, #000) 50%);
  border: 4px solid var(--h2); clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%);
  border-radius: 6px;
}
.crest.big { width: 7rem; height: 8rem; font-size: 3.8rem; }

/* ---------- start screen ---------- */
.hero { text-align: center; margin: .5rem 0 1.2rem; }
.hero p { margin: 0; opacity: .85; }
.start-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 860px) { .start-grid { grid-template-columns: 1fr; } }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.pcard {
  position: relative; text-align: left; border: 0; padding: 0; border-radius: 22px; overflow: hidden;
  background: linear-gradient(160deg, var(--h1), color-mix(in srgb, var(--h1) 55%, #000));
  box-shadow: 0 0 0 3px var(--h2), 0 10px 24px #0009; color: #fff;
}
.pcard .pc-main { display: flex; gap: .9rem; align-items: center; padding: 1rem 1rem .6rem; width: 100%; background: none; border: 0; text-align: left; min-height: 120px; }
.pcard .pc-name { font-family: Georgia, serif; font-size: 1.6rem; font-weight: bold; }
.pcard .pc-house { font-size: .9rem; opacity: .9; }
.pcard .pc-points { font-size: 1.05rem; margin-top: .25rem; }
.pcard .pc-points b { color: var(--gold); font-size: 1.3rem; }
.pcard .pc-foot { display: flex; justify-content: space-between; align-items: center; padding: .4rem 1rem .8rem; gap: .5rem; }
.langtoggle { display: inline-flex; border-radius: 12px; overflow: hidden; border: 2px solid #ffffff60; }
.langtoggle button { min-width: 52px; min-height: 44px; border: 0; background: #0003; color: #fff; font-weight: bold; }
.langtoggle button[aria-pressed="true"] { background: #fff; color: #222; }
.duel-cta { margin-top: 1.2rem; display: flex; align-items: center; gap: 1rem; padding: 1rem 1.2rem; border-radius: 22px; background: linear-gradient(120deg, #3b1d6e, #6b2a8f); border: 3px solid #c9a4ff; width: 100%; text-align: left; color: #fff; box-shadow: 0 10px 24px #0008; }
.duel-cta .big-emoji { font-size: 2.6rem; }
.duel-cta strong { font-size: 1.3rem; font-family: Georgia, serif; display: block; }

/* ---------- house cup ---------- */
.cup h2 { display: flex; align-items: center; gap: .5rem; color: var(--gold); }
.tabs { display: flex; gap: .4rem; margin-bottom: .8rem; flex-wrap: wrap; }
.tabs button { min-height: 48px; padding: .3rem 1rem; border-radius: 12px; border: 2px solid #ffffff30; background: #ffffff10; }
.tabs button[aria-selected="true"] { background: var(--gold); color: #2a1a00; border-color: var(--gold); font-weight: bold; }
.cup-row { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: .6rem; align-items: center; padding: .55rem .3rem; border-bottom: 1px solid #ffffff1a; }
.cup-row:last-child { border: 0; }
.cup-rank { font-size: 1.4rem; text-align: center; }
.cup-bar { height: 12px; border-radius: 6px; background: #ffffff18; overflow: hidden; margin-top: .25rem; }
.cup-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--h1, var(--gold)), var(--h2, var(--gold))); border-radius: 6px; transition: width .6s; }
.cup-pts { font-weight: bold; color: var(--gold); font-size: 1.2rem; }

/* ---------- hub ---------- */
.hub-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.classes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .9rem; }
.class-tile { border: 0; border-radius: 20px; padding: 1rem; min-height: 130px; text-align: left; color: var(--ink); background: linear-gradient(180deg, var(--parch), var(--parch2)); box-shadow: 0 6px 0 #8a6a2c, 0 10px 20px #0007; display: flex; flex-direction: column; gap: .2rem; }
.class-tile:active { transform: translateY(4px); box-shadow: 0 2px 0 #8a6a2c; }
.class-tile .ic { font-size: 2.2rem; }
.class-tile strong { font-family: Georgia, serif; font-size: 1.25rem; }
.class-tile span { font-size: .85rem; }
.class-tile.featured { grid-column: 1 / -1; background: linear-gradient(120deg, #ffe9a8, #f2c94c); }

/* ---------- play ---------- */
.play-top { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.dots { display: flex; gap: .3rem; flex: 1; }
.dots i { flex: 1; height: 12px; border-radius: 6px; background: #ffffff22; }
.dots i.ok { background: #4cd17a; }
.dots i.miss { background: #ffb15c; }
.dots i.now { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.streak { font-weight: bold; color: #ffb347; min-width: 4rem; }
.qcard { position: relative; }
.qcard .qmeta { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.qcard .prompt { font-size: 1.35rem; font-weight: 600; margin: .2rem 0 1rem; white-space: pre-wrap; }
.answer-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.answer-input { flex: 1; min-width: 200px; min-height: 64px; font-size: 1.6rem; padding: .3rem .9rem; border-radius: 14px; border: 3px solid #8a6a2c; background: #fffdf6; color: var(--ink); }
.hint { font-size: .85rem; opacity: .75; margin-top: .3rem; }
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; margin-top: .8rem; max-width: 520px; }
.keypad button { min-height: 58px; border-radius: 12px; border: 0; background: #e3cf9f; color: var(--ink); font-size: 1.3rem; font-weight: bold; box-shadow: 0 3px 0 #8a6a2c; }
.keypad button:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a6a2c; }
.keypad button.wide { grid-column: span 2; font-size: 1rem; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .6rem; }
.choices button { min-height: 72px; border-radius: 16px; border: 3px solid #8a6a2c; background: #fffdf6; color: var(--ink); font-size: 1.25rem; font-weight: bold; padding: .4rem .8rem; }
.choices button:hover { background: #fff3cf; }
.choices button.picked { background: var(--gold); }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.feedback { margin-top: 1rem; border-radius: 16px; padding: 1rem 1.2rem; font-size: 1.05rem; }
.feedback.ok { background: var(--okbg); color: #0f4a23; border: 3px solid #4cd17a; }
.feedback.miss { background: var(--warmbg); color: #5c2e00; border: 3px solid #ffb15c; }
.feedback .fb-title { font-size: 1.35rem; font-weight: bold; font-family: Georgia, serif; }
.feedback .fb-points { float: right; font-size: 1.5rem; font-weight: bold; color: var(--ok); animation: pop .5s; }
.feedback .fb-answer { font-size: 1.3rem; font-weight: bold; margin: .4rem 0; }
.figure { display: flex; justify-content: center; margin: .2rem 0 1rem; }
.figure svg { max-width: 100%; height: auto; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.25); } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.shake { animation: shake .3s; }
.sparkles { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.sparkles i { position: absolute; font-style: normal; animation: fly 1s ease-out forwards; }
@keyframes fly { from { transform: translate(0, 0) scale(.5); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(1.4); opacity: 0; } }

.summary { text-align: center; }
.summary .stars { font-size: 3rem; letter-spacing: .3rem; }
.summary .big-num { font-size: 2.6rem; font-weight: bold; color: var(--gold2); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; margin: 1rem 0; }
.stat { background: #0000000d; border-radius: 14px; padding: .7rem; }
.stat b { display: block; font-size: 1.6rem; }

/* ---------- sorting ---------- */
.sort-answers { display: grid; gap: .6rem; }
.sort-answers button { min-height: 64px; text-align: left; padding: .6rem 1rem; border-radius: 14px; border: 3px solid #8a6a2c; background: #fffdf6; color: var(--ink); font-size: 1.1rem; }
.sort-answers button:hover { background: #fff3cf; }
.reveal { text-align: center; padding: 2rem 1rem; border-radius: 24px; background: linear-gradient(160deg, var(--h1), color-mix(in srgb, var(--h1) 50%, #000)); box-shadow: 0 0 0 4px var(--h2), 0 0 60px var(--h2); animation: pop .8s; }
.reveal .crest { margin: 0 auto 1rem; }
.quill { font-size: 4rem; display: inline-block; animation: wiggle 1s infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }
.house-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; }
.house-pick { border: 0; border-radius: 18px; padding: 1rem; color: #fff; text-align: center; background: linear-gradient(160deg, var(--h1), color-mix(in srgb, var(--h1) 50%, #000)); box-shadow: 0 0 0 3px var(--h2); }
.house-pick .crest { margin: 0 auto .5rem; }

/* ---------- duel ---------- */
.duelists { display: grid; grid-template-columns: 1fr auto 1fr; gap: .8rem; align-items: center; margin-bottom: 1rem; }
.duelist { border-radius: 18px; padding: .7rem 1rem; background: linear-gradient(160deg, var(--h1), color-mix(in srgb, var(--h1) 50%, #000)); box-shadow: 0 0 0 3px var(--h2); display: flex; align-items: center; gap: .7rem; transition: transform .3s, box-shadow .3s; opacity: .75; }
.duelist.active { opacity: 1; transform: scale(1.04); box-shadow: 0 0 0 4px var(--gold), 0 0 30px var(--gold); }
.duelist .crest { width: 3rem; height: 3.4rem; font-size: 1.5rem; }
.duelist .hits { font-size: 1.2rem; letter-spacing: .1rem; }
.vs { font-family: Georgia, serif; font-size: 1.6rem; color: var(--gold); font-weight: bold; }
@media (max-width: 640px) { .duelists { grid-template-columns: 1fr; } .vs { text-align: center; } }
.pick-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; }
.pick-cards button { min-height: 90px; border: 0; border-radius: 18px; color: #fff; display: flex; align-items: center; gap: .7rem; padding: .7rem; background: linear-gradient(160deg, var(--h1), color-mix(in srgb, var(--h1) 50%, #000)); box-shadow: 0 0 0 3px var(--h2); font-size: 1.2rem; font-weight: bold; opacity: .7; }
.pick-cards button[aria-pressed="true"] { opacity: 1; box-shadow: 0 0 0 5px var(--gold), 0 0 24px var(--gold); }
.pick-cards .crest { width: 3rem; height: 3.4rem; font-size: 1.5rem; }
.spell-burst { text-align: center; font-family: Georgia, serif; font-size: 2rem; font-weight: bold; color: var(--gold); text-shadow: 0 0 20px #ffcf40; animation: pop .6s; margin: .5rem 0; }
.pass { text-align: center; padding: 2.5rem 1rem; }
.pass .crest { margin: 0 auto 1rem; }

/* ---------- parent ---------- */
.pinpad { display: grid; grid-template-columns: repeat(3, 76px); gap: .6rem; justify-content: center; margin: 1rem auto; }
.pinpad button { min-height: 70px; border-radius: 16px; border: 0; background: var(--parch); color: var(--ink); font-size: 1.6rem; font-weight: bold; }
.pin-dots { text-align: center; font-size: 2rem; letter-spacing: .6rem; min-height: 2.6rem; }
.parent .parch { margin-bottom: 1rem; }
.parent label { display: block; font-weight: bold; font-size: .9rem; margin: .5rem 0 .2rem; }
.parent input, .parent select, .parent textarea { width: 100%; min-height: 48px; border-radius: 10px; border: 2px solid #8a6a2c; background: #fffdf6; color: var(--ink); padding: .3rem .6rem; }
.parent textarea { min-height: 110px; }
.parent table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.parent th, .parent td { text-align: left; padding: .45rem .4rem; border-bottom: 1px solid #0002; vertical-align: top; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; align-items: end; }
@media (max-width: 720px) { .grid2, .grid4 { grid-template-columns: 1fr; } }
.acc-bar { width: 100px; height: 12px; border-radius: 6px; background: #0002; overflow: hidden; display: inline-block; vertical-align: middle; }
.acc-bar span { display: block; height: 100%; background: #2e9e57; }
.weak td { background: #ffe6c7; }
.warn { color: #9a4b00; font-weight: bold; }
.item { display: flex; gap: .8rem; justify-content: space-between; align-items: flex-start; padding: .6rem 0; border-bottom: 1px solid #0002; }
.item .item-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item .row { flex-wrap: wrap; justify-content: flex-end; }
.item.off .item-main { opacity: .5; }
.switch { min-width: 70px; }
.proposal { display: flex; gap: .6rem; align-items: flex-start; padding: .4rem 0; }
.proposal input { width: 28px !important; min-height: 28px !important; flex: none; }
.modal-back { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 40; padding: 1rem; }
.modal { max-width: 720px; width: 100%; max-height: 90vh; overflow: auto; }

/* ---------- v2 additions ---------- */
.ink { color: var(--ink) !important; text-shadow: none; }
.ink-btn { color: var(--ink) !important; border-color: #8a6a2c !important; }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.lead { font-size: 1.15rem; }
.white { color: #fff; }
.grow { flex: 1; }
.gold-big { color: var(--gold); font-size: 1.4rem; }
.narrow { max-width: 760px; margin: 0 auto; }
.narrow.wide { max-width: 900px; }
.pad { padding: 3rem 1rem; }
.row.spread { justify-content: space-between; }
.tag.light { background: #ffffff22; font-size: .9rem; }
.tag.focus { background: #ffe08a; color: #4a3200; }
.linkish { background: none; border: 0; color: inherit; text-decoration: underline; opacity: .7; min-height: 44px; }
.foot { text-align: center; padding: 0 1rem 2rem; font-size: .8rem; }

/* forms */
.field { display: flex; flex-direction: column; gap: .25rem; font-weight: bold; }
.field > span { font-size: .9rem; }
.field small { font-weight: normal; }
.field input, .field select, .field textarea, .parent input, .parent select, .parent textarea {
  min-height: 48px; padding: .4rem .7rem; border-radius: 12px; border: 2px solid #8a6a2c; background: #fffdf6; color: var(--ink); width: 100%;
}
.parent textarea, .field textarea { min-height: 110px; }
.parent textarea.short { min-height: 70px; }
.parent input[type="checkbox"], .check input { width: 26px; height: 26px; min-height: 0; accent-color: #8a6a2c; flex: none; }
.form-msg { color: #8e1b1b; font-weight: bold; min-height: 1.2em; margin: 0; }
.auth-wrap { display: flex; justify-content: center; padding: 1.5rem 0; }
.auth-card { width: 100%; max-width: 520px; }
.auth-card .btn { width: 100%; }

/* PIN */
.pin-screen { max-width: 440px; margin: 1.5rem auto; display: flex; flex-direction: column; align-items: center; background: linear-gradient(160deg, var(--h1), var(--night2)); }
.pin-wrap { width: 100%; }
.pin-dots { display: flex; gap: 1rem; justify-content: center; margin: .6rem 0 1rem; }
.pin-dots i { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; }
.pin-dots i.on { background: var(--gold); border-color: var(--gold); }
.pin-msg { min-height: 1.4em; font-weight: bold; color: #ffd27a; }

/* player cards, hub */
.pcard.active { outline: 4px solid var(--gold); }
.class-tile.focus { background: linear-gradient(120deg, #fff3c4, #ffd76a); }

/* parent area */
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .4rem .8rem; }
.check { display: flex; gap: .6rem; align-items: center; min-height: 44px; cursor: pointer; }
.big-check { font-size: 1.15rem; font-weight: bold; }
.focus-on { outline: 4px solid #e8b923; }
.ok-note { color: var(--ok); font-weight: bold; }
.table-wrap { overflow-x: auto; }

/* What's new */
.md h2, .md h3, .md h4 { color: var(--ink); margin-top: 1rem; }
.md ul { padding-left: 1.3rem; }
.md li { margin: .2rem 0; }
.md code { background: #0000000f; padding: 0 .3rem; border-radius: 6px; }

@media (max-width: 760px) {
  .start-grid, .grid2, .grid4 { grid-template-columns: 1fr !important; }
  .topbar .brand #brandText { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 600px) { .cupbar { display: none; } }

/* ---------- phase 2: the Adventure Map ---------- */
.board-wrap { margin: .8rem 0; border-radius: 28px; box-shadow: 0 10px 30px #0009; }
.board-svg { display: block; width: 100%; height: auto; }
.board-svg .token.me circle { animation: bob 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-bottom: 1rem; }
.lg { display: inline-flex; align-items: center; gap: .2rem; padding: .15rem .6rem; border-radius: 999px; background: #ffffff14; border: 2px solid transparent; }
.lg-small { border-color: #e8b923; } .lg-big { border-color: #d64545; } .lg-passage { border-color: #3fb6a8; } .lg-story { border-color: #a67cf0; } .lg-boss { border-color: #ffd76a; }
.boss-banner { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .9rem 1.2rem; border-radius: 20px; background: linear-gradient(120deg, #4a1010, #8e2a2a); border: 3px solid #ffd76a; margin: .6rem 0; }
.boss-icon, .big-emoji { font-size: 2.6rem; }
.graduated { margin: .6rem 0; }
.world { margin-top: 1rem; }
.world-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.world-book { background: #ffffff10; border: 2px solid #ffffff25; border-radius: 16px; padding: .7rem; display: flex; flex-direction: column; gap: .25rem; min-height: 140px; }
.world-book.here { border-color: var(--gold); box-shadow: 0 0 16px #e8b92355; }
.world-book.locked { opacity: .55; }
.wb-icon { font-size: 1.8rem; }
.wb-num { font-size: .75rem; opacity: .8; }
.wb-title { font-weight: bold; font-family: Georgia, serif; line-height: 1.2; }
.wb-state { color: #7ee0a0; font-size: .85rem; font-weight: bold; }
.wb-player { display: flex; align-items: center; gap: .4rem; font-size: .85rem; }
.wb-player.me { font-weight: bold; }
.wb-bar { flex: 1; height: 8px; border-radius: 4px; background: #ffffff22; overflow: hidden; }
.wb-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--h1, var(--gold)), var(--h2, var(--gold))); }
.adventure-tile { display: flex; gap: 1rem; align-items: center; width: 100%; text-align: left; margin: .4rem 0 1rem; padding: 1rem 1.2rem; border-radius: 22px; border: 3px solid var(--gold); color: #fff; background: linear-gradient(120deg, #241a52, #3b2a7a); box-shadow: 0 8px 22px #0008; }
.adventure-tile strong { display: block; font-family: Georgia, serif; font-size: 1.3rem; color: var(--gold); }
.adventure-tile .at-book { display: block; font-weight: bold; }
.at-icon { font-size: 2.8rem; }
.at-bar { display: block; height: 12px; border-radius: 6px; background: #ffffff22; overflow: hidden; margin: .35rem 0; }
.at-bar span { display: block; height: 100%; background: linear-gradient(90deg, #ffd76a, #e8b923); }
.story { text-align: center; }
.story-scene { font-size: 2.6rem; letter-spacing: .5rem; margin-bottom: .3rem; }
.story-text { font-size: 1.2rem; line-height: 1.55; text-align: left; }
.adventure-strip { margin-bottom: .4rem; }
.strip-btn { text-decoration: none; opacity: .9; font-size: .9rem; text-align: left; }
.boss-status { display: flex; gap: 1.2rem; align-items: center; font-weight: bold; font-size: 1.1rem; flex-wrap: wrap; }
.event-card { text-align: center; }
.event-card.big { box-shadow: 0 8px 24px #0008, inset 0 0 0 4px #d64545; }
.event-icon { font-size: 4rem; }
.event-banner { display: inline-block; margin-bottom: .6rem; padding: .3rem .9rem; border-radius: 999px; background: #ffe08a; color: #4a3200; font-weight: bold; }
.tag.event { background: #ffe08a; color: #4a3200; }
.fb-extra { margin-top: .6rem; display: flex; flex-direction: column; gap: .2rem; }
.moved { font-weight: bold; }
.moved.back { color: #8a4b00; }
.pace-box { border-radius: 14px; padding: .6rem .9rem; margin: .6rem 0; background: #0000000d; border-left: 6px solid #9a8a6a; }
.pace-ahead { border-left-color: #3fb6a8; } .pace-onPace { border-left-color: #1d7a3c; } .pace-behind { border-left-color: #c46a00; }
.acc-bar.wide-bar { width: 200px; }
.parent details { margin-top: .6rem; }
.parent summary { cursor: pointer; font-weight: bold; min-height: 44px; display: flex; align-items: center; }
.boss-result.won { box-shadow: 0 8px 24px #0008, inset 0 0 0 4px #e8b923; }

/* ---------- phase 3: Galleons, shop, characters ---------- */
.wallet { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .8rem; border-radius: 999px; background: #e8b92322; border: 2px solid #e8b92366; color: #ffe08a; font-weight: bold; }
.char-chip { display: inline-flex; align-items: center; gap: .3rem; min-height: 40px; padding: .2rem .8rem; border-radius: 999px; background: #ffffff18; border: 2px solid #ffffff40; font-weight: bold; }
.hub-tiles { display: grid; grid-template-columns: 2fr 1fr; gap: .8rem; }
@media (max-width: 760px) { .hub-tiles { grid-template-columns: 1fr; } }
.shop-tile { border-color: #3fb6a8; background: linear-gradient(120deg, #123b3a, #1f5e5a); }
.shop-tile strong { color: #9ff0e3; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .8rem; }
.shop-item { display: flex; gap: .8rem; align-items: center; padding: .8rem 1rem; border-radius: 18px; background: linear-gradient(180deg, var(--parch), var(--parch2)); color: var(--ink); box-shadow: 0 6px 16px #0007; }
.shop-item.locked { opacity: .55; }
.shop-item.owned { box-shadow: 0 6px 16px #0007, inset 0 0 0 3px #1d7a3c; }
.si-icon { font-size: 2.2rem; flex: none; }
.si-main { flex: 1; min-width: 0; }
.si-foot { display: flex; gap: .6rem; align-items: center; margin-top: .3rem; flex-wrap: wrap; }
.si-price { font-weight: bold; color: var(--gold2); }
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; }
.char-card { display: flex; flex-direction: column; gap: .35rem; align-items: center; text-align: center; padding: 1rem; border-radius: 18px; border: 0; background: linear-gradient(180deg, var(--parch), var(--parch2)); color: var(--ink); box-shadow: 0 6px 16px #0007; }
.char-card.mine { box-shadow: 0 6px 16px #0007, inset 0 0 0 4px var(--gold); }
.char-icon { font-size: 2.6rem; }
.hint-bar { margin-bottom: .6rem; }
.hint-text { background: #fff7d6; color: var(--ink); border: 3px dashed #c9a14a; border-radius: 14px; padding: .7rem 1rem; }
.event-options { margin-top: 1rem; border-top: 2px dashed #8a6a2c55; padding-top: .6rem; }
.moved.gold { color: #8a6200; }
.adventure-strip { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.shop-item { display: grid; grid-template-columns: auto 1fr; align-items: start; }
.shop-item > .btn { grid-column: 1 / -1; width: 100%; }
.shop-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

/* ---------- phase 4: boss battles ---------- */
.arena { display: flex; flex-direction: column; gap: .6rem; padding: 1rem 1.2rem; margin-bottom: .8rem; border-radius: 22px; background: radial-gradient(circle at 20% 20%, #5c1f2a, #1d0d18 70%); border: 3px solid #ffd76a55; box-shadow: 0 10px 30px #000a; }
.arena-boss { display: flex; gap: 1rem; align-items: center; }
.arena-icon { font-size: 3.6rem; filter: drop-shadow(0 0 12px #ff6a6a88); }
.boss-hit .arena-icon { animation: bosshit .6s; }
@keyframes bosshit { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px) rotate(-6deg); } 40% { transform: translateX(10px) rotate(6deg); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
.hp-bar { height: 16px; border-radius: 8px; background: #ffffff1f; overflow: hidden; margin: .3rem 0; }
.hp-bar span { display: block; height: 100%; background: linear-gradient(90deg, #ff5e5e, #ffb347); transition: width .6s; }
.arena-you { display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; align-items: center; font-weight: bold; }
.charge .dim { opacity: .25; }
.cast-panel { margin-top: .6rem; }
.spell-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.spell-btn { display: flex; flex-direction: column; align-items: center; gap: .15rem; min-height: 96px; padding: .6rem; border-radius: 16px; border: 3px solid #8a6a2c; background: #fffdf6; color: var(--ink); text-align: center; }
.spell-btn.attack { border-color: #c0392b; } .spell-btn.shield { border-color: #1f3c88; } .spell-btn.heal { border-color: #1d7a3c; } .spell-btn.save { border-style: dashed; }
.spell-btn:not(:disabled):hover { background: #fff3cf; }
.spell-btn:disabled { opacity: .45; cursor: default; }
.sp-icon { font-size: 1.8rem; }
.spell-burst-big { font-size: 4rem; animation: pop .5s; }

/* ---------- phase 5: duels, cloak, race ---------- */
.duel-tile { border-color: #c9a4ff; background: linear-gradient(120deg, #3b1d6e, #6b2a8f); }
.duel-tile strong { color: #e5d4ff; }
.hub-tiles { grid-template-columns: 2fr 1fr 1fr; }
@media (max-width: 1100px) { .hub-tiles { grid-template-columns: 1fr 1fr; } .hub-tiles > :first-child { grid-column: 1 / -1; } }
@media (max-width: 560px) { .hub-tiles { grid-template-columns: 1fr; } }
.badge-count { min-width: 32px; height: 32px; border-radius: 16px; background: #ff5e5e; color: #fff; font-weight: bold; display: inline-flex; align-items: center; justify-content: center; }
.duel-head { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: .6rem 0; }
.duelist-card { padding: .8rem 1rem; border-radius: 18px; background: linear-gradient(135deg, var(--h1), var(--night2)); display: flex; flex-direction: column; gap: .2rem; }
.duelist-card .dim, .duel-head .dim { opacity: .3; }
.duel-vs { grid-column: 1 / -1; text-align: center; font-weight: bold; }
.reveal-side { text-align: center; }
.race-banner { margin: .4rem 0; padding: .5rem .9rem; border-radius: 14px; background: #ffffff14; border: 2px solid #ffffff22; font-weight: bold; }

/* ---------- phase 6: reports ---------- */
.viz-root { --series-1: #257de0; --series-2: #f47230; --text-primary: var(--ink); --text-secondary: #5c4a33; margin: .6rem 0; }
.chart-svg { display: block; width: 100%; height: auto; max-height: 280px; }
.chart-svg .grid { stroke: #2a1c0c1f; stroke-width: 1; }
.chart-svg .axis { stroke: #2a1c0c55; stroke-width: 1; }
.chart-svg .tick { fill: var(--text-secondary); font-size: 12px; }
.chart-svg .label { fill: var(--text-primary); font-size: 13px; font-weight: bold; }
.chart-svg .s1, .swatch.s1 { fill: var(--series-1); background: var(--series-1); }
.chart-svg .s2, .swatch.s2 { fill: var(--series-2); background: var(--series-2); }
.chart-svg .hit { fill: transparent; }
.chart-svg .bar:hover .s1, .chart-svg .bar:hover .s2 { opacity: .85; }
.legend-row { display: flex; gap: 1.2rem; color: var(--text-primary); }
.legend-row span { display: inline-flex; align-items: center; gap: .4rem; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin: .4rem 0 .8rem; }
.stat-tile { background: #0000000d; border-radius: 14px; padding: .6rem .8rem; display: flex; flex-direction: column; }
.stat-tile b { font-size: 1.6rem; }
.activity-list { display: flex; flex-direction: column; }
.activity-line { display: grid; grid-template-columns: 11rem 1fr; gap: .8rem; padding: .45rem 0; border-bottom: 1px solid #0001; }
.activity-list.compact .activity-line { grid-template-columns: 1fr; gap: 0; font-size: .85rem; }
@media (max-width: 600px) { .activity-line { grid-template-columns: 1fr; gap: 0; } }
.report { max-width: 900px; margin: 0 auto; }
.report-page { background: #fff; color: #1d1d1d; border-radius: 12px; padding: 1.6rem 2rem; margin-top: .8rem; box-shadow: 0 8px 24px #0008; }
.report-page h1 { color: #1d1d1d; text-shadow: none; font-size: 1.7rem; margin: 0; }
.report-page h2 { font-size: 1.1rem; margin: 1rem 0 .4rem; color: #3b2a7a; }
.report-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid #3b2a7a; padding-bottom: .6rem; }
.report-logo { font-size: 2.6rem; }
.report-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.report-page table { font-size: .85rem; }
.report-foot { margin-top: 1rem; border-top: 1px solid #ddd; padding-top: .4rem; }
@media print {
  @page { size: letter; margin: 12mm; }
  body { background: #fff !important; font-size: 11pt; }
  .sky, .topbar, .foot, .toast, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .report-page { box-shadow: none; padding: 0; margin: 0; border-radius: 0; }
  .report-page section, .report-cols { break-inside: avoid; }
  .chart-svg { max-height: 200px; }
}
