/* LEGO Quest - brick-inspired, touch-first.  Original artwork; no trademark assets. */
:root {
  --bg: #1f3a5f; --bg2: #16304f; --panel: #ffffff; --ink: #0f172a; --muted: #5b6577;
  --red: #dc2626; --red-d: #a01818; --yellow: #facc15; --yellow-d: #ca8a04; --blue: #2563eb; --blue-d: #1d4ed8;
  --green: #16a34a; --green-d: #15803d; --orange: #ea580c; --grey: #cbd5e1;
  --radius: 18px; --tap: 56px; --shadow: 0 6px 0 rgba(0,0,0,.18), 0 10px 24px rgba(0,0,0,.18);
  font-size: 17px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink);
  background: var(--bg) radial-gradient(circle at 20px 20px, rgba(255,255,255,.07) 6px, transparent 7px) 0 0/48px 48px;
  -webkit-tap-highlight-color: transparent; line-height: 1.35;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--blue-d); }
.muted { color: var(--muted); } .small { font-size: .9rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.sr { position: absolute; left: -9999px; }
:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; border-radius: 10px; }

main#app { max-width: 1280px; margin: 0 auto; padding: 14px 16px 90px; }
.loading { display: grid; place-items: center; height: 60vh; color: #fff; }

/* offline banner + toast */
.offline { background: #7c2d12; color: #fff; text-align: center; padding: 10px 14px; font-weight: 600; position: sticky; top: 0; z-index: 50; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; transition: .25s; z-index: 60;
  background: #0f172a; color: #fff; padding: 14px 20px; border-radius: 14px; font-weight: 600; max-width: 92vw; box-shadow: var(--shadow); pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--red-d); } #toast.ok { background: var(--green-d); }

/* cards + buttons */
.card { background: var(--panel); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.btn { min-height: var(--tap); padding: 12px 22px; border-radius: 14px; border: 0; font-weight: 800; font-size: 1.05rem; color: #fff;
  background: var(--blue); box-shadow: 0 5px 0 var(--blue-d); transition: transform .08s, box-shadow .08s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--blue-d); }
.btn.primary { background: var(--red); box-shadow: 0 5px 0 var(--red-d); } .btn.primary:active { box-shadow: 0 1px 0 var(--red-d); }
.btn.yellow { background: var(--yellow); color: var(--ink); box-shadow: 0 5px 0 var(--yellow-d); } .btn.yellow:active { box-shadow: 0 1px 0 var(--yellow-d); }
.btn.green { background: var(--green); box-shadow: 0 5px 0 var(--green-d); } .btn.green:active { box-shadow: 0 1px 0 var(--green-d); }
.btn.ghost { background: #e2e8f0; color: var(--ink); box-shadow: 0 5px 0 #94a3b8; } .btn.ghost:active { box-shadow: 0 1px 0 #94a3b8; }
.btn.danger { background: #b91c1c; box-shadow: 0 5px 0 #7f1d1d; }
.btn.link { background: none; box-shadow: none; color: var(--blue-d); min-height: 44px; padding: 8px 10px; text-decoration: underline; font-weight: 600; }
.btn.sm { min-height: 44px; padding: 8px 14px; font-size: .95rem; border-radius: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.btn.big { font-size: 1.3rem; min-height: 68px; width: 100%; }
label { display: block; font-weight: 700; margin: 12px 0 6px; }
input, select, textarea { width: 100%; min-height: 50px; padding: 10px 14px; border: 2px solid var(--grey); border-radius: 12px; background: #fff; color: var(--ink); }
textarea { min-height: 90px; } input[type=checkbox] { width: 26px; height: 26px; min-height: 0; vertical-align: middle; margin-right: 8px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; } .grow { flex: 1; } .gap { gap: 18px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 10px 0; }
table { width: 100%; border-collapse: collapse; } th, td { padding: 10px 8px; border-bottom: 1px solid #e2e8f0; text-align: left; vertical-align: top; }
th { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: .85rem; }
.pill.pending { background: #fef3c7; color: #92400e; } .pill.approved { background: #dcfce7; color: #166534; }
.pill.rejected { background: #fee2e2; color: #991b1b; } .pill.cancelled { background: #e2e8f0; color: #334155; }
.pill.plus { background: #dcfce7; color: #166534; } .pill.minus { background: #fee2e2; color: #991b1b; }

/* ── brick loader ── */
.brick-loader { display: flex; gap: 8px; margin-bottom: 14px; }
.brick-loader i { width: 30px; height: 22px; border-radius: 4px; background: var(--red); position: relative; animation: bob 1s infinite ease-in-out; }
.brick-loader i::before { content: ""; position: absolute; top: -7px; left: 6px; width: 8px; height: 8px; border-radius: 50%; background: #f87171; box-shadow: 10px 0 0 #f87171; }
.brick-loader i:nth-child(2) { background: var(--yellow); animation-delay: .15s; } .brick-loader i:nth-child(2)::before { background: #fde68a; box-shadow: 10px 0 0 #fde68a; }
.brick-loader i:nth-child(3) { background: var(--blue); animation-delay: .3s; } .brick-loader i:nth-child(3)::before { background: #93c5fd; box-shadow: 10px 0 0 #93c5fd; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ── kid board ── */
.kid-head { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; color: #fff; padding: 6px 4px 14px; }
.kid-head .avatar { width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center; font-size: 40px; background: var(--red); box-shadow: 0 5px 0 var(--red-d); }
.kid-head h1 { margin: 0; font-size: clamp(1.4rem, 3.5vw, 2.2rem); letter-spacing: .01em; }
.kid-head .date { opacity: .85; font-weight: 600; }
.kid-head .sign { justify-self: end; }
.wallet { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.wallet .card { padding: 16px 18px; position: relative; overflow: hidden; }
.wallet .label { font-weight: 700; color: var(--muted); font-size: .9rem; text-transform: uppercase; letter-spacing: .05em; }
.wallet .amt { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 900; line-height: 1.1; }
.wallet .amt.green { color: var(--green-d); } .wallet .amt.pend { color: #b45309; }
.wallet .coin { position: absolute; right: 14px; top: 14px; font-size: 30px; animation: coinbob 2.4s infinite ease-in-out; }
@keyframes coinbob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-6px) rotate(6deg); } }

/* goal tower - a brick per 10% */
.goal { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.goal .bar { height: 26px; background: #e2e8f0; border-radius: 13px; overflow: hidden; position: relative; }
.goal .bar > span { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--green) 0 36px, var(--green-d) 36px 40px); border-radius: 13px; transition: width .8s cubic-bezier(.2,.9,.3,1.2); min-width: 0; }
.goal .bar > span::after { content: ""; position: absolute; inset: 4px 0 auto 0; height: 6px; background: repeating-linear-gradient(90deg, transparent 0 10px, rgba(255,255,255,.35) 10px 18px, transparent 18px 28px); }
.tower { display: flex; flex-direction: column-reverse; align-items: center; gap: 2px; min-width: 70px; }
.tower i { display: block; width: 54px; height: 16px; border-radius: 3px; background: var(--c, var(--red)); position: relative; animation: drop .45s both; animation-delay: calc(var(--i) * 60ms); }
.tower i::before { content: ""; position: absolute; top: -5px; left: 9px; width: 10px; height: 6px; border-radius: 50% 50% 0 0; background: inherit; filter: brightness(1.25); box-shadow: 13px 0 0 0 currentColor, 26px 0 0 0 currentColor; color: inherit; opacity: .9; }
.tower i.ghost { background: #e2e8f0; animation: none; }
@keyframes drop { from { transform: translateY(-60px) scale(1.1); opacity: 0; } 60% { transform: translateY(4px); opacity: 1; } to { transform: translateY(0); } }
.goal img { max-height: 70px; border-radius: 10px; }

/* chore grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.chore { position: relative; display: grid; grid-template-rows: auto 1fr auto; gap: 10px; min-height: 230px; border-top: 10px solid var(--red); overflow: hidden;
  background: var(--panel); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.chore .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.chore .emoji { font-size: 40px; line-height: 1; }
.chore h3 { margin: 4px 0 0; font-size: 1.3rem; }
.chore .price { font-weight: 900; font-size: 1.5rem; color: var(--green-d); background: #dcfce7; padding: 4px 12px; border-radius: 12px; white-space: nowrap; }
.chore p { margin: 0; color: #334155; }
.chore .status { font-weight: 800; display: flex; align-items: center; gap: 8px; min-height: 28px; }
.chore.awaiting { border-top-color: var(--yellow); background: #fffbeb; }
.chore.done, .chore.completed { border-top-color: var(--green); background: #f0fdf4; }
.chore.locked { border-top-color: var(--grey); background: #f1f5f9; } .chore.locked .price { background: #e2e8f0; color: #475569; }
.chore .brick-drop { position: absolute; left: 50%; top: 42%; width: 70px; height: 44px; margin-left: -35px; border-radius: 6px; background: var(--yellow); box-shadow: 0 6px 0 var(--yellow-d); animation: brickdrop .7s cubic-bezier(.3,1.4,.5,1) both; pointer-events: none; }
.chore .brick-drop::before { content: ""; position: absolute; top: -12px; left: 8px; width: 18px; height: 12px; border-radius: 50% 50% 0 0; background: #fde047; box-shadow: 36px 0 0 #fde047; }
@keyframes brickdrop { from { transform: translateY(-160px) rotate(-25deg); opacity: 0; } 70% { transform: translateY(0) rotate(0); opacity: 1; } 85% { transform: translateY(-10px); } to { transform: translateY(0); opacity: 0; } }
.chore .btn.big.didit { font-size: 1.35rem; }

/* push-up studs */
.sets { display: flex; gap: 8px; justify-content: space-between; margin: 4px 0; }
.sets .stud { flex: 1; aspect-ratio: 1; max-width: 72px; border-radius: 50%; border: 0; background: #e2e8f0; box-shadow: inset 0 -6px 0 #cbd5e1; font-weight: 900; font-size: 1.1rem; color: #64748b; display: grid; place-items: center; min-height: 46px; min-width: 0; padding: 0; }
.sets .stud.pending { background: var(--yellow); box-shadow: inset 0 -6px 0 var(--yellow-d); color: #713f12; animation: pop .35s; }
.sets .stud.approved { background: var(--green); box-shadow: inset 0 -6px 0 var(--green-d); color: #fff; animation: pop .35s; }
.sets .stud.open { background: var(--red); box-shadow: 0 5px 0 var(--red-d); color: #fff; cursor: pointer; }
.sets .stud.open:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--red-d); }
.sets .stud.locked { opacity: .5; }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.tally { display: flex; justify-content: space-between; font-weight: 800; }
.tally .pend { color: #b45309; } .tally .ok { color: var(--green-d); }

/* recent */
.recent { margin-top: 20px; color: #fff; } .recent ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.recent li { background: rgba(255,255,255,.12); border-radius: 12px; padding: 10px 14px; display: flex; justify-content: space-between; gap: 10px; }

/* brick burst confetti */
.burst { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.burst i { position: absolute; left: var(--x); top: -40px; width: 26px; height: 18px; border-radius: 3px; background: var(--c); transform: scale(var(--s));
  animation: fall var(--d) var(--delay) cubic-bezier(.3,.6,.6,1) both; }
.burst i::before { content: ""; position: absolute; top: -6px; left: 4px; width: 7px; height: 6px; border-radius: 50% 50% 0 0; background: inherit; filter: brightness(1.3); box-shadow: 10px 0 0 0; color: inherit; }
@keyframes fall { from { transform: translate(0, 0) rotate(0) scale(var(--s)); opacity: 1; } to { transform: translate(var(--dx), 110vh) rotate(var(--r)) scale(var(--s)); opacity: .2; } }

/* celebrate toast */
.celebrate { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 65; background: #fff; border-radius: 22px; padding: 22px 28px; box-shadow: var(--shadow); text-align: center; animation: pop .5s; border: 6px solid var(--yellow); max-width: 92vw; }
.celebrate .big { font-size: 2.2rem; font-weight: 900; color: var(--green-d); } .celebrate p { margin: 6px 0 0; font-weight: 700; }

/* kid picker */
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.picker .kidbtn { background: #fff; border: 0; border-radius: var(--radius); padding: 22px 10px; font-weight: 800; font-size: 1.2rem; box-shadow: var(--shadow); min-height: 150px; display: grid; gap: 8px; place-items: center; }
.picker .kidbtn .face { font-size: 56px; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 320px; margin: 14px auto 0; }
.pinpad button { min-height: 68px; font-size: 1.6rem; font-weight: 800; border-radius: 16px; border: 0; background: #e2e8f0; box-shadow: 0 5px 0 #94a3b8; }
.pinpad button:active { transform: translateY(4px); box-shadow: 0 1px 0 #94a3b8; }
.dots { display: flex; justify-content: center; gap: 14px; margin: 10px 0; } .dots i { width: 20px; height: 20px; border-radius: 50%; background: #e2e8f0; } .dots i.on { background: var(--red); }
.hero { color: #fff; text-align: center; padding: 24px 10px 10px; } .hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); margin: 0; }
.hero .bricks { display: flex; justify-content: center; gap: 6px; margin: 10px 0 18px; }
.hero .bricks i { width: 44px; height: 30px; border-radius: 5px; background: var(--c); position: relative; animation: bob 2s infinite ease-in-out; animation-delay: calc(var(--i) * .15s); }
.hero .bricks i::before { content: ""; position: absolute; top: -9px; left: 7px; width: 12px; height: 9px; border-radius: 50% 50% 0 0; background: inherit; filter: brightness(1.3); box-shadow: 18px 0 0 0; color: inherit; }
.stack { display: grid; gap: 16px; max-width: 760px; margin: 0 auto; }
.signin h2 { margin-top: 0; }

/* ── parent ── */
body.parent { background: #eef2f7; }
.pnav { background: var(--bg); color: #fff; padding: 10px 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; position: sticky; top: 0; z-index: 40; }
.pnav .brand { font-weight: 900; font-size: 1.2rem; margin-right: auto; display: flex; align-items: center; gap: 8px; }
.pnav a { color: #fff; text-decoration: none; padding: 10px 14px; border-radius: 10px; font-weight: 700; min-height: 44px; display: inline-flex; align-items: center; }
.pnav a.on, .pnav a:hover { background: rgba(255,255,255,.15); }
.pnav .badge { background: var(--yellow); color: var(--ink); border-radius: 999px; padding: 2px 8px; font-size: .8rem; margin-left: 6px; }
.ptitle { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 14px; } .ptitle h1 { margin: 0; font-size: 1.6rem; }
.claimrow { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid #e2e8f0; }
.claimrow:last-child { border-bottom: 0; } .claimrow .em { font-size: 34px; } .claimrow .who { font-weight: 800; } .claimrow .meta { color: var(--muted); font-size: .9rem; }
.claimrow .acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: grid; place-items: center; z-index: 80; padding: 14px; }
.modal .card { width: min(720px, 100%); max-height: 92vh; overflow: auto; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; } .kv b { font-size: 1.2rem; }
.help h2 { margin-top: 26px; } .help ol li, .help ul li { margin: 8px 0; } .help code { background: #e2e8f0; padding: 2px 6px; border-radius: 6px; }
.help .card { color: var(--ink); }
.kidlist .kidcard { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
.kidlist .face { font-size: 44px; }

/* ── display / kiosk ── */
body.display main#app { max-width: 1600px; }
body.display { font-size: 19px; }
body.display .grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
body.display .kid-head .sign { display: none; }

@media (max-width: 640px) {
  :root { font-size: 16px; --tap: 52px; }
  main#app { padding: 10px 12px 80px; }
  .kid-head { grid-template-columns: auto 1fr; } .kid-head .sign { grid-column: 1 / -1; justify-self: start; }
  .claimrow { grid-template-columns: auto 1fr; } .claimrow .acts { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
