@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --primary: #E0F7FA;
  --primary-dark: #B2EBF2;
  --primary-light: #80DEEA;
  --primary-glow: rgba(79, 70, 229, 0.15);
  --secondary: #4DD0E1;
  --secondary-light: #00838F;
  --accent: #F59E0B;
  --accent-light: #FCD34D;
  --success: #10B981;
  --danger: #EF4444;
  --danger-light: #FCA5A5;
  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-input: #F1F5F9;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --border: #E2E8F0;
  --border-focus: #4F46E5;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.2);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

::selection {
  background: var(--primary-light);
  color: white;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Loading Screen */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 1rem;
}

.loading-dice {
  font-size: 3rem;
  animation: diceSpin 1.5s ease-in-out infinite;
}

@keyframes diceSpin {
  0%, 100% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.2); }
}

.loading-screen p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* App Layout */
.app {
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 2rem;
}

.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.header-icon {
  font-size: 1.5rem;
}

.header-brand h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tab-nav {
  display: flex;
  gap: 0.25rem;
}

.tab-btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  position: relative;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-icon {
  font-size: 1rem;
}

.tab-badge {
  font-size: 0.6rem;
  font-weight: 700;
  background: var(--success);
  color: white;
  padding: 0.1rem 0.35rem;
  border-radius: 99px;
  letter-spacing: 0.05em;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.app-main {
  padding: 1.5rem;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease-out both;
}

@keyframes cardEntrance {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-anim {
  animation: cardEntrance 0.35s ease-out both;
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.empty-state h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* Buttons */
.btn-primary {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.7rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 1.2rem;
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--primary-light);
  color: white;
}

.btn-ghost {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: var(--radius-sm);
}

.btn-ghost:hover {
  background: var(--bg-input);
  color: var(--text);
}

.btn-danger {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-danger-text {
  color: var(--danger);
}

.btn-danger-text:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  font-size: 0.9rem;
}

.btn-icon:hover {
  background: var(--bg-input);
}

.btn-remove:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.btn-start {
  font-size: 1rem;
  padding: 0.85rem 2rem;
}

/* Input Fields */
.input-field {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.65rem 0.9rem;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  width: 100%;
  transition: all 0.2s ease;
  outline: none;
}

.input-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-card);
}

.input-field::placeholder {
  color: var(--text-light);
}

.input-group {
  margin-bottom: 1.25rem;
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.mt-sm {
  margin-top: 0.5rem;
}

/* Setup */
.setup-container {
  max-width: 560px;
  margin: 0 auto;
}

.setup-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.step-num {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--bg-input);
  color: var(--text-light);
  transition: all 0.3s ease;
}

.progress-step.active .step-num {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-glow);
}

.step-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-light);
}

.progress-step.active .step-label {
  color: var(--primary);
}

.progress-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin-bottom: 1rem;
}

.setup-step {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.step-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

/* Presets */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.preset-card {
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.85rem 0.5rem;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.preset-card.selected {
  border-color: var(--primary);
  background: var(--primary-glow);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.preset-icon {
  font-size: 1.6rem;
}

.preset-name {
  font-size: 0.8rem;
  font-weight: 600;
}

.preset-desc {
  font-size: 0.65rem;
  color: var(--text-light);
  text-align: center;
  line-height: 1.2;
}

/* Players */
.players-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.player-input-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.player-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-input-row .input-field {
  flex: 1;
}

.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  gap: 0.5rem;
}

/* Rules */
.rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.rule-card {
  background: var(--bg-input);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.rule-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.toggle-group {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 0.2rem;
  border: 1px solid var(--border);
}

.toggle-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  flex: 1;
  padding: 0.4rem;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.toggle-btn.active {
  background: var(--primary);
  color: white;
}

/* Scoreboard */
.scoreboard {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.game-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.game-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
}

.round-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-glow);
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  margin-top: 0.25rem;
}

.target-badge {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  background: rgba(245, 158, 11, 0.1);
  padding: 0.3rem 0.7rem;
  border-radius: 99px;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Winner Banner */
.winner-banner {
  text-align: center;
  background: linear-gradient(135deg, var(--accent), #D97706);
  color: white;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
  animation: fadeIn 0.5s ease-out;
}

.winner-trophy {
  font-size: 2.5rem;
  margin-bottom: 0.25rem;
  animation: bounce 0.8s ease infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.winner-banner h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
}

.winner-banner p {
  font-size: 0.95rem;
  opacity: 0.9;
}

/* Standings */
.standings-row {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.standing-card {
  flex: 1;
  min-width: 110px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.standing-card.leader {
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.15);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.04), var(--bg-card));
}

.standing-rank {
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.standing-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0 auto 0.3rem;
}

.standing-name {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.standing-score {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.2rem 0;
}

.leader .standing-score {
  color: var(--accent);
}

.progress-bar-mini {
  height: 3px;
  background: var(--bg-input);
  border-radius: 99px;
  overflow: hidden;
  margin: 0.3rem 0;
}

.progress-fill-mini {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease;
}

.last-round-score {
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 500;
}

/* Score Entry */
.score-entry {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
}

.entry-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.score-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.score-input-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.player-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-label {
  font-size: 0.85rem;
  font-weight: 500;
  min-width: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-input {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  width: 90px;
  text-align: center;
  padding: 0.5rem;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: all 0.2s;
}

.score-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-card);
}

.multiplier-select {
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.45rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.multiplier-select:focus {
  border-color: var(--primary);
}

.entry-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Round History */
.round-history {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.history-header h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
}

.history-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 0.5rem 0.6rem;
  border-bottom: 2px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

.history-table td {
  padding: 0.5rem 0.6rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.round-num {
  color: var(--text-light);
  font-size: 0.8rem;
}

.th-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.positive {
  color: var(--success);
}

.negative {
  color: var(--danger);
}

.mult-tag {
  font-size: 0.65rem;
  color: var(--primary-light);
  margin-left: 0.2rem;
}

.totals-row td {
  font-weight: 700;
  border-bottom: none;
  border-top: 2px solid var(--border);
  padding-top: 0.65rem;
}

.total-cell {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--primary);
}

.editing-row {
  background: var(--primary-glow);
}

.btn-edit {
  font-size: 0.75rem;
}

.compact {
  font-size: 0.8rem;
}

.compact th {
  font-size: 0.7rem;
}

.compact td {
  padding: 0.35rem 0.5rem;
}

/* Game Actions */
.game-actions {
  display: flex;
  justify-content: center;
  padding-top: 0.5rem;
}

.confirm-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.confirm-inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* History */
.history-container {
  max-width: 700px;
  margin: 0 auto;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.history-card:hover {
  box-shadow: var(--shadow-md);
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: background 0.2s;
  gap: 0.5rem;
}

.history-card-header:hover {
  background: var(--bg-input);
}

.hc-left {
  flex: 1;
  min-width: 0;
}

.hc-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hc-date {
  display: block;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.1rem;
}

.hc-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hc-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.hc-winner {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.hc-trophy {
  font-size: 1rem;
}

.hc-winner-name {
  font-weight: 600;
  font-size: 0.85rem;
}

.hc-winner-score {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
}

.expand-arrow {
  font-size: 0.85rem;
  color: var(--text-light);
  transition: transform 0.2s ease;
}

.expand-arrow.open {
  transform: rotate(180deg);
}

.history-card-body {
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}

.final-standings {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.final-standings h4,
.history-rounds-table h4 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.6rem;
}

.final-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.final-row.gold {
  background: rgba(245, 158, 11, 0.08);
}

.final-rank {
  font-size: 0.85rem;
  min-width: 24px;
}

.final-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.final-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.9rem;
}

.final-score {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
}

.history-rounds-table {
  margin-top: 1rem;
}

.history-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 640px) {
  .app-main {
    padding: 1rem;
  }

  .preset-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .rules-grid {
    grid-template-columns: 1fr;
  }

  .standings-row {
    gap: 0.45rem;
  }

  .standing-card {
    min-width: 90px;
    padding: 0.65rem;
  }

  .standing-score {
    font-size: 1.2rem;
  }

  .player-label {
    min-width: 60px;
    font-size: 0.8rem;
  }

  .score-input {
    width: 70px;
  }

  .tab-btn {
    padding: 0.5rem 0.6rem;
    font-size: 0.8rem;
  }

  .tab-icon {
    display: none;
  }

  .history-card-actions {
    flex-direction: column;
  }

  .hc-winner-name {
    display: none;
  }
}

@media (max-width: 380px) {
  .preset-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }

  .preset-desc {
    display: none;
  }

  .standings-row {
    flex-wrap: wrap;
  }

  .standing-card {
    min-width: calc(50% - 0.3rem);
    flex: none;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

button:focus:not(:focus-visible) {
  outline: none;
}
```

<!-- WALKTHROUGH_SCRIPT:
[
  {"step": 1, "narration": "Welcome to ScoreKeep! This is your universal board game score tracker. Let's set up your first game.", "view": "user", "highlight_selector": ".tab-btn:first-child", "wait_for": "tap_to_continue"},
  {"step": 2, "narration": "Start by choosing a game preset or create a custom game. Pick one that matches your board game.", "view": "user", "highlight_selector": ".preset-grid", "wait_for": "user_interaction"},
  {"step": 3, "narration": "Give your game session a name — like 'Friday Night Catan' — and click Next.", "view": "user", "highlight_selector": ".input-group", "wait_for": "user_interaction"},
  {"step": 4, "narration": "Add all players. Each gets a unique color. You need at least 2 players to start.", "view": "user", "highlight_selector": ".players-list", "wait_for": "user_interaction"},
  {"step": 5, "narration": "Configure scoring rules: free entry or fixed points per round, optional multipliers, and win conditions.", "view": "user", "highlight_selector": ".rules-grid", "wait_for": "user_interaction"},
  {"step": 6, "narration": "Hit Start Game! You'll see player standings with the leader highlighted in gold.", "view": "user", "highlight_selector": ".btn-start", "wait_for": "user_interaction"},
  {"step": 7, "narration": "Each round, enter scores for all players and hit Submit. Scores update in real-time with running totals.", "view": "user", "highlight_selector": ".score-entry", "wait_for": "user_interaction"},
  {"step": 8, "narration": "The standings cards show who's winning. You can undo rounds or edit past scores if there's a mistake.", "view": "user", "highlight_selector": ".standings-row", "wait_for": "tap_to_continue"},
  {"step": 9, "narration": "When the game ends — by target score, max rounds, or manually — see the final winner celebration!", "view": "user", "highlight_selector": ".game-actions", "wait_for": "tap_to_continue"},
  {"step": 10, "narration": "Check the History tab to review past games, see detailed score breakdowns, or replay with the same players.", "view": "user", "highlight_selector": ".tab-btn:last-child", "wait_for": "tap_to_continue"}
]
-->

.history-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.history-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.history-stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.history-stat-value {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--text);
}

.history-error-banner {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.18);
  color: var(--danger);
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .history-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.turn-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.45rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
}

.turn-timer.urgent,
.turn-timer-panel.urgent {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.turn-timer-label,
.turn-timer-panel-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: inherit;
  opacity: 0.8;
}

.turn-timer-count {
  font-family: var(--font-display);
}

.turn-timer-panel {
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.06), rgba(79, 70, 229, 0.02));
  border: 1px solid rgba(79, 70, 229, 0.18);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  margin-bottom: 1rem;
}

.turn-timer-panel-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.turn-timer-panel-player {
  font-family: var(--font-display);
  font-weight: 700;
}

.turn-timer-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
}

.turn-timer-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 1s linear;
}

.turn-timer-panel.urgent .turn-timer-fill {
  background: linear-gradient(90deg, var(--danger), #F59E0B);
}

.turn-timer-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .turn-timer-meta {
    flex-direction: column;
    gap: 0.2rem;
  }

  .turn-timer-panel-top {
    flex-direction: column;
    align-items: flex-start;
  }
}

.results-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.results-chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.results-chart-header {
  margin-bottom: 0.75rem;
}

.results-chart-header h3 {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.results-chart-header p {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.03), transparent);
  border: 1px solid rgba(226, 232, 240, 0.7);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.chart-canvas-tall {
  height: 240px;
}

.chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-empty-state {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.chart-legend-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chart-legend-name {
  font-weight: 600;
  color: var(--text);
}

.chart-legend-meta {
  margin-left: auto;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .results-charts {
    grid-template-columns: 1fr;
  }

  .chart-canvas-tall {
    height: 220px;
  }
}

.play-reactions-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.play-reactions-header {
  margin-bottom: 0.75rem;
}

.play-reactions-header h3 {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.play-reactions-header p {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.play-reaction-feed {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.play-reaction-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.03), transparent);
}

.play-reaction-card-header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.82rem;
  margin-bottom: 0.55rem;
}

.play-reaction-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.play-reaction-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.play-reaction-emoji {
  font-size: 1rem;
}

.play-reaction-user {
  font-weight: 600;
  color: var(--text);
}

.play-reaction-time {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-light);
}

.play-reaction-composer {
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}

.play-reaction-target {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.play-reaction-target-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.play-reaction-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.reaction-btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-input);
  cursor: pointer;
  transition: all 0.2s ease;
}

.reaction-btn:hover {
  background: var(--primary-glow);
  border-color: var(--primary-light);
  transform: translateY(-1px);
}

.round-cell-main {
  font-weight: 700;
}

.round-reaction-count {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 0.15rem;
}

@media (max-width: 640px) {
  .play-reaction-card-header,
  .play-reaction-item {
    flex-wrap: wrap;
  }

  .play-reaction-time {
    margin-left: 0;
    width: 100%;
  }
}

.share-results-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.share-results-header {
  margin-bottom: 0.75rem;
}

.share-results-header h3 {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.share-results-header p {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.share-results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.share-results-preview {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}

.share-results-preview-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.share-results-preview-value {
  font-size: 0.85rem;
  color: var(--text);
  word-break: break-all;
}

.share-results-preview-text {
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text);
  background: transparent;
}

.share-results-message {
  margin-top: 0.65rem;
  font-size: 0.82rem;
  color: var(--success);
}

.share-actions-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.share-btn {
  font-family: var(--font-body);
  font-size: 0.78rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-input);
  cursor: pointer;
}

.share-btn:hover {
  background: var(--primary-glow);
  border-color: var(--primary-light);
}

.handicap-card {
  background: var(--bg-input);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-top: 1rem;
}

.handicap-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.handicap-helper {
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.handicap-suggestion {
  margin-top: 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
}

.handicap-suggestion p {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
}

.handicap-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.selected-handicap {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.selected-handicap:hover {
  background: #059669;
}

@media (max-width: 640px) {
  .handicap-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .handicap-actions {
    justify-content: stretch;
  }

  .handicap-actions .btn-secondary {
    width: 100%;
  }
}
