/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1117; --surface: #1a1d27; --surface2: #252830;
  --border: #2e3140; --text: #e4e6ef; --text-dim: #8b8fa3;
  --primary: #4f8cff; --primary-hover: #3a75e6;
  --danger: #e74c5e; --success: #2ecc71;
  --radius: 10px; --radius-sm: 6px;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ===== Navbar ===== */
.navbar { display: flex; align-items: center; padding: 0.75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.nav-brand { font-weight: 700; font-size: 1.2rem; color: var(--text); margin-right: auto; }
.nav-links a { margin-left: 1.5rem; color: var(--text-dim); font-size: 0.95rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }

/* ===== Container ===== */
.container { max-width: 700px; margin: 0 auto; padding: 1rem; }

/* ===== Buttons ===== */
.btn { display: inline-block; padding: 0.5rem 1.2rem; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.95rem; color: var(--text); background: var(--surface2); transition: background 0.15s; text-align: center; }
.btn:hover { background: var(--border); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: default; }
.btn-secondary { background: var(--surface2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-large { padding: 0.75rem 2rem; font-size: 1.1rem; margin-top: 1rem; }
.btn-sm { padding: 0.25rem 0.7rem; font-size: 0.85rem; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 99px; font-size: 0.8rem; font-weight: 600; }
.badge-finished { background: var(--success); color: #fff; }
.badge-active { background: var(--primary); color: #fff; }

/* ===== Forms ===== */
.form-narrow { max-width: 400px; }
.form-group { margin-bottom: 1rem; }
label { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; color: var(--text-dim); }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; padding: 0.55rem 0.75rem; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 0.95rem;
}
input:focus, select:focus { outline: none; border-color: var(--primary); }
.error { color: var(--danger); font-size: 0.9rem; margin-top: 0.25rem; }

/* ===== Lobby ===== */

/* Centered wrapper — single column, same width on all viewports */
.lobby-wrapper {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- Shared card frame for all lobby controls ---- */
.lobby-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, color 0.15s;
}
.lobby-card:hover {
  border-color: var(--primary);
}

/* Selectable toggle cards (guest toggle, double finish) */
.lobby-card-toggle {
  color: var(--text-dim);
}
.lobby-card-toggle:hover {
  color: var(--text);
}
.lobby-card-toggle.active {
  border-color: var(--primary);
  background: rgba(79,140,255,0.08);
  box-shadow: 0 0 12px rgba(79,140,255,0.2);
  color: var(--text);
}

/* ---- Player grid — 3 columns ---- */
.player-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  width: 100%;
  margin-bottom: 0.75rem;
}
.player-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.1s;
  position: relative;
}
.player-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}
.player-card.selected {
  border-color: var(--primary);
  background: rgba(79,140,255,0.08);
  box-shadow: 0 0 12px rgba(79,140,255,0.2);
}
.player-photo img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
}
.photo-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-dim);
  margin: 0 auto;
}
.photo-placeholder.small { width: 40px; height: 40px; font-size: 1rem; }
.photo-placeholder.tiny  { width: 32px; height: 32px; font-size: 0.85rem; }
.player-name { font-weight: 600; margin-top: 0.4rem; font-size: 0.9rem; }
.player-rating { color: var(--text-dim); font-size: 0.8rem; }
.player-stats-link { font-size: 0.75rem; }

/* Guest toggle — full width below the grid */
#guest-toggle {
  width: 100%;
  display: block;
}

/* ---- Settings row — 3 equal columns matching player grid ---- */
.lobby-settings-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  width: 100%;
  margin-bottom: 0.75rem;
}

/* Select dropdown styled as a card */
select.lobby-select {
  width: 100%;
  appearance: auto;
  -webkit-appearance: auto;
}
select.lobby-select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 12px rgba(79,140,255,0.2);
}

/* Remove margin from toggle cards inside settings row */
.lobby-settings-row .lobby-card-toggle {
  margin-bottom: 0;
}

/* Start button — primary action card */
.lobby-card-start {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}
.lobby-card-start:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.lobby-card-start:disabled {
  opacity: 0.4;
  cursor: default;
}
.lobby-card-start:disabled:hover {
  background: var(--primary);
  border-color: var(--primary);
}

/* ===== Match ===== */
.match-container { max-width: none; transition: opacity 0.4s ease; }
.match-header { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 1rem; }
/* Players bar: max 3 cards, always centered */
.players-bar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
}
/* Wide spacing only when exactly 2 player cards */
.players-bar:has(.match-player:nth-child(2):last-child) {
  gap: 6rem;
}
.match-player {
  flex: 0 1 160px;
  min-width: 0;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
}
.match-player.active { border-color: var(--primary); box-shadow: 0 0 12px rgba(79,140,255,0.3); }
.match-player.finished { opacity: 0.5; }
.mp-photo img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.mp-name { font-weight: 600; font-size: 0.9rem; margin-top: 0.3rem; }
.mp-score { font-size: 1.4rem; font-weight: 700; color: var(--primary); margin-top: 0.25rem; }

/* Dart input */
.dart-input { background: var(--surface); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.5rem; }

/* Each throw input box */
.throw-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem;
  margin-bottom: 0.35rem;
}

/* Score info column: right of S/D/T */
.throw-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 50px;
  flex-shrink: 0;
  font-size: 0.75rem;
  line-height: 1.2;
}
.throw-score-before {
  color: var(--text-dim);
}
.throw-input-result {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}
.throw-score-after {
  font-weight: 700;
  color: var(--text);
}

/* Input row: segment grid + multiplier side by side */
.input-row {
  display: flex;
  gap: 0.35rem;
  align-items: stretch;
}

/* Segment grid: MISS | 1-10 / 11-20 | BULL */
.segment-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1.2fr repeat(10, 1fr) 1.2fr;
  grid-template-rows: 1fr 1fr;
  gap: 0.25rem;
}
.seg-btn {
  padding: 0.4rem 0.1rem;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  text-align: center;
  transition: background 0.1s, border-color 0.1s;
}
.seg-btn:hover { border-color: var(--primary); color: var(--text); }
.seg-btn:active { transform: scale(0.95); }
.seg-btn.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.seg-btn.miss {
  grid-column: 1;
  grid-row: 1 / 3;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.seg-btn.bull {
  grid-column: 12;
  grid-row: 1 / 3;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Multiplier bar: always takes space, buttons hidden via visibility */
.multiplier-bar {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 42px;
  flex-shrink: 0;
}
.mul-btn {
  flex: 1;
  padding: 0.3rem 0.2rem;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  text-align: center;
}
.mul-btn:active { transform: scale(0.95); }
.mul-btn:hover { border-color: var(--primary); }
.mul-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Action bar: undo left, submit right */
.action-bar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

/* Turn history */
.turn-history { background: var(--surface); border-radius: var(--radius); padding: 1rem; }
.history-row { padding: 0.35rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

/* ===== Cricket Board ===== */
.cricket-board {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

/* 3-column grid: Player A | Segments | Player B */
.cricket-board-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  width: 100%;
}


/* Segment rows */
.cricket-row {
  display: contents;
}
.cricket-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
  transition: background 0.15s;
}
.cricket-seg-label {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  min-width: 56px;
  text-align: center;
}
.cricket-row.dead .cricket-cell,
.cricket-dead-cell {
  opacity: 0.4;
  background: rgba(128,128,128,0.08);
}

/* Mark symbols */
.cricket-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  position: relative;
}
.cricket-mark-slash {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.cricket-mark-x {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.cricket-mark-closed {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cricketPop 0.25s ease;
}
.cricket-mark-closed .cricket-mark-x {
  font-size: 1.1rem;
}
.cricket-mark-overflow {
  font-size: 0.7rem;
  color: var(--primary);
  font-weight: 700;
  position: absolute;
  top: -2px;
  right: -6px;
}

@keyframes cricketPop {
  0%   { transform: scale(0.7); }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Responsive: mobile */
@media (max-width: 600px) {
  .cricket-seg-label { font-size: 0.9rem; min-width: 44px; }
  .cricket-cell { min-height: 40px; padding: 0.35rem; }
  .cricket-mark { width: 34px; height: 34px; }
  .cricket-mark-slash { font-size: 1.3rem; }
  .cricket-mark-x { font-size: 1.1rem; }
  .cricket-mark-closed { width: 28px; height: 28px; }
  .cricket-mark-closed .cricket-mark-x { font-size: 0.9rem; }
}

/* ===== Stats ===== */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 1rem; text-align: center; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.2rem; }
.chart-container { background: var(--surface); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.5rem; }
.section { margin-bottom: 1.5rem; }
.section h2 { margin-bottom: 0.75rem; }

/* Data tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--text-dim); font-size: 0.85rem; font-weight: 600; }
.data-table .thumb { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }

/* Achievements */
.achievements-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.5rem; }
.achievement { display: flex; align-items: center; gap: 0.75rem; background: var(--surface); padding: 0.75rem; border-radius: var(--radius-sm); }
.achievement.locked { opacity: 0.45; }
.ach-icon { font-size: 1.5rem; }

/* Achievement rarity */
.ach-rarity { color: var(--text-dim); font-style: italic; }

/* Game history achievement tooltips */
.game-ach-icon {
  position: relative;
  cursor: default;
  font-size: 1.2rem;
  padding: 0 0.1rem;
}
.game-ach-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}
.game-ach-icon:hover::after {
  opacity: 1;
}

/* ===== VS Intro (arc layout) ===== */

/* Full-screen overlay backdrop */
.vs-intro {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  overflow: hidden;
  animation: vsBackdropIn 0.3s ease-out;
}
.vs-intro.fade-out {
  animation: vsBackdropOut 0.4s ease-in forwards;
}
@keyframes vsBackdropIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes vsBackdropOut { from { opacity: 1; } to { opacity: 0; } }

/* Central VS image — absolutely centered */
.vs-intro-vs {
  position: absolute;
  left: 50%;
  top: 45%;
  width: 100px;
  height: 100px;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  filter: drop-shadow(0 0 10px rgba(79,140,255,0.2));
  pointer-events: none;
}
/* Pulsing glow applied by JS after pop-in */
.vs-intro-vs.pulse {
  animation: vsGlow 1.4s ease-in-out infinite alternate;
}
@keyframes vsGlow {
  from { filter: drop-shadow(0 0 10px rgba(79,140,255,0.25)); }
  to   { filter: drop-shadow(0 0 30px rgba(79,140,255,0.55)); }
}

/* Player cards — positioned absolutely by JS */
.vs-intro-card {
  position: absolute;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  text-align: center;
  width: 120px;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}
.vs-intro-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 0.4rem;
  display: block;
  border: 2px solid var(--border);
}
.vs-intro-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Skip button — fixed at bottom-center */
.vs-intro-skip {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 0.4rem 1.5rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  z-index: 1;
}
.vs-intro-skip:hover {
  background: rgba(255,255,255,0.15);
  color: var(--text);
}

/* Match container hidden during VS intro */
.match-container.hidden-for-intro {
  opacity: 0;
  pointer-events: none;
}

/* Responsive card / VS sizing */
@media (min-width: 600px) {
  .vs-intro-vs { width: 120px; height: 120px; }
  .vs-intro-card { width: 140px; padding: 1.25rem 1rem; }
  .vs-intro-avatar { width: 64px; height: 64px; }
  .vs-intro-name { font-size: 1rem; }
}
@media (min-width: 900px) {
  .vs-intro-vs { width: 150px; height: 150px; }
  .vs-intro-card { width: 160px; padding: 1.5rem 1.25rem; }
  .vs-intro-avatar { width: 76px; height: 76px; }
  .vs-intro-name { font-size: 1.05rem; }
}

/* ===== Player Stats Header ===== */
.player-stats-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.stats-avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; }
.stats-subtitle { color: var(--text-dim); margin-top: 0.25rem; }

/* ===== Segment Distribution Table ===== */
.segment-table .seg-label { font-weight: 600; }
.segment-table .heat { text-align: center; }
.segment-table .na-cell { text-align: center; color: var(--text-dim); opacity: 0.4; }
.table-scroll { overflow-x: auto; }
.section-subtitle { color: var(--text-dim); margin-top: -0.5rem; margin-bottom: 0.75rem; font-size: 0.9rem; }

/* ===== Global Stats Leaderboard ===== */
.table-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; vertical-align: middle; }
.avatar-cell { width: 40px; padding-right: 0; }
.guest-tag { color: var(--text-dim); }
.btn-small { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

/* ===== Summary ===== */
.summary-table { background: var(--surface); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.summary-player { display: flex; align-items: center; gap: 0.5rem; }
.summary-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.subtitle { color: var(--text-dim); margin-bottom: 1rem; }

/* Summary achievements */
.summary-ach-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.summary-ach-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.summary-ach-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.summary-ach-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}
.summary-ach-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}
.summary-ach-info {
  display: flex;
  flex-direction: column;
}
.summary-ach-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.summary-ach-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ===== Manage Players ===== */
.manage-wrapper { max-width: 700px; margin: 0 auto; }
.manage-section { margin-bottom: 2rem; }
.manage-section h2 { margin-bottom: 1rem; font-size: 1.2rem; }

/* Flash messages */
.flash-messages { margin-bottom: 1rem; }
.flash { padding: 0.6rem 1rem; border-radius: var(--radius-sm); margin-bottom: 0.5rem; font-size: 0.9rem; }
.flash-success { background: rgba(46,204,113,0.15); color: var(--success); border: 1px solid rgba(46,204,113,0.3); }
.flash-error { background: rgba(231,76,94,0.15); color: var(--danger); border: 1px solid rgba(231,76,94,0.3); }

/* Add player form */
.add-player-form .form-row {
  display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap;
}
.add-player-form .form-group { min-width: 140px; }
.form-check-group { display: flex; align-items: flex-end; padding-bottom: 0.3rem; }
.check-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; color: var(--text); cursor: pointer; white-space: nowrap; }
.check-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

/* File input styling */
.file-input {
  width: 100%; padding: 0.4rem; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 0.85rem;
}
.file-input::file-selector-button {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.25rem 0.6rem; cursor: pointer; margin-right: 0.5rem;
}
.file-input-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-upload-label { cursor: pointer; position: relative; }

/* Player management card */
.player-manage-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 0.75rem;
}
.pmc-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.pmc-avatar img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.pmc-info { display: flex; flex-direction: column; gap: 0.15rem; }
.pmc-name { font-weight: 600; font-size: 1rem; }
.pmc-photo-count { font-size: 0.8rem; }

.pmc-upload { margin-bottom: 0.5rem; }
.upload-limit-msg { font-size: 0.85rem; }

/* Photo gallery */
.pmc-gallery { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.gallery-thumb {
  position: relative; width: 64px; height: 64px; border-radius: var(--radius-sm);
  overflow: hidden; border: 2px solid var(--border); transition: border-color 0.15s;
}
.gallery-thumb.active { border-color: var(--primary); box-shadow: 0 0 8px rgba(79,140,255,0.3); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-badge {
  position: absolute; bottom: 0; left: 0; right: 0; background: rgba(79,140,255,0.85);
  color: #fff; font-size: 0.65rem; font-weight: 700; text-align: center; padding: 1px 0;
}
.thumb-set-btn {
  position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.7);
  color: #fff; font-size: 0.65rem; font-weight: 600; text-align: center; padding: 2px 0;
  border: none; cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.gallery-thumb:hover .thumb-set-btn { opacity: 1; }

.text-dim { color: var(--text-dim); }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .dart-input { padding: 0.5rem; }
  .throw-input { padding: 0.4rem; }
  .segment-grid {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: auto;
  }
  .seg-btn.miss {
    grid-column: 1 / 3;
    grid-row: auto;
    order: -2;
  }
  .seg-btn.bull {
    grid-column: 4 / 6;
    grid-row: auto;
    order: -1;
  }
  .seg-btn { font-size: 0.8rem; padding: 0.35rem 0.1rem; }
  .multiplier-bar {
    flex-direction: row;
    width: auto;
    flex-shrink: 1;
  }
  .mul-btn { padding: 0.3rem 0.5rem; }
  .stat-cards { grid-template-columns: repeat(3, 1fr); }
  .player-stats-header { flex-direction: column; text-align: center; }
  .add-player-form .form-row { flex-direction: column; }
  .add-player-form .form-group { min-width: auto; }
}

/* Lobby desktop scaling */
@media (min-width: 768px) {
  .lobby-wrapper {
    max-width: 660px;
  }
  .player-grid,
  .lobby-settings-row {
    gap: 1rem;
  }
  .player-card {
    padding: 1rem 0.75rem;
  }
  .player-photo img {
    width: 64px;
    height: 64px;
  }
  .photo-placeholder {
    width: 64px;
    height: 64px;
    font-size: 1.4rem;
  }
  .player-name { font-size: 1rem; }
  .player-rating { font-size: 0.85rem; }
  .player-stats-link { font-size: 0.8rem; }
  .lobby-card {
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }
}

/* ===== Training Mode ===== */

/* Training Home */
.training-home {
  max-width: 540px;
  margin: 0 auto;
  text-align: center;
}
.training-title {
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
}
.training-subtitle {
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}
.training-category {
  margin-bottom: 1.5rem;
}
.training-cat-label {
  font-size: 1rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.training-drill-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
.training-drill-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1.25rem 0.75rem;
  text-decoration: none;
  color: var(--text);
}
.training-drill-card:hover {
  text-decoration: none;
  border-color: var(--primary);
  transform: translateY(-2px);
}
.training-drill-icon {
  font-size: 2rem;
}
.training-drill-icon-lg {
  font-size: 2.5rem;
}
.training-drill-name {
  font-weight: 700;
  font-size: 1rem;
}
.training-drill-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.3;
}

/* Training Setup */
.training-setup {
  max-width: 540px;
  margin: 0 auto;
}
.training-setup-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.training-section-label {
  font-size: 1rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  margin-top: 1rem;
}
.training-config {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.training-config-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.training-config-field label {
  flex: 0 0 auto;
  margin-bottom: 0;
  white-space: nowrap;
}
.training-config-input {
  max-width: 120px;
}

/* Training Session */
.training-session-container {
  max-width: 700px;
  margin: 0 auto;
}
.training-session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.training-session-header h1 {
  font-size: 1.3rem;
}
.training-player-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.training-player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.training-player-name {
  font-weight: 600;
  font-size: 0.95rem;
}

/* Target display */
.training-target {
  text-align: center;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.training-target-label {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.training-target-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}

/* Live stats bar */
.training-live-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
  padding: 0.6rem 0;
  background: var(--surface);
  border-radius: var(--radius);
}
.training-live-stat {
  text-align: center;
}
.training-live-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}
.training-live-lbl {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: block;
}

/* Training Results */
.training-results {
  max-width: 700px;
  margin: 0 auto;
}
.training-results-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.training-result-cards {
  margin-bottom: 1.5rem;
}
.training-results-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
}
.training-hit-row {
  background: rgba(46, 204, 113, 0.08);
}

/* Training Stats section on player stats page */
.training-stats-section {
  margin-top: 1.5rem;
}
.training-stats-section h2 {
  margin-bottom: 0.75rem;
}

@media (max-width: 600px) {
  .training-drill-grid {
    grid-template-columns: 1fr;
  }
  .training-setup-header {
    flex-direction: column;
    text-align: center;
  }
  .training-session-header {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
  .training-results-header {
    flex-direction: column;
    text-align: center;
  }
  .training-target-value {
    font-size: 2rem;
  }
  .training-live-stats {
    gap: 0.75rem;
  }
  .training-live-val {
    font-size: 1.1rem;
  }
}
