/* Hubbaloo student app. Phone first (360 px up); one column; the "sticker" look from the logo:
   flat bright fills, dark ink outlines, hard offset shadows, generous rounding (SPEC 10.1).
   Text on a role colour is always Ink. */
:root {
  --paper: #FFF4D6; --panel: #FFFDF6; --card: #FFFFFF; --ink: #1F1B3A; --muted: #575270; --line: #1F1B3A;
  --on-role: #1F1B3A; --accent: #3B6CF6; --on-accent: #1F1B3A; --hold: #FFE08A; --hold-ink: #1F1B3A;
  --good: #0B7468; --bad: #B92D25; --tick: #FFB400; --shadow: 3px 3px 0 var(--line);
  --role: #FF5A4E;
  --role-A: #FF5A4E; --role-B: #3B6CF6; --role-C: #12B5A6; --role-D: #FFB400;
  --display: "Baloo 2", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --body: "Figtree", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #14112A; --panel: #1F1B3A; --card: #2A2550; --ink: #FFFFFF; --muted: #BDB8DA; --line: #F4F1FF;
  --hold: #5A4A00; --hold-ink: #FFE9A3; --good: #5FD8C7; --bad: #FF9A92; color-scheme: dark; } }
:root[data-theme="dark"] {
  --paper: #14112A; --panel: #1F1B3A; --card: #2A2550; --ink: #FFFFFF; --muted: #BDB8DA; --line: #F4F1FF;
  --hold: #5A4A00; --hold-ink: #FFE9A3; --good: #5FD8C7; --bad: #FF9A92; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.45;
  padding-left: max(0px, env(safe-area-inset-left, 0px)); padding-right: max(0px, env(safe-area-inset-right, 0px)); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 800; line-height: 1.1; margin: 0; }
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--panel); display: flex; flex-direction: column; }
@media (min-width: 520px) { .app { border-left: 2px solid var(--line); border-right: 2px solid var(--line); } }
.pad { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.label { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.muted { color: var(--muted); }
.box { background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); }
.box p { margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 2px solid var(--line); border-radius: 14px;
  padding: 12px 16px; font-weight: 800; font-family: var(--display); font-size: 1.1rem; background: var(--card); box-shadow: var(--shadow); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: none; text-decoration: underline; color: var(--muted); padding: 8px; font-size: .9rem; }

/* loading text (stays only if the scripts cannot load) and the offline bar */
.boot { padding: 40px 16px; text-align: center; color: var(--muted); margin: 0; }
.net { position: sticky; top: 0; z-index: 5; background: var(--ink); color: var(--paper); text-align: center; font-weight: 700; font-size: .9rem; padding: 6px 12px; }
.net[hidden] { display: none; }

/* join */
.brand { padding: 28px 16px 8px; text-align: center; }
.brand img { width: min(260px, 70vw); height: auto; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 700; }
.field input, .field select { border: 2px solid var(--line); border-radius: 12px; padding: 12px; background: var(--card); font-size: 1.1rem; }
.field input.code { font-family: var(--display); font-weight: 800; letter-spacing: .3em; text-transform: uppercase; font-size: 1.5rem; }
.error { color: var(--bad); font-weight: 700; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2px solid var(--line); border-radius: 999px; padding: 4px 12px; background: var(--card); font-weight: 700; font-size: .9rem; text-align: left; }
.chip small { display: block; font-weight: 500; color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 13px; font-weight: 700; font-size: .92rem; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* card header */
.top { background: var(--role); color: var(--on-role); padding: 16px 18px 14px; border-bottom: 3px solid var(--on-role);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; position: sticky; top: 0; z-index: 2; }
.top img { width: 56px; height: auto; flex: none; }
.room { display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: #FFFFFF;
  color: #1F1B3A; border: 2px solid #1F1B3A; border-radius: 999px; padding: 1px 10px; }
.who { font-family: var(--display); font-size: 2rem; font-weight: 800; line-height: 1.05; margin-top: 6px; }

/* pictures from the asset library (SPEC 10): sticker look, Ink outline, hard shadow */
img.avatar { width: 76px; height: 76px; flex: none; border: 3px solid #1F1B3A; border-radius: 18px; box-shadow: 3px 3px 0 #1F1B3A; background: #FFFFFF; object-fit: cover; }
img.avatar.small { width: 34px; height: 34px; border-width: 2px; border-radius: 10px; box-shadow: none; }
img.scene, img.cover { display: block; width: 100%; height: auto; object-fit: cover; border: 2px solid var(--line); border-radius: 16px; background: var(--card); }
img.scene { aspect-ratio: 2 / 1; box-shadow: var(--shadow); }
img.cover { aspect-ratio: 3 / 2; }
.box > img.cover { margin-bottom: 10px; }
.scard > img.cover { border-radius: 10px; }
.place { font-weight: 700; font-size: 1.15rem; }

.tools { display: flex; gap: 8px; }
.tool { flex: 1; border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 9px 6px; font-weight: 700; font-size: .95rem; }
.tool[aria-expanded="true"] { background: var(--hold); color: var(--hold-ink); }
.sheet { background: var(--card); border: 2px dashed var(--line); border-radius: 12px; padding: 10px 14px; }
.sheet ul { margin: 4px 0 0; padding-left: 20px; }

/* hidden items */
.reveal { display: flex; flex-direction: column; gap: 8px; }
.item { border: 2px solid var(--line); border-radius: 12px; background: var(--card); overflow: hidden;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.item > button { width: 100%; text-align: left; background: none; border: none; padding: 12px 14px; font-weight: 700;
  display: flex; justify-content: space-between; gap: 10px; align-items: center; -webkit-user-select: none; user-select: none; }
.item .hint { font-size: .78rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.item .ans { display: none; margin: 0; padding: 0 14px 12px; }
.item.open .ans { display: block; }
.item.open { background: var(--hold); color: var(--hold-ink); }
.item.open .hint { color: var(--hold-ink); }
.item .bar { height: 4px; background: var(--tick); width: 0; }
.item.open.timed .bar { animation: drain 6s linear forwards; width: 100%; }
@keyframes drain { from { width: 100%; } to { width: 0; } }
@media (prefers-reduced-motion: reduce) { .item.open.timed .bar { animation: none; } }

/* checklist and notebook */
.ticks { display: flex; flex-direction: column; gap: 6px; }
.tick { display: flex; gap: 10px; align-items: center; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--card); font-weight: 600; }
.tick input { width: 22px; height: 22px; accent-color: var(--tick); flex: none; }
.tick:has(input:checked) { background: var(--hold); color: var(--hold-ink); }
.notes { display: flex; flex-direction: column; gap: 8px; }
.notes label { font-weight: 700; font-size: .9rem; }
.notes input { width: 100%; border: 2px solid var(--line); border-radius: 10px; padding: 9px; background: var(--card); }

/* start screen and rounds (SPEC 4, 7; 0.12) */
.center { text-align: center; }
.goal { background: var(--role); color: var(--on-role); }
.goal .label { color: var(--on-role); }
.link-btn { background: none; border: none; padding: 0 2px; font-weight: 700; color: inherit; text-decoration: underline; }
.plan { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plan li { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.mark { width: 26px; height: 26px; flex: none; border: 2px solid var(--line); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem; background: var(--card); }
.progress-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; scroll-margin-top: 150px; }
.dots { display: flex; gap: 6px; }
.dots span { width: 26px; height: 8px; border-radius: 4px; border: 2px solid var(--line); background: var(--card); }
.dots span.on { background: var(--role); }
.round { background: var(--card); border: 3px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: 4px 4px 0 var(--line); display: flex; flex-direction: column; gap: 14px; }
.round-head { display: flex; align-items: center; gap: 10px; }
.round-head h4 { font-size: 1.35rem; }
.round-head img.avatar.small { width: 44px; height: 44px; }
.step { display: flex; gap: 10px; align-items: flex-start; }
.step > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.step p { margin: 0; }
.step .num { width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--ink); color: var(--paper); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; }
.laters { display: flex; flex-direction: column; gap: 6px; }
.later { display: flex; align-items: center; gap: 10px; border: 2px dashed var(--line); border-radius: 12px; padding: 6px 10px; color: var(--muted); font-weight: 600; background: none; text-align: left; width: 100%; }
.later.done { border-style: solid; color: var(--ink); }
.later.done .mark { background: var(--hold); color: var(--hold-ink); }
.later .hint { margin-left: auto; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.item ul.ans { display: none; margin: 0; padding: 0 14px 12px 32px; }
.item.open ul.ans { display: block; }
.dock { position: sticky; bottom: 8px; z-index: 1; }
/* "About you" stands out from the white card: role colour (Ink text), heavier outline and shadow */
.dock .item { background: var(--role); color: var(--on-role); border-width: 3px; box-shadow: 4px 4px 0 var(--line); }
.dock .item > button { font-family: var(--display); font-size: 1.15rem; }
.dock .item .hint { color: var(--on-role); }
.dock .item.open, .dock .item.open .hint { background: var(--hold); color: var(--hold-ink); }

/* closing */
.locked { border: 2px dashed var(--line); border-radius: 14px; padding: 14px; color: var(--muted); text-align: center; }
.q { background: var(--card); border: 3px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: 4px 4px 0 var(--line); display: flex; flex-direction: column; gap: 10px; }
.q h4 { font-size: 1.35rem; }
.q p { margin: 0; }
.q ul { margin: 0; padding-left: 20px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opts.long { grid-template-columns: 1fr; }
.opt { border: 2px solid var(--line); border-radius: 12px; padding: 10px; background: var(--panel); font-weight: 700; text-align: left; }
.opt[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.fb { font-weight: 800; }
.fb.good { color: var(--good); }
.fb.bad { color: var(--bad); }
.tally { display: flex; flex-wrap: wrap; gap: 6px; }
.tally span { border: 2px solid var(--line); border-radius: 999px; padding: 1px 10px; font-weight: 700; font-size: .9rem; }
.foot { margin-top: auto; padding: 8px 16px 24px; text-align: center; }
.big { font-family: var(--display); font-size: 2.6rem; font-weight: 800; text-align: center; }

/* teacher page (F4, minimal): wider, rooms side by side */
.app.wide { max-width: 1100px; }
.bar-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 2px solid var(--line); flex-wrap: wrap; }
.bar-top .muted { margin-left: auto; font-size: .9rem; }
.brand-small img { width: 140px; height: auto; display: block; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.room-card .code { letter-spacing: .12em; margin: 0; }
.status { border: 2px solid var(--line); border-radius: 999px; padding: 1px 10px; font-weight: 700; font-size: .85rem; }
.players { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.players img.avatar.small { vertical-align: middle; margin-right: 6px; }
.pill { display: inline-block; background: var(--role); color: #1F1B3A; border: 2px solid #1F1B3A; border-radius: 999px; padding: 0 7px; font-size: .75rem; font-weight: 800; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* teacher app (F5) */
.credits { margin: 0; font-weight: 700; }
.notice { border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--hold); color: var(--hold-ink); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.notice p { margin: 0; }
a.btn { text-decoration: none; color: inherit; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; font-weight: 700; }
.tab[aria-current="page"] { background: var(--ink); color: var(--paper); }
.bar-top .who { margin-left: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.scard p, .pcard p, .keybox p { margin: 0; }
.pcard { border-top: 8px solid var(--role); }
.pcard h3 { font-size: 1.2rem; }
.pcard ul, .keybox ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.keybox { background: var(--hold); color: var(--hold-ink); }
.key { display: inline-block; margin-left: 6px; background: var(--hold); color: var(--hold-ink); border-radius: 8px; padding: 0 6px; font-weight: 700; }
.filters { align-items: flex-end; }
.grow { flex: 1; min-width: 200px; }
.filters input, .field textarea, select { border: 2px solid var(--line); border-radius: 10px; padding: 8px; background: var(--card); width: 100%; }
.field textarea { font-size: 1rem; resize: vertical; }
select { width: auto; padding: 3px 6px; font-size: .85rem; }
.field.bad textarea { border-color: var(--bad); border-width: 3px; }
fieldset { margin: 0; }
.left { align-self: flex-start; padding-left: 0; }
.small { font-size: .85rem; }
.st-ready { background: var(--good); color: #FFFFFF; border-color: var(--good); }
.st-draft { background: var(--hold); color: var(--hold-ink); }
.st-failed { background: var(--bad); color: #FFFFFF; border-color: var(--bad); }
.qr svg { width: 160px; height: 160px; background: #FFFFFF; border: 2px solid var(--line); border-radius: 8px; }
.progress { height: 10px; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.progress span { display: block; height: 100%; width: 40%; background: var(--tick); animation: slide 1.4s ease-in-out infinite alternate; }
@keyframes slide { from { margin-left: 0; } to { margin-left: 60%; } }
@media (prefers-reduced-motion: reduce) { .progress span { animation: none; width: 100%; } }
details summary { cursor: pointer; font-weight: 700; margin: 6px 0; }
