*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

/* A game screen: scrolling only — no pinch/double-tap zoom, no text selection or long-press menus,
   no rubber-banding (and if an engine bounces anyway, the area it reveals is our paper, not the
   host's black backdrop). The rest lives in core/touch-lock.js. */
html, body { margin: 0; height: 100%; touch-action: pan-x pan-y; overscroll-behavior: none; }
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  transition: background-color .3s var(--ease-out);
}
img, svg { -webkit-user-drag: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  display: grid;
}

.screen {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.screen > .scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--gutter) 24px;
}

/* Buttons */
.btn {
  appearance: none;
  border: 0;
  min-height: 52px;
  padding: 0 22px;
  border-radius: var(--r-pill);
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  transition: transform .18s var(--ease-out), background-color .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible, .icon-btn:focus-visible, .row-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.block { width: 100%; }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.good { background: var(--good); color: #fff; }
.btn[disabled], .icon-btn[disabled] { opacity: .45; pointer-events: none; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  width: var(--tap);
  height: var(--tap);
  border-radius: var(--r-pill);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink);
  transition: background-color .15s, transform .15s var(--ease-out);
}
.icon-btn:active { transform: scale(.92); background: var(--surface-2); }
.icon-btn svg { width: 24px; height: 24px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font-weight: 800;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Bottom sheet */
.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--scrim);
  /* --scrim-k (0–1) fades the scrim while the sheet is swiped down (ui/sheet-drag.js) */
  background: color-mix(in srgb, var(--scrim) calc(var(--scrim-k, 1) * 100%), transparent);
  animation: fade-in .22s var(--ease-out);
}
.sheet-layer.closing { animation: fade-out .2s var(--ease-out) forwards; }
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 10px var(--gutter) calc(20px + var(--safe-bottom));
  animation: sheet-up .38s var(--ease-out);
}
.sheet-layer.closing .sheet { animation: sheet-down .22s var(--ease-in-out) forwards; }
.sheet.settling { transition: transform .26s var(--ease-out); }
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 14px; }
.sheet h2 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top) + 64px);
  z-index: 60;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--r-pill);
  font-weight: 800;
  font-size: 15px;
  box-shadow: var(--shadow-2);
  pointer-events: none;
  white-space: nowrap;
  animation: toast-in .3s var(--ease-spring);
}

.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -12px) scale(.9); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
