/* Game Time — bright, friendly, readable. Light and dark themes share these tokens. */

:root {
  --bg: #F4F3FB;
  --surface: #FFFFFF;
  --surface-2: #EAE8F7;
  --text: #1E1B33;
  --muted: #625E7A;
  --line: #DEDBF0;
  --accent: #5B4BDB;
  --accent-text: #FFFFFF;
  --accent-soft: #E6E2FC;
  --plus: #217A47;
  --minus: #B3412E;
  --gold: #E2A93B;
  --danger: #B3412E;
  --shadow: 0 1px 2px rgb(30 27 51 / .06), 0 4px 16px rgb(30 27 51 / .07);
  --radius: 18px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14131F;
    --surface: #1E1C2D;
    --surface-2: #2A273C;
    --text: #EDEBFA;
    --muted: #A9A4C4;
    --line: #363250;
    --accent: #A99BFF;
    --accent-text: #15103A;
    --accent-soft: #332D5C;
    --plus: #7BD3A0;
    --minus: #F09A88;
    --gold: #E9C46A;
    --danger: #F09A88;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14131F;
  --surface: #1E1C2D;
  --surface-2: #2A273C;
  --text: #EDEBFA;
  --muted: #A9A4C4;
  --line: #363250;
  --accent: #A99BFF;
  --accent-text: #15103A;
  --accent-soft: #332D5C;
  --plus: #7BD3A0;
  --minus: #F09A88;
  --gold: #E9C46A;
  --danger: #F09A88;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 650; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.full { width: 100%; }
.grow { flex: 1; min-width: 0; }
.danger-text { color: var(--danger); }
.switch-label { color: var(--text); font-size: 1rem; flex: 1; }
.stack { display: grid; gap: .6rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ─── Controls ─── */
label { font-size: .875rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; width: 100%;
}
textarea { min-height: 5.5rem; resize: vertical; }
.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: .75rem 1.2rem; cursor: pointer; text-align: center; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn.link { background: none; border: 0; color: var(--accent); padding: .4rem; min-height: 0; }
.btn.danger { color: var(--danger); }
.btn.small { padding: .4rem .8rem; font-size: .875rem; min-height: 36px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  background: none; border: 0; color: var(--muted); width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center; cursor: pointer; font-size: 1.1rem; flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button {
  flex: 1; font: inherit; font-size: .9rem; font-weight: 600; border: 0; background: none; color: var(--muted);
  padding: .5rem .6rem; border-radius: 999px; cursor: pointer; min-height: 38px;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ─── Layout ─── */
.view {
  max-width: 560px; margin: 0 auto; outline: none;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 96px);
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.card.soft { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; margin-bottom: .4rem; }
.head { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.head h1 { margin: 0; }

.tabs {
  position: fixed; inset: auto 0 0 0; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px); z-index: 5;
}
.tabs a {
  flex: 1; display: grid; justify-items: center; gap: 2px; color: var(--muted); text-decoration: none;
  font-size: .72rem; font-weight: 600; padding: 4px 0; border-radius: 12px;
}
.tabs svg { width: 24px; height: 24px; fill: currentColor; }
.tabs a[aria-current="page"] { color: var(--accent); }

/* ─── Sign in ─── */
.signin { max-width: 400px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12vh) 16px 40px; text-align: center; }
.signin form { text-align: left; margin-top: 1.5rem; }
.signin-logo { border-radius: 18px; margin-bottom: .75rem; }
.msg { min-height: 1.5em; margin-top: 1rem; color: var(--muted); }
.msg.error { color: var(--danger); }

/* ─── Lists / editing ─── */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: .4rem; align-items: center; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .ref { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; }
.menu-list a, .menu-list button {
  display: flex; width: 100%; align-items: center; gap: .75rem; text-decoration: none; color: var(--text);
  background: none; border: 0; font: inherit; padding: .85rem 0; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left;
}
.menu-list > :last-child { border-bottom: 0; }
.menu-list .chev { margin-left: auto; color: var(--muted); }
.pill { display: inline-block; font-size: .75rem; font-weight: 650; padding: .1rem .55rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.pill.on { background: var(--accent-soft); color: var(--accent); }
.switch { appearance: none; width: 48px; height: 28px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; flex: none; padding: 0; border: 0; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgb(0 0 0 / .25); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

/* ─── Banner / toast / sheet ─── */
.banner {
  position: sticky; top: 0; z-index: 10; display: flex; gap: .75rem; align-items: center; justify-content: center; flex-wrap: wrap;
  background: var(--accent); color: var(--accent-text); padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; font-size: .95rem;
}
.banner .btn { background: var(--accent-text); color: var(--accent); border: 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 12px; font-size: .95rem; z-index: 20;
  max-width: calc(100vw - 32px); box-shadow: 0 4px 20px rgb(0 0 0 / .2);
}
dialog {
  border: 0; border-radius: 22px; padding: 1.2rem 1.1rem; background: var(--surface); color: var(--text);
  width: min(520px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgb(0 0 0 / .25);
}
dialog::backdrop { background: rgb(12 10 28 / .55); }

.list.card { padding: .2rem 1rem; margin-bottom: 1rem; }

/* Cookies-blocked help */
.cookie-help { text-align: left; margin-top: 1rem; }
.cookie-help p { margin-bottom: .4rem; }
.cookie-help summary { color: var(--accent); font-weight: 600; cursor: pointer; padding: .2rem 0; }
.cookie-help ol { margin: .5rem 0 0; padding-left: 1.2rem; display: grid; gap: .3rem; }

/* Cards that open a screen */
.tappable { cursor: pointer; transition: transform .12s ease; }
.tappable:active { transform: scale(.985); }
.tappable .chev { color: var(--muted); font-size: 1.3rem; line-height: 1; margin-left: .25rem; }


/* ─── Money ─── */
.plus { color: var(--plus); }
.minus { color: var(--minus); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 650; }
.title-row { display: flex; align-items: center; gap: .6rem; margin: .25rem 0 1rem; }
.title-row h1 { margin: 0; flex: 1; }
.title-row img { border-radius: 10px; }

.avatar {
  flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.6rem; line-height: 1; background: var(--accent-soft);
}
.avatar.big { width: 72px; height: 72px; font-size: 2.5rem; }
.avatar.sm { width: 32px; height: 32px; font-size: 1.1rem; }
.avatar.c1 { background: #FDE7C8; } .avatar.c2 { background: #D7EEDC; } .avatar.c3 { background: #DCE6FA; }
.avatar.c4 { background: #EEDDF7; } .avatar.c5 { background: #D6F0EF; }
:root[data-theme="dark"] .avatar:not(.c0) { filter: saturate(.8) brightness(.55); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar:not(.c0) { filter: saturate(.8) brightness(.55); } }
.avatar.parents { background: var(--surface-2); }

.kid-card { display: flex; align-items: center; gap: .9rem; text-decoration: none; color: var(--text); }
.kid-card .who { flex: 1; min-width: 0; }
.kid-card .who strong { display: block; font-size: 1.1rem; }
.kid-card .who .small { display: block; }
.kid-card .bal { font-size: 1.35rem; }
.kid-cards { display: grid; gap: .75rem; margin-bottom: 1rem; }
.kid-cards .card { margin: 0; }

.balance-card { text-align: center; padding: 1.4rem 1.1rem 1.2rem; }
.balance-card .avatar { margin: 0 auto .5rem; }
.balance-card .big-money { font-size: 2.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; margin: .2rem 0 .3rem; }
.balance-card .label { color: var(--muted); font-size: .9rem; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: 1rem; }
.actions .btn { padding: .65rem .4rem; font-size: .95rem; }
.facts { display: flex; justify-content: center; gap: .4rem 1.2rem; flex-wrap: wrap; margin-top: .6rem; font-size: .9rem; color: var(--muted); }

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: 1rem; }
.quick-actions .btn { flex-direction: column; gap: .1rem; padding: .7rem .3rem; border-radius: 16px; font-size: .9rem; }
.quick-actions .btn b { font-size: 1.3rem; line-height: 1.1; }

.tx-list { list-style: none; margin: 0; padding: 0; }
.tx-list li { display: flex; align-items: center; gap: .7rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.tx-list li:last-child { border-bottom: 0; }
.tx-list .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tx-list .what .small { display: block; color: var(--muted); }
.tx-list button.what { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.day-head { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; margin: 1rem 0 .2rem; }
.day-head:first-child { margin-top: .2rem; }

.summary { display: flex; gap: .75rem; margin-bottom: 1rem; }
.summary .card { flex: 1; margin: 0; padding: .8rem .9rem; }
.summary b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 1.6rem 1rem; }
.empty .emoji { font-size: 3rem; line-height: 1; margin-bottom: .5rem; }

/* Dialogs */
dialog h2 { margin-bottom: .8rem; }
dialog form { display: grid; gap: .6rem; }
.dialog-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .4rem; }
.amount-input { font-size: 2rem; font-weight: 650; text-align: center; padding: .5rem; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips button {
  font: inherit; font-size: .92rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: .45rem .85rem; cursor: pointer; min-height: 38px; display: inline-flex; align-items: center; gap: .35rem;
}
.chips button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px var(--accent) inset; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: .3rem; }
.emoji-grid button {
  font-size: 1.5rem; line-height: 1; aspect-ratio: 1; border: 1px solid transparent; border-radius: 12px; background: var(--surface-2); cursor: pointer; padding: 0;
}
.emoji-grid button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.hint { font-size: .85rem; color: var(--muted); margin: -.2rem 0 0; }
.reorder { display: flex; flex-direction: column; }
.reorder .icon-btn { width: 32px; height: 26px; font-size: .9rem; }
.mb { margin-bottom: 1rem; }
.big-money { font-size: 2.2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; margin: .2rem 0 .5rem; }

/* Music button and volume slider */
.music-btn svg { width: 22px; height: 22px; fill: currentColor; }
.music-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.music-btn[aria-pressed="false"] { opacity: .65; }
input[type="range"] { padding: 0; border: 0; background: none; accent-color: var(--accent); height: 32px; }

.actions.two { grid-template-columns: 1fr 1fr; }

/* Approvals */
.approve-card { display: flex; align-items: center; gap: .8rem; text-decoration: none; color: var(--text); background: var(--accent-soft); border-color: transparent; }
.approve-count {
  flex: none; min-width: 40px; height: 40px; border-radius: 20px; padding: 0 .6rem; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 1.1rem;
}
.pending-text { color: var(--gold); }
:root:not([data-theme="dark"]) .pending-text { color: #9A6A10; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pending-text { color: var(--gold); } }
.pending-card { border-style: dashed; }
.approval { align-items: flex-start !important; }
.approval .grow strong { display: block; }
.approval .small { display: block; }
.approval-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }
.approval-actions:empty { display: none; }
.tabs a { position: relative; }
.tabs .badge {
  position: absolute; top: 0; left: 50%; margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; line-height: 1;
}

/* ─── Game time ─── */
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--plus); border-radius: 99px; transition: width 1s linear; }
.summary .card b { font-size: 1.1rem; }
.summary .card .small { display: block; line-height: 1.25; }
.kind-icon { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); font-size: 1rem; }
.btn.take { color: var(--minus); }
.btn.primary.take-btn { background: var(--minus); border-color: var(--minus); }
.playing-text { color: var(--accent); font-weight: 600; }
.kid-card.is-playing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow); }

.timer-card { text-align: center; border-color: var(--accent); background: var(--accent-soft); }
.timer-card .label { font-weight: 650; }
.timer-card .big-clock { font-size: 3rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.1; margin: .3rem 0 .6rem; }
.timer-card .bar { margin-bottom: .5rem; background: var(--surface); }
.timer-card .bar i { background: var(--accent); }
.timer-card.over { border-color: var(--minus); }
.timer-card.over .big-clock { color: var(--minus); }
.actions .btn[disabled] { opacity: .45; }

/* Games list */
.games-left { display: grid; gap: .2rem; background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.games-left.locked { background: var(--surface-2); }
.game-list { display: grid; gap: .75rem; }
.game-list .card { margin: 0; }
.game-card { display: flex; align-items: center; gap: .9rem; width: 100%; font: inherit; color: var(--text); text-align: left; }
.game-card .grow .small { display: block; }
.game-card .best { color: var(--accent); font-weight: 600; }
.game-card[disabled] { opacity: .5; cursor: default; }
.game-emoji { flex: none; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 2rem; background: var(--surface-2); }

/* Playing a game: the tabs step aside */
body.playing .tabs { display: none; }
body.playing .view { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.play-head h1 { font-size: 1.3rem; }
.play-left { font-variant-numeric: tabular-nums; font-size: .9rem; padding: .3rem .7rem; }
.game-box { position: relative; display: grid; justify-items: center; gap: .75rem; min-height: 360px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.game-status { margin: 0; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }
.game-over {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 1rem; text-align: center; padding: 1.5rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent); border-radius: var(--radius); z-index: 2;
}
.game-over-text { font-size: 1.2rem; font-weight: 650; max-width: 18rem; margin: 0; }

.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; width: min(100%, 400px); }
.memory-card {
  aspect-ratio: 1; border-radius: 14px; border: 0; cursor: pointer; font-size: 2rem; padding: 0;
  background: linear-gradient(135deg, var(--accent), #8E7BFF); color: transparent; box-shadow: var(--shadow); transition: transform .15s;
}
.memory-card span { opacity: 0; transition: opacity .15s; }
.memory-card.up { background: var(--surface); outline: 2px solid var(--line); color: inherit; transform: rotateY(0); }
.memory-card.up span { opacity: 1; }
.memory-card.done { outline-color: var(--plus); background: color-mix(in srgb, var(--plus) 14%, var(--surface)); }

.worm-canvas { border-radius: 14px; display: block; touch-action: none; }
.worm-pad { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 52px); gap: .4rem; }
.worm-pad .btn { padding: 0; font-size: 1.2rem; border-radius: 14px; touch-action: manipulation; }
.worm-up { grid-column: 2; grid-row: 1; }
.worm-left { grid-column: 1; grid-row: 2; }
.worm-down { grid-column: 2; grid-row: 2; }
.worm-right { grid-column: 3; grid-row: 2; }

.mole-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; width: min(100%, 360px); }
.mole-hole {
  aspect-ratio: 1; border-radius: 50%; border: 0; padding: 0; cursor: pointer; overflow: hidden; position: relative;
  background: radial-gradient(circle at 50% 70%, #3E2C22 0 45%, #6B4A35 46% 100%);
}
.mole { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.6rem; transform: translateY(80%); transition: transform .12s ease-out; }
.mole-hole.up .mole { transform: translateY(0); }
.mole-hole.bopped { box-shadow: 0 0 0 4px var(--gold) inset; }

.echo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; width: min(100%, 340px); }
.echo-pad { aspect-ratio: 1; border-radius: 22px; border: 0; cursor: pointer; opacity: .55; transition: opacity .08s, transform .08s; }
.echo-pad.g { background: #2FAE66; } .echo-pad.r { background: #E0533D; }
.echo-pad.y { background: #F2C230; } .echo-pad.b { background: #3C7BE0; }
.echo-pad.lit { opacity: 1; transform: scale(1.04); box-shadow: 0 0 24px rgb(255 255 255 / .6); }

.math-q { font-size: 2.6rem; font-weight: 750; font-variant-numeric: tabular-nums; min-height: 3.5rem; }
.math-a { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; width: min(100%, 340px); }
.math-btn { font-size: 1.6rem; min-height: 72px; border-radius: 18px; }
.math-btn.wrong { color: var(--minus); text-decoration: line-through; }
