:root {
  --bg-dark: #0c0c0e;
  --bg-card: #161618;
  --bg-card-hover: #1c1c1f;
  --border: #27272a;
  --border-subtle: #1f1f23;
  --text: #fafafa;
  --text-muted: #71717a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-muted: rgba(59, 130, 246, 0.15);
  --success: #22c55e;
  --danger: #dc2626;
  --danger-muted: rgba(220, 38, 38, 0.15);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: contain;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-subtle);
}

.logo {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  letter-spacing: -0.02em;
}

.logo-icon {
  font-size: 1.75rem;
  color: var(--accent);
  opacity: 0.9;
}

.tagline {
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  font-size: 0.9375rem;
  font-weight: 400;
}

/* Timer section */
.timer-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.timer-icon-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.9;
  transition: opacity 0.2s;
}

.timer-icon-btn:hover {
  opacity: 1;
}

.timer-display {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  background: linear-gradient(180deg, #0d1117 0%, #161b22 50%, #0d1117 100%);
  border: 3px solid #30363d;
  border-radius: 6px;
  padding: 0.6rem 1.2rem;
  color: #3fb950;
  text-shadow: 0 0 12px rgba(63, 185, 80, 0.4);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.05);
  min-width: 9em;
  text-align: center;
  display: inline-block;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
}

.timer-display:hover {
  border-color: #484f58;
}

.timer-alarm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
}

.timer-alarm-overlay.hidden {
  display: none;
}

.timer-alarm-dismiss {
  padding: 1.5rem 2rem;
  font-size: 1.25rem;
  font-weight: 600;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  animation: timer-alarm-pulse 1s ease-in-out infinite;
}

@keyframes timer-alarm-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.timer-controls {
  display: flex;
  gap: 0.5rem;
}

.btn-timer {
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-timer:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

/* Timer modal */
.timer-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.timer-modal.hidden {
  display: none;
}

.timer-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.timer-modal-content {
  position: relative;
  max-width: 320px;
  width: 100%;
}

.timer-modal-title {
  margin: 0 0 1rem;
  font-size: 1.125rem;
}

.timer-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timer-inputs {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.timer-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.timer-input-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.timer-input-group input {
  width: 4rem;
  font-size: 1.25rem;
  text-align: center;
}

/* Tile cards */
.tile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tile-card:hover {
  border-color: var(--border);
}

/* Add User section (collapsible) */
.add-user-section {
  margin-bottom: 1rem;
}

.add-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: color 0.2s;
}

.add-section-toggle:hover {
  color: var(--accent);
}

.add-section-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.add-user-section:not(.add-section-collapsed) .add-section-chevron {
  transform: rotate(180deg);
}

.add-user-wrap {
  overflow: hidden;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.add-user-section.add-section-collapsed .add-user-wrap {
  display: none;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.input-with-btn {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.input-with-btn input {
  width: 160px;
}

/* Rounds section */
.rounds-section {
  margin-bottom: 1.5rem;
}

.rounds-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.5rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.rounds-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rounds-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 1.25rem;
  min-width: 2rem;
  text-align: center;
}

/* Buttons */
.btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-round {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  background: var(--bg-dark);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-round:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-round:active {
  transform: scale(0.95);
}

.btn-round:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-round:disabled:hover {
  background: var(--bg-dark);
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-danger {
  background: var(--danger-muted);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.4);
}

.btn-danger:hover {
  background: rgba(220, 38, 38, 0.25);
}

/* Inputs */
input[type="text"],
input[type="number"] {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.2s;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* Score section */
.score-section {
  margin-bottom: 2rem;
}

#score-content.hidden {
  display: none;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.75rem;
}

#leaderboard-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

#rounds-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.leader-card.tile-card,
.rounds-card.tile-card {
  padding: 1rem;
  overflow: visible;
}

.rounds-card.tile-card {
  padding-left: 0.125rem;
  padding-right: 0.125rem;
}

.leader-card,
.rounds-card {
  position: relative;
  min-width: 0;
}

.rounds-card-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.75rem;
  text-align: center;
}

.card-header {
  text-align: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  overflow: visible;
}

.leader-card .card-header {
  border-bottom: none;
}

.user-total {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
  margin: 0 0 0.15rem;
}

.user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

/* Rank highlight wrapper */
.rank-highlight {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
}


.rank-highlight::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.rank-highlight .user-total,
.rank-highlight .user-name {
  position: relative;
  z-index: 1;
}

/* 1st place: gold fireworks */
.card-gold .user-total,
.card-gold .user-name {
  color: #ffd700;
}

.rank-gold::before {
  animation: fireworks-gold 2.5s ease-in-out infinite;
}

@keyframes fireworks-gold {
  0%, 100% {
    box-shadow:
      0 -14px 4px 0 rgba(255, 215, 0, 0.9),
      10px -10px 4px 0 rgba(255, 215, 0, 0.9),
      14px 0 4px 0 rgba(255, 215, 0, 0.9),
      10px 10px 4px 0 rgba(255, 215, 0, 0.9),
      0 14px 4px 0 rgba(255, 215, 0, 0.9),
      -10px 10px 4px 0 rgba(255, 215, 0, 0.9),
      -14px 0 4px 0 rgba(255, 215, 0, 0.9),
      -10px -10px 4px 0 rgba(255, 215, 0, 0.9),
      0 -24px 6px 0 rgba(255, 215, 0, 0.7),
      17px -17px 6px 0 rgba(255, 215, 0, 0.7),
      24px 0 6px 0 rgba(255, 215, 0, 0.7),
      17px 17px 6px 0 rgba(255, 215, 0, 0.7),
      0 24px 6px 0 rgba(255, 215, 0, 0.7),
      -17px 17px 6px 0 rgba(255, 215, 0, 0.7),
      -24px 0 6px 0 rgba(255, 215, 0, 0.7),
      -17px -17px 6px 0 rgba(255, 215, 0, 0.7);
    transform: scale(0.9);
    opacity: 0.95;
  }
  50% {
    box-shadow:
      0 -20px 6px 0 rgba(255, 215, 0, 0.95),
      14px -14px 6px 0 rgba(255, 215, 0, 0.95),
      20px 0 6px 0 rgba(255, 215, 0, 0.95),
      14px 14px 6px 0 rgba(255, 215, 0, 0.95),
      0 20px 6px 0 rgba(255, 215, 0, 0.95),
      -14px 14px 6px 0 rgba(255, 215, 0, 0.95),
      -20px 0 6px 0 rgba(255, 215, 0, 0.95),
      -14px -14px 6px 0 rgba(255, 215, 0, 0.95),
      0 -34px 8px 0 rgba(255, 215, 0, 0.8),
      24px -24px 8px 0 rgba(255, 215, 0, 0.8),
      34px 0 8px 0 rgba(255, 215, 0, 0.8),
      24px 24px 8px 0 rgba(255, 215, 0, 0.8),
      0 34px 8px 0 rgba(255, 215, 0, 0.8),
      -24px 24px 8px 0 rgba(255, 215, 0, 0.8),
      -34px 0 8px 0 rgba(255, 215, 0, 0.8),
      -24px -24px 8px 0 rgba(255, 215, 0, 0.8);
    transform: scale(1.1);
    opacity: 1;
  }
}

/* 2nd place: silver fireworks */
.card-silver .user-total,
.card-silver .user-name {
  color: #e8e8e8;
}

.rank-silver::before {
  animation: fireworks-silver 2.5s ease-in-out infinite;
  animation-delay: 0.4s;
}

@keyframes fireworks-silver {
  0%, 100% {
    box-shadow:
      0 -14px 4px 0 rgba(232, 232, 232, 0.9),
      10px -10px 4px 0 rgba(232, 232, 232, 0.9),
      14px 0 4px 0 rgba(232, 232, 232, 0.9),
      10px 10px 4px 0 rgba(232, 232, 232, 0.9),
      0 14px 4px 0 rgba(232, 232, 232, 0.9),
      -10px 10px 4px 0 rgba(232, 232, 232, 0.9),
      -14px 0 4px 0 rgba(232, 232, 232, 0.9),
      -10px -10px 4px 0 rgba(232, 232, 232, 0.9),
      0 -24px 6px 0 rgba(200, 200, 200, 0.7),
      17px -17px 6px 0 rgba(200, 200, 200, 0.7),
      24px 0 6px 0 rgba(200, 200, 200, 0.7),
      17px 17px 6px 0 rgba(200, 200, 200, 0.7),
      0 24px 6px 0 rgba(200, 200, 200, 0.7),
      -17px 17px 6px 0 rgba(200, 200, 200, 0.7),
      -24px 0 6px 0 rgba(200, 200, 200, 0.7),
      -17px -17px 6px 0 rgba(200, 200, 200, 0.7);
    transform: scale(0.9);
    opacity: 0.95;
  }
  50% {
    box-shadow:
      0 -20px 6px 0 rgba(232, 232, 232, 0.95),
      14px -14px 6px 0 rgba(232, 232, 232, 0.95),
      20px 0 6px 0 rgba(232, 232, 232, 0.95),
      14px 14px 6px 0 rgba(232, 232, 232, 0.95),
      0 20px 6px 0 rgba(232, 232, 232, 0.95),
      -14px 14px 6px 0 rgba(232, 232, 232, 0.95),
      -20px 0 6px 0 rgba(232, 232, 232, 0.95),
      -14px -14px 6px 0 rgba(232, 232, 232, 0.95),
      0 -34px 8px 0 rgba(200, 200, 200, 0.8),
      24px -24px 8px 0 rgba(200, 200, 200, 0.8),
      34px 0 8px 0 rgba(200, 200, 200, 0.8),
      24px 24px 8px 0 rgba(200, 200, 200, 0.8),
      0 34px 8px 0 rgba(200, 200, 200, 0.8),
      -24px 24px 8px 0 rgba(200, 200, 200, 0.8),
      -34px 0 8px 0 rgba(200, 200, 200, 0.8),
      -24px -24px 8px 0 rgba(200, 200, 200, 0.8);
    transform: scale(1.1);
    opacity: 1;
  }
}

/* 3rd place: bronze fireworks */
.card-bronze .user-total,
.card-bronze .user-name {
  color: #cd7f32;
}

.rank-bronze::before {
  animation: fireworks-bronze 2.5s ease-in-out infinite;
  animation-delay: 0.8s;
}

@keyframes fireworks-bronze {
  0%, 100% {
    box-shadow:
      0 -14px 4px 0 rgba(205, 127, 50, 0.9),
      10px -10px 4px 0 rgba(205, 127, 50, 0.9),
      14px 0 4px 0 rgba(205, 127, 50, 0.9),
      10px 10px 4px 0 rgba(205, 127, 50, 0.9),
      0 14px 4px 0 rgba(205, 127, 50, 0.9),
      -10px 10px 4px 0 rgba(205, 127, 50, 0.9),
      -14px 0 4px 0 rgba(205, 127, 50, 0.9),
      -10px -10px 4px 0 rgba(205, 127, 50, 0.9),
      0 -24px 6px 0 rgba(205, 127, 50, 0.7),
      17px -17px 6px 0 rgba(205, 127, 50, 0.7),
      24px 0 6px 0 rgba(205, 127, 50, 0.7),
      17px 17px 6px 0 rgba(205, 127, 50, 0.7),
      0 24px 6px 0 rgba(205, 127, 50, 0.7),
      -17px 17px 6px 0 rgba(205, 127, 50, 0.7),
      -24px 0 6px 0 rgba(205, 127, 50, 0.7),
      -17px -17px 6px 0 rgba(205, 127, 50, 0.7);
    transform: scale(0.9);
    opacity: 0.95;
  }
  50% {
    box-shadow:
      0 -20px 6px 0 rgba(205, 127, 50, 0.95),
      14px -14px 6px 0 rgba(205, 127, 50, 0.95),
      20px 0 6px 0 rgba(205, 127, 50, 0.95),
      14px 14px 6px 0 rgba(205, 127, 50, 0.95),
      0 20px 6px 0 rgba(205, 127, 50, 0.95),
      -14px 14px 6px 0 rgba(205, 127, 50, 0.95),
      -20px 0 6px 0 rgba(205, 127, 50, 0.95),
      -14px -14px 6px 0 rgba(205, 127, 50, 0.95),
      0 -34px 8px 0 rgba(205, 127, 50, 0.8),
      24px -24px 8px 0 rgba(205, 127, 50, 0.8),
      34px 0 8px 0 rgba(205, 127, 50, 0.8),
      24px 24px 8px 0 rgba(205, 127, 50, 0.8),
      0 34px 8px 0 rgba(205, 127, 50, 0.8),
      -24px 24px 8px 0 rgba(205, 127, 50, 0.8),
      -34px 0 8px 0 rgba(205, 127, 50, 0.8),
      -24px -24px 8px 0 rgba(205, 127, 50, 0.8);
    transform: scale(1.1);
    opacity: 1;
  }
}

.btn-remove-user {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 0.35rem;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s, color 0.2s;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove-user:hover {
  opacity: 1;
  color: var(--danger);
}

.card-rounds {
  padding-top: 0.75rem;
}

.round-row {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  margin-right: 0.15rem;
  margin-bottom: 0.5rem;
  white-space: nowrap;
}

.round-row .round-edit {
  flex-shrink: 0;
}

.round-label {
  font-size: 0.75rem;
  color: var(--text);
}

.round-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.35rem 0.3rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 1.75rem;
  min-height: 36px;
  text-align: center;
  transition: border-color 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.round-value:hover {
  border-color: var(--accent);
}

.round-value:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.round-edit {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.round-edit.hidden {
  display: none;
}

.round-value.hidden {
  display: none;
}

.round-input {
  width: 3rem;
  min-height: 36px;
  font-size: 16px;
  padding: 0.25rem 0.35rem;
  text-align: center;
}

.btn-round-submit {
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 1rem;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state.hidden {
  display: none;
}

/* Mobile-first: small phones (iPhone 13 mini ~375px) */
@media (max-width: 480px) {
  .app {
    padding: 1rem max(0.75rem, env(safe-area-inset-left)) max(1.5rem, env(safe-area-inset-bottom));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }

  .header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
  }

  .logo {
    font-size: 1.5rem;
  }

  .logo-icon {
    font-size: 1.35rem;
  }

  .tagline {
    font-size: 0.875rem;
  }

  .timer-section {
    margin-top: 0.5rem;
    gap: 0.4rem;
  }

  .timer-icon-btn {
    font-size: 1.25rem;
    padding: 0.2rem;
  }

  .timer-display {
    font-size: 1.35rem;
    min-width: 6.5em;
    padding: 0.3rem 0.5rem;
    letter-spacing: 0.05em;
    border-width: 2px;
  }

  .timer-controls {
    gap: 0.35rem;
  }

  .btn-timer {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }

  .timer-alarm-dismiss {
    padding: 1rem 1.5rem;
    font-size: 1rem;
  }

  .timer-modal-content {
    margin: 0.5rem;
  }

  .timer-inputs {
    gap: 0.75rem;
  }

  .timer-input-group input {
    width: 3rem;
    font-size: 1rem;
  }

  .tile-card {
    padding: 1rem;
  }

  .add-user-section .add-user-card.tile-card {
    padding: 0.5rem 1rem;
  }

  .add-section-toggle {
    min-height: 36px;
    font-size: 0.875rem;
  }

  .add-user-wrap {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
  }

  .add-user-wrap .input-with-btn {
    flex-direction: column;
  }

  .add-user-wrap .input-with-btn input {
    width: 100%;
    min-height: 48px;
    font-size: 16px;
  }

  .add-user-wrap .btn-primary {
    width: 100%;
    min-height: 48px;
  }

  .rounds-section .rounds-card.tile-card {
    padding: 0.5rem 0.125rem;
  }

  .rounds-row {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 0.75rem;
  }

  .rounds-section .btn-danger {
    min-height: 36px;
    width: auto;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
  }

  .rounds-section .control-group label {
    font-size: 0.75rem;
  }

  .input-with-btn {
    flex-direction: column;
    gap: 0.5rem;
  }

  .input-with-btn input {
    width: 100%;
    min-height: 48px;
    font-size: 16px; /* prevents iOS zoom on focus */
    padding: 0.75rem 1rem;
  }

  .btn-primary {
    min-height: 48px;
    width: 100%;
    font-size: 1rem;
  }

  .rounds-section .rounds-control {
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .rounds-section .rounds-value {
    font-size: 1.125rem;
    min-width: 2rem;
  }

  .rounds-section .btn-round {
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
  }

  .btn-danger {
    min-height: 48px;
    width: 100%;
  }

  .score-section {
    margin-bottom: 1rem;
  }

  #leaderboard-wrap {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
  }

  #rounds-wrap {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
  }

  .leader-card.tile-card {
    padding: 0.5rem;
  }

  .rounds-card.tile-card {
    padding: 0.75rem 0.125rem;
  }

  .leader-card .user-total {
    font-size: 1.5rem;
  }

  .leader-card .user-name {
    font-size: 0.6875rem;
  }

  .card-rounds {
    padding-top: 0.5rem;
  }

  .round-row {
    margin-right: 0.1rem;
    margin-bottom: 0.4rem;
  }

  .round-value {
    min-height: 40px;
    min-width: 2rem;
    font-size: 0.875rem;
  }

  .round-label {
    font-size: 0.6875rem;
  }

  .round-input {
    width: 2.5rem;
    min-height: 36px;
  }

  .btn-round-submit {
    min-width: 32px;
    min-height: 32px;
  }

  .btn-remove-user {
    min-width: 32px;
    min-height: 32px;
    top: 0.35rem;
    right: 0.35rem;
  }

  .empty-state {
    padding: 2rem 1rem;
  }
}

/* Medium breakpoint */
@media (max-width: 640px) and (min-width: 481px) {
  .app {
    padding: 1.25rem max(1rem, env(safe-area-inset-left));
  }

  .rounds-row {
    flex-direction: column;
    align-items: stretch;
  }

  .add-user-wrap .input-with-btn input {
    flex: 1;
    min-width: 0;
  }
}
