:root {
  --cream: #fff6e9;
  --cream-deep: #ffeccb;
  --coral: #ff6b5e;
  --coral-deep: #e8503f;
  --teal: #2ec4b6;
  --teal-deep: #1ba294;
  --gold: #ffc857;
  --gold-deep: #f0ad26;
  --ink: #34303a;
  --ink-soft: #5b5560;
  --white: #fffdf8;

  --border: 4px;
  --radius: 22px;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  font-weight: 700;
  -webkit-text-size-adjust: 100%;
}

body {
  /* dotted "sticker book" backdrop */
  background-image: radial-gradient(var(--cream-deep) 18%, transparent 18%);
  background-size: 26px 26px;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

h1, h2, h3, .display {
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  line-height: 1.05;
  margin: 0;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}
.logo {
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo .spark { font-size: 1.6rem; }
.who {
  font-size: 0.95rem;
  background: var(--gold);
  border: var(--border) solid var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: var(--shadow-sm);
}
.bar-right { display: flex; align-items: center; gap: 10px; }
/* Coin badge (Brief 6) — taps through to /wallet. Same CSS coin token as Learn/Games. */
.coin-badge {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  font-family: "Nunito", sans-serif; font-weight: 800; font-size: 0.95rem;
  color: var(--ink); background: #fff;
  border: var(--border) solid var(--ink); border-radius: 999px;
  padding: 4px 12px 4px 7px; box-shadow: var(--shadow-sm); white-space: nowrap;
}

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border: var(--border) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 1.25rem;
  margin: 22px 4px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--white);
  border: var(--border) solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 13px 18px;
  cursor: pointer;
  transition: transform .05s ease, box-shadow .05s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn.coral { background: var(--coral); color: var(--white); }
.btn.teal  { background: var(--teal);  color: var(--white); }
.btn.gold  { background: var(--gold); }
.btn.ghost { background: var(--cream); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: auto; flex: 1; }

/* ---------- Profile picker ---------- */
.profiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.profile {
  border: var(--border) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 10px;
  text-align: center;
  cursor: pointer;
  background: var(--white);
  transition: transform .05s ease, box-shadow .05s ease;
}
.profile:active { transform: translate(4px,4px); box-shadow: 0 0 0 var(--ink); }
.profile.selected { outline: 4px dashed var(--ink); outline-offset: 4px; }
.profile .avatar {
  width: 64px; height: 64px; margin: 0 auto 8px;
  border-radius: 50%;
  border: var(--border) solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}
.profile .pname { font-family: "Baloo 2"; font-weight: 800; font-size: 1.15rem; }
.profile .page  { color: var(--ink-soft); font-size: .9rem; }
.av-coral { background: var(--coral); }
.av-teal  { background: var(--teal); }
.av-gold  { background: var(--gold); }

/* ---------- Subjects ---------- */
.subjects { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.subject {
  border: var(--border) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: transform .05s ease, box-shadow .05s ease;
}
.subject:active { transform: translate(4px,4px); box-shadow: 0 0 0 var(--ink); }
.subject.locked { cursor: default; opacity: .8; }
.subject.locked:active { transform: none; box-shadow: var(--shadow-sm); }
.subject .emoji { font-size: 2.4rem; display: block; margin-bottom: 6px; }
.subject .label { font-family: "Baloo 2"; font-weight: 800; font-size: 1.15rem; }
.subject.math { background: var(--coral); color: var(--white); }
.subject.lang { background: var(--teal);  color: var(--white); }
.subject.sci  { background: var(--gold); }
.subject.art  { background: #c9a4ff; color: var(--white); }
.subject .soon {
  position: absolute; top: -10px; right: -8px;
  background: var(--ink); color: var(--white);
  font-size: .65rem; padding: 4px 8px; border-radius: 999px;
  transform: rotate(8deg);
}

/* ---------- Forms ---------- */
label { display: block; font-size: .9rem; margin: 10px 0 4px; }
input[type="text"], input[type="number"], input[type="password"] {
  width: 100%;
  font-family: "Nunito"; font-weight: 700; font-size: 1.1rem;
  padding: 12px 14px;
  border: var(--border) solid var(--ink);
  border-radius: 14px;
  background: var(--cream);
  color: var(--ink);
}
input:focus { outline: none; background: var(--white); box-shadow: var(--shadow-sm); }

/* ---------- Quiz ---------- */
.quiz-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pill {
  background: var(--gold); border: var(--border) solid var(--ink);
  border-radius: 999px; padding: 4px 12px; font-size: .85rem;
  box-shadow: var(--shadow-sm);
}
.progress-track {
  height: 16px; background: var(--cream-deep);
  border: var(--border) solid var(--ink); border-radius: 999px;
  overflow: hidden; margin-bottom: 16px;
}
.progress-fill { height: 100%; background: var(--teal); width: 0; transition: width .3s ease; }
.question {
  font-family: "Baloo 2"; font-weight: 800;
  font-size: 2.8rem; text-align: center; margin: 18px 0 22px;
}
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice {
  font-family: "Baloo 2"; font-weight: 800; font-size: 1.8rem;
  padding: 22px 10px;
  border: var(--border) solid var(--ink); border-radius: 18px;
  box-shadow: var(--shadow-sm); background: var(--white);
  cursor: pointer;
  transition: transform .05s ease, box-shadow .05s ease;
}
.choice:active { transform: translate(4px,4px); box-shadow: 0 0 0 var(--ink); }
.choice.correct { background: var(--teal); color: var(--white); }
.choice.wrong   { background: var(--coral); color: var(--white); }
.choice.disabled { pointer-events: none; }

/* ---------- Result ---------- */
.result { text-align: center; }
.result .big-stars { font-size: 3.4rem; margin: 6px 0; }
.result h2 { font-size: 2rem; margin-bottom: 6px; }
.result .tally { color: var(--ink-soft); margin-bottom: 16px; }

/* ---------- Leaderboard ---------- */
.lb-row {
  display: flex; align-items: center; gap: 12px;
  border: var(--border) solid var(--ink); border-radius: 18px;
  box-shadow: var(--shadow-sm); padding: 12px 14px; margin-bottom: 12px;
  background: var(--white);
}
.lb-rank { font-family: "Baloo 2"; font-weight: 800; font-size: 1.4rem; width: 34px; text-align: center; }
.lb-av {
  width: 46px; height: 46px; border-radius: 50%;
  border: var(--border) solid var(--ink);
  display:flex; align-items:center; justify-content:center; font-size: 1.4rem;
}
.lb-main { flex: 1; }
.lb-name { font-family: "Baloo 2"; font-weight: 800; font-size: 1.15rem; }
.lb-sub { color: var(--ink-soft); font-size: .82rem; }
.lb-stars { font-family: "Baloo 2"; font-weight: 800; font-size: 1.3rem; white-space: nowrap; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card { max-width: 380px; width: 100%; text-align: center; }
.login-card .spark { font-size: 3rem; }
.login-card h1 { font-size: 2.2rem; margin: 6px 0 2px; }
.login-card p { color: var(--ink-soft); margin: 0 0 18px; }
.err { color: var(--coral-deep); min-height: 1.2em; margin-top: 10px; font-size: .9rem; }

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--ink-soft); }
.spacer { height: 8px; }
.pop { animation: pop .25s ease; }
@keyframes pop { 0% { transform: scale(.9); } 60% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* ===================== Hub-specific ===================== */
.people { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.person {
  position: relative;
  border: var(--border) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--white);
  padding: 18px 10px 16px;
  text-align: center;
  cursor: pointer;
  transition: transform .05s ease, box-shadow .05s ease;
}
.person:active { transform: translate(5px,5px); box-shadow: 0 0 0 var(--ink); }
.person .emoji-big {
  font-size: 3.2rem; line-height: 1; margin-bottom: 8px;
  width: 84px; height: 84px; margin-inline: auto;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: var(--border) solid var(--ink); background: var(--cream-deep);
}
.person .pname { font-family: "Baloo 2"; font-weight: 800; font-size: 1.3rem; }
.person .edit-btn {
  position: absolute; top: -10px; right: -10px;
  width: 40px; height: 40px; border-radius: 50%;
  border: var(--border) solid var(--ink); background: var(--gold);
  box-shadow: var(--shadow-sm); font-size: 1.1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.person .edit-btn:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--ink); }

/* Edit sheet (emoji + name) */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(52,48,58,.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
  padding: 0; animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  background: var(--cream); width: 100%; max-width: 560px;
  border: var(--border) solid var(--ink); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -6px 0 var(--ink);
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 85dvh; overflow-y: auto;
}
.sheet h2 { font-size: 1.4rem; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin: 10px 0 6px;
}
.emoji-grid .ebtn {
  font-size: 1.6rem; padding: 6px 0; line-height: 1;
  border: 3px solid var(--ink); border-radius: 12px; background: var(--white);
  cursor: pointer; text-align: center;
}
.emoji-grid .ebtn.sel { background: var(--gold); box-shadow: var(--shadow-sm); }
.emoji-grid .ebtn:active { transform: translate(2px,2px); }

/* App chooser */
.apps { display: grid; grid-template-columns: 1fr; gap: 16px; }
.app-tile {
  display: block; text-decoration: none; color: var(--ink); position: relative;
  border: var(--border) solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 20px;
  transition: transform .05s ease, box-shadow .05s ease;
}
.app-tile:active { transform: translate(5px,5px); box-shadow: 0 0 0 var(--ink); }
/* coming-soon placeholder: greyed + non-clickable, matching the Learn subject treatment */
.app-tile.locked { background: var(--cream-deep); color: var(--ink-soft); opacity: .7; cursor: default; pointer-events: none; }
.app-tile.locked .at-desc { color: var(--ink-soft); }
.app-tile.locked:active { transform: none; box-shadow: var(--shadow); }
.app-tile .soon {
  position: absolute; top: -10px; right: -8px;
  background: var(--ink); color: var(--white);
  font-family: "Baloo 2"; font-weight: 800; font-size: .72rem;
  padding: 5px 11px; border-radius: 999px; transform: rotate(8deg);
}
.app-tile .at-emoji { font-size: 2.8rem; }
.app-tile .at-name { font-family: "Baloo 2"; font-weight: 800; font-size: 1.6rem; margin-top: 4px; }
.app-tile .at-desc { color: var(--ink-soft); font-size: .95rem; }
.app-tile.learn { background: var(--coral); color: var(--white); }
.app-tile.learn .at-desc { color: rgba(255,255,255,.9); }
.app-tile.games { background: var(--teal); color: var(--white); }
.app-tile.games .at-desc { color: rgba(255,255,255,.9); }

/* Admin "reset PIN" affordance — mirrors the edit-btn, top-left, only shown to Stefan */
.person .reset-btn {
  position: absolute; top: -10px; left: -10px;
  width: 40px; height: 40px; border-radius: 50%;
  border: var(--border) solid var(--ink); background: var(--teal);
  box-shadow: var(--shadow-sm); font-size: 1.05rem; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.person .reset-btn:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--ink); }

/* ---------- PIN pad ---------- */
.pin-sheet { text-align: center; }
.pin-sheet h2 { justify-content: center; }
.pin-dots {
  display: flex; justify-content: center; gap: 14px; margin: 6px 0 4px;
}
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: var(--border) solid var(--ink); background: var(--white);
}
.pin-dot.filled { background: var(--coral); }
.pin-dots.shake { animation: shake .4s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
@media (prefers-reduced-motion: reduce) {
  .pin-dots.shake { animation: none; }
}
.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  max-width: 320px; margin: 6px auto 0;
}
.key {
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.9rem;
  padding: 16px 0; color: var(--ink); background: var(--white);
  border: var(--border) solid var(--ink); border-radius: 18px;
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform .05s ease, box-shadow .05s ease;
}
.key:active { transform: translate(4px,4px); box-shadow: 0 0 0 var(--ink); }
.key-fn { background: var(--cream); font-size: 1.5rem; }

/* ===================== Admin (Brief 5 — Stefan-only) ===================== */
/* Coin token — same gold disc + $ as the Learn/Games top bars, so balances render on iPad. */
.coin {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%; vertical-align: -3px;
  background: radial-gradient(circle at 35% 30%, #ffe27a, var(--gold) 70%);
  border: 2px solid var(--ink); position: relative;
}
.coin::after {
  content: "$"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 11px; color: var(--ink); line-height: 1;
}

/* The inked admin band at the top of /admin */
.admin-band {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--ink); color: var(--white);
  border: var(--border) solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 18px;
}
.admin-band .ab-title { font-family: "Baloo 2"; font-weight: 800; font-size: 1.2rem; }
.admin-band .ab-exit {
  color: var(--ink); background: var(--gold); text-decoration: none;
  border: 3px solid var(--white); border-radius: 999px; padding: 5px 12px;
  font-family: "Baloo 2"; font-weight: 800; font-size: .85rem; white-space: nowrap;
}

/* Admin home menu */
.admin-menu { display: grid; gap: 14px; }
.admin-entry {
  display: flex; align-items: center; gap: 14px; text-align: left;
  border: var(--border) solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); background: var(--white); padding: 16px;
  cursor: pointer; transition: transform .05s ease, box-shadow .05s ease;
}
.admin-entry:active { transform: translate(5px,5px); box-shadow: 0 0 0 var(--ink); }
.admin-entry .ae-emoji { font-size: 2.2rem; }
.admin-entry .ae-text { display: flex; flex-direction: column; }
.admin-entry .ae-text b { font-family: "Baloo 2"; font-weight: 800; font-size: 1.25rem; }
.admin-entry .ae-text small { color: var(--ink-soft); font-size: .9rem; }

/* Sub-screen header: back · title · action */
.admin-subhead { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.admin-subhead .section-title { flex: 1; }
.btn.back-btn, .btn.add-btn { width: auto; padding: 8px 14px; }

/* Listing cards (Manage Shop) */
.listing-card {
  display: flex; align-items: center; gap: 12px;
  border: var(--border) solid var(--ink); border-radius: 18px;
  box-shadow: var(--shadow-sm); background: var(--white); padding: 10px; margin-bottom: 12px;
}
.listing-card.inactive { opacity: .6; background: var(--cream-deep); }
.lc-thumb { width: 56px; height: 56px; border-radius: 12px; border: 3px solid var(--ink); object-fit: cover; flex: 0 0 auto; }
.lc-noimg { display: flex; align-items: center; justify-content: center; font-size: 1.8rem; background: var(--cream); }
.lc-main { flex: 1; min-width: 0; }
.lc-title { font-family: "Baloo 2"; font-weight: 800; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-meta { color: var(--ink-soft); font-size: .85rem; }
.lc-cost { white-space: nowrap; font-weight: 800; color: var(--ink); }
.lc-hidden { display: inline-block; font-size: .7rem; background: var(--ink); color: var(--white); border-radius: 999px; padding: 1px 8px; margin-top: 2px; }
.lc-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 3px solid var(--ink);
  background: var(--white); box-shadow: var(--shadow-sm); font-size: 1.05rem; cursor: pointer; padding: 0;
}
.icon-btn:active { transform: translate(2px,2px); box-shadow: 0 0 0 var(--ink); }

/* Product form bits */
.img-drop {
  border: 3px dashed var(--ink); border-radius: 16px; padding: 12px; background: var(--white);
}
.img-preview { display: flex; align-items: center; justify-content: center; min-height: 96px; margin-bottom: 10px; }
.img-preview img { max-height: 160px; max-width: 100%; border-radius: 12px; border: 3px solid var(--ink); }
.img-controls { display: flex; flex-direction: column; gap: 8px; }
.img-controls .btn { width: 100%; }
.img-hint { font-size: .8rem; margin-top: 6px; }
.select {
  width: 100%; font-family: "Nunito"; font-weight: 700; font-size: 1.1rem;
  padding: 12px 14px; border: var(--border) solid var(--ink); border-radius: 14px;
  background: var(--cream); color: var(--ink);
}
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper .key { padding: 10px 0; width: 54px; flex: 0 0 auto; }
.stepper input { text-align: center; }
.switch-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 1rem; }
.switch-row input { width: 22px; height: 22px; }

/* Transactions */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  font-family: "Nunito"; font-weight: 800; font-size: .85rem;
  border: 3px solid var(--ink); border-radius: 999px; padding: 6px 12px;
  background: var(--white); box-shadow: var(--shadow-sm); cursor: pointer;
}
.chip.on { background: var(--gold); }
.chip .chip-bal { font-weight: 800; }
.tx-row {
  display: flex; align-items: flex-start; gap: 12px;
  border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow-sm);
  background: var(--white); padding: 10px 12px; margin-bottom: 10px;
}
.tx-av {
  width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--ink);
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex: 0 0 auto; background: var(--cream-deep);
}
.tx-main { flex: 1; min-width: 0; }
.tx-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tx-name { font-family: "Baloo 2"; font-weight: 800; font-size: 1.05rem; }
.tx-delta { font-family: "Baloo 2"; font-weight: 800; white-space: nowrap; }
.tx-delta.pos { color: var(--teal-deep); }
.tx-delta.neg { color: var(--coral-deep); }
.tx-sub { color: var(--ink-soft); font-size: .88rem; }
.tx-time { color: var(--ink-soft); font-size: .76rem; }

/* Grant screen */
.grant-pick { padding: 12px 8px; }
.grant-pick .emoji-big { width: 56px; height: 56px; font-size: 2rem; }
.grant-pick .pname { font-size: 1rem; }
.ok-note { color: var(--teal-deep); font-weight: 800; min-height: 1.2em; margin-top: 8px; }

/* Stefan-only Admin tile on the app chooser */
.app-tile.admin { background: var(--ink); color: var(--white); }
.app-tile.admin .at-desc { color: rgba(255,255,255,.85); }
