@font-face { font-family: "Fredoka"; src: url("fredoka.ttf") format("truetype"); font-weight: 300 700; font-display: swap; }

:root {
  --bg: #f5f2ff; --card: #ffffff; --ink: #2b1d52; --muted: #7b6f9c; --line: #e7e1f7;
  --brand: #6c4df6; --brand-2: #8a6bff; --brand-soft: #efeaff; --gold: #ffc928; --gold-dark: #e09a00;
  --green: #1fbf6a; --green-dark: #149153; --red: #ff5a7a; --blue: #2e8bff;
  --shadow: 0 6px 20px rgba(43, 29, 82, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15112a; --card: #211b3d; --ink: #f1edff; --muted: #a79dca; --line: #342b5c;
    --brand-soft: #2e2560; --shadow: 0 6px 20px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); min-height: 100vh;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: linear-gradient(160deg, #6c4df6, #9c6bff 55%, #ff8a65); }
.login { width: min(420px, 100%); background: var(--card); border-radius: 28px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login .logo { font-size: 56px; text-align: center; animation: bob 2.4s ease-in-out infinite; }
.login h1 { text-align: center; font-size: 32px; }
.login p { text-align: center; margin: 4px 0 18px; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }

/* ---------- layout ---------- */
.shell { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0); z-index: 5; background: var(--bg);
  display: flex; align-items: center; gap: 12px; padding: 14px 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand .star { font-size: 30px; }
.brand h1 { font-size: 22px; }
.tabs { display: flex; gap: 6px; background: var(--card); padding: 5px; border-radius: 999px; box-shadow: var(--shadow); }
.tab { border: 0; background: transparent; padding: 8px 16px; border-radius: 999px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.tab[aria-selected="true"] { background: var(--brand); color: #fff; }
.count { background: var(--red); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; min-width: 20px; text-align: center; }

/* ---------- cards & rows ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--card); border-radius: 22px; box-shadow: var(--shadow); padding: 16px; }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 0 4px 10px; flex-wrap: wrap; }
.section-head h2 { font-size: 19px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.list { background: var(--card); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.empty { padding: 18px; color: var(--muted); text-align: center; }
.emoji { font-size: 30px; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; background: var(--brand-soft); flex: none; }
.avatar { font-size: 32px; width: 60px; height: 60px; display: grid; place-items: center; border-radius: 50%; background: var(--brand-soft); flex: none; }

.kid { display: flex; gap: 14px; align-items: center; cursor: pointer; border: 3px solid transparent; transition: transform .15s, border-color .15s; }
.kid:hover { transform: translateY(-2px); border-color: var(--brand-2); }
.kid h3 { font-size: 20px; }
.stats { display: flex; gap: 10px; font-weight: 700; margin-top: 4px; flex-wrap: wrap; }

.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.pill.gold { background: #fff3c4; color: #7a5b00; }
.pill.blue { background: #e3f2fd; color: #0d47a1; }
.pill.orange { background: #ffe8d6; color: #b23a00; }

.time { border: 0; border-radius: 12px; padding: 6px 10px; font-weight: 700; font-size: 17px; min-width: 70px;
  background: var(--brand); color: #fff; }
.time.none { background: var(--brand-soft); color: var(--brand); font-size: 13px; }

/* ---------- buttons ---------- */
.btn { border: 0; border-radius: 14px; padding: 10px 16px; font-weight: 600; background: var(--brand-soft); color: var(--brand);
  display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 4px 0 #4b30c9; }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #4b30c9; }
.btn.ok { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-dark); }
.btn.ok:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-dark); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; font-size: 18px; padding: 6px 8px; border-radius: 10px; }
.icon-btn:hover { background: var(--brand-soft); }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=time] {
  width: 100%; padding: 11px 13px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); outline: none; }
input:focus { border-color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-weight: 600; }
.chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.icons { display: grid; grid-template-columns: repeat(auto-fill, 48px); gap: 6px; margin-bottom: 12px; }
.icons button { width: 48px; height: 48px; font-size: 26px; border-radius: 14px; border: 2px solid transparent; background: var(--brand-soft); }
.icons button[aria-pressed="true"] { border-color: var(--brand); background: #fff3c4; }
.choice { display: block; width: 100%; text-align: left; border: 2px solid var(--line); background: var(--card); border-radius: 16px; padding: 10px 12px; margin-bottom: 8px; }
.choice[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.hint { font-size: 13px; color: var(--muted); margin: -4px 0 12px; }
.switch { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.error { color: var(--red); font-weight: 600; margin: 8px 0; }

/* ---------- modal & toast ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(18, 11, 46, .55); display: grid; place-items: center; padding: 16px; z-index: 20; animation: fade .15s; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--card); border-radius: 24px; padding: 22px; animation: pop .2s cubic-bezier(.2, 1.4, .4, 1); }
.modal h2 { margin-bottom: 14px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0)); transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 14px; font-weight: 600; max-width: calc(100% - 32px); }
.fade-out { animation: fadeOut .3s forwards; }
@keyframes fadeOut { to { opacity: 0; transform: translateX(-30px); } }

@media (max-width: 600px) {
  .tab .label { display: none; }
  .tab { padding: 8px 14px; font-size: 18px; }
  .brand h1 { font-size: 19px; }
}

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bar { height: 8px; border-radius: 99px; background: var(--brand-soft); margin: 6px 0 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, #3ddc84, #ffa000 70%, #ff5a7a); }
.live { color: var(--blue); font-weight: 700; margin-top: 2px; }
.live-card { display: flex; gap: 12px; align-items: center; border: 3px solid var(--blue); flex-wrap: wrap; }
.time.play { background: var(--blue); display: inline-block; text-align: center; }
