/* CEP Quest. Every colour, font, radius and shadow comes from the IE brand kit's
   tokens (css/ie/ie-tokens.css, linked first). These short names alias them. */
:root {
  --navy: var(--ie-navy);
  --navy-2: var(--ie-navy-hover);
  --navy-3: var(--ie-navy-hover);
  --blue: var(--ie-blue);
  --green: var(--ie-green);
  --pale: var(--ie-pale-green);
  --coral: var(--ie-coral);
  --orange: var(--ie-yellow);
  --cream: var(--ie-light-yellow);
  --ink: var(--ie-text-alt);
  --muted: var(--ie-text-muted);
  --white: var(--ie-surface);
  --ok: var(--ie-success-text);
  --bad: var(--ie-danger-text);
  --line: var(--ie-border);
  --control: var(--ie-border-strong);
  --radius: var(--ie-radius-lg);
  --shadow: var(--ie-shadow);
  --font: var(--ie-font-sans);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 16px/1.5 var(--font);
  color: var(--ink);
  background: var(--pale);
  min-height: 100vh;
}
button { font: inherit; cursor: pointer; }
a { color: var(--ie-link); }
a:hover { color: var(--ie-link-hover); }
h1, h2, h3 { color: var(--navy); line-height: 1.2; margin: 0 0 .5em; }
h1, .title-art { font-family: var(--ie-font-display); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy); color: var(--cream);
  display: flex; align-items: center; gap: 1rem;
  padding: .55rem 1rem;
  box-shadow: var(--ie-shadow);
}
.topbar img { height: 30px; }
.topbar .brand { font-weight: 700; letter-spacing: .02em; color: var(--orange); cursor: pointer; }
.topbar .who { margin-left: auto; display: flex; gap: .9rem; align-items: center; font-size: .9rem; }
.topbar .pill { background: var(--navy-3); padding: .15rem .6rem; border-radius: 99px; white-space: nowrap; }
.topbar button.link { background: none; border: 0; color: var(--orange); text-decoration: underline; padding: 0; }
.topbar a.link { color: var(--orange); }
.xpbar { width: 110px; height: 8px; border-radius: 99px; background: var(--navy-3); overflow: hidden; }
.xpbar > i { display: block; height: 100%; background: var(--coral); }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

/* ---------- cards & buttons */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

a.btn { text-decoration: none; }
.btn {
  border: 0; border-radius: 10px; padding: .65rem 1.1rem;
  background: var(--navy); color: var(--white); font-weight: 600;
  transition: transform .08s ease, background .15s;
}
.btn:hover { background: var(--navy-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.cta { background: var(--coral); color: var(--navy); }
.btn.cta:hover { background: var(--ie-coral-hover); }
.btn.ghost { background: transparent; color: var(--navy); border: 2px solid var(--blue); }
.btn.ghost:hover { background: var(--pale); }
.btn.small { padding: .35rem .7rem; font-size: .85rem; }

.tag {
  display: inline-block; font-size: .75rem; font-weight: 600;
  padding: .1rem .55rem; border-radius: 99px; background: var(--orange); color: var(--navy);
}
.tag.blue { background: var(--blue); color: var(--white); }
.tag.green { background: var(--green); }
.tag.coral { background: var(--coral); }

input[type=text], input[type=password], input[type=number], textarea, select {
  font: inherit; padding: .6rem .75rem; border-radius: 10px;
  border: 2px solid var(--control); background: var(--white); color: var(--ink); width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--blue); }
label { font-weight: 600; color: var(--navy); display: block; margin: .6rem 0 .25rem; }

/* ---------- gate / login */
.splash {
  min-height: calc(100vh - 60px); display: grid; place-items: center;
  background: radial-gradient(circle at 20% 10%, var(--navy-3), var(--navy) 60%);
  color: var(--cream); padding: 1rem;
}
.splash .card { max-width: 430px; width: 100%; color: var(--navy); }
.splash .card .title-art { color: var(--navy); }
.splash h1 { font-size: 2rem; }
.title-art { font-size: 2.6rem; font-weight: 700; color: var(--orange); letter-spacing: .02em; }
.title-art span { color: var(--coral); }
.err { color: var(--bad); font-weight: 600; min-height: 1.4em; }

/* ---------- hub (career ladder) */
.hero {
  background: linear-gradient(120deg, var(--navy), var(--navy-3));
  color: var(--cream); border-radius: var(--radius); padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow); display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap;
}
.hero h1 { color: var(--orange); margin: 0; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.6rem; font-weight: 800; background: var(--coral); color: var(--navy); flex: none;
}
.avatar.sm { width: 40px; height: 40px; font-size: 1rem; }
.level-card { position: relative; overflow: hidden; }
.level-card .floor-num {
  position: absolute; right: -10px; top: -22px; font-size: 7rem; font-weight: 900;
  color: var(--pale); z-index: 0;
}
.level-card > * { position: relative; z-index: 1; }
.level-card.locked { filter: grayscale(.8); opacity: .75; }
.wedges { display: flex; gap: .35rem; margin: .5rem 0; }
.wedge {
  width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center;
  font-size: .9rem; background: var(--pale); border: 2px dashed var(--blue);
}
.wedge.on { background: var(--coral); border: 2px solid var(--navy); }
.meter { height: 10px; border-radius: 99px; background: var(--pale); overflow: hidden; }
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--ok)); }

/* ---------- floor map */
.map-wrap { background: var(--cream); border-radius: var(--radius); padding: .75rem; box-shadow: var(--shadow); }
.map-wrap svg { width: 100%; height: auto; display: block; }
.district-room { cursor: default; }
.desk { cursor: pointer; transition: transform .12s; transform-box: fill-box; transform-origin: center; }
.desk:hover { transform: scale(1.12); }
.boss-door { cursor: pointer; }
.boss-door:hover rect { fill: var(--coral); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; margin-top: .5rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: .3rem; vertical-align: -1px; }

/* ---------- encounters */
.encounter { max-width: 760px; margin: 0 auto; }
.enc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; gap: .5rem; flex-wrap: wrap; }
.progress-dots { display: flex; gap: 4px; flex-wrap: wrap; }
.progress-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.progress-dots i.ok { background: var(--ok); }
.progress-dots i.bad { background: var(--bad); }
.progress-dots i.cur { background: var(--coral); }
.ticket {
  border-left: 6px solid var(--blue); background: var(--white);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem 1.3rem;
}
.ticket .from { display: flex; gap: .7rem; align-items: center; margin-bottom: .7rem; color: var(--muted); font-size: .9rem; }
.ticket .stem { font-size: 1.08rem; font-weight: 500; white-space: pre-line; }
.options { display: grid; gap: .55rem; margin-top: 1rem; }
.opt {
  text-align: left; background: var(--pale); border: 2px solid transparent; border-radius: 10px;
  padding: .7rem .9rem; color: var(--ink); display: flex; gap: .7rem; align-items: flex-start;
}
.opt:hover:not(:disabled) { border-color: var(--blue); }
.opt .k {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--white);
  display: grid; place-items: center; font-weight: 700; color: var(--navy); font-size: .85rem;
}
.opt.sel { border-color: var(--navy); background: var(--cream); }
.opt.right { border-color: var(--ok); background: var(--ie-success-bg); }
.opt.wrong { border-color: var(--bad); background: var(--ie-danger-bg); }
.opt .why { display: block; font-size: .85rem; color: var(--muted); margin-top: .25rem; }
.confidence { margin-top: 1rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.confidence .btn { flex: 1; min-width: 120px; }
.feedback {
  margin-top: 1rem; padding: .9rem 1rem; border-radius: 10px; background: var(--cream);
  border-left: 5px solid var(--orange);
}
.feedback.ok { border-color: var(--ok); }
.feedback.bad { border-color: var(--bad); }
.feedback .src { font-size: .78rem; color: var(--muted); margin-top: .4rem; word-break: break-word; }
.calc-step { display: grid; grid-template-columns: 1fr 180px; gap: .6rem; align-items: center; margin: .45rem 0; }
.calc-step.given { opacity: .75; }
.calc-step .ans { font-weight: 700; }
.calc-step .mark { font-weight: 700; }
.solution { font-family: Consolas, "Cascadia Mono", monospace; font-size: .88rem; white-space: pre-wrap; background: var(--pale); padding: .7rem; border-radius: 8px; }
.exhibit { overflow-x: auto; margin: .6rem 0; }
.exhibit table { border-collapse: collapse; font-size: .9rem; min-width: 60%; }
.exhibit th, .exhibit td { border: 1px solid var(--line); padding: .3rem .6rem; text-align: left; }
.exhibit tr:nth-child(even) td { background: var(--cream); }
.exhibit th { background: var(--navy); color: var(--white); }

/* match game */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.match-col { display: grid; gap: .5rem; }
.chip {
  background: var(--white); border: 2px solid var(--control); border-radius: var(--ie-radius); padding: .55rem .7rem;
  text-align: left; color: var(--ink); min-height: 48px;
}
.chip.sel { border-color: var(--navy); background: var(--cream); }
.chip.done { background: var(--green); border-color: var(--ok); color: var(--navy); cursor: default; }
.chip.shake { animation: shake .3s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--navy); }

/* boss */
.boss-intro {
  background: linear-gradient(135deg, var(--navy), var(--ie-navy-deep));
  color: var(--cream); border-radius: var(--radius); padding: 1.5rem; text-align: center;
  box-shadow: var(--shadow);
}
.boss-intro .boss-face { font-size: 4rem; animation: bob 2s ease-in-out infinite; }
.boss-intro h2 { color: var(--coral); }
@keyframes bob { 50% { transform: translateY(-6px); } }
.hp { height: 14px; border-radius: 99px; background: color-mix(in srgb, var(--ie-surface) 20%, transparent); overflow: hidden; margin: .5rem auto; max-width: 360px; }
.hp > i { display: block; height: 100%; background: var(--coral); transition: width .4s; }

/* mock exam */
.mock-nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 4px; margin-top: .75rem; }
.mock-nav button {
  border: 1px solid var(--line); background: var(--white); border-radius: var(--ie-radius-sm); font-size: .75rem; padding: .3rem 0;
}
.mock-nav button.ans { background: var(--green); }
.mock-nav button.flag { background: var(--orange); }
.mock-nav button.cur { outline: 2px solid var(--navy); }

/* leaderboard */
table.lb { width: 100%; border-collapse: collapse; }
table.lb th, table.lb td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--line); }
table.lb th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.lb tr.me td { background: var(--cream); font-weight: 600; }
table.lb td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* toasts & modal */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 50; }
.toast {
  background: var(--navy); color: var(--cream); padding: .7rem 1rem; border-radius: 10px;
  box-shadow: var(--shadow); animation: pop .25s ease-out; max-width: 320px;
}
.toast.gold { background: var(--coral); color: var(--navy); font-weight: 700; }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } }
.modal-back {
  position: fixed; inset: 0; background: color-mix(in srgb, var(--ie-navy) 55%, transparent); display: grid; place-items: center; z-index: 40; padding: 1rem;
}
.modal { background: var(--white); border-radius: var(--radius); padding: 1.25rem; max-width: 520px; width: 100%; box-shadow: var(--shadow); }

.office { display: flex; gap: .5rem; flex-wrap: wrap; font-size: 1.6rem; }
.office span { background: var(--pale); border-radius: 10px; padding: .2rem .45rem; }
.office span.locked { filter: grayscale(1); opacity: .3; }

@media (max-width: 640px) {
  .topbar .xpbar, .topbar .hide-sm { display: none; }
  .topbar { gap: .6rem; }
  .topbar .brand { white-space: nowrap; }
  .topbar .who { flex-wrap: wrap; justify-content: flex-end; gap: .25rem .7rem; }
  main { padding: 1rem 16px 4rem; }
  .calc-step { grid-template-columns: 1fr; }
  .match-grid { grid-template-columns: 1fr; }
  .title-art { font-size: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- landing (game picker) */
main.bleed { max-width: none; padding: 0; }
.landing { width: 100%; max-width: 760px; text-align: center; }
.landing .lead { font-size: 1.1rem; margin: .25rem 0 1.5rem; }
.landing .signin { max-width: 430px; margin: 0 auto; color: var(--navy); }
.landing .signin .btn { display: block; }
.games { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); text-align: left; }
.gamecard { display: flex; flex-direction: column; color: var(--ink); text-decoration: none; transition: transform .1s ease, box-shadow .15s; }
.gamecard + .gamecard { margin-top: 0; }
.gamecard:hover, .gamecard:focus-visible { transform: translateY(-3px); box-shadow: var(--ie-shadow-lg); outline: none; }
.gamecard h2 { margin: .5rem 0 .35rem; }
.gamecard p { margin: 0 0 .6rem; }
.gamecard .tag { align-self: flex-start; }
.gamecard .btn { margin-top: auto; align-self: flex-start; }
.gamecard[data-game="rpg"] { border-top: 6px solid var(--coral); }
.gamecard[data-game="quest"] { border-top: 6px solid var(--blue); }
