/* shared/theme.css — dark system v3 ("warm ink"). Link it before the app's own <style>:

     <link rel="stylesheet" href="../shared/theme.css">

   An app sets three variables and writes CSS only for the thing that is its own (the balls,
   the dice, the board). Everything a home / setup / list / sheet screen needs is here.

     :root{ --accent:var(--amber); --accent-ink:var(--amber-ink); --accent-soft:var(--amber-soft);
            --accent-2:var(--sky); --accent-2-ink:var(--sky-ink); --accent-2-soft:var(--sky-soft) }

   Colour rules (the whole system):
   1. A person's colour only ever means that person (their avatar).
   2. --accent only ever marks the app's data: a score, a send, whose turn it is. Choosing things
      and primary buttons are neutral: light fill, dark text.
   3. --accent-2 marks the app's second state (projecting vs sent, side B, a shot vs a brain).
   4. --warn (amber) only ever means careful or not finished: a hold in progress, provisional.
   House minimums: 18px base, nothing under 15px except the 14px tracked caps label, targets 60px,
   greys never dimmed with opacity. Read screens are in rem so the phone's text size applies;
   a play screen may stay in px so the whole game fits one screen. */

@font-face{font-family:"Space Grotesk";font-weight:600;font-display:swap;src:url(fonts/space-grotesk-600.woff2) format("woff2")}
@font-face{font-family:"Space Grotesk";font-weight:700;font-display:swap;src:url(fonts/space-grotesk-700.woff2) format("woff2")}

:root{
  /* ground: warm, OLED-cheap, one step per surface, no shadows */
  --ink-0:#0E0D0B; --ink-1:#1A1816; --ink-2:#262320;
  --line:rgba(240,236,228,.10);
  /* ink */
  --text:#F0ECE4;    /* 16:1 */
  --text-2:#CEC8BE;  /* 11:1 idle figures, chip text */
  --dim:#AEA79C;     /* 8:1 sub-lines and meta */
  --faint:#8E877B;   /* 5.4:1 ranks and disabled, never body text */
  --warn:#FFC14D;
  /* the accent ramp: pick two per app. Same lightness and chroma, so every app sits the same. */
  --teal:#2FD4B3;  --teal-ink:#04271F;  --teal-soft:#10281F;
  --green:#5FD68A; --green-ink:#06240F; --green-soft:#10251A;
  --lime:#B9DF57;  --lime-ink:#1A2406;  --lime-soft:#1F2614;
  --amber:#F3B84B; --amber-ink:#2A1A03; --amber-soft:#2A2214;
  --coral:#FF8C6B; --coral-ink:#2E1007; --coral-soft:#2C1C17;
  --pink:#FF8AB8;  --pink-ink:#2E0A1A;  --pink-soft:#2B1A22;
  --lilac:#C0A5FF; --lilac-ink:#1B0F33; --lilac-soft:#231E33;
  --sky:#7CC3FF;   --sky-ink:#04213A;   --sky-soft:#16222E;
  --accent:var(--teal); --accent-ink:var(--teal-ink); --accent-soft:var(--teal-soft);
  --accent-2:var(--lilac); --accent-2-ink:var(--lilac-ink); --accent-2-soft:var(--lilac-soft);
  --r-chip:12px; --r-ctl:14px; --r-card:18px; --r-sheet:24px;
  --tap:60px; --tap-lg:76px;
  --grot:"Space Grotesk",ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  --fast:.16s; --snap:.24s cubic-bezier(.2,.8,.2,1);
  /* the shared people sheet */
  --pk-card:var(--ink-1); --bg:var(--ink-0); --ink:var(--text); --ink-dim:var(--dim);
  --pk-go:var(--text); --pk-go-ink:var(--ink-0); --danger:var(--warn);
}

/* ---- base ---- */
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;margin:0;padding:0;touch-action:manipulation}
html{height:100%;font-size:112.5%}
body{height:100dvh;overscroll-behavior:none;background:var(--ink-0);color:var(--text);
  font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;font-variant-numeric:tabular-nums;
  font-size:1rem;line-height:1.5;-webkit-user-select:none;user-select:none;display:flex;flex-direction:column;
  padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition:background-color .18s ease}
@supports not (height: 100dvh){ body{height:100%} }
.hidden{display:none !important}
.dim{color:var(--dim)}
a{color:var(--text)} a:active{color:var(--text-2)}

/* ---- type ---- */
/* Figures are the hero. Grotesk for anything you glance at; the system face for anything you read. */
.fig{font-family:var(--grot);font-weight:600;letter-spacing:-.02em;line-height:1.05}
.fig-xl{font-family:var(--grot);font-weight:600;font-size:4rem;letter-spacing:-.03em;line-height:1}
.fig-lg{font-family:var(--grot);font-weight:600;font-size:2.4444rem;letter-spacing:-.02em;line-height:1.05}
.lbl{font-family:var(--grot);font-size:.7778rem;font-weight:700;letter-spacing:.1em;text-transform:uppercase;line-height:1.3}
.note{font-size:.8889rem;color:var(--dim);line-height:1.45}
.sect{color:var(--dim);margin:30px 0 10px}
.sect:first-child{margin-top:4px}

/* ---- the page ---- */
.apphead{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:18px 16px 12px;min-height:76px;flex:none}
.apphead h1{font-family:var(--grot);font-size:1.5556rem;font-weight:600;letter-spacing:-.02em;line-height:1.2;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.apphead .lbl{color:var(--faint)}
/* The account button: your avatar. Tapping it opens the account sheet (ui.account). */
.me{flex:none;width:48px;height:48px;border-radius:50%;padding:0;min-height:0;background:var(--ink-2);display:grid;place-items:center;overflow:hidden}
.me img{width:100%;height:100%;object-fit:cover}
.me>.pk-av{width:100%;height:100%}
.me-in{min-height:48px;padding:0 16px;font-size:.8889rem}   /* signed out, the avatar's place says Sign in */
main.page{flex:1;min-height:0;padding:4px 16px 24px;overflow-y:auto;max-width:40rem;width:100%;margin:0 auto}
main.page>*{flex-shrink:0}
.foot{padding:10px 16px;font-size:.8333rem;color:var(--dim);text-align:center}
.gate{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;padding:28px;text-align:center}
.gate p{color:var(--dim)}
.gate button{width:100%;max-width:22rem;min-height:var(--tap-lg);font-size:1.1111rem}
.gate-err{padding:16px 24px;text-align:center;color:var(--warn);font-size:.9444rem;line-height:1.5}
.empty{color:var(--dim);text-align:center;padding:26px 20px;line-height:1.5}

/* ---- buttons ---- */
button{font:inherit;font-weight:700;color:var(--text);border:none;border-radius:var(--r-ctl);background:var(--ink-2);
  min-height:var(--tap);padding:0 20px;line-height:1.25;transition:transform var(--fast) ease,filter var(--fast) ease}
button:active{filter:brightness(1.18);transform:scale(.98)}
button:disabled{color:var(--faint);background:var(--ink-1);transform:none}
button:focus-visible{outline:3px solid var(--text);outline-offset:2px}
.primary{background:var(--text);color:var(--ink-0)}
.primary:disabled{background:var(--ink-2);color:var(--dim)}
.quiet{background:transparent;color:var(--text-2);box-shadow:inset 0 0 0 1px rgba(240,236,228,.18)}
.quiet:disabled{background:transparent}
.back{min-height:var(--tap);padding:0 18px;font-size:.9444rem}
.warnbtn{color:var(--warn);box-shadow:inset 0 0 0 1px rgba(255,193,77,.45)}
.big{min-height:var(--tap-lg);font-size:1.1111rem}
.wide{width:100%}
.row{display:flex;gap:12px;margin-top:12px}
.row>button{flex:1;min-width:0}
/* Hold to confirm (ui.hold): 600ms, a fill rising from the bottom; let go early to cancel. */
.hold{position:relative;overflow:hidden;isolation:isolate}
.hold::before{content:"";position:absolute;inset:0;z-index:-1;background:rgba(255,193,77,.3);transform:scaleY(0);transform-origin:bottom;transition:transform .12s ease}
.hold.holding::before{transform:scaleY(1);transition:transform .6s linear}

/* ---- parts ---- */
/* Segmented choice: a trough, the chosen segment filled. aria-pressed. */
.seg{display:flex;gap:4px;padding:4px;background:var(--ink-1);border-radius:var(--r-card)}
.seg button{flex:1;min-width:0;min-height:56px;padding:0 4px;border-radius:var(--r-ctl);background:none;color:var(--text-2);font-weight:600;font-size:.9444rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.seg button[aria-pressed="true"]{background:var(--text);color:var(--ink-0)}
/* People chips: avatar and name, the chosen ones filled neutral. */
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chips button{flex:1 1 auto;min-width:5.5rem;min-height:var(--tap);display:inline-flex;align-items:center;justify-content:flex-start;gap:10px;padding:0 16px 0 8px;background:var(--ink-1);color:var(--text-2);border-radius:var(--r-card);font-weight:600}
.chips button>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chips button[aria-pressed="true"]{background:var(--text);color:var(--ink-0)}
.chips .n{flex:none;margin-left:auto;font-family:var(--grot);font-weight:600}
/* Card rows: a figure or avatar, two lines, then at most ONE action — a ⋯ that opens the row's
   sheet (ui.menu). Delete lives in that sheet behind a hold, never on the row. */
.rows{list-style:none;display:flex;flex-direction:column;gap:8px}
.rows>li{display:flex;align-items:center;gap:12px;min-height:76px;background:var(--ink-1);border-radius:var(--r-card);padding:8px 8px 8px 14px}
.rows>li.empty{display:block;background:none;min-height:0}
.rows .who{flex:1;min-width:0;line-height:1.3}
.rows .l1{font-size:1rem;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rows .l2{font-size:.8889rem;font-weight:600;color:var(--dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rows .fig{flex:none;min-width:2.8rem;text-align:center;font-size:1.6667rem;color:var(--accent)}
.rows .fig.alt{color:var(--accent-2)}
.rows .fig.off{color:var(--dim)}
.rows .more{flex:none;width:56px;min-width:56px;padding:0;background:transparent;color:var(--dim);font-size:1.4444rem;letter-spacing:.1em}
.rows>li.live{background:var(--accent-soft);box-shadow:inset 3px 0 0 var(--accent)}
.rows>li.live .l2{color:var(--accent)}
/* The card: a titled block of content, and the shell of a resume / brief / rules block. */
.card{background:var(--ink-1);border-radius:var(--r-card);padding:16px}
.card+.card{margin-top:10px}
.card .lbl{color:var(--dim);margin-bottom:8px}
/* Resume: a game left mid-way, offered back. The accent marks that it's live. */
.resume{display:flex;align-items:center;gap:12px;padding:12px 12px 12px 16px;background:var(--accent-soft);box-shadow:inset 3px 0 0 var(--accent);border-radius:var(--r-card)}
.resume .t{flex:1;min-width:0;font-weight:600}
.resume .t small{display:block;color:var(--accent);font-size:.8889rem}
.resume button{background:var(--accent);color:var(--accent-ink)}
/* Stat tiles: a big figure over a caps label. The figure is the point; make it big. */
.tiles{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:12px 0}
.tile{background:var(--ink-1);border-radius:var(--r-card);padding:16px 8px 14px;text-align:center}
.tile b{display:block;font-family:var(--grot);font-size:2.2222rem;font-weight:600;letter-spacing:-.02em;line-height:1}
.tile span{display:block;margin-top:8px;color:var(--dim)}
.tile.on b{color:var(--accent)}
.chart{background:var(--ink-1);border-radius:var(--r-card);padding:12px 8px 8px}
.chart svg{display:block;width:100%;height:auto;overflow:visible}
.chart .cap{font-size:.8889rem;color:var(--dim);text-align:center;padding:6px 0 4px}
/* Bars: a label, a track, a count. */
.bars{display:flex;flex-direction:column;gap:4px}
.brow{display:flex;align-items:center;gap:10px;min-height:36px}
.brow .g{width:3.4rem;text-align:right;font-family:var(--grot);font-weight:600;font-size:1rem}
.brow .track{flex:1;height:14px;background:var(--ink-2);border-radius:7px;overflow:hidden}
.brow .track i{display:block;height:100%;background:var(--accent);border-radius:7px 4px 4px 7px;transition:width .25s ease}
.brow .n{width:2.8rem;font-size:.8889rem;color:var(--dim)}
/* Big-number grid: grades, counts, anything picked from a set. */
.grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.grid button{min-height:76px;padding:0;background:var(--ink-1);color:var(--text);border-radius:var(--r-card);display:flex;flex-direction:column;align-items:center;justify-content:center;line-height:1.1}
.grid button>span{font-family:var(--grot);font-size:1.8889rem;font-weight:600}
.grid button small{font-size:.8333rem;font-weight:600;margin-top:2px}
.grid button[aria-pressed="true"]{background:var(--text);color:var(--ink-0)}
input[type=text],input[type=email],input[type=date],input[type=number],select,textarea{
  font:inherit;color:var(--text);background:var(--ink-2);border:1px solid var(--line);border-radius:var(--r-chip);
  padding:13px 14px;width:100%;min-height:var(--tap);-webkit-user-select:text;user-select:text}
textarea{min-height:8rem;resize:vertical;line-height:1.45}
input:focus,select:focus,textarea:focus{outline:2px solid var(--accent);outline-offset:0}
label{display:block;font-size:.8889rem;font-weight:600;color:var(--dim);margin:14px 0 6px}
/* Tabs: an app with four or more screens. Selected = accent text + a 3px bar at the top. */
.tabbar{flex:0 0 auto;display:flex;background:var(--ink-0);box-shadow:inset 0 1px 0 var(--line)}
.tabbar button{flex:1;min-height:60px;border-radius:0;background:none;color:var(--dim);padding:0 2px;position:relative;transform:none}
.tabbar button.sel{color:var(--accent)}
.tabbar button.sel::before{content:"";position:absolute;left:30%;right:30%;top:0;height:3px;border-radius:0 0 3px 3px;background:var(--accent)}
/* Live strip: something in progress, pinned above the tabs. */
.livestrip{flex:0 0 auto;display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--accent-soft);box-shadow:inset 0 1px 0 var(--line)}
.livestrip>span{flex:1;min-width:0;display:flex;align-items:center;gap:8px;font-size:.9444rem;font-weight:700;color:var(--accent)}
.livestrip>span::before{content:"";flex:0 0 8px;height:8px;border-radius:50%;background:var(--accent)}
.livestrip button{flex:0 0 auto;min-height:var(--tap);padding:0 14px;font-size:.9444rem}
.livestrip .go{background:var(--accent);color:var(--accent-ink)}
/* Pending on someone else's phone (a rated result to confirm): amber, because it isn't done. */
.livestrip.pend{background:rgba(255,193,77,.12)}
.livestrip.pend>span{color:var(--warn)} .livestrip.pend>span::before{background:var(--warn)}
.livestrip.pend .go{background:var(--warn);color:var(--ink-0)}

/* ---- shared games (CONNECT.md) ---- */
/* Presence (ui.presence): one avatar per other phone in the game, and when each was last seen.
   Tap one for its sheet. Light: no heartbeat, no watchers (KIT-PLAN.md). */
.presence{display:flex;align-items:center;gap:8px;min-height:44px;padding:0 4px}
.presence .ph{position:relative;flex:none;padding:0;min-height:0;background:none;border-radius:50%}
.presence .say{margin-left:auto;font-size:15px;font-weight:600;color:var(--dim)}
/* The echo strip (ui.echo): another phone changed the game in the last five seconds. Undo undoes theirs. */
.echo{display:flex;align-items:center;gap:10px;min-height:52px;padding:6px 6px 6px 14px;border-radius:var(--r-ctl);background:var(--accent-2-soft);font-size:16px;font-weight:600;animation:rise var(--snap)}
.echo>span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.echo b{color:var(--accent-2)}
.echo button{min-height:40px;padding:0 14px;font-size:15px;background:var(--ink-2)}
/* A mirror: this phone isn't the current player's. Controls stay where they are, dimmed, not tappable. */
.mirror{pointer-events:none}
.mirror button{color:var(--faint);background:var(--ink-1);box-shadow:none}
.mirror .primary,.mirror .go{background:var(--ink-2);color:var(--faint)}

/* ---- play screens ---- */
/* The player panel: one per player across the top of a game, the one playing filled in --accent. */
.pl{flex:1 1 0;min-width:0;padding:10px 12px;border-radius:var(--r-ctl);background:var(--ink-1);color:var(--text);text-align:left;display:flex;flex-direction:column;gap:2px;line-height:1.2;transition:background-color .18s ease,color .18s ease}
.pl .nm{display:flex;align-items:center;gap:8px;font-size:15px;font-weight:700;color:var(--dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pl .sc{font-family:var(--grot);font-size:44px;font-weight:600;letter-spacing:-.02em;line-height:1}
.pl.on{background:var(--accent);color:var(--accent-ink)}
.pl.on .nm{color:var(--accent-ink)}
/* The stage: whatever the game stares at, centred. */
.stage{flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;text-align:center}
/* Controls: Undo always left, the primary action widest, the careful one on the right behind a hold. */
.controls{flex:none;display:flex;gap:12px;padding:0 0 4px}
.controls button{height:76px;min-height:0;font-size:18px}
.controls .undo{flex:0 0 104px;box-shadow:inset 0 0 0 1px var(--line)}
.controls .go{flex:1 1 auto;background:var(--text);color:var(--ink-0);font-size:20px}
.controls .end{flex:0 0 88px;background:transparent;color:var(--warn);box-shadow:inset 0 0 0 1px rgba(255,193,77,.45);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;line-height:1.1}
.controls .end small{font-size:15px;font-weight:700}

/* ---- sheets and overlays ---- */
/* A bottom sheet (ui.sheet, ui.menu, ui.account): slides up, never a dialog in the middle. */
.scrim{position:fixed;inset:0;z-index:20;background:rgba(14,13,11,.72);display:flex;align-items:flex-end;justify-content:center;animation:fade var(--fast) ease}
.sheet{width:100%;max-width:30rem;max-height:calc(100dvh - 24px);overflow-y:auto;overscroll-behavior:contain;background:var(--ink-1);border-radius:var(--r-sheet) var(--r-sheet) 0 0;padding:10px 16px calc(16px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:10px;animation:rise var(--snap)}
.sheet:focus{outline:none}
.sheet>*{flex-shrink:0}
.sheet::before{content:"";width:40px;height:4px;border-radius:2px;background:var(--faint);margin:0 auto 6px}
.sheet h2{font-family:var(--grot);font-size:1.3333rem;font-weight:600;letter-spacing:-.01em;padding:4px 2px}
.sheet p{color:var(--dim);padding:0 2px}
.sheet button{width:100%;min-height:var(--tap);text-align:left;padding:0 18px;display:flex;align-items:center;gap:12px}
.sheet button.primary,.sheet button.cancel{justify-content:center}
.sheet button.cancel{background:transparent;color:var(--dim)}
/* A full-screen moment: rack complete, hand the phone over, you won. */
.done{position:fixed;inset:0;z-index:10;background:rgba(14,13,11,.94);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:20px;padding:28px 20px;text-align:center;animation:fade var(--fast) ease}
.done h2{font-family:var(--grot);font-size:2.2222rem;font-weight:600;letter-spacing:-.02em;line-height:1.1}
.done p{color:var(--text-2);font-size:1.0556rem;line-height:1.5;max-width:30ch}
.done button{min-height:76px;width:100%;max-width:22rem;border-radius:var(--r-card);font-size:1.1111rem}
.toast{pointer-events:none;position:fixed;left:50%;bottom:24px;transform:translateX(-50%);z-index:30;background:var(--ink-2);color:var(--text);padding:14px 20px;border-radius:var(--r-ctl);border:1px solid var(--line);font-size:.9444rem;max-width:90vw;text-align:center;animation:rise var(--snap)}
@keyframes rise{from{transform:translateY(24px);opacity:0}to{transform:none;opacity:1}}
@keyframes fade{from{opacity:0}to{opacity:1}}
.toast{animation-name:toastin} @keyframes toastin{from{transform:translate(-50%,16px);opacity:0}to{transform:translate(-50%,0);opacity:1}}
@media (prefers-reduced-motion: reduce){ *{transition:none !important;animation:none !important} }
