/* ============================================================
   KOSEN·KMITL Live Quiz — shared stylesheet
   Design: "Premium Academic / Editorial" + game energy
   Answers are always coded by COLOR + SHAPE + TEXT (WCAG-AA).
   ============================================================ */

:root {
  /* Brand (KMITL IDENTITY 2022 + KOSEN logo blue) */
  --kmitl-orange: #E35205;
  --kmitl-orange-deep: #B83E00;
  --kosen-blue: #017BC4;
  --kosen-blue-deep: #015C93;

  /* Surface / ink */
  --paper: #FBF9F5;
  --paper-2: #FFFFFF;
  --ink: #181512;
  --ink-2: #3A342E;
  --muted: #726A61;   /* 5.06:1 on paper */
  --faint: #615948;   /* 6.59:1 on paper, 5.26:1 on the dark gradient — AA for informational text */
  --decor: #A89F94;   /* decorative only (e.g. the "·" separator); never load-bearing text */
  --hair: rgba(24, 21, 18, .14);
  --hair-2: rgba(24, 21, 18, .08);

  /* Answer hues (tiles only — chrome stays brand orange+blue) */
  --a-red: #E21B3C;    --a-red-d: #B01430;
  --a-blue: #1368CE;   --a-blue-d: #0E4E9E;
  --a-yellow: #D89E00; --a-yellow-d: #A87A00;
  --a-green: #26890C;  --a-green-d: #1B6408;
  --yellow-ink: #3a2a00;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --shadow-card: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 18px 44px -22px rgba(24, 21, 18, .42), 0 2px 8px -3px rgba(24, 21, 18, .18);
  --shadow-soft: 0 10px 30px -18px rgba(24, 21, 18, .5);
}

* { box-sizing: border-box; }
html { margin: 0; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1400px 700px at 50% -12%, #F3F0E9 0%, rgba(243, 240, 233, 0) 60%),
    linear-gradient(180deg, #EAE6DD 0%, #E4E0D6 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
[hidden] { display: none !important; }
/* all answer-shape glyphs inherit their box color (color+shape+text coding) */
.glyph, .pglyph, .bglyph, .rglyph, .pwait .shapes svg { fill: currentColor; }

button { font-family: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(1, 123, 196, .6);
  outline-offset: 2px;
}

/* ---------- brand masthead ---------- */
.masthead {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  flex-wrap: wrap;
}
.mark { display: flex; flex-direction: column; gap: 3px; line-height: 1; }
.mark .word { font: 700 clamp(20px, 2.3vw, 30px)/1 var(--serif); letter-spacing: .005em; }
.mark .word .k { color: var(--kosen-blue); }
.mark .word .m { color: var(--kmitl-orange); }
.mark .word .dot { color: var(--decor); padding: 0 2px; }
.mark .sub { font: 600 10px/1 var(--mono); letter-spacing: .34em; text-transform: uppercase; color: var(--muted); }

.live { display: flex; align-items: center; gap: 8px; }
.live .d {
  width: 9px; height: 9px; border-radius: 50%; background: var(--kosen-blue);
  box-shadow: 0 0 0 4px rgba(1, 123, 196, .16); animation: pulse 1.8s ease-in-out infinite;
}
.live .t { font: 600 11px/1 var(--mono); letter-spacing: .24em; text-transform: uppercase; color: var(--kosen-blue-deep); }

.pin-chip {
  display: flex; flex-direction: column; align-items: flex-end; gap: 5px;
  padding: 9px 16px 11px; border: 1.5px solid var(--kmitl-orange);
  border-radius: 12px; background: linear-gradient(180deg, #fff, #FFF7F2);
  box-shadow: 0 6px 18px -12px rgba(227, 82, 5, .6);
}
.pin-chip .lab { font: 700 10px/1 var(--mono); letter-spacing: .30em; text-transform: uppercase; color: var(--kmitl-orange-deep); }
.pin-chip .digits { font: 700 clamp(24px, 3vw, 34px)/1 var(--mono); letter-spacing: .16em; color: var(--kmitl-orange); font-variant-numeric: tabular-nums; }

.drule { height: 0; border-top: 2px solid var(--kmitl-orange); position: relative; margin-top: 12px; }
.drule::after { content: ""; position: absolute; left: 0; right: 0; top: 4px; height: 1px; background: var(--kosen-blue); opacity: .55; }

/* ---------- page scaffold ---------- */
.stage {
  max-width: 1360px; margin: 0 auto; min-height: 100vh;
  padding: clamp(18px, 3vh, 36px) clamp(16px, 4vw, 52px) clamp(18px, 3vh, 40px);
  display: flex; flex-direction: column; gap: clamp(12px, 2vh, 20px);
  position: relative;
}
.stage::before {
  content: ""; position: fixed; left: 0; top: 0; bottom: 0; width: 6px;
  background: linear-gradient(180deg, var(--kmitl-orange), var(--kosen-blue));
  opacity: .9; z-index: 10;
}

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: none; cursor: pointer; border-radius: 14px;
  padding: 16px 28px; font: 800 17px/1 var(--sans); letter-spacing: .02em;
  color: #fff; background: linear-gradient(180deg, var(--kmitl-orange-deep), #9A3600);
  box-shadow: 0 14px 28px -12px rgba(227, 82, 5, .65), inset 0 1px 0 rgba(255, 255, 255, .3);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.04); }
.btn:active { transform: translateY(1px) scale(.99); box-shadow: 0 6px 14px -8px rgba(227, 82, 5, .55); }
.btn:disabled {
  cursor: default; color: #fff; background: #C9C2B8; box-shadow: none; transform: none; filter: none;
}
.btn.blue {
  background: linear-gradient(180deg, var(--kosen-blue-deep), #014A78);
  box-shadow: 0 14px 28px -12px rgba(1, 123, 196, .6), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.btn-ghost {
  appearance: none; cursor: pointer; border-radius: 10px; padding: 10px 16px;
  font: 700 13px/1 var(--sans); color: var(--kosen-blue-deep);
  background: transparent; border: 1.5px solid rgba(1, 123, 196, .45);
  transition: background .12s ease;
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.btn-ghost:hover { background: rgba(1, 123, 196, .08); }

/* ---------- host: setup ---------- */
.setup-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
.setup-card {
  width: min(560px, 94vw); background: var(--paper); border: 1px solid var(--hair);
  border-radius: 20px; box-shadow: var(--shadow-card); padding: 36px 38px 38px;
  display: flex; flex-direction: column; gap: 22px;
}
.setup-card h1 { margin: 0; font: 600 34px/1.15 var(--serif); }
.setup-card .lead { margin: -10px 0 0; font: 400 15px/1.55 var(--sans); color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font: 700 11px/1 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--ink-2); }
.select-wrap { position: relative; }
.select-wrap select {
  appearance: none; width: 100%; padding: 15px 44px 15px 16px;
  font: 600 17px/1.2 var(--sans); color: var(--ink);
  background: var(--paper-2); border: 1.5px solid var(--hair); border-radius: 12px;
}
.select-wrap::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 10px; height: 10px;
  border-right: 2.5px solid var(--kmitl-orange); border-bottom: 2.5px solid var(--kmitl-orange);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.empty-banks {
  padding: 14px 16px; border-radius: 12px; border: 1.5px solid rgba(227, 82, 5, .4);
  background: #FFF4EC; font: 500 14px/1.5 var(--sans); color: var(--ink-2);
}
.empty-banks code { font: 600 12px var(--mono); color: var(--kmitl-orange-deep); }

/* ---------- host: meta row / timer ---------- */
.qmeta { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.progress { display: flex; flex-direction: column; gap: 11px; min-width: 220px; }
.progress .plabel { font: 600 15px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.progress .plabel b { color: var(--kmitl-orange-deep); font-weight: 800; }
.progress .plabel .cat { color: var(--faint); font-weight: 600; margin-left: 10px; text-transform: none; letter-spacing: .02em; }
.segs { display: flex; gap: 6px; }
.segs i { flex: 1; max-width: 34px; height: 6px; border-radius: 3px; background: var(--hair); }
.segs i.on { background: var(--kmitl-orange); }
.segs i.cur { background: var(--kmitl-orange); box-shadow: 0 0 0 3px rgba(227, 82, 5, .18); }

.status { display: flex; align-items: center; gap: 26px; }
.answered { text-align: right; line-height: 1; }
.answered .n { font: 800 30px/1 var(--sans); color: var(--ink); font-variant-numeric: tabular-nums; }
.answered .l { display: block; margin-top: 6px; font: 600 11px/1 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }

.timer { position: relative; width: 96px; height: 96px; flex: none; }
.timer svg { width: 96px; height: 96px; transform: rotate(-90deg); }
.timer .track { fill: none; stroke: var(--hair); stroke-width: 9; }
.timer .arc {
  fill: none; stroke: var(--kmitl-orange); stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 276.46; stroke-dashoffset: 0;
}
.timer.low .arc { stroke: var(--a-red); }
.timer.low { animation: heartbeat .9s ease-in-out infinite; }
.timer .cap { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.timer .cap .sec { font: 700 32px/1 var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.timer .cap .of { margin-top: 3px; font: 600 9px/1 var(--mono); letter-spacing: .16em; color: var(--muted); }

/* ---------- host: stem + answers ---------- */
.stem {
  font: 600 clamp(30px, 4.3vw, 52px)/1.14 var(--serif); color: var(--ink);
  letter-spacing: .002em; margin: 2px 0; max-width: 1100px; text-wrap: balance;
}

.answers {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; min-height: 0;
  align-content: stretch;
}
.opt {
  position: relative; display: flex; align-items: stretch; min-height: 118px;
  background: var(--paper-2); border: 1.5px solid var(--o);
  border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-soft);
}
.opt .band {
  flex: none; width: clamp(90px, 10vw, 150px); background: var(--o);
  display: flex; align-items: center; justify-content: center;
}
.opt .band .glyph { width: clamp(40px, 4.6vw, 62px); height: clamp(40px, 4.6vw, 62px); color: #fff; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .22)); }
.opt.yellow .band .glyph { color: var(--yellow-ink); }
.opt .body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 14px clamp(14px, 2vw, 26px); min-width: 0; }
.opt .otag { font: 700 11px/1 var(--mono); letter-spacing: .24em; text-transform: uppercase; color: var(--muted); }
.opt .otxt { font: 600 clamp(19px, 2.3vw, 31px)/1.12 var(--sans); color: var(--ink); letter-spacing: -.01em; overflow-wrap: anywhere; }
.opt .ghost {
  position: absolute; right: 16px; bottom: -14px; font: 800 96px/1 var(--serif);
  color: var(--o); opacity: .08; pointer-events: none;
}

/* ---------- host: lobby ---------- */
.lobby {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; text-align: center;
}
.lobby .join-line { font: 600 clamp(22px, 2.6vw, 34px)/1.3 var(--serif); color: var(--ink); }
.lobby .join-line code {
  font: 700 clamp(20px, 2.4vw, 30px) var(--mono); color: var(--kosen-blue-deep);
  background: rgba(1, 123, 196, .08); padding: 3px 12px; border-radius: 10px;
}
.lobby .pcount { display: flex; align-items: baseline; gap: 14px; }
.lobby .pcount .n { font: 800 clamp(54px, 7vw, 88px)/1 var(--sans); color: var(--kmitl-orange); font-variant-numeric: tabular-nums; }
.lobby .pcount .l { font: 600 13px/1 var(--mono); letter-spacing: .26em; text-transform: uppercase; color: var(--muted); }
.roster { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 900px; }
.roster .chip {
  font: 700 14px/1 var(--mono); color: var(--ink-2);
  background: var(--paper-2); border: 1px solid var(--hair); border-radius: 999px;
  padding: 8px 14px; box-shadow: var(--shadow-soft);
  animation: pop-in .3s cubic-bezier(.3, 1.4, .5, 1) both;
}

/* ---------- host: results ---------- */
.reveal {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 16px 22px; border-radius: 16px;
  background: linear-gradient(180deg, #fff, #F7FAFE);
  border: 1.5px solid rgba(1, 123, 196, .35);
  box-shadow: 0 20px 44px -26px rgba(1, 123, 196, .55), var(--shadow-soft);
  animation: rise-in .5s cubic-bezier(.3, 1.2, .4, 1) both;
}
.reveal .rglyph { width: 56px; height: 56px; flex: none; color: var(--o, var(--kosen-blue)); filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .18)); }
.reveal .rb-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.reveal .rb-k { font: 700 11px/1 var(--mono); letter-spacing: .26em; text-transform: uppercase; color: var(--kosen-blue-deep); }
.reveal .rb-a { font: 600 clamp(22px, 2.6vw, 34px)/1.1 var(--serif); color: var(--ink); }
.reveal .rb-pill {
  margin-left: auto; flex: none; display: flex; align-items: center; gap: 9px;
  padding: 11px 18px; border-radius: 999px; background: var(--kmitl-orange-deep);
  box-shadow: 0 10px 22px -10px rgba(227, 82, 5, .7);
}
.reveal .rb-pill .ck { width: 20px; height: 20px; color: #fff; }
.reveal .rb-pill .lab { font: 800 14px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: #fff; }

.results-grid { flex: 1; display: grid; grid-template-columns: 1.55fr 1fr; gap: clamp(18px, 3vw, 34px); min-height: 0; }
.col-h {
  display: flex; align-items: baseline; justify-content: space-between;
  font: 600 13px/1 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--muted);
  padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--hair);
}
.col-h .accent { color: var(--kmitl-orange-deep); }

.bars { display: flex; flex-direction: column; gap: 17px; }
.bar { display: flex; align-items: center; gap: 15px; }
.bar .bglyph { width: 30px; height: 30px; flex: none; color: var(--o); }
.bar .name { flex: none; width: clamp(150px, 18vw, 242px); font: 600 17px/1.15 var(--sans); color: var(--ink); letter-spacing: -.01em; overflow-wrap: anywhere; }
.bar .track { position: relative; flex: 1; height: 38px; border-radius: 9px; background: rgba(24, 21, 18, .06); overflow: hidden; }
.bar .fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: var(--w, 0%);
  background: var(--o); border-radius: 9px;
  animation: grow 1.05s cubic-bezier(.4, 0, .15, 1) both;
}
.bar .end { flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.bar .cnt { min-width: 34px; text-align: right; font: 800 26px/1 var(--sans); color: var(--ink); font-variant-numeric: tabular-nums; }
.bar.correct .track { box-shadow: 0 0 0 2px var(--kmitl-orange), 0 12px 24px -14px rgba(227, 82, 5, .55); }
.bar.correct .name { color: var(--kmitl-orange-deep); font-weight: 800; }
.bar.correct .cnt { color: var(--kmitl-orange-deep); }
.bar .ctag {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 9px; border-radius: 999px; background: rgba(227, 82, 5, .12);
  font: 800 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--kmitl-orange-deep);
}
.bar .ctag .ck { width: 12px; height: 12px; }

.lb { display: flex; flex-direction: column; gap: 9px; }
.lrow {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 14px; border-radius: 12px; background: var(--paper-2);
  border: 1px solid var(--hair-2);
}
.lrow .rk {
  width: 30px; height: 30px; flex: none; border-radius: 8px; border: 1.5px solid var(--hair);
  display: flex; align-items: center; justify-content: center;
  font: 800 14px/1 var(--mono); color: var(--muted);
}
.lrow.first .rk { background: var(--kmitl-orange-deep); border-color: var(--kmitl-orange-deep); color: #fff; }
.lrow .nm { font: 600 18px/1 var(--mono); color: var(--ink); letter-spacing: .01em; overflow-wrap: anywhere; }
.lrow .pts { margin-left: auto; font: 700 19px/1 var(--sans); color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- host: podium / finished ---------- */
.finished { flex: 1; display: flex; flex-direction: column; gap: 26px; min-height: 0; }
.fin-title { text-align: center; font: 600 clamp(30px, 4vw, 46px)/1.1 var(--serif); margin: 4px 0 0; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 18px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(240px, 28vw); }
.pod .pnm { font: 700 clamp(15px, 1.6vw, 20px)/1.1 var(--mono); color: var(--ink); text-align: center; overflow-wrap: anywhere; }
.pod .ppts { font: 800 clamp(16px, 1.8vw, 22px)/1 var(--sans); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pod .block {
  width: 100%; border-radius: 14px 14px 0 0; display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12px; font: 800 26px/1 var(--serif); color: #fff;
  box-shadow: var(--shadow-soft); animation: podium-rise .7s cubic-bezier(.3, 1.2, .4, 1) both;
}
.pod.p1 .block { height: clamp(120px, 20vh, 190px); background: linear-gradient(180deg, #F06120, var(--kmitl-orange-deep)); animation-delay: .25s; }
.pod.p2 .block { height: clamp(84px, 14vh, 130px); background: linear-gradient(180deg, #1D93DD, var(--kosen-blue-deep)); animation-delay: .12s; }
.pod.p3 .block { height: clamp(60px, 10vh, 96px); background: linear-gradient(180deg, #8B8175, #6b6357); animation-delay: 0s; }
.fin-rest { max-width: 720px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; overflow: auto; min-height: 0; }

/* ---------- host: footer / next ---------- */
.host-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: auto; }
.foot-hint { font: 500 12px/1.5 var(--mono); letter-spacing: .06em; color: var(--faint); text-transform: uppercase; }

/* ---------- player ---------- */
.pwrap {
  max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; padding: 0; position: relative;
}

.pjoin { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 28px 22px 40px; gap: 26px; }
.pjoin .mark { align-items: center; text-align: center; }
.join-card {
  background: var(--paper); border: 1px solid var(--hair); border-radius: 20px;
  box-shadow: var(--shadow-card); padding: 28px 26px 30px;
  display: flex; flex-direction: column; gap: 18px;
}
.join-card h1 { margin: 0; font: 600 28px/1.15 var(--serif); }
.join-card input {
  width: 100%; padding: 16px; border: 1.5px solid var(--hair); border-radius: 12px;
  font: 600 18px/1.2 var(--sans); color: var(--ink); background: var(--paper-2);
}
.join-card input#pin-input { font: 700 24px var(--mono); letter-spacing: .3em; text-align: center; }
.join-err { font: 600 14px/1.4 var(--sans); color: var(--a-red-d); min-height: 20px; }
.pdpa { font: 500 12px/1.5 var(--sans); color: var(--muted); }

.pgame { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.pstatus { padding: 18px 18px 14px; border-bottom: 1px solid var(--hair); background: var(--paper); }
.pstatus .prow { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.pstatus .q { font: 700 13px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.pstatus .q b { color: var(--kmitl-orange-deep); }
.pstatus .brand { font: 700 14px/1 var(--serif); }
.pstatus .brand .k { color: var(--kosen-blue); }
.pstatus .brand .m { color: var(--kmitl-orange); }
.pstatus .brand .dot { color: var(--decor); }
.ptimer { display: flex; align-items: center; gap: 12px; }
.ptimer .track { flex: 1; height: 10px; border-radius: 6px; background: rgba(24, 21, 18, .09); overflow: hidden; }
.ptimer .fill { height: 100%; width: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--kmitl-orange), #F5792F); }
.ptimer.low .fill { background: linear-gradient(90deg, var(--a-red-d), var(--a-red)); }
.ptimer .sec { font: 700 17px/1 var(--mono); color: var(--kmitl-orange-deep); font-variant-numeric: tabular-nums; min-width: 26px; text-align: right; }

.pstem { padding: 14px 18px 0; font: 600 18px/1.35 var(--serif); color: var(--ink); }

.ptiles { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px 16px 12px; min-height: 0; }
.ptile {
  position: relative; border: none; cursor: pointer; border-radius: 20px; background: var(--o);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  box-shadow: 0 14px 26px -14px var(--o), inset 0 1px 0 rgba(255, 255, 255, .25);
  color: #fff; overflow: hidden; padding: 14px 10px; min-height: 120px;
  transition: transform .1s ease, box-shadow .1s ease, opacity .25s ease, filter .25s ease;
}
.ptile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(0, 0, 0, .10)); pointer-events: none; }
.ptile:active { transform: scale(.96); box-shadow: 0 6px 14px -10px var(--o), inset 0 1px 0 rgba(255, 255, 255, .25); }
.ptile .pglyph { width: 46px; height: 46px; color: #fff; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .28)); z-index: 1; }
.ptile .pl { font: 700 16px/1.15 var(--sans); text-align: center; z-index: 1; letter-spacing: -.01em; overflow-wrap: anywhere; }
.ptile.yellow { color: var(--yellow-ink); }
.ptile.yellow .pglyph { color: var(--yellow-ink); }
.ptile.picked { box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--o), 0 14px 26px -12px var(--o); }
.ptile.picked::before {
  content: "✓"; position: absolute; top: 8px; right: 12px; z-index: 2;
  font: 800 22px/1 var(--sans); color: inherit;
}
.ptile.dim { opacity: .32; filter: saturate(.55); }
.ptile.reveal-correct { box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--kmitl-orange), 0 16px 30px -12px rgba(227, 82, 5, .6); }
.ptile:disabled { cursor: default; }

.plock {
  margin: 0 16px; padding: 12px 16px; border-radius: 12px; text-align: center;
  font: 700 14px/1.3 var(--sans); color: var(--kosen-blue-deep);
  background: rgba(1, 123, 196, .08); border: 1.5px solid rgba(1, 123, 196, .3);
}

.pfeedback {
  margin: 0 16px; padding: 16px; border-radius: 14px; text-align: center;
  font: 800 20px/1.2 var(--sans); animation: pop-in .35s cubic-bezier(.3, 1.4, .5, 1) both;
}
.pfeedback.good { color: #fff; background: linear-gradient(180deg, #2FA412, var(--a-green-d)); box-shadow: 0 14px 28px -14px rgba(38, 137, 12, .7); }
.pfeedback.bad { color: #fff; background: linear-gradient(180deg, var(--a-red), var(--a-red-d)); box-shadow: 0 14px 28px -14px rgba(226, 27, 60, .7); }
.pfeedback .sub { display: block; margin-top: 5px; font: 600 13px/1.3 var(--sans); opacity: .92; }

.pboard { padding: 14px 16px 6px; }
.pboard .col-h { margin-bottom: 10px; }

.pwait { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 30px 24px; }
.pwait .big { font: 600 26px/1.25 var(--serif); }
.pwait .sub { font: 500 15px/1.5 var(--sans); color: var(--muted); }
.pwait .shapes { display: flex; gap: 14px; }
.pwait .shapes svg { width: 34px; height: 34px; animation: bob 2.4s ease-in-out infinite; }
.pwait .shapes svg:nth-child(2) { animation-delay: .3s; }
.pwait .shapes svg:nth-child(3) { animation-delay: .6s; }
.pwait .shapes svg:nth-child(4) { animation-delay: .9s; }

.pfooter {
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--hair);
  background: linear-gradient(180deg, #fff, var(--paper));
  display: flex; align-items: center; gap: 12px;
}
.pfooter .av {
  width: 42px; height: 42px; flex: none; border-radius: 12px;
  background: linear-gradient(145deg, var(--kosen-blue), var(--kosen-blue-deep));
  display: flex; align-items: center; justify-content: center;
  font: 800 18px/1 var(--sans); color: #fff; text-transform: uppercase;
  box-shadow: 0 8px 18px -10px rgba(1, 123, 196, .8);
}
.pfooter .pf-txt { display: flex; flex-direction: column; gap: 3px; line-height: 1; min-width: 0; }
.pfooter .pf-l { font: 600 10px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.pfooter .pf-name { font: 700 17px/1 var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.pfooter .pf-right { margin-left: auto; text-align: right; line-height: 1; }
.pfooter .pf-pts { font: 800 20px/1 var(--sans); color: var(--ink); font-variant-numeric: tabular-nums; }
.pfooter .pf-pts small { font: 600 11px var(--mono); color: var(--muted); }
.pfooter .pf-rank { margin-top: 5px; display: inline-block; font: 800 11px/1 var(--mono); letter-spacing: .1em; color: #fff; background: var(--kmitl-orange-deep); padding: 5px 9px; border-radius: 999px; }

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i {
  position: absolute; top: -4vh; width: 10px; height: 14px; border-radius: 2px;
  animation: fall linear both;
}

/* ---------- reconnect banner ---------- */
.netbar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60;
  padding: 10px 18px; border-radius: 999px; font: 700 13px/1 var(--sans); color: #fff;
  background: var(--ink-2); box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .5);
}

/* ---------- motion ---------- */
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 4px rgba(1, 123, 196, .16); } 50% { box-shadow: 0 0 0 7px rgba(1, 123, 196, .04); } }
@keyframes grow { from { width: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes podium-rise { from { transform: translateY(60%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.045); } }
@keyframes fall {
  from { transform: translateY(-6vh) rotate(0deg); }
  to { transform: translateY(106vh) rotate(720deg); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============================================================
   PLATFORM — teacher auth + console (same editorial system)
   ============================================================ */

/* ---------- auth (login / register) refinements ---------- */
.join-card .lead { margin: -8px 0 2px; font: 400 14px/1.55 var(--sans); color: var(--muted); }
.join-card .field + .field { margin-top: 2px; }
.pdpa a { color: var(--kosen-blue-deep); font-weight: 700; text-decoration: none; border-bottom: 1.5px solid rgba(1, 123, 196, .32); }
.pdpa a:hover { border-bottom-color: var(--kosen-blue-deep); }
.pjoin .drule { width: 100%; margin: 2px 0 -6px; }

/* ---------- console: layout ---------- */
.console-body { width: 100%; max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: clamp(18px, 3vh, 26px); }
.console-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px 24px; flex-wrap: wrap; }
.console-top .ct-txt { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.console-top h1 { margin: 0; font: 600 clamp(28px, 3.4vw, 38px)/1.1 var(--serif); color: var(--ink); }
.console-top .lead { margin: 0; max-width: 560px; font: 400 15px/1.55 var(--sans); color: var(--muted); }
.console-top .btn { flex: none; text-decoration: none; }

/* ---------- console: set cards ---------- */
.set-list { display: flex; flex-direction: column; gap: 14px; }
.set-card {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 18px 22px; border: 1px solid var(--hair); border-radius: 16px;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  box-shadow: var(--shadow-soft);
  transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease;
}
.set-card:hover { box-shadow: var(--shadow-card); border-color: rgba(1, 123, 196, .34); transform: translateY(-1px); }
.set-main { display: flex; flex-direction: column; gap: 9px; min-width: min(100%, 240px); flex: 1; }
.set-title { font: 600 clamp(19px, 2vw, 23px)/1.2 var(--serif); color: var(--ink); overflow-wrap: anywhere; }
.set-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.set-count {
  font: 700 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--kmitl-orange-deep); background: rgba(227, 82, 5, .10);
  border: 1px solid rgba(227, 82, 5, .18); padding: 6px 10px; border-radius: 999px;
}
.topic-chip {
  font: 600 12px/1 var(--sans); color: var(--kosen-blue-deep);
  background: rgba(1, 123, 196, .08); border: 1px solid rgba(1, 123, 196, .16);
  padding: 6px 11px; border-radius: 999px; overflow-wrap: anywhere;
}
.topic-chip.more { color: var(--muted); background: transparent; border-color: transparent; }
.set-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

/* compact select (branded chevron) + small buttons for the action cluster */
.start-form { display: flex; align-items: center; gap: 8px; }
.select-sm { position: relative; display: inline-flex; }
.select-sm select {
  appearance: none; padding: 11px 40px 11px 14px; max-width: 220px;
  font: 600 14px/1 var(--sans); color: var(--ink);
  background: var(--paper-2); border: 1.5px solid var(--hair); border-radius: 10px;
}
.select-sm::after {
  content: ""; position: absolute; right: 15px; top: 50%; width: 8px; height: 8px;
  border-right: 2.5px solid var(--kmitl-orange); border-bottom: 2.5px solid var(--kmitl-orange);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.btn.btn-sm { padding: 11px 18px; font-size: 14px; border-radius: 10px; box-shadow: 0 10px 20px -12px rgba(1, 123, 196, .55), inset 0 1px 0 rgba(255, 255, 255, .3); }
.btn-ghost.btn-sm { padding: 10px 15px; }
.btn-ghost.danger { color: var(--a-red-d); border-color: rgba(226, 27, 60, .4); }
.btn-ghost.danger:hover { background: rgba(226, 27, 60, .08); }

/* ---------- console: empty state ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 46px 26px; border: 1.5px dashed var(--hair); border-radius: 18px;
  background: rgba(255, 255, 255, .40);
}
.empty-state .es-shapes { display: flex; gap: 12px; margin-bottom: 4px; }
.empty-state .es-shapes svg { width: 26px; height: 26px; }
.empty-state .es-title { font: 600 21px/1.2 var(--serif); color: var(--ink-2); }
.empty-state .es-sub { font: 500 14px/1.5 var(--sans); color: var(--muted); max-width: 380px; }

/* ---------- set form: fields + preview ---------- */
.setup-card.wide { width: min(760px, 94vw); }
.inp {
  width: 100%; padding: 14px 16px; font: 600 16px/1.25 var(--sans); color: var(--ink);
  background: var(--paper-2); border: 1.5px solid var(--hair); border-radius: 12px;
}
.ta {
  width: 100%; padding: 14px 16px; font: 500 14px/1.6 var(--mono); color: var(--ink);
  background: var(--paper-2); border: 1.5px solid var(--hair); border-radius: 12px; resize: vertical;
}
.inp:focus, .ta:focus { border-color: rgba(1, 123, 196, .5); }
.file-field input[type="file"] { font: 500 13px/1.4 var(--sans); color: var(--ink-2); }
.file-field input[type="file"]::file-selector-button {
  appearance: none; cursor: pointer; margin-right: 12px; padding: 9px 14px; border-radius: 9px;
  font: 700 12px/1 var(--sans); color: var(--kosen-blue-deep);
  background: transparent; border: 1.5px solid rgba(1, 123, 196, .45);
}
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.preview-panel {
  margin-top: 8px; padding: 14px 16px; border-radius: 12px;
  border: 1.5px solid var(--hair); background: rgba(1, 123, 196, .045);
  font: 500 14px/1.6 var(--sans); color: var(--ink-2);
}
.preview-panel.empty { color: var(--muted); font-style: italic; }
.preview-panel .pv-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.preview-panel .pv-row .pv-t { overflow-wrap: anywhere; min-width: 0; }
.preview-panel .pv-row .pv-c { flex: none; font: 700 12px/1 var(--mono); letter-spacing: .1em; color: var(--kosen-blue-deep); }
.preview-panel .pv-total { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--hair); font: 800 14px/1.3 var(--sans); color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .answers { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr; }
  .opt { min-height: 84px; }
  .stage::before { width: 4px; }
  .set-card { align-items: stretch; }
  .set-actions { width: 100%; }
  .select-sm, .select-sm select { flex: 1; max-width: none; width: 100%; }
  .start-form { flex: 1; min-width: 100%; }
}
@media (max-height: 720px) {
  .timer, .timer svg { width: 76px; height: 76px; }
  .timer .cap .sec { font-size: 26px; }
}

/* ---------- home: the front door ----------------------------------------
   The bare hostname used to render the live-game PIN box, so a student who
   typed it had no route to the 19 weeks of material, the graded quiz, the
   hand-in or the arena. This page exists to answer one question — "where do I
   go?" — and to be honest about what each destination COSTS: a code, a PIN, or
   the class VPN. A student who reaches a page only to discover they needed a
   slip they left at home has been failed by the front door, not by the page. */
.home-sec { display: flex; flex-direction: column; gap: 10px; }
.home-sec > h2 {
  margin: 0; font: 700 12px/1 var(--mono); letter-spacing: .16em;
  text-transform: uppercase; color: var(--faint);
}
.home-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.home-item a {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 13px 15px; border: 1px solid var(--hair); border-radius: 13px;
  background: var(--paper-2); text-decoration: none; color: var(--ink);
  transition: border-color .12s ease, transform .12s ease;
}
.home-item a:hover { border-color: var(--kosen-blue); transform: translateY(-1px); }
.home-item a:focus-visible { outline: 3px solid var(--kosen-blue); outline-offset: 2px; }
.home-item b { font: 600 17px/1.25 var(--serif); }
.home-item .what { font: 400 13px/1.5 var(--sans); color: var(--muted); flex: 1 1 100%; }
/* What it costs to walk through the door. Deliberately not a colour-only cue. */
.home-item .need {
  font: 700 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 7px; border-radius: 6px; white-space: nowrap;
  color: var(--kmitl-orange-deep); background: rgba(227, 82, 5, .09);
}
.home-item .need.free { color: var(--faint); background: rgba(97, 89, 72, .09); }
