/* Kotityökisa – light, phone-first */
:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #15233a;
  --muted: #5d6b80;
  --line: #e3e8ef;
  --soft: #e9eef5;
  --primary: #1d5fd6;
  --primary-ink: #ffffff;
  --good: #0f7a54;
  --good-bg: #e3f5ec;
  --bad: #b4401f;
  --bad-bg: #fde8e4;
  --gold: #ffc83d;
  --gold-ink: #3d2c00;
  --gold-bg: #fff4d6;
  --gold-text: #7a5000;
  --display: "Fredoka", ui-rounded, system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 var(--body); -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }
[hidden] { display: none !important; }

.boot { padding: 40vh 16px 0; text-align: center; color: var(--muted); }

.screen {
  max-width: 520px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 100px) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 12px;
}
.screen.no-tabs { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); }

h1, h2, .display { font-family: var(--display); }
h1 { margin: 0; font-weight: 700; font-size: 28px; letter-spacing: -0.01em; }
h2 { margin: 0; font-weight: 600; font-size: 18px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.card { background: var(--card); border-radius: 18px; }
.pad { padding: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* Header */
.top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.top .actions { display: flex; align-items: center; gap: 8px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--good); background: var(--good-bg); padding: 6px 10px; border-radius: 999px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #13a36e; }
.live.off { color: var(--muted); background: var(--soft); }
.live.off i { background: var(--muted); }
.icon-btn { position: relative; width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--card); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); flex: none; }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: #e0452b; border: 2px solid #fff; }
.avatar { border-radius: 50%; overflow: hidden; display: inline-flex; align-items: flex-end; justify-content: center; flex: none; box-sizing: border-box; background-size: cover; background-position: center; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Banner */
.banner { background: var(--ink); color: #fff; border-radius: 16px; padding: 10px 10px 10px 12px; display: flex; align-items: center; gap: 10px; animation: drop .35s ease-out; }
.banner .b-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; }
.banner .b-sub { font-size: 13px; color: #b9c4d4; }
.banner button { width: 40px; height: 40px; border: 0; border-radius: 12px; background: #24344f; display: flex; align-items: center; justify-content: center; flex: none; }
.banner button.on { background: #3b4e6e; box-shadow: inset 0 0 0 2px #7fa6e6; }
.banner .close { background: transparent; }
@keyframes drop { from { transform: translateY(-10px); opacity: 0; } }

/* Stake */
.stake { background: var(--gold-bg); border-radius: 16px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.stake .eyebrow { color: var(--gold-text); }
.stake button.link { border: 0; background: transparent; color: var(--gold-text); font-weight: 700; font-size: 14px; padding: 10px 4px; }
.stake input { flex: 1; min-width: 0; height: 44px; border: 1px solid #ecd9a0; border-radius: 12px; padding: 0 12px; background: #fff; }
.stake .save { height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--gold-text); color: #fff; font-weight: 700; }

/* Pool */
.pool { background: var(--card); border-radius: 24px; padding: 18px 16px 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 1px 2px rgba(21,35,58,.06), 0 8px 24px rgba(21,35,58,.06); }
.double { display: flex; align-items: center; gap: 8px; background: var(--ink); color: #fff; border-radius: 12px; padding: 8px 12px; font-size: 14px; font-weight: 600; }
.double b { font-family: var(--display); background: var(--gold); color: var(--gold-ink); padding: 1px 8px; border-radius: 8px; }
.tanks { display: grid; gap: 14px; }
.player { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.tank { position: relative; width: 100%; height: 250px; border-radius: 20px; overflow: hidden; }
.water { position: absolute; left: 0; right: 0; bottom: 0; transition: height .9s cubic-bezier(.2,.8,.2,1); }
.water svg { position: absolute; top: -13px; left: 0; width: 200%; height: 14px; display: block; animation: wave 3.5s linear infinite; }
@keyframes wave { to { transform: translateX(-50%); } }
.floater { position: absolute; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; transition: bottom .9s cubic-bezier(.2,.8,.2,1); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { translate: 0 -3px; } }
.lead-tag { font-size: 11px; font-weight: 700; background: var(--gold); color: var(--gold-ink); padding: 2px 8px; border-radius: 999px; margin-bottom: 4px; letter-spacing: .04em; }
.face { position: relative; width: 80px; height: 80px; }
.face .avatar { width: 80px; height: 80px; border: 4px solid #fff; box-shadow: 0 4px 12px rgba(21,35,58,.18); }
.face .mood { position: absolute; right: -4px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%; background: #ffd66b; border: 3px solid #fff; display: flex; align-items: center; justify-content: center; }
.score { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-family: var(--display); font-weight: 700; font-size: 44px; color: #fff; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0,0,0,.12); }
.pname { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 6px; max-width: 100%; }
.pname span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.streak { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 700; color: var(--bad); background: var(--bad-bg); padding: 2px 7px; border-radius: 999px; }
.level { font-size: 12px; color: var(--muted); text-align: center; }

/* Goal */
.bar { height: 14px; border-radius: 999px; background: var(--soft); overflow: hidden; display: flex; }
.bar > div { height: 100%; transition: width .9s ease; }

/* Buttons */
.btn { height: 60px; border-radius: 18px; border: 0; background: var(--primary); color: var(--primary-ink); text-decoration: none; display: flex; align-items: center; justify-content: center; gap: 10px; font-family: var(--display); font-weight: 600; font-size: 20px; box-shadow: 0 6px 16px rgba(29,95,214,.28); width: 100%; }
.btn:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; }
.btn.secondary { background: var(--card); color: var(--ink); box-shadow: none; border: 1px solid var(--line); font-family: var(--body); font-size: 16px; height: 50px; border-radius: 14px; }
.btn.small { height: 44px; font-size: 15px; border-radius: 12px; font-family: var(--body); box-shadow: none; }
.textbtn { border: 0; background: transparent; color: var(--primary); font-weight: 600; font-size: 14px; padding: 10px 4px; }
.textbtn.danger { color: var(--bad); }

/* Lists */
.list { background: var(--card); border-radius: 16px; display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid #edf1f6; }
.item { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; display: flex; align-items: center; justify-content: center; border: 0; padding: 0; }
.plus { font-weight: 700; color: var(--good); font-variant-numeric: tabular-nums; }
.empty { padding: 16px 14px; color: var(--muted); }

/* Log screen */
.back { display: flex; align-items: center; gap: 8px; }
.who { display: flex; align-items: center; gap: 12px; }
.chores { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chore { min-height: 56px; border-radius: 14px; border: 2px solid transparent; background: var(--card); display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 14px; font-weight: 600; font-size: 15px; text-align: left; }
.chore .pts { font-weight: 700; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.chore.dbl { border-color: var(--gold); background: #fff8e3; }
.chore.dbl .pts { color: var(--gold-text); }
.chore .x2 { font-size: 11px; background: var(--gold); color: var(--gold-ink); padding: 1px 5px; border-radius: 6px; }
.chore[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.chore[aria-pressed="true"] .pts { color: #fff; }
.field { height: 52px; border-radius: 14px; border: 1px solid #dbe2ec; background: var(--card); padding: 0 14px; width: 100%; min-width: 0; }
label.lbl { font-size: 13px; color: var(--muted); }
.preview { position: relative; width: 72px; height: 72px; }
.preview img { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; }
.preview button { position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; padding: 0; }

/* History */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid #dbe2ec; background: var(--card); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip i { width: 8px; height: 8px; border-radius: 50%; }
.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hrow { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 14px; }
.hrow.del { background: #fbfcfe; }
.hrow.del .t, .hrow.del .w, .hrow.del .plus { color: #8a96a8; text-decoration: line-through; }
.hrow .t { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.hrow .w { font-weight: 600; font-size: 15px; }
.trace { font-size: 12px; color: var(--muted); }
.late { color: var(--gold-text); font-weight: 600; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 2px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--soft); border: 0; color: var(--ink); }
.tag.heart { background: #fde8ec; color: #a3243a; }
.tag.react { background: var(--card); border: 1px solid #dbe2ec; height: 32px; padding: 0 10px; }
.tag.react.on { background: #eaf2fd; border-color: var(--primary); color: var(--primary); }
.tag.delbtn { background: transparent; color: var(--bad); height: 32px; padding: 0 6px; }
.tag.delbtn.arm { background: var(--bad-bg); }

/* Season */
.season-head { background: var(--ink); color: #fff; border-radius: 22px; padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.vs { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center; }
.vs .big { font-family: var(--display); font-weight: 700; font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; }

/* Profile */
.toggle { display: flex; align-items: center; gap: 12px; padding: 14px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.photo-slot { background: var(--card); border-radius: 18px; padding: 16px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.photo-slot .ph { width: 104px; height: 104px; border-radius: 50%; border: 2px dashed #9bb6dc; background: #eef4fd; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.photo-slot .ph img { width: 100%; height: 100%; object-fit: cover; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.admin-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px auto; gap: 8px; align-items: center; padding: 10px 12px; }
.admin-row input[type=text], .admin-row input[type=number] { height: 42px; border: 1px solid #dbe2ec; border-radius: 10px; padding: 0 10px; min-width: 0; width: 100%; }
.admin-row.off input[type=text] { color: var(--muted); text-decoration: line-through; }
.notice { background: var(--gold-bg); color: var(--gold-text); border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.error { background: var(--bad-bg); color: #8f2e14; border-radius: 14px; padding: 12px 14px; font-size: 14px; }

/* Tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 6px) max(8px, env(safe-area-inset-left, 0px)); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 52px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.tabs a[aria-current="page"] { color: var(--primary); font-weight: 700; }
.tabs a svg { stroke: currentColor; }

/* Overlays */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(21,35,58,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { background: var(--bg); width: 100%; max-width: 520px; max-height: 80vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 20px) max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 12px; animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(40px); } }
@keyframes fade { from { opacity: 0; } }
.lightbox { position: fixed; inset: 0; z-index: 45; background: rgba(10,16,28,.92); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 12px; }

.lead { position: fixed; inset: 0; z-index: 50; background: #c24e27; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: calc(env(safe-area-inset-top, 0px) + 32px) max(24px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 32px) max(24px, env(safe-area-inset-left, 0px)); text-align: center; overflow: hidden; animation: fade .3s; }
.lead.me { background: #1b55c2; }
.lead .drops { position: absolute; inset: 0; pointer-events: none; }
.lead .drops span { position: absolute; border-radius: 50%; background: rgba(255,255,255,.18); animation: rise 4s ease-in infinite; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } 30% { opacity: 1; } to { transform: translateY(-120px); opacity: 0; } }
.lead h1 { font-size: 38px; line-height: 1.05; text-wrap: balance; }
.lead .duo { position: relative; width: 220px; height: 210px; }
.lead .duo .main { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); width: 150px; height: 150px; border: 6px solid #fff; animation: pop .6s cubic-bezier(.2,1.6,.4,1); }
.lead .duo .other { position: absolute; left: 0; bottom: 0; width: 76px; height: 76px; border: 4px solid #fff; }
.lead .duo .tag2 { position: absolute; left: 50%; top: 0; transform: translateX(-50%); z-index: 2; font-size: 12px; font-weight: 700; background: var(--gold); color: var(--gold-ink); padding: 3px 10px; border-radius: 999px; letter-spacing: .04em; white-space: nowrap; }
@keyframes pop { from { transform: translateX(-50%) scale(.4); } }
.lead .btn { background: #fff; color: #b0451f; box-shadow: none; }
.lead.me .btn { color: #1b55c2; }
.lead .ghost { height: 48px; border: 0; background: transparent; color: #fff; font-weight: 600; font-size: 15px; }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(21,35,58,.25); animation: drop .25s; }
#toast.err { background: #8f2e14; }

/* Login */
.login { max-width: 420px; margin: 0 auto; min-height: 100vh; padding: calc(env(safe-area-inset-top, 0px) + 48px) max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 16px; justify-content: center; }
.login form { display: flex; flex-direction: column; gap: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
