/* Punten — mobile-first card-game point counter */
:root {
  --bg: oklch(0.98 0.005 80);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.955 0.006 80);
  --ink: oklch(0.18 0.01 80);
  --ink-2: oklch(0.42 0.01 80);
  --ink-3: oklch(0.62 0.01 80);
  --line: oklch(0.9 0.005 80);
  --accent: oklch(0.62 0.16 145);
  --accent-ink: oklch(0.42 0.18 145);
  --accent-soft: oklch(0.94 0.05 145);
  --blue: oklch(0.55 0.15 250);
  --blue-soft: oklch(0.94 0.04 250);
  --warn: oklch(0.6 0.18 30);
  --warn-soft: oklch(0.95 0.04 30);
  --crown: oklch(0.78 0.15 85);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --shadow-card: 0 1px 0 oklch(1 0 0 / 0.6) inset, 0 1px 2px oklch(0 0 0 / 0.04), 0 8px 24px -16px oklch(0 0 0 / 0.12);
  --tap: 56px;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Geist', -apple-system, system-ui, sans-serif;
  background:
    radial-gradient(1200px 800px at 0% 0%, oklch(0.96 0.01 145) 0%, transparent 60%),
    radial-gradient(1000px 700px at 100% 100%, oklch(0.96 0.01 250) 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  letter-spacing: -0.01em;
  min-height: 100dvh;
  overflow-x: hidden;
}
.mono { font-family: 'Geist Mono', ui-monospace, SFMono-Regular, monospace; font-feature-settings: 'tnum' 1; }
.tabular { font-variant-numeric: tabular-nums; }

/* App shell — mobile */
.shell {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Desktop layout */
@media (min-width: 768px) {
  body { background-attachment: fixed; }
  .shell {
    max-width: none;
    width: 100%;
    min-height: 100dvh;
    flex-direction: row;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }
  .shell.desktop {
    display: flex;
    flex-direction: row;
    height: 100dvh;
    overflow: hidden;
  }
  .desktop-sidebar {
    width: 340px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    position: sticky;
    top: 0;
  }
  .desktop-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100dvh;
  }
  /* Wrapper for screen content — natural flow, no auto-stretching */
  .screen-fill {
    display: flex;
    flex-direction: column;
  }
  /* Numpad on desktop: natural top margin, no auto-push */
  .desktop-main .numpad-push {
    margin-top: 24px !important;
    padding-bottom: 20px;
  }
  /* Rounds table: fixed height so it fills the viewport */
  .desktop-main .rounds-wrap {
    height: calc(100dvh - 320px);
    min-height: 200px;
    flex: none !important;
    margin: 8px 24px;
  }
  .desktop-main .round-add-bar { margin: 8px 24px; }
  /* Icon sizing on desktop */
  .icon-btn svg { width: 16px; height: 16px; max-height: 100%; }
  /* Numpad and entry panel centered */
  .desktop-main .numpad { max-width: 400px; margin-left: auto; margin-right: auto; }
  .desktop-main .entry-panel { max-width: 580px; margin-left: auto; margin-right: auto; }
}

/* Status spacer */
.status-spacer { height: 14px; }
@media (min-width: 768px) {
  .status-spacer { height: 28px; }
}

/* Topbar */
.topbar {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 16px;
}
.topbar h1 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  text-align: center; margin: 0;
  display: flex; align-items: center; gap: 8px; justify-content: center;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
  color: var(--ink);
  transition: transform .12s ease, background .12s ease;
}
.icon-btn:active { transform: scale(0.94); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; max-height: 100%; }
.pill-btn {
  height: 40px; padding: 0 16px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  border: 0; font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; letter-spacing: -0.01em;
}
.pill-btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.pill-btn:active { transform: scale(0.97); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.card.flat { box-shadow: none; }
.list-card {
  margin: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.row .sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.row .chev { color: var(--ink-3); }

/* Section labels */
.section-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  padding: 18px 24px 8px;
}

/* Buttons */
.btn-primary {
  height: var(--tap); border-radius: 16px;
  background: var(--accent); color: white;
  border: 0; font: inherit; font-weight: 600; font-size: 16px;
  cursor: pointer; letter-spacing: -0.01em;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 1px 0 oklch(1 0 0 / 0.3) inset, 0 4px 16px -4px oklch(0.62 0.16 145 / 0.4);
}
.btn-primary:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.fab {
  width: 56px; height: 56px; border-radius: 999px;
  background: var(--accent); color: white;
  border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px -8px oklch(0.62 0.16 145 / 0.5);
}

/* Tabs (segmented) */
.segmented {
  display: flex; gap: 4px;
  background: var(--surface-2);
  padding: 4px; border-radius: 14px;
  border: 1px solid var(--line);
}
.segmented button {
  flex: 1; height: 38px; border: 0; background: transparent;
  font: inherit; font-weight: 600; font-size: 14px; color: var(--ink-2);
  border-radius: 10px; cursor: pointer;
  letter-spacing: -0.01em;
}
.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.05), 0 1px 0 oklch(1 0 0 / 0.6) inset;
}

/* Game card hero */
.game-card {
  margin: 6px 16px 12px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.game-card .name { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.game-card .players { font-size: 14px; color: var(--ink-2); margin-top: 4px; }
.game-card .meta { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 12px; color: var(--ink-3); }
.game-card .badge {
  padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink);
  font-weight: 600; font-size: 11px; letter-spacing: 0.02em;
}
.game-card .right-stack { text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.game-card .leader-tag {
  font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em;
}
.game-card .leader-name { font-size: 16px; font-weight: 600; }

/* New game tile */
.new-tile {
  margin: 14px 16px 8px;
  padding: 18px;
  display: flex; align-items: center; gap: 14px;
  background: oklch(0.99 0.01 145);
  border: 1.5px dashed oklch(0.78 0.06 145);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--accent-ink);
  font-weight: 600;
}
.new-tile .plus {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 600;
}
.new-tile .plus svg { width: 22px; height: 22px; }

/* Player score row (quick mode) */
.score-row {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 18px;
  cursor: pointer;
  background: transparent;
  transition: background .12s ease;
}
.score-row.active {
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.score-row .marker {
  width: 4px; align-self: stretch; border-radius: 4px;
  background: transparent;
}
.score-row.active .marker { background: var(--accent); }
.score-row .name { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 6px; }
.score-row .turns { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.score-row .total {
  font-size: 36px; font-weight: 600; letter-spacing: -0.04em;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.score-row.active .total { color: var(--accent-ink); }
.score-row .crown { color: var(--crown); }

/* Quick-entry panel */
.entry-panel {
  margin: 10px 16px 8px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: grid;
  grid-template-columns: 70px 1fr 70px;
  gap: 12px;
  align-items: center;
}
.entry-panel .display {
  background: var(--surface-2);
  border-radius: 18px;
  height: 88px;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; font-weight: 600; letter-spacing: -0.04em;
  color: var(--ink);
  position: relative;
  font-variant-numeric: tabular-nums;
}
.entry-panel .display .caret {
  width: 2px; height: 44px; background: var(--accent);
  margin-left: 4px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.entry-panel .small-label {
  font-size: 11px; color: var(--ink-3); margin-top: 6px;
  text-align: center; text-transform: uppercase; letter-spacing: 0.08em;
}
.entry-panel .side-btn {
  width: 60px; height: 60px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  border: 0; cursor: pointer; color: white;
  font-weight: 600;
  margin: 0 auto;
}
.entry-panel .side-btn.minus { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.entry-panel .side-btn.add {
  background: var(--accent);
  box-shadow: 0 4px 16px -4px oklch(0.62 0.16 145 / 0.5);
}
.entry-panel .side-btn:active { transform: scale(0.94); }

/* Numpad */
.numpad {
  margin: 12px 12px 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.numpad button {
  height: 64px; border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 26px; font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -0.02em;
  transition: transform .08s ease;
}
.numpad button:active { transform: scale(0.96); background: var(--surface-2); }
.numpad button.action { background: var(--accent); color: white; border-color: transparent; }
.numpad button.action svg { width: 28px; height: 28px; max-width: 100%; max-height: 100%; }
.numpad button.del { background: var(--surface-2); color: var(--ink-2); }
.numpad button.del svg { width: 28px; height: 28px; max-width: 100%; max-height: 100%; }
.numpad .quick-strip {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); gap: 6px;
  margin-bottom: 4px;
}
.numpad .quick-strip button {
  height: 40px; font-size: 13px; font-weight: 600;
  background: var(--surface-2);
  border-radius: 12px;
  font-family: 'Geist', sans-serif;
  padding: 0 8px;
}

/* Rounds table */
.rounds-wrap {
  margin: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.rounds-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.rounds-table th, .rounds-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  font-size: 18px;
  font-weight: 500;
}
.rounds-table thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 12px 6px 10px;
  letter-spacing: -0.01em;
}
.rounds-table thead th .player-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.rounds-table .col-rd { width: 44px; color: var(--ink-3); font-size: 13px; font-weight: 600; }
.rounds-table .col-del { width: 36px; }
.rounds-table tr:last-child td { border-bottom: none; }
.rounds-table .total-row td { background: var(--surface-2); font-weight: 700; font-size: 20px; padding: 14px 8px; }
.rounds-table .total-row td.col-rd { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.rounds-table input {
  width: 100%; min-width: 0;
  height: 40px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: center;
  font: inherit;
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  color: var(--ink);
  outline: none;
}
.rounds-table td.editing input {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 0 0 2px var(--accent) inset;
}
.rounds-table td.zero { color: var(--ink-3); }
.rounds-table .winner { color: var(--accent-ink); font-weight: 700; background: oklch(0.97 0.04 145 / 0.5); }

/* Round delete button */
.round-del-btn {
  width: 32px; height: 32px; border-radius: 999px;
  background: transparent; color: var(--ink-3);
  border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.round-del-btn:hover { background: var(--warn-soft); color: var(--warn); }
.round-del-btn:active { transform: scale(0.9); }
.round-del-btn svg { width: 12px; height: 12px; max-height: 100%; }
@media (min-width: 768px) {
  .round-del-btn {
    width: 36px; height: 36px;
  }
  .round-del-btn svg { width: 14px; height: 14px; max-height: 100%; }
}

/* History */
.history-row {
  display: grid;
  grid-template-columns: 36px 1fr auto 36px;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.history-row .idx {
  font-family: 'Geist Mono', monospace;
  color: var(--ink-3);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.history-row .player { font-weight: 600; font-size: 16px; }
.history-row .when { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.history-row .pts {
  font-size: 22px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.history-row .trash {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--warn-soft); color: var(--warn);
  border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.history-row.removed { opacity: 0.4; }
.history-row.removed .pts { text-decoration: line-through; }

/* Settings */
.settings-list .row { padding: 16px; }
.player-input {
  flex: 1; min-width: 0;
  border: 0; background: transparent; outline: none;
  font: inherit; font-size: 16px; font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.delete-btn {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--warn); color: white;
  border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .delete-btn {
    width: 36px; height: 36px;
    font-size: 18px;
  }
}
.add-player-row { color: var(--accent-ink); }
.add-player-row .plus { background: var(--accent); color: white; }

/* Delete game button */
.delete-game-btn {
  margin: 8px 16px 0;
  height: var(--tap);
  border-radius: 16px;
  width: calc(100% - 32px);
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid oklch(0.85 0.08 30);
  font: inherit; font-weight: 600; font-size: 15px;
  cursor: pointer; letter-spacing: -0.01em;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.delete-game-btn:active { transform: scale(0.98); }

/* Confirm overlay */
.confirm-overlay {
  position: fixed; inset: 0;
  background: oklch(0 0 0 / 0.4);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.confirm-sheet {
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  padding: 24px 20px 32px;
  width: 100%; max-width: 430px;
  box-shadow: 0 -8px 40px -8px oklch(0 0 0 / 0.2);
}
.confirm-sheet h2 {
  font-size: 20px; font-weight: 700; margin: 0 0 8px;
}
.confirm-sheet p {
  font-size: 14px; color: var(--ink-2); margin: 0 0 24px;
}
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions button { flex: 1; height: 50px; border-radius: 14px; font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; border: 0; }
.confirm-cancel { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line) !important; }
.confirm-delete { background: var(--warn); color: white; }

/* App tab bar */
.tabbar {
  position: sticky; bottom: 0;
  margin: 0; padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  display: flex; gap: 8px;
}
.tabbar .pill-btn { flex: 1; }

/* Win badge */
.win-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: oklch(0.94 0.1 85);
  color: oklch(0.45 0.18 85);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Icon picker row */
.icon-picker {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(48px, 1fr)); gap: 8px;
  padding: 12px 16px;
}
.icon-picker button {
  aspect-ratio: 1; border-radius: 12px;
  font-size: 22px; border: 2px solid transparent;
  background: var(--surface-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-picker button.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Misc */
.crown-badge {
  display: inline-flex; align-items: center;
  width: 18px; height: 18px;
  color: var(--crown);
}
.crown-badge svg { width: 18px; height: 18px; }
.dot { width: 6px; height: 6px; border-radius: 999px; display: inline-block; }
.spacer { height: 12px; }
.spacer-lg { height: 24px; }

/* Round-input quick-add bar */
.round-add-bar {
  margin: 8px 12px;
  display: flex; gap: 8px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.round-add-bar button {
  flex: 1; height: 42px; border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; color: var(--ink-2);
}
.round-add-bar button.go { background: var(--accent); color: white; border-color: transparent; }
.round-add-bar button.go svg { width: 20px; height: 20px; }

/* Focus ring */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 92px;
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 12px 32px -8px oklch(0 0 0 / 0.3);
  pointer-events: none; opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Scrollable area for screens with overflow */
.scroll-area {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* New game form */
.new-player-inline {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px 8px 16px;
  border-top: 1px solid var(--line);
}
.new-player-inline input {
  flex: 1; height: 40px; border: 1px solid var(--line);
  border-radius: 10px; padding: 0 12px;
  font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface-2); outline: none;
}
.new-player-inline input:focus { border-color: var(--accent); }
.new-player-inline button {
  height: 40px; width: 40px; border-radius: 10px;
  background: var(--accent); color: white; border: 0;
  font: inherit; font-weight: 600; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .new-player-inline button {
    width: 44px;
    font-size: 18px;
  }
}
