/* The arcade shell: a neutral look, separate from any game's style. */
:root {
  --ink: #1d2330;
  --muted: #667085;
  --line: #e1e4ea;
  --soft: #f3f4f7;
  --accent: #3b5bdb;
  --accent-soft: #e8ecfd;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  --berry: #e5484d;
  color-scheme: light;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #fff; color: var(--ink); overflow: hidden; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; }
svg { display: block; }

#app { position: fixed; inset: 0; }

/* ---- Shared pieces ---- */
.round-btn, .icon-btn, .hold.round {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 64px; height: 64px; padding: 0; border-radius: 50%; border: 2px solid var(--line);
  background: var(--soft); color: var(--ink); touch-action: manipulation;
}
.round-btn svg, .icon-btn svg, .hold.round svg.icon { width: 30px; height: 30px; }
.round-btn:active, .icon-btn:active { background: #e6e8ee; }
.round-btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.round-btn.accent:active { background: #2f49b3; }
.hold { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.hold .ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); pointer-events: none; }
.hold .ring circle { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 289; stroke-dashoffset: 289; }
.hold.danger .ring circle { stroke: var(--danger); }
.hold.danger.round { color: var(--danger); background: var(--danger-soft); border-color: #f4c7c3; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; padding: 0 28px;
  border-radius: 32px; border: 2px solid var(--line); background: var(--soft); font-size: 20px; font-weight: 700; touch-action: manipulation;
}
.btn svg { width: 28px; height: 28px; flex: none; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:active { background: #2f49b3; }
.btn:disabled { opacity: .45; }
.hold.wide { position: relative; overflow: hidden; }
.hold.wide.danger { color: var(--danger); background: var(--danger-soft); border-color: #f4c7c3; }
.hold.wide .hold-fill { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0); background: rgba(217, 45, 32, .22); pointer-events: none; }
.hold.wide .hold-in { position: relative; display: inline-flex; align-items: center; gap: 10px; pointer-events: none; }

.avatar { display: block; width: 100%; height: 100%; border-radius: 50%; overflow: hidden; }
.avatar svg { width: 100%; height: 100%; }
.berry { width: 32px; height: 32px; flex: none; }

/* ---- Launcher ---- */
.launcher { position: absolute; inset: 0; display: flex; flex-direction: column; background: #fff; }
.topbar {
  display: flex; align-items: center; gap: 16px; flex: none;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line);
}
.me { width: 64px; height: 64px; flex: none; padding: 0; border: 0; background: none; border-radius: 50%; }
.me:is(div) { cursor: default; }
.app-name { flex: 1; font-size: 30px; font-weight: 800; letter-spacing: -.01em; }
.home-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 20px max(16px, env(safe-area-inset-right, 0px)) calc(56px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.wallet {
  display: inline-flex; align-items: center; gap: 10px; padding: 8px 22px 8px 14px; margin-bottom: 24px;
  background: var(--soft); border: 2px solid var(--line); border-radius: 999px;
  font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.home-scroll h2 { font-size: 22px; font-weight: 800; margin: 0 0 14px; }
.home-scroll section + section { margin-top: 28px; }
.lately { display: flex; gap: 20px; overflow-x: auto; padding: 4px 4px 12px; margin: 0 -4px; -webkit-overflow-scrolling: touch; }
.lately .tile { flex: none; width: clamp(200px, 22vw, 260px); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 20px; }
@media (orientation: landscape) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.none { color: var(--muted); font-size: 18px; padding: 8px 0; }

.tile {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 10px; min-height: 200px; min-width: 0;
  padding: 0; border: 0; background: none; text-align: center; font-size: 20px; font-weight: 700; touch-action: manipulation;
}
.tile .art-wrap {
  position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: 26px; overflow: hidden; background: var(--soft);
  box-shadow: 0 1px 0 rgba(16, 24, 40, .06), 0 6px 18px rgba(16, 24, 40, .14); transition: transform .1s;
}
.tile:not(:disabled):active .art-wrap { transform: scale(.96); }
.tile .art { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile .art-soon { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; background: #e6e8ec; color: #9aa1af; }
.tile .art-soon svg { width: 42%; height: 42%; }
.tile.soon { color: var(--muted); }
.tile.soon .art-wrap { box-shadow: none; }
.tile .clock {
  position: absolute; right: 10px; bottom: 10px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: #fff; color: var(--muted); box-shadow: 0 1px 4px rgba(16, 24, 40, .2);
}
.tile .clock svg { width: 22px; height: 22px; }
.tile .dot { position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 4px solid #fff; box-shadow: 0 1px 4px rgba(16, 24, 40, .3); }
.tile .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Who's playing ---- */
.who { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 32px; padding: 32px 16px; }
.who h1 { font-size: clamp(30px, 6vmin, 48px); font-weight: 800; text-align: center; }
.who-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 28px 36px; max-width: 960px; }
.who-card { display: flex; flex-direction: column; align-items: center; gap: 12px; width: clamp(130px, 22vmin, 190px); padding: 0; border: 0; background: none; font-size: 22px; font-weight: 800; touch-action: manipulation; }
.who-card .who-av { display: block; width: 100%; aspect-ratio: 1; border-radius: 50%; box-shadow: 0 6px 18px rgba(16, 24, 40, .18); transition: transform .1s; }
.who-card:active .who-av { transform: scale(.94); }
.who-card .who-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Game frame ---- */
.game-layer { position: absolute; inset: 0; z-index: 1; isolation: isolate; background: #fff; }
.game-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 14px; }
.game-loading span { width: 18px; height: 18px; border-radius: 50%; background: #c5cad6; animation: blink 1.1s infinite ease-in-out; }
.game-loading span:nth-child(2) { animation-delay: .18s; }
.game-loading span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.game-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; }
.house-btn {
  position: absolute; z-index: 5; top: max(12px, env(safe-area-inset-top, 0px)); left: max(16px, env(safe-area-inset-left, 0px));
  width: 64px; height: 64px; background: #fff; border: 2px solid rgba(29, 35, 48, .16); box-shadow: 0 4px 12px rgba(16, 24, 40, .22);
}
.house-btn svg { width: 32px; height: 32px; }
.pause-panel { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; background: rgba(20, 24, 34, .55); padding: 16px; }
.pause-card { display: flex; gap: clamp(20px, 6vmin, 48px); padding: clamp(20px, 5vmin, 36px); border-radius: 40px; background: #fff; box-shadow: 0 16px 48px rgba(16, 24, 40, .35); }
.big-btn {
  display: flex; align-items: center; justify-content: center; width: clamp(110px, 30vmin, 160px); height: clamp(110px, 30vmin, 160px);
  padding: 0; border-radius: 50%; border: 2px solid var(--line); background: var(--soft); color: var(--ink); touch-action: manipulation;
}
.big-btn svg { width: 52%; height: 52%; }
.big-btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.big-btn:active { filter: brightness(.94); }
.oops { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; background: #fff; padding: 16px; }
.oops-card { display: flex; flex-direction: column; align-items: center; gap: 24px; max-width: 420px; padding: 36px 32px; text-align: center; border-radius: 36px; background: var(--soft); border: 2px solid var(--line); }
.oops-card h2 { font-size: 34px; font-weight: 800; }
.oops-card p { font-size: 20px; color: var(--muted); }
.oops-actions { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }

/* ---- Sheets (grown-up corner, editor, game settings) ---- */
.sheets { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.sheet {
  position: absolute; inset: 0; overflow-y: auto; background: #fff; pointer-events: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 0 max(24px, env(safe-area-inset-right, 0px)) calc(48px + env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
}
.sheet-head {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 16px; margin: 0 -24px 20px; background: #fff; border-bottom: 1px solid var(--line);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 24px 12px;
}
.sheet-head h2 { flex: 1; font-size: 28px; font-weight: 800; }
.gu { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(0, 2fr); gap: 28px; align-items: start; }
@media (max-width: 760px), (orientation: portrait) { .gu { grid-template-columns: minmax(0, 1fr); } }
.panel { padding: 20px; border: 2px solid var(--line); border-radius: 28px; background: #fff; }
.panel + .panel { margin-top: 20px; }
.panel h3 { font-size: 22px; font-weight: 800; margin-bottom: 14px; }
.sub { font-size: 14px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.sub:first-child { margin-top: 0; }
.player-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 14px; padding: 8px; border-radius: 24px; border: 2px solid transparent; }
.player-actions { display: flex; gap: 18px; padding-right: 6px; }
.player-row + .player-row { margin-top: 6px; }
.player-row.on { background: var(--accent-soft); border-color: #c4cdf6; }
.player-pick { flex: 1 1 100%; min-width: 0; display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 0 8px 0 0; border: 0; background: none; text-align: left; font-size: 22px; font-weight: 700; }
.player-pick .pav { width: 64px; height: 64px; flex: none; }
.player-pick .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-pick .badge { flex: none; font-size: 13px; font-weight: 800; color: var(--accent); background: #fff; border: 2px solid #c4cdf6; border-radius: 999px; padding: 2px 10px; }
.add-row { margin-top: 14px; }
.who-head { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.who-head .pav { width: 56px; height: 56px; }
.who-head h3 { margin: 0; }
.row { display: flex; align-items: center; gap: 16px; min-height: 64px; width: 100%; padding: 8px 4px; border: 0; background: none; text-align: left; font-size: 20px; }
.row + .row, .row + .help, .help + .row { border-top: 1px solid var(--line); }
.row .txt { flex: 1; min-width: 0; }
.row .lbl { display: block; font-weight: 700; }
.row .hint { display: block; margin-top: 2px; font-size: 15px; color: var(--muted); font-weight: 400; }
.switch { position: relative; flex: none; width: 76px; height: 44px; border-radius: 22px; background: #c9ceda; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 4px; left: 4px; width: 36px; height: 36px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(16, 24, 40, .3); transition: transform .15s; }
[aria-checked="true"] > .switch { background: var(--accent); }
[aria-checked="true"] > .switch::after { transform: translateX(32px); }
.val { flex: none; font-size: 20px; font-weight: 700; text-align: right; }
.val.muted { color: var(--muted); font-weight: 400; }
.berries-big { display: inline-flex; align-items: center; gap: 10px; padding: 6px 18px 6px 12px; border-radius: 999px; background: var(--soft); border: 2px solid var(--line); font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ledger { list-style: none; margin: 12px 0 0; padding: 0; }
.ledger li { display: flex; align-items: baseline; gap: 12px; padding: 10px 4px; font-size: 17px; }
.ledger li + li { border-top: 1px solid var(--line); }
.ledger .when { flex: none; width: 150px; color: var(--muted); font-size: 15px; }
.ledger .what { flex: 1; min-width: 0; }
.ledger .amt { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; }
.ledger .amt.plus { color: #1a7f4b; }
.ledger .amt.minus { color: var(--danger); }
.empty { color: var(--muted); font-size: 17px; padding: 6px 4px; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choice { min-height: 64px; padding: 0 24px; border-radius: 32px; border: 2px solid var(--line); background: var(--soft); font-size: 20px; font-weight: 700; touch-action: manipulation; }
.choice[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.num { width: 120px; min-height: 56px; padding: 0 14px; border: 2px solid var(--line); border-radius: 16px; font: inherit; font-size: 20px; text-align: right; }
.danger-zone { margin-top: 8px; }
.danger-zone .btn { width: 100%; }
.settings-body { max-width: 760px; margin: 0 auto; }
.field-row { padding: 14px 4px; }
.field-row + .field-row { border-top: 1px solid var(--line); }
.field-row .lbl { display: block; font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.done-note { font-weight: 700; color: #1a7f4b; }

/* ---- Add or edit player ---- */
.editor-body { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.editor-body .preview { align-self: center; width: 128px; height: 128px; }
.editor-body label.name-field { display: block; font-size: 18px; font-weight: 800; }
.editor-body input[type="text"] { display: block; width: 100%; margin-top: 8px; min-height: 64px; padding: 0 18px; border: 2px solid var(--line); border-radius: 20px; font: inherit; font-size: 24px; font-weight: 700; background: #fff; color: var(--ink); }
.editor-body .grp { font-size: 18px; font-weight: 800; margin-bottom: 10px; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 12px; }
.av-pick { padding: 4px; border: 4px solid transparent; border-radius: 50%; background: none; aspect-ratio: 1; touch-action: manipulation; }
.av-pick[aria-pressed="true"] { border-color: var(--ink); }
.swatches { display: flex; flex-wrap: wrap; gap: 14px; }
.swatch { width: 64px; height: 64px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 2px var(--line); touch-action: manipulation; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 4px var(--ink); }
.editor-actions { display: flex; gap: 16px; justify-content: flex-end; flex-wrap: wrap; }
.editor-actions .btn { min-width: 160px; }
.error-note { color: var(--danger); font-weight: 700; font-size: 18px; min-height: 24px; }

/* ---- Sign in, family password, account ---- */
.sr-only { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.lede { font-size: 20px; color: var(--muted); text-align: center; }
.big-input { display: block; width: 100%; min-height: 72px; padding: 0 20px; border: 2px solid var(--line); border-radius: 22px; font: inherit; font-size: 28px; font-weight: 700; background: #fff; color: var(--ink); }
.signin { flex: 1; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.signin-card { display: flex; flex-direction: column; gap: 20px; width: 100%; max-width: 460px; }
.signin-card h1 { font-size: clamp(30px, 6vmin, 48px); font-weight: 800; text-align: center; }
.signin-actions { display: flex; flex-direction: column; gap: 14px; }
.signin-actions .btn { width: 100%; }
.pw-body { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.gu-note:empty { display: none; }
.gu-note { margin: -8px 0 16px; }
.btn.compact { min-height: 56px; padding: 0 22px; font-size: 18px; }
.link-btn { min-height: 64px; padding: 0 4px; border: 0; background: none; color: var(--accent); font-size: 20px; font-weight: 700; text-decoration: underline; touch-action: manipulation; }
.acct { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 16px; }
.acct .lbl { font-size: 20px; font-weight: 700; }
.devices { list-style: none; margin: 0; padding: 0; }
.devices li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; }
.devices li + li { border-top: 1px solid var(--line); }
.devices .dev { flex: 1; min-width: 0; }
.devices .dev-name { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 18px; font-weight: 700; }
.devices .badge { font-size: 13px; font-weight: 800; color: var(--accent); background: #fff; border: 2px solid #c4cdf6; border-radius: 999px; padding: 2px 10px; }
.devices .seen { display: block; margin-top: 2px; font-size: 15px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .game-loading span { animation: none; opacity: .6; }
  .tile .art-wrap, .who-card .who-av, .switch, .switch::after { transition: none; }
}
