:root {
  --bg: #2a1d15;
  --surface: #3a2a1f;
  --surface-press: #4a3627;
  --cream: #f1e6cf;
  --muted: #a8977c;
  --accent: #d9694a;
  --mark: #f2c230;
  --inset-top: env(safe-area-inset-top, 0px);
  --inset-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--cream);
  font: 300 15px/1.3 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  position: fixed;
  inset: 0;
  width: 100%;
}

#board {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#board:active { cursor: grabbing; }

/* Scores float straight on the ground: no card, no outline. */
.hud {
  position: fixed;
  top: calc(var(--inset-top) + 14px);
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.stat { display: flex; flex-direction: column; }
.stat.right { align-items: flex-end; }
.stat .label { font-size: 11px; font-weight: 400; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.stat b { font-size: 30px; font-weight: 200; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* Top-centre utilities: bare icons, no bar behind them. */
.tools {
  position: fixed;
  top: calc(var(--inset-top) + 18px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
}
.icon {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s ease, color .15s ease;
}
.icon:active { background: var(--surface); color: var(--cream); }
.icon svg, .fab svg { fill: none; stroke: currentColor; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
.icon svg { width: 24px; height: 24px; }

/* The one thing you reach for constantly: a lone round button, not a bar. */
.fab {
  position: fixed;
  bottom: calc(var(--inset-bottom) + 22px);
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--mark);
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s ease;
}
.fab:active { background: var(--surface-press); }
.fab svg { width: 28px; height: 28px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--inset-bottom) + 100px);
  transform: translate(-50%, 8px);
  max-width: min(92vw, 420px);
  padding: 10px 18px;
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.sheet {
  position: fixed;
  left: 50%;
  bottom: calc(var(--inset-bottom) + 100px);
  transform: translateX(-50%);
  width: min(92vw, 360px);
  padding: 20px 20px 18px;
  border-radius: 26px;
  text-align: center;
  background: var(--surface);
  animation: rise .25s cubic-bezier(.2, .9, .3, 1.1);
}
.sheet[hidden] { display: none; }
.sheet h2 { margin: 0 0 4px; font-size: 26px; font-weight: 300; }
.sheet p { margin: 0 0 16px; color: var(--muted); }
.row { display: flex; gap: 10px; }
.pill {
  flex: 1;
  height: 48px;
  border: 0;
  border-radius: 18px;
  background: var(--cream);
  color: var(--bg);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}
.pill.ghost { background: var(--surface-press); color: var(--cream); }
.pill:active { opacity: .8; }
.pill[hidden] { display: none; }

@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

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