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

:root {
  --primary: #166534;
  --primary-hover: #14532d;
  --primary-dark: #0f3d24;
  --primary-shadow: rgba(22, 101, 52, 0.32);
  --primary-shadow-hover: rgba(22, 101, 52, 0.4);
  --accent: #dc2626;
  --accent-soft: #fef2f2;
  --pitch: #dcfce7;
  --pitch-dark: #bbf7d0;
  --bg: #f4faf5;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-disabled: #94a3b8;
  --border: #d1e7d7;
  --border-pill: #a7d4b5;
  --pill-hover-bg: #ecfdf3;
  --disabled-bg: #f1f5f9;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius-card: 16px;
  --radius-btn: 10px;
  --max-width: 600px;
  --font: "Roboto", "Helvetica", "Arial", sans-serif;
  --toolbar-height: 56px;
  --toolbar-height-lg: 62px;
  --ad-bar-height: 62px;
  --ad-bar-total-height: calc(var(--ad-bar-height) + env(safe-area-inset-bottom, 0px));
  --cricfuego-safe-top: env(safe-area-inset-top, 0px);
  --cricfuego-safe-bottom: env(safe-area-inset-bottom, 0px);
  --cricfuego-safe-left: env(safe-area-inset-left, 0px);
  --cricfuego-safe-right: env(safe-area-inset-right, 0px);
  --keyboard-inset: 0px;
}

html {
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100svh;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: var(--font);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 100% 0%, rgba(22, 101, 52, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 0% 100%, rgba(220, 38, 38, 0.04) 0%, transparent 35%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  padding-top: var(--cricfuego-safe-top);
  padding-left: var(--cricfuego-safe-left);
  padding-right: var(--cricfuego-safe-right);
  box-sizing: border-box;
}

/* Capacitor: native shell injects exact insets — toolbar uses them, not whole .app */
html.capacitor-native {
  --cricfuego-safe-top: 0px;
  --cricfuego-safe-bottom: 0px;
  --cricfuego-safe-left: 0px;
  --cricfuego-safe-right: 0px;
}

html.capacitor-native .app {
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
}

html.capacitor-native .header .toolbar {
  align-items: center;
  min-height: calc(var(--toolbar-height) + env(safe-area-inset-top, 0px));
  height: calc(var(--toolbar-height) + env(safe-area-inset-top, 0px));
  padding:
    env(safe-area-inset-top, 0px)
    calc(12px + env(safe-area-inset-right, 0px))
    0
    calc(12px + env(safe-area-inset-left, 0px));
  box-sizing: border-box;
}

html.capacitor-native .drawer-header--cricket {
  min-height: calc(var(--toolbar-height) + env(safe-area-inset-top, 0px));
  padding:
    calc(10px + env(safe-area-inset-top, 0px))
    calc(16px + env(safe-area-inset-right, 0px))
    10px
    calc(16px + env(safe-area-inset-left, 0px));
  box-sizing: border-box;
}

@media (min-width: 600px) {
  html.capacitor-native .drawer-header--cricket {
    min-height: calc(var(--toolbar-height-lg) + env(safe-area-inset-top, 0px));
    padding:
      calc(12px + env(safe-area-inset-top, 0px))
      calc(20px + env(safe-area-inset-right, 0px))
      12px
      calc(20px + env(safe-area-inset-left, 0px));
  }
}

html.capacitor-native body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html.capacitor-native .main {
  padding-bottom: var(--cricfuego-safe-bottom);
}

@media (min-width: 600px) {
  html.capacitor-native .header .toolbar {
    min-height: calc(var(--toolbar-height-lg) + env(safe-area-inset-top, 0px));
    height: calc(var(--toolbar-height-lg) + env(safe-area-inset-top, 0px));
    padding:
      env(safe-area-inset-top, 0px)
      calc(16px + env(safe-area-inset-right, 0px))
      0
      calc(16px + env(safe-area-inset-left, 0px));
  }
}

/* Header — cricket pitch banner */
.header {
  position: sticky;
  top: 0;
  z-index: 1100;
  color: #fff;
  flex-shrink: 0;
  background: linear-gradient(120deg, var(--primary-dark) 0%, var(--primary) 45%, #15803d 100%);
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(15, 61, 36, 0.25);
}

.header-banner {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 28px,
      rgba(255, 255, 255, 0.07) 28px,
      rgba(255, 255, 255, 0.07) 30px
    );
}

.header-inner {
  position: relative;
  z-index: 1;
}

.toolbar {
  display: flex;
  align-items: center;
  min-height: var(--toolbar-height);
  height: var(--toolbar-height);
  padding: 0 12px;
  box-sizing: border-box;
}

@media (min-width: 600px) {
  .toolbar {
    min-height: var(--toolbar-height-lg);
    height: var(--toolbar-height-lg);
    padding: 0 16px;
  }
}

.toolbar .icon-btn {
  width: 44px;
  height: 44px;
  margin-left: -10px;
  font-size: 1.625rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-left: -12px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1.75rem;
  transition: background-color 0.15s;
}

.icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.toolbar-home-btn {
  flex-shrink: 0;
  margin-left: auto;
  margin-right: -4px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.toolbar-home-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.header-title {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75em;
  height: 1.75em;
  flex-shrink: 0;
  line-height: 1;
  border-radius: 6px;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.12);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Crect x='3' y='1.5' width='4.5' height='15' rx='2' transform='rotate(-32 5.25 9)' fill='%23f5e6c8'/%3E%3Ccircle cx='17.5' cy='17' r='4.75' fill='%23ffb347'/%3E%3Cpath d='M15.5 15.8c1.4-1.2 3.2-1.2 4.6 0' stroke='%23fff' stroke-width='0.85' stroke-linecap='round' opacity='0.9'/%3E%3C/svg%3E");
  background-size: 85%;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.header-mark.brand-mark:not(.brand-mark-ready),
.drawer-brand-icon.brand-mark:not(.brand-mark-ready) {
  background-image: url("/assets/brand-mark-geometric.png");
  background-size: contain;
  background-color: transparent;
}

.header-mark.brand-mark-ready,
.drawer-brand-icon.brand-mark-ready {
  background-image: none;
  background-color: transparent;
}

.header-mark.brand-mark-ready {
  overflow: visible;
}

/* Brand mark image (geometric batsman) */
.header-mark img.brand-mark-img,
.drawer-brand-icon img.brand-mark-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.header-mark .brand-mark-img,
.drawer-brand-icon .brand-mark-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  opacity: 1;
}

.header-mark svg.brand-mark-img,
.drawer-brand-icon svg.brand-mark-img {
  width: 100%;
  height: 100%;
  display: block;
}

.header-inner {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
}

/* Drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 1200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: min(280px, 85vw);
  height: 100%;
  background: var(--surface);
  z-index: 1300;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
}

html:not(.capacitor-native) .drawer {
  top: var(--cricfuego-safe-top);
  left: var(--cricfuego-safe-left);
  height: calc(100% - var(--cricfuego-safe-top));
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.drawer-header--cricket {
  background: linear-gradient(120deg, var(--primary-dark), var(--primary));
  color: #fff;
  border-bottom: none;
  min-height: var(--toolbar-height);
  /* Vertical padding, not a fixed height: the user + group lines wrap on narrow phones. */
  padding: 10px 16px;
  box-sizing: border-box;
}

@media (min-width: 600px) {
  .drawer-header--cricket {
    min-height: var(--toolbar-height-lg);
    padding: 12px 20px;
  }
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.drawer-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  line-height: 1.2;
}

.drawer-brand-name {
  font-weight: 700;
}

.drawer-brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.12);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Crect x='3' y='1.5' width='4.5' height='15' rx='2' transform='rotate(-32 5.25 9)' fill='%23f5e6c8'/%3E%3Ccircle cx='17.5' cy='17' r='4.75' fill='%23ffb347'/%3E%3Cpath d='M15.5 15.8c1.4-1.2 3.2-1.2 4.6 0' stroke='%23fff' stroke-width='0.85' stroke-linecap='round' opacity='0.9'/%3E%3C/svg%3E");
  background-size: 85%;
  background-repeat: no-repeat;
  background-position: center;
}

.drawer-brand-icon .brand-mark-img {
  opacity: 1;
}

.drawer-user {
  font-size: 0.8125rem;
  font-weight: 500;
  opacity: 0.92;
}

.drawer-user:empty {
  display: none;
}

.drawer-nav {
  padding: 12px 0;
}

.drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  color: var(--text);
  font-size: 0.9375rem;
  transition: background 0.15s, color 0.15s;
}

.drawer-icon {
  width: 1.5rem;
  text-align: center;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.drawer-link:hover,
.drawer-link.active {
  background: var(--pill-hover-bg);
  color: var(--primary);
}

.drawer-header--cricket + .drawer-nav .drawer-link:hover,
.drawer-header--cricket + .drawer-nav .drawer-link.active {
  background: var(--pitch);
}

/* Main content */
.main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

@media (min-width: 600px) {
  .main {
    padding: 24px;
  }
}

.hero {
  margin-bottom: 16px;
}

.page-banner {
  position: relative;
  padding: 18px 20px;
  border-radius: var(--radius-card);
  border: 1px solid var(--pitch-dark);
  background: linear-gradient(135deg, var(--pitch) 0%, #fff 72%);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(22, 101, 52, 0.08);
}

.page-banner::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  opacity: 0.18;
  background: center / contain no-repeat;
  pointer-events: none;
}

.page-banner--setup::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='none'%3E%3Cpath d='M12 52 L32 8 L52 52 Z' stroke='%23166534' stroke-width='3' fill='%23dcfce7'/%3E%3Ccircle cx='48' cy='16' r='8' fill='%23dc2626'/%3E%3C/svg%3E");
}

.page-banner--match::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect x='8' y='20' width='48' height='28' rx='4' fill='%23166534'/%3E%3Ctext x='32' y='40' text-anchor='middle' fill='white' font-size='14' font-family='sans-serif' font-weight='bold'%3E120%3C/text%3E%3C/svg%3E");
}

.page-banner--players::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='none'%3E%3Ccircle cx='24' cy='20' r='8' fill='%23166534'/%3E%3Cpath d='M10 46c0-7.7 6.3-12 14-12s14 4.3 14 12' stroke='%23166534' stroke-width='3' stroke-linecap='round'/%3E%3Ccircle cx='44' cy='22' r='7' fill='%23166534'/%3E%3Cpath d='M34 48c1.2-6.5 7-10.5 14-10.5 7.2 0 12.8 4 14 10.5' stroke='%23166534' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}

.page-banner--career::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='none'%3E%3Crect x='10' y='34' width='10' height='16' rx='2' fill='%23166534'/%3E%3Crect x='27' y='22' width='10' height='28' rx='2' fill='%23166534'/%3E%3Crect x='44' y='14' width='10' height='36' rx='2' fill='%23166534'/%3E%3C/svg%3E");
}

.page-banner--history::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect x='14' y='10' width='36' height='44' rx='3' stroke='%23166534' stroke-width='3' fill='%23dcfce7'/%3E%3Cline x1='22' y1='24' x2='42' y2='24' stroke='%23166534' stroke-width='2'/%3E%3Cline x1='22' y1='34' x2='38' y2='34' stroke='%23166534' stroke-width='2'/%3E%3C/svg%3E");
}

.page-banner h1 {
  padding-right: 48px;
}

.hero h1 {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 6px;
}

@media (min-width: 600px) {
  .hero h1 {
    font-size: 1.75rem;
  }
}

.hero p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.43;
}

/* Card */
.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow:
    0 1px 4px rgba(15, 23, 42, 0.06),
    0 4px 16px rgba(15, 23, 42, 0.04);
  padding: 16px;
  margin-bottom: 12px;
}

@media (min-width: 600px) {
  .card {
    padding: 20px;
  }
}

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

.card-section + .card-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.card-heading {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.card-heading-note {
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  opacity: 0.85;
}

.player-picker-option--empty {
  color: var(--text-muted, #64748b);
  font-style: italic;
  pointer-events: none;
}

.team-picker .player-picker-list {
  max-height: 220px;
}

/* Pill options */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--border-pill);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0 12px;
  min-width: 44px;
  user-select: none;
  transition: all 0.15s ease;
}

.pill.custom {
  font-weight: 500;
  color: var(--text-muted);
}

.pill:hover {
  border-color: var(--primary);
  background: var(--pill-hover-bg);
}

.pill.custom:hover {
  color: var(--primary);
}

.pill.selected {
  border-color: var(--primary);
  background: #ecfdf3;
  color: var(--primary);
}

.custom-input-wrap {
  margin-top: 10px;
  display: none;
}

.custom-input-wrap.visible {
  display: block;
}

.custom-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1.5px solid var(--border-pill);
  border-radius: var(--radius-btn);
  font-size: 0.9375rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.custom-input:focus {
  border-color: var(--primary);
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-btn);
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 2px 8px var(--primary-shadow);
  transition: all 0.2s ease-in-out;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 14px var(--primary-shadow-hover);
}

.btn-primary:disabled {
  background: var(--disabled-bg);
  color: var(--text-disabled);
  box-shadow: none;
  cursor: not-allowed;
}

.tagline {
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Scoring page */
.scoreboard {
  text-align: center;
  padding: 8px 0 20px;
}

.score-main {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}

.score-main span {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-muted);
}

.score-meta {
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.score-meta strong {
  color: var(--text);
  font-weight: 600;
}

.score-live-stats {
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.score-live-stats strong {
  color: var(--text);
  font-weight: 600;
}

.score-live-stats-sep {
  margin: 0 6px;
  opacity: 0.55;
}

.score-chase-panel {
  margin-top: 10px;
}

.score-chase-need {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.score-chase-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0 8px;
}

.score-chase-rrr strong,
.score-chase-rrr #score-rrr {
  color: #2563eb;
  font-weight: 700;
}

.innings-team-stat-rrr,
.innings-stat-rrr {
  color: #2563eb;
}

.innings-chase-detail {
  margin-bottom: 12px;
}

.innings-chase-detail .score-chase-divider {
  margin: 8px 0;
}

.innings-team-stats {
  margin: 8px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.innings-team-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--pill-hover-bg);
  border-radius: var(--radius-btn);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.innings-team-stat-row.is-active {
  box-shadow: inset 0 0 0 1px var(--border);
}

.innings-team-stat-name {
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.innings-team-stat-metrics strong {
  color: var(--text);
  font-weight: 600;
}

.innings-team-stat-sep {
  margin: 0 6px;
  opacity: 0.55;
}

.this-over {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--pill-hover-bg);
  border-radius: var(--radius-btn);
  font-size: 0.8125rem;
  color: var(--text-muted);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

.ball-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
}

.ball-dot.wicket {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.ball-dot.four,
.ball-dot.six {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.ball-dot.extra {
  background: var(--warning);
  border-color: var(--warning);
  color: #fff;
  border-radius: 6px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

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

.score-btn.extra {
  color: var(--warning);
  font-size: 0.875rem;
}

#scoring-extra:not(.hidden) ~ .action-row,
#scoring-extra:not(.hidden) + .action-row {
  margin-top: 12px;
}

#scoring-extra.hidden {
  display: none !important;
}

#scoring-normal.hidden {
  display: none !important;
}

.extra-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.extra-panel-title {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--text);
}

.panel-cancel {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: inherit;
  padding: 4px 0;
  cursor: pointer;
}

.panel-cancel:hover {
  color: var(--text);
}

.extra-panel-subtext {
  margin-bottom: 14px;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.extra-wicket-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--pill-hover-bg);
  border-radius: var(--radius-btn);
  cursor: pointer;
  user-select: none;
}

.extra-wicket-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.extra-wicket-toggle span {
  font-size: 0.875rem;
  font-weight: 500;
}

.wicket-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-field-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.dismissal-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border-pill);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 0.9375rem;
}

.dismissal-text {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 400;
  white-space: normal;
  line-height: 1.35;
}

.records-table th.dismissal-col,
.records-table td.dismissal-cell {
  min-width: 76px;
  max-width: 110px;
  text-align: left !important;
  vertical-align: middle;
  padding-left: 6px;
  padding-right: 6px;
  font-size: 0.6875rem;
  color: var(--text-muted);
  white-space: normal;
  line-height: 1.35;
  word-break: break-word;
}

.extra-runs-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.extra-bat-run-btn {
  height: 48px;
  border: none;
  border-radius: var(--radius-btn);
  background: var(--pill-hover-bg);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.extra-bat-run-btn:hover {
  background: #e2e8f0;
}

.extra-bat-run-btn:active {
  background: var(--primary);
  color: #fff;
}

@media (max-width: 380px) {
  .extra-runs-row {
    gap: 6px;
  }

  .extra-bat-run-btn {
    height: 44px;
    font-size: 0.9375rem;
  }
}

.score-btn {
  height: 52px;
  border: 1.5px solid var(--border-pill);
  border-radius: var(--radius-btn);
  background: var(--surface);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  transition: all 0.15s;
}

.score-btn:hover {
  border-color: var(--primary);
  background: var(--pill-hover-bg);
}

.score-btn.runs-4,
.score-btn.runs-6 {
  color: var(--primary);
}

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

.score-btn.wicket:hover {
  border-color: var(--danger);
  background: #fef2f2;
}

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.scoring-undo-row {
  margin-bottom: 4px;
}

.btn-secondary {
  flex: 1;
  padding: 11px 16px;
  border: 1.5px solid var(--border-pill);
  border-radius: var(--radius-btn);
  background: var(--surface);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s;
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--pill-hover-bg);
}

.btn-secondary:disabled,
.btn-secondary:disabled:hover {
  opacity: 0.55;
  cursor: not-allowed;
  border-color: var(--border-pill);
  color: var(--text-disabled);
  background: var(--disabled-bg);
}

.match-over-banner {
  text-align: center;
  padding: 20px;
  background: linear-gradient(135deg, #ecfdf3, #f0fdf4);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.match-result-hero {
  margin-bottom: 12px;
}

.winner-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

.match-winner-name {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text);
}

.match-margin {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0;
}

.match-final-line {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.match-awards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  text-align: left;
}

.award-card {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
}

.award-card--featured {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border-color: #fcd34d;
}

.award-icon {
  font-size: 1.35rem;
  line-height: 1;
  display: block;
  margin-bottom: 4px;
}

.award-icon--trophy::before {
  content: "\1F3C6";
}

.award-icon--bat::before {
  content: "\1F3CF";
}

.award-icon--target::before {
  content: "\1F3AF";
}

.award-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.award-name {
  display: block;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.award-stat {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

@media (max-width: 420px) {
  .match-awards {
    grid-template-columns: 1fr;
  }

  .award-card--featured {
    grid-column: auto;
  }
}

.match-over-banner h2 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.match-over-banner p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

body.quick-score-session .drawer-link[data-nav="players"],
body.quick-score-session .drawer-link[data-nav="personal"],
body.quick-score-session .drawer-link[data-nav="career"],
body.quick-score-session .drawer-link[data-nav="profile"],
body.play-track-session .drawer-link[data-nav="profile"] {
  display: none !important;
}

.quick-score-team-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.quick-score-team-form .custom-input {
  flex: 1 1 auto;
}

.quick-score-team-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border, #e5e7eb);
}

.quick-score-team-name-row:first-child {
  border-top: none;
  padding-top: 0;
}

.quick-score-team-name-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.quick-score-team-name-label {
  font-size: 0.9375rem;
  color: var(--text);
}

.quick-score-team-name-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.quick-score-team-name-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

body.admin-user .drawer-link[data-nav="setup"] {
  display: none !important;
}

html.admin-user #user-match-view,
body.admin-user #user-match-view {
  display: none !important;
}

html.admin-user #admin-match-view,
body.admin-user #admin-match-view {
  display: block !important;
}

/* Teams setup */
.teams-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.team-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.team-field {
  position: relative;
  overflow: visible;
}

.card-section:has(.player-picker) {
  overflow: visible;
}

@media (max-width: 420px) {
  .teams-grid {
    grid-template-columns: 1fr;
  }
}

.teams-grid--setup {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 520px) {
  .teams-grid--setup {
    grid-template-columns: 1fr;
  }
}

.setup-error {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--danger);
}

.setup-live-notice {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-card);
  background: #fffbeb;
  border: 1px solid #fde68a;
  font-size: 0.875rem;
  color: #92400e;
}

.setup-live-notice a {
  color: var(--primary);
  font-weight: 600;
}

.setup-clear-match {
  display: block;
  margin-top: 8px;
  padding: 0;
  border: none;
  background: none;
  color: #b45309;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.setup-clear-match:disabled {
  opacity: 0.6;
  cursor: wait;
}

.setup-match-actions {
  border-top: none;
  padding-top: 0;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setup-match-actions .btn-primary,
.setup-match-actions .setup-exit-scoring-btn {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  box-sizing: border-box;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.setup-exit-scoring-btn {
  text-decoration: none;
}

body.match-team-only #players-panel,
body.match-team-only #records-panel,
body.match-team-only #match-awards,
body.match-team-only #scoring-wicket {
  display: none !important;
}

.match-hero-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.match-hero-row > div:first-child {
  min-width: 0;
}

.match-hero-row h1 {
  margin: 0;
  line-height: 1.25;
}

.match-hero-row #match-format {
  margin: 4px 0 0;
  line-height: 1.35;
  word-break: break-word;
}

.match-hero-actions .btn-secondary.btn-sm {
  min-height: 40px;
  padding: 11px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.match-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
}

@media (min-width: 720px) {
  .match-hero-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }

  .match-hero-row > div:first-child {
    flex: 1;
    min-width: 0;
  }

  .match-hero-actions {
    flex-shrink: 0;
    justify-content: flex-end;
  }
}

.match-hero-actions .btn-end-match {
  color: var(--danger, #b42318);
  border-color: rgba(180, 35, 24, 0.35);
}

body.match-finished #btn-end-match {
  display: none !important;
}

.edit-match-modal {
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  outline: none;
}

.modal-overlay .player-picker-list {
  z-index: 20;
}

body.edit-modal-open .app {
  pointer-events: none;
}

.edit-match-field {
  margin-bottom: 16px;
}

.edit-match-field .card-heading {
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.add-player-modal-form .login-field {
  margin-bottom: 0;
}

.add-player-modal-form .player-mobile-row {
  margin-bottom: 12px;
}

.add-player-modal-form .modal-actions {
  margin-top: 16px;
}

.add-player-modal-form .modal-actions .btn-primary,
.add-player-modal-form .modal-actions .btn-secondary {
  flex: 1;
  min-height: 48px;
  margin-top: 0;
}

body.add-player-modal-open {
  overflow: hidden;
}

.add-team-name-modal {
  width: min(100%, 22rem);
  max-width: calc(100vw - 2rem);
  margin: auto;
  padding: 1.25rem 1rem 1rem;
}

.add-team-name-modal-form .login-field {
  margin-bottom: 0;
}

.add-team-name-modal-form .modal-actions {
  margin-top: 1rem;
}

body.add-team-name-modal-open {
  overflow: hidden;
}

body.add-team-name-modal-open .app {
  pointer-events: none;
}

body.add-team-name-modal-open #add-team-name-modal-overlay,
body.add-team-name-modal-open #add-team-name-modal-overlay * {
  pointer-events: auto;
}

.modal-actions .btn-primary,
.modal-actions .btn-secondary {
  flex: 1;
}

/* Innings tabs */
.innings-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.innings-tab {
  padding: 10px 12px;
  border: 1.5px solid var(--border-pill);
  border-radius: var(--radius-btn);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  line-height: 1.3;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.innings-tab:hover:not(.disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.innings-tab.active {
  border-color: var(--primary);
  background: #ecfdf3;
  color: var(--primary);
}

.innings-tab.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Records tabs (batting / bowling) */
.records-tabs-wrap {
  margin-top: 4px;
}

.records-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.25rem, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.records-tab {
  padding: 10px 12px;
  border: 1.5px solid var(--border-pill);
  border-radius: var(--radius-btn);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.records-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.records-tab.active {
  border-color: var(--primary);
  background: #ecfdf3;
  color: var(--primary);
}

.records-tab-panel.hidden {
  display: none;
}

.score-team {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.score-target {
  margin-top: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
}

.history-innings-block + .history-innings-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.history-awards {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.history-winner-line {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.history-awards-grid {
  margin-bottom: 0;
}

.history-awards-grid .winner-badge {
  margin-bottom: 0;
}

.history-innings-title {
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.innings-stats-line {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: -6px 0 12px;
}

.innings-stats-line strong {
  color: var(--text);
  font-weight: 600;
}

.innings-stats-sep {
  margin: 0 6px;
  opacity: 0.55;
}

/* Match summary (over-by-over) */
.match-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-over {
  padding: 12px;
  background: var(--pill-hover-bg);
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
}

.summary-over--current {
  border-color: var(--primary);
  background: #ecfdf3;
}

.summary-over-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.summary-over-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.summary-over-bowler {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

.summary-over-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.summary-empty {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0;
}

/* Player inputs & records */
.players-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.players-col {
  min-width: 0;
  padding: 0 4px;
}

.players-col-bowling {
  border-left: 1px solid var(--border);
  padding-left: 16px;
}

.players-col-title {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.player-field {
  margin-bottom: 16px;
  position: relative;
}

.player-picker {
  position: relative;
}

.player-picker.open:not(.phone-code-picker),
.player-picker.player-picker--active:not(.phone-code-picker) {
  z-index: 80;
}

.phone-code-picker.open,
.phone-code-picker.player-picker--active {
  z-index: 80;
}

.player-picker.open .player-combobox,
.player-picker.player-picker--active .player-combobox {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12);
}

.player-picker.open .player-picker-toggle,
.player-picker.player-picker--active .player-picker-toggle {
  color: var(--primary);
}

.player-picker-control {
  position: relative;
}

.player-picker-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0 var(--radius-btn) var(--radius-btn) 0;
}

.player-picker-toggle:hover {
  color: var(--primary);
}

.player-picker-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--surface);
  border: 1.5px solid var(--border-pill);
  border-radius: var(--radius-btn);
  box-shadow:
    0 8px 24px rgba(15, 23, 42, 0.12),
    0 2px 8px rgba(15, 23, 42, 0.06);
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.player-picker-option {
  padding: 10px 12px;
  font-size: 0.9375rem;
  color: var(--text);
  cursor: pointer;
}

.player-picker-option:hover,
.player-picker-option:focus {
  background: #ecfdf3;
  color: var(--primary);
}

.player-picker-option--add {
  font-weight: 600;
  color: var(--primary);
  border-top: 1px solid var(--border, #e5e7eb);
}

.player-picker-option--add:hover,
.player-picker-option--add:focus {
  background: #ecfdf3;
}

#players-panel {
  overflow: visible;
}

.player-field:last-child {
  margin-bottom: 0;
}

.player-field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.role-badge {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
  background: #ecfdf3;
  padding: 2px 6px;
  border-radius: 4px;
}

.player-combobox {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 12px;
  border: 1.5px solid var(--border-pill);
  border-radius: var(--radius-btn);
  background: var(--surface);
  font-size: 0.9375rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.player-combobox:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12);
}

.striker-input {
  border-color: #93c5fd;
  background-color: #f8fbff;
}

.player-combobox.needs-pick {
  border-color: #f59e0b;
  background-color: #fffbeb;
}

.player-combobox.needs-urgent {
  border-color: var(--danger);
  background-color: #fef2f2;
}

.player-select.needs-urgent,
.dismissal-select.needs-urgent {
  border-color: var(--danger);
  background-color: #fef2f2;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

.player-alert {
  margin-top: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.player-alert--urgent {
  color: var(--danger);
  font-weight: 600;
}

.player-stats {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.45;
  background: var(--pill-hover-bg);
  border-radius: 8px;
  min-height: 34px;
}

.player-stats strong {
  color: var(--text);
  font-weight: 700;
}

@media (max-width: 560px) {
  .players-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .players-col-bowling {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 4px;
    padding-top: 16px;
  }
}

.records-table tr.striker td:first-child {
  color: inherit;
}

.batter-striker-mark {
  color: var(--primary);
  font-weight: 700;
  margin-right: 1px;
}

.batter-striker-name {
  color: var(--primary);
  font-weight: 700;
}

.batter-out {
  color: var(--text-muted);
  font-weight: 400;
}

.records-table tr.non-striker td:first-child {
  color: inherit;
}

.records-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 520px) {
  .records-grid {
    grid-template-columns: 1fr;
  }
}

.records-heading {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.records-table-wrap {
  overflow-x: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.records-table th,
.records-table td {
  padding: 6px 4px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.records-table th {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.records-table td:first-child,
.records-table th:first-child {
  padding-left: 0;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.records-table td:not(:first-child):not(.dismissal-cell),
.records-table th:not(:first-child):not(.dismissal-col) {
  text-align: center;
  width: 32px;
}

.records-table tr.active td:first-child {
  color: var(--primary);
  font-weight: 600;
}

.records-table tr.out td:first-child {
  color: inherit;
}

.records-empty {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
}

.main > .records-empty {
  margin: 2px 4px 0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

@media (max-width: 599px) {
  .modal-overlay {
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    padding-bottom: max(24px, var(--keyboard-inset, 0px), env(safe-area-inset-bottom, 0px));
  }

  .modal-overlay .modal {
    margin-top: auto;
    margin-bottom: auto;
    flex-shrink: 0;
  }
}

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

.modal {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.28);
  padding: 20px;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.modal-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.modal-hint {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.player-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.scoring-disabled {
  opacity: 0.55;
  pointer-events: none;
}

/* Players page */
.add-player-card {
  padding-top: 0;
  overflow: hidden;
}

.add-player-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}

.add-player-toggle-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.add-player-toggle-label .card-label {
  margin: 0;
}

.add-player-toggle-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 400;
}

.add-player-toggle-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #ecfdf3;
  color: var(--primary);
  transition: transform 0.2s ease, background 0.2s ease;
}

.add-player-card.is-expanded .add-player-toggle-icon {
  transform: rotate(180deg);
}

.add-player-panel {
  padding: 0 16px 16px;
}

.add-player-panel[hidden] {
  display: none;
}

.add-player-form-actions {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-top: 4px;
}

.add-player-form-actions .btn-primary,
.add-player-form-actions .btn-secondary {
  flex: 1;
  width: auto;
  min-height: 48px;
  margin-top: 0;
  padding: 12px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.2;
}

.add-player-form-actions .add-player-clear {
  flex: 1;
}

.add-player-form-actions .add-player-clear.hidden {
  display: none;
}

.team-squad-tools .add-player-form-actions {
  margin-top: 8px;
}

.team-squad-tools .player-mobile-row {
  margin-bottom: 0;
}

.team-squad-tools .add-player-form-actions.add-player-form-actions--compact {
  margin-top: 0;
}

.add-player-form-actions--compact {
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.add-player-form-actions--compact .btn-primary,
.add-player-form-actions--compact .btn-secondary {
  flex: 0 0 auto;
  width: auto;
  min-height: 0;
  min-width: 96px;
  margin-top: 0;
  padding: 9px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
}

.team-squad-form-actions--continue-only {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.team-squad-form-actions--continue-only .btn-primary {
  width: auto;
  min-width: min(100%, 280px);
  max-width: 280px;
  margin-top: 0;
  padding-left: 28px;
  padding-right: 28px;
}

.add-player-form-actions .add-player-btn {
  flex: 1;
}

.add-player-form-actions .add-player-cancel {
  flex: 0 0 auto;
  min-width: 96px;
}

.add-player-form-actions .add-player-cancel.hidden {
  display: none;
}

.add-player-card.is-editing {
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.22);
}

.add-player-card.is-editing .add-player-toggle-icon {
  background: #dcfce7;
}

.player-list-item.is-editing {
  background: #f0fdf4;
  border-radius: 8px;
  margin: 0 -8px;
  padding: 0 8px;
}

.add-player-form {
  display: block;
}

.add-player-form .custom-input {
  width: 100%;
}

.add-player-btn {
  width: 100%;
  min-width: 80px;
  flex-shrink: 0;
}

.form-hint {
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--danger);
}

.player-list {
  list-style: none;
}

.player-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.player-list-item:last-child {
  border-bottom: none;
}

.player-list-name {
  font-weight: 500;
  font-size: 0.9375rem;
}

.player-list-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-icon-edit,
.btn-icon-delete {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--border-pill);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  transition: all 0.15s;
}

.btn-icon-edit:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #ecfdf5;
}

.btn-icon-delete {
  font-size: 1.25rem;
}

.btn-icon-delete:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: #fef2f2;
}

/* History page */
.history-card {
  padding: 0;
  overflow: hidden;
}

.history-card-header {
  width: 100%;
  display: block;
  padding: 16px;
  border: none;
  background: transparent;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.history-card-layout {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.history-scoreboard {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
}

.history-score-team {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.history-score-team--b {
  align-items: flex-end;
  text-align: right;
}

.history-score-team-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.history-score-team.is-winner .history-score-team-name {
  font-weight: 700;
}

.history-score-team-runs {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.history-score-team-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.history-score-team-stats strong {
  color: var(--text);
  font-weight: 600;
}

.history-score-team-stats-sep {
  margin: 0 5px;
  opacity: 0.55;
}

.history-score-team--b .history-score-team-stats {
  text-align: right;
}

.history-team-winner {
  align-self: flex-start;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  font-size: 0.5625rem;
  padding: 2px 6px;
  letter-spacing: 0.04em;
}

.history-score-team--b .history-team-winner {
  align-self: flex-end;
}

.history-card-date {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-card-details {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.history-card-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-flow-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.2;
  white-space: nowrap;
}

.history-flow-badge--quick-match {
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
  border: 1px solid rgba(22, 163, 74, 0.22);
}

.history-flow-badge--quick-score {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.history-flow-badge--teams {
  background: rgba(234, 88, 12, 0.1);
  color: #c2410c;
  border: 1px solid rgba(234, 88, 12, 0.22);
}

.history-result-badge--tie {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-muted, #e5e7eb);
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.history-card-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-card-summary strong {
  font-size: 1.125rem;
  color: var(--text);
}

.history-card-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.history-card-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s ease;
  padding: 0 16px;
  border-top: 1px solid transparent;
  min-height: 0;
}

.history-card-header[aria-expanded="true"] + .history-card-body {
  grid-template-rows: 1fr;
  padding: 14px 16px 16px;
  border-top-color: var(--border);
}

.history-card-body-inner {
  overflow: hidden;
  min-height: 0;
}

.live-role-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-card);
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.live-role-banner-text {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.end-match-panel {
  text-align: center;
  padding-top: 16px;
  padding-bottom: 16px;
}

.btn-end-match {
  width: 100%;
  max-width: 280px;
}

.end-match-hint {
  margin: 10px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.unclaimed-role-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.admin-role-banner {
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  color: #5b21b6;
}

.live-role-banner .btn-sm {
  flex-shrink: 0;
  white-space: nowrap;
}

.viewer-role-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.scorer-role-banner {
  background: #ecfdf3;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.live-role-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  animation: live-pulse 1.5s ease-in-out infinite;
}

@keyframes live-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.viewer-readonly .player-picker-control,
.viewer-readonly .player-combobox {
  pointer-events: none;
  touch-action: none;
}

.viewer-readonly .player-combobox {
  background: var(--disabled-bg);
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  border-color: var(--border);
  cursor: default;
}

.viewer-readonly .player-picker-toggle {
  pointer-events: none;
  opacity: 0.45;
}

.history-card-actions {
  padding: 0 16px 12px;
  display: flex;
  justify-content: flex-end;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.8125rem;
  flex: 0;
  width: auto;
}

.records-empty-cell {
  text-align: center !important;
  color: var(--text-muted);
  font-style: italic;
  padding: 12px 4px !important;
}

/* Login */
.login-page {
  background:
    linear-gradient(160deg, rgba(220, 252, 231, 0.9) 0%, var(--bg) 50%),
    radial-gradient(circle at 80% 10%, rgba(220, 38, 38, 0.06) 0%, transparent 40%);
}

html.capacitor-native body.login-page {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 100dvh;
}

.login-shell {
  min-height: 100svh;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 16px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
}

html.capacitor-native .login-shell {
  justify-content: flex-start;
  min-height: auto;
}

@media (max-width: 599px) {
  .login-shell {
    justify-content: flex-start;
    padding-top: max(24px, env(safe-area-inset-top, 0px));
    padding-bottom: 48px;
  }
}

.login-brand {
  text-align: center;
  padding: 16px 16px 20px;
  border-radius: var(--radius-card);
  background: linear-gradient(135deg, var(--pitch) 0%, #fff 100%);
  border: 1px solid var(--pitch-dark);
  box-shadow: 0 4px 16px rgba(22, 101, 52, 0.1);
}

.login-hero {
  display: block;
  width: min(32vw, 120px);
  max-width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  margin: 0 auto 6px;
  filter: drop-shadow(0 8px 16px rgba(15, 61, 36, 0.14));
}

.login-logo {
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 6.5rem;
  height: 6.5rem;
  margin: 0 auto 8px;
  border-radius: 16px;
  overflow: hidden;
  background: transparent;
  filter: drop-shadow(0 2px 6px rgba(22, 101, 52, 0.18));
}

.login-logo .brand-mark-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.login-brand h1 {
  font-size: 1.85rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--primary-dark);
  letter-spacing: 0.01em;
}

.login-brand p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.login-brand .tagline {
  color: var(--primary-dark);
  font-weight: 600;
}

.login-brand-sub {
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.login-card {
  margin: 0;
}

.login-field {
  margin-bottom: 16px;
}

.login-field .team-label {
  display: block;
  margin-bottom: 6px;
}

.password-input-wrap {
  position: relative;
}

.password-input-wrap .custom-input {
  padding-right: 46px;
}

.password-toggle-btn {
  appearance: none;
  position: absolute;
  top: 50%;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transform: translateY(-50%);
  transition: color 0.15s, background-color 0.15s;
}

.password-toggle-btn:hover {
  color: var(--primary);
  background: rgba(22, 101, 52, 0.08);
}

.password-toggle-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.password-toggle-icon {
  display: block;
}

.password-toggle-icon--hide {
  display: none;
}

.password-toggle-btn.is-visible .password-toggle-icon--show {
  display: none;
}

.password-toggle-btn.is-visible .password-toggle-icon--hide {
  display: block;
}

.login-error {
  color: var(--danger);
  font-size: 0.875rem;
  margin-bottom: 12px;
}

.form-error {
  color: var(--danger);
  font-size: 0.875rem;
  line-height: 1.45;
  margin: 10px 0 0;
  padding: 0;
  width: 100%;
  text-align: left;
}

.form-error[hidden] {
  display: none !important;
}

.add-player-form .form-error,
.add-player-modal-form .form-error,
.team-squad-tools .form-error {
  margin-top: 10px;
}

#add-player-error:not([hidden]),
#add-player-error:not(.hidden),
#add-player-modal-error:not([hidden]),
#add-player-modal-error:not(.hidden) {
  display: block;
  color: var(--danger);
}

.login-success {
  color: var(--success);
  font-size: 0.875rem;
  margin-bottom: 12px;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: -4px 0 16px;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.login-remember input {
  width: 17px;
  height: 17px;
  margin: 0;
  flex: none;
  accent-color: var(--primary);
  cursor: pointer;
}

.login-hint {
  margin-top: 16px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.career-table th,
.career-table td {
  white-space: nowrap;
}

.career-table td:first-child,
.career-table th:first-child {
  min-width: 5rem;
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.setup-shell {
  max-width: 520px;
}

.setup-step {
  margin: 0;
}

.setup-text {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 12px;
}

.setup-text.muted {
  font-size: 0.8125rem;
  margin-top: 12px;
  margin-bottom: 0;
}

.setup-text strong {
  color: var(--text);
}

.setup-link-btn {
  display: block;
  text-align: center;
  text-decoration: none;
  margin-bottom: 12px;
}

.setup-sql {
  width: 100%;
  margin: 8px 0 12px;
  padding: 10px 12px;
  font-family: ui-monospace, monospace;
  font-size: 0.6875rem;
  line-height: 1.45;
  border: 1.5px solid var(--border-pill);
  border-radius: var(--radius-btn);
  background: var(--pill-hover-bg);
  resize: vertical;
  min-height: 120px;
}

.setup-list {
  margin: 0 0 16px 1.1rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.setup-list code {
  font-size: 0.8125rem;
  background: var(--pill-hover-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.setup-next {
  margin-top: 8px;
  width: 100%;
}

.field-optional {
  font-weight: 400;
  color: #64748b;
  font-size: 0.85em;
}

.login-hint a {
  color: var(--primary);
  font-weight: 600;
}

.page-banner--home {
  background: linear-gradient(135deg, #ecfdf3 0%, #fff 100%);
}

.page-banner--teams {
  background: linear-gradient(135deg, #eff6ff 0%, #fff 100%);
}

.home-actions {
  display: grid;
  gap: 14px;
}

body[data-page="home"] .main {
  flex: 1 1 auto;
  gap: 20px;
  padding-bottom: max(48px, env(safe-area-inset-bottom, 24px));
}

body[data-page="home"] .tagline {
  margin-top: 8px;
}

.history-list--grouped {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-group + .history-group {
  margin-top: 0;
}

.history-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 16px 18px;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  color: inherit;
}

.history-group-toggle:hover,
.history-group-toggle:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(22, 101, 52, 0.1);
}

.history-group-toggle-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.history-group-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.history-group-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.history-group-chevron {
  flex: 0 0 auto;
  font-size: 1.125rem;
  color: var(--primary);
  line-height: 1;
  transition: transform 0.28s ease;
  transform: rotate(0deg);
}

.history-group-toggle[aria-expanded="true"] .history-group-chevron {
  transform: rotate(90deg);
}

.history-group-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s ease, margin-top 0.28s ease;
  margin-top: 0;
}

.history-group-panel.is-expanded {
  grid-template-rows: 1fr;
  margin-top: 10px;
}

.history-group-panel-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  min-height: 0;
  padding-left: 2px;
}

.history-group-panel .history-card {
  margin-bottom: 0;
}

.team-stats-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.team-stats-groups + .personal-stats-category {
  margin-top: 20px;
}

.team-stats-group .history-group-panel-inner .card {
  margin: 0;
}

#career-stats-root.team-stats-restoring .history-group-panel,
#career-stats-root.team-stats-restoring .history-group-chevron {
  transition: none;
}

.team-stats-group .history-group-panel:not(.is-expanded) .history-group-panel-inner {
  content-visibility: hidden;
}

.history-list--loading {
  min-height: 12rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#career-stats-root,
#personal-stats-root {
  min-height: 14rem;
}

#career-stats-root:empty,
#personal-stats-root:empty {
  display: none;
  min-height: 0;
}

#career-stats-root[aria-busy="true"],
#personal-stats-root[aria-busy="true"],
#history-list.history-list--loading {
  display: block;
}

#history-list.history-list--loading {
  position: relative;
}

#career-stats-root[aria-busy="true"] > .app-brand-loader,
#career-stats-root[aria-busy="true"] > .stats-loading,
#personal-stats-root[aria-busy="true"] > .app-brand-loader,
#personal-stats-root[aria-busy="true"] > .stats-loading,
#profile-root[aria-busy="true"] > .app-brand-loader,
#history-list.history-list--loading > .app-brand-loader,
#history-list.history-list--loading > .stats-loading {
  position: absolute;
  inset: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  box-sizing: border-box;
}

#career-stats-root[aria-busy="true"],
#personal-stats-root[aria-busy="true"],
#profile-root[aria-busy="true"] {
  position: relative;
  min-height: 220px;
}

.team-stats-reveal {
  animation: team-stats-fade-in 0.32s ease;
}

@keyframes team-stats-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .team-stats-reveal {
    animation: none;
  }
}

#career-stats-root[aria-busy="true"] .app-brand-loader,
#personal-stats-root[aria-busy="true"] .app-brand-loader,
#profile-root[aria-busy="true"] .app-brand-loader,
#history-list .app-brand-loader {
  margin-inline: auto;
}

.history-list-status {
  margin: 12px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

.stats-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 16px;
  min-height: 4.5rem;
}

.stats-loading-bar {
  width: min(220px, 70%);
  height: 4px;
  border-radius: 999px;
  background: rgba(22, 101, 52, 0.12);
  overflow: hidden;
}

.stats-loading-bar::after {
  content: "";
  display: block;
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary, #166534);
  animation: stats-loading-slide 1s ease-in-out infinite;
}

.stats-loading .history-list-status {
  margin: 0;
}

.app-brand-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 16px;
  padding: 36px 16px;
  box-sizing: border-box;
}

.app-brand-loader-orb {
  width: 48px;
  height: 48px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  animation: app-brand-loader-pulse 1.35s ease-in-out infinite;
}

.app-brand-loader-ball {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.app-brand-loader-name {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1px;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--primary, #166534);
  line-height: 1;
}

.app-brand-loader-letter {
  display: inline-block;
  transform: translateY(0);
  opacity: 0.45;
  animation: app-brand-loader-wave 1.15s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.07s);
}

.app-brand-loader .history-list-status {
  font-size: 0.8125rem;
}

@keyframes stats-loading-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

@keyframes app-brand-loader-pulse {
  0%,
  100% {
    transform: scale(0.92);
    filter: drop-shadow(0 0 0 rgba(234, 88, 12, 0));
  }
  50% {
    transform: scale(1);
    filter: drop-shadow(0 0 10px rgba(234, 88, 12, 0.35));
  }
}

@keyframes app-brand-loader-wave {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.42;
  }
  40% {
    transform: translateY(-7px);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stats-loading-bar::after {
    animation: none;
    width: 100%;
    opacity: 0.55;
  }

  .app-brand-loader-orb,
  .app-brand-loader-letter {
    animation: none;
  }

  .app-brand-loader-orb {
    transform: none;
    filter: none;
  }

  .app-brand-loader-letter {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .history-group-panel,
  .history-card-body,
  .history-group-chevron {
    transition: none;
  }
}

.home-action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  border-radius: var(--radius-card);
  border: 1.5px solid var(--border-pill);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.home-action-card:hover,
.home-action-card:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(22, 101, 52, 0.12);
  transform: translateY(-1px);
}

.home-action-card--primary {
  border-color: rgba(22, 101, 52, 0.25);
  background: linear-gradient(135deg, #ecfdf3 0%, #fff 100%);
}

.home-action-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex: 0 0 auto;
}

.home-action-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}

.home-action-body strong {
  font-size: 1.0625rem;
  color: var(--text);
}

.home-action-body span:last-child {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.home-action-arrow {
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.teams-placeholder-card {
  margin-top: 0;
}

.teams-placeholder-text {
  margin: 0 0 16px;
  color: var(--text-muted);
  line-height: 1.55;
}

.teams-placeholder-link {
  display: inline-flex;
  width: auto;
  text-decoration: none;
  justify-content: center;
}

.required-mark {
  color: #c0392b;
}

.team-squad-help {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.team-group-tabs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.team-group-tabs .history-group-toggle {
  border-radius: var(--radius-card, 12px);
}

.team-group-players-empty {
  margin: 0;
  padding: 8px 4px;
}

.team-squad-tools {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.team-squad-tools .custom-input[type="search"] {
  margin-bottom: 0;
}

.team-squad-group-section + .team-squad-group-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border, #e5e7eb);
}

.team-squad-group-heading {
  margin: 0 0 10px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.team-squad-player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 0;
}

#team-match-player-list .team-squad-player-list {
  max-height: 260px;
  min-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.team-squad-player-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: var(--surface, #fff);
  cursor: pointer;
}

.team-squad-player-option input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.team-squad-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.team-squad-summary-section {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 14px;
  background: rgba(22, 101, 52, 0.04);
}

.team-squad-selected-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.team-squad-selected-list:not(:empty) + .records-empty {
  display: none;
}

.team-squad-selected-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: var(--surface, #fff);
}

.team-squad-selected-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.team-squad-selected-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.team-squad-remove-btn {
  flex-shrink: 0;
}

.team-squad-search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.team-squad-search-results:not(:empty) {
  margin: 8px 0 10px;
}

.match-squad-add-tools {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border, #e5e7eb);
  gap: 8px;
}

.match-squad-add-tools .player-name-row,
.match-squad-add-tools .player-mobile-row {
  margin-bottom: 0;
}

.team-squad-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: var(--surface, #fff);
}

.team-squad-search-item--selectable {
  cursor: pointer;
}

.team-squad-search-item--selectable:hover,
.team-squad-search-item--selectable:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(22, 101, 52, 0.08);
}

.team-squad-search-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.team-squad-search-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.team-squad-search-added {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
}

.team-squad-list-row {
  cursor: default;
}

.team-names-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.team-names-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 10px;
  align-items: start;
  padding: 14px 0;
  border-top: 1px solid var(--border, #e5e7eb);
}

.team-names-row:first-child {
  border-top: none;
  padding-top: 0;
}

.team-names-row .quick-score-team-name-main {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.team-names-row .quick-score-team-name-label {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  word-break: break-word;
}

.team-names-row .quick-score-team-name-actions {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
}

.team-names-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  grid-column: 1 / -1;
  grid-row: 2;
  width: auto;
  margin-top: 0;
  padding-top: 10px;
  border-top: 1px solid var(--border, #e5e7eb);
}

.team-names-link {
  font-size: 0.8125rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.team-names-link:hover,
.team-names-link:focus-visible {
  text-decoration: underline;
}

@media (max-width: 520px) {
  .team-names-row {
    grid-template-columns: 1fr;
  }

  .team-names-row .quick-score-team-name-actions {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
  }

  .team-names-row .team-names-links {
    grid-row: 3;
  }
}

.team-match-team-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.team-match-team-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: var(--surface, #fff);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

.team-match-team-option strong {
  font-size: 0.9375rem;
}

.team-match-team-option span {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.team-match-team-option.is-selected,
.team-match-team-option:hover,
.team-match-team-option:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(22, 101, 52, 0.08);
}

.teams-stats-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.teams-stats-card .team-squad-help {
  margin: 0;
}

.teams-exit-row {
  margin-top: 8px;
  padding: 0 4px 12px;
}

.teams-create-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.teams-create-card .team-squad-help {
  margin: 0;
}

.teams-create-btn {
  align-self: flex-start;
  text-decoration: none;
  text-align: center;
}

.team-saved-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.team-saved-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.team-saved-row:hover,
.team-saved-row:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(22, 101, 52, 0.08);
}

.team-saved-row-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.team-saved-row-name {
  font-size: 1rem;
  font-weight: 600;
}

.team-saved-row-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.team-saved-row-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 1.125rem;
}

button.team-saved-row {
  width: 100%;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.team-saved-row--live {
  border-color: var(--primary);
}

.team-saved-row--live .home-live-group-banner {
  margin-bottom: 2px;
}

.personal-stats-category {
  margin: 8px 4px 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.personal-stats-category + .card,
.personal-stats-card + .personal-stats-category {
  margin-top: 4px;
}

.personal-stats-card + .card,
.card + .personal-stats-category {
  margin-top: 18px;
}

.teams-page-tabs {
  margin-bottom: 16px;
}

.teams-page-tabs .auth-tab {
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.teams-page-tabs span.auth-tab.is-active {
  pointer-events: none;
}

.player-name-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.add-player-form .login-field {
  margin-bottom: 0;
}

.add-player-form .add-player-search-field {
  margin-bottom: 16px;
}

.add-player-form .phone-row {
  margin-bottom: 0;
}

.add-player-form .player-name-row {
  margin-top: 4px;
}

.player-mobile-row {
  margin-bottom: 16px;
}

.player-mobile-row .phone-code-field,
.player-mobile-row .phone-number-field {
  margin-bottom: 0;
}

.add-player-form .btn-primary {
  margin-top: 4px;
}

.player-list-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.player-list-mobile {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

@media (max-width: 420px) {
  .player-name-row {
    grid-template-columns: 1fr;
  }
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  align-items: stretch;
}

.auth-tab {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.25;
  min-height: 44px;
  height: 100%;
  align-self: stretch;
  box-sizing: border-box;
}

.auth-tab.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.auth-tabs.match-squad-edit-tabs {
  display: flex;
  gap: 16px;
  margin: 0 0 20px;
  align-items: center;
}

.auth-tabs.match-squad-edit-tabs .auth-tab {
  flex: 1;
  min-width: 0;
  padding: 6px 12px;
  min-height: 32px;
  height: auto;
  align-self: auto;
  font-size: 0.8125rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#match-squad-edit-panel-a > .card-heading,
#match-squad-edit-panel-b > .card-heading {
  display: none;
}

#match-squad-edit-panel-a > .team-squad-help,
#match-squad-edit-panel-b > .team-squad-help {
  margin-top: 0;
}

.play-track-setup-team-tabs {
  margin-bottom: 12px;
}

.play-track-setup-team-tabs .auth-tab {
  flex: 1;
}

#play-track-squad-overlay {
  z-index: 2100;
}

.play-track-squad-modal {
  position: relative;
  width: min(560px, 100%);
  max-height: min(90vh, 760px);
  overflow: auto;
}

.play-track-squad-modal .modal-title {
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.play-track-squad-modal .modal-text {
  font-size: 0.8125rem;
  margin-bottom: 12px;
}

.play-track-squad-tabs {
  margin-bottom: 12px;
}

.play-track-squad-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(22, 101, 52, 0.04);
  margin-bottom: 10px;
}

.play-track-squad-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.play-track-squad-box-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.play-track-squad-clear-link {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
}

.play-track-squad-clear-link:hover,
.play-track-squad-clear-link:focus-visible {
  text-decoration: underline;
}

.play-track-squad-clear-link.is-disabled,
.play-track-squad-clear-link:disabled {
  color: var(--text-muted);
  cursor: default;
  text-decoration: none;
  opacity: 0.55;
}

.play-track-squad-box-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.play-track-squad-box-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.play-track-squad-list {
  max-height: calc(6 * 2.75rem);
  overflow-y: auto;
  margin: 0;
  padding-right: 2px;
}

.play-track-squad-player-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.play-track-squad-player-row {
  min-height: 2.5rem;
  padding: 6px 8px;
  font-size: 0.875rem;
  gap: 8px;
}

.play-track-squad-modal .play-track-squad-add-card {
  padding: 0;
  margin-bottom: 10px;
}

.play-track-squad-modal .play-track-squad-add-card .player-name-row {
  grid-template-columns: 1fr;
}

.play-track-squad-footer-actions {
  margin-top: 4px;
}

.play-track-squad-modal .form-error {
  font-size: 0.75rem;
}

.play-track-squad-confirm {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px 18px;
  border-radius: inherit;
  z-index: 3;
  background: rgba(255, 255, 255, 0.72);
}

.play-track-squad-confirm.hidden {
  display: none;
}

.play-track-squad-confirm-card {
  width: min(100%, 280px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 14px 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.play-track-squad-confirm-body {
  display: flex;
  align-items: center;
  gap: 12px;
}

.play-track-squad-confirm-icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-track-squad-confirm-icon svg {
  width: 56px;
  height: 36px;
}

.play-track-squad-confirm-text {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text);
  text-align: left;
}

.play-track-edit-squad-btn {
  margin-top: 0;
  width: 100%;
}

body.play-track-squad-open {
  overflow: hidden;
}

.auth-panel.hidden {
  display: none;
}

.phone-row {
  display: grid;
  grid-template-columns: 5.75rem 1fr;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.phone-row .phone-code-field,
.phone-row .phone-number-field {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.phone-row .phone-code-field {
  position: relative;
  overflow: visible;
}

.phone-row .phone-code-field:has(.phone-code-picker.open),
.phone-row .phone-code-field:has(.phone-code-picker.player-picker--active) {
  z-index: 40;
}

.phone-row .phone-number-field {
  position: relative;
  z-index: 1;
}

.phone-row .team-label {
  min-height: 1.25rem;
}

.phone-row .custom-input {
  height: 44px;
  margin-bottom: 0;
}

.phone-code-display.player-combobox {
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  font-size: 0.875rem;
}

.phone-code-picker.player-picker {
  position: relative;
}

.phone-code-select-native {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}

.phone-code-picker .player-picker-list {
  min-width: max(100%, 7.5rem);
  z-index: 100;
}

.login-page .phone-code-picker.open,
.login-page .phone-code-picker.player-picker--active {
  z-index: 100;
}

.login-phone-suggest {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.login-phone-suggest.hidden {
  display: none;
}

.login-phone-suggest-item {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border-pill);
  border-radius: var(--radius-btn);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.login-phone-suggest-item:hover,
.login-phone-suggest-item:focus-visible {
  border-color: var(--primary);
  background: #f0fdf4;
  outline: none;
}

.otp-input {
  letter-spacing: 0.35em;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
}

.otp-sent-text {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.login-dev-otp {
  margin: 0 0 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: #fef9c3;
  border: 1px solid #fde047;
  color: #713f12;
  font-size: 1.0625rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.08em;
}

.otp-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.verify-email-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.auth-info-panel .card-label,
.auth-info-panel .otp-sent-text,
.auth-info-panel .login-hint,
.auth-info-panel .login-success,
.auth-info-panel .login-error {
  text-align: center;
}

.auth-info-panel > .login-hint:first-of-type {
  margin-top: 0;
}

.verify-email-actions .btn-secondary {
  flex: none;
  width: 100%;
}

.btn-link {
  appearance: none;
  border: none;
  background: none;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.drawer-logout {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 16px;
  color: var(--danger);
  font-size: 1rem;
  font-weight: 500;
}

.admin-live-hero {
  margin-bottom: 12px;
}

.admin-live-subtitle {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.admin-live-card {
  margin-bottom: 16px;
}

.admin-live-empty-title {
  margin: 0 0 8px;
  font-size: 1.0625rem;
  font-weight: 700;
}

.admin-live-empty-text {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.admin-live-owner {
  margin: 0 0 6px;
  font-size: 1.0625rem;
  font-weight: 700;
  text-transform: capitalize;
}

.admin-live-line {
  margin: 0 0 4px;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.admin-live-score {
  margin: 0 0 12px;
  font-size: 1.125rem;
  font-weight: 600;
}

.admin-live-status {
  margin: 0 0 16px;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.admin-live-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Mobile keyboard + scroll-to-error UX */
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
textarea,
select,
.player-combobox {
  font-size: 16px;
  scroll-margin-top: 88px;
  scroll-margin-bottom: calc(160px + var(--keyboard-inset, 0px));
}

@media (max-width: 599px) {
  .main {
    padding-bottom: calc(24px + var(--keyboard-inset, 0px));
  }

  html.keyboard-open body[data-page="home"] .main {
    padding-bottom: calc(48px + var(--keyboard-inset, 0px));
  }
}

.player-picker-list {
  max-height: min(40vh, 240px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

/* Bottom ad slot — reserved space so it never overlays app content */
body.has-ad-bar .app {
  padding-bottom: var(--ad-bar-total-height);
  box-sizing: border-box;
}

body.has-ad-bar .login-shell {
  padding-bottom: calc(48px + var(--ad-bar-total-height));
}

body.has-ad-bar .app-toast {
  bottom: calc(var(--ad-bar-total-height) + 12px);
}

.app-ad-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  height: var(--ad-bar-total-height);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
}

.app-ad-bar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--ad-bar-height);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 12px;
  box-sizing: border-box;
}

.app-ad-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--primary);
  font-size: 1.35rem;
  line-height: 1;
}

.app-ad-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-ad-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.app-ad-title {
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-ad-badge {
  flex-shrink: 0;
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #92400e;
  background: #fef3c7;
  border-radius: 3px;
  padding: 1px 4px;
  line-height: 1.3;
}

.app-ad-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.app-ad-subtitle {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-ad-rating {
  flex-shrink: 0;
  color: #b45309;
  font-weight: 600;
}

.app-ad-cta {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  padding: 7px 16px;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.app-ad-cta:hover {
  background: var(--primary-hover);
}

/* Keyboard covers the bar anyway — hide it so no vertical space is wasted. */
html.keyboard-open .app-ad-bar {
  display: none;
}

html.keyboard-open body.has-ad-bar .app {
  padding-bottom: 0;
}

html.keyboard-open body.has-ad-bar .login-shell {
  padding-bottom: 32px;
}

.app-toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 1200;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 12px;
  background: #1e293b;
  color: #f8fafc;
  font-size: 0.9375rem;
  line-height: 1.45;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
  pointer-events: none;
}

.app-toast.hidden {
  display: none;
}

.app-toast.app-toast--error {
  background: #991b1b;
}

.app-toast.app-toast--syncing {
  background: #0f4c5c;
}

.app-toast.app-toast--syncing::before {
  content: "⟳ ";
}

.login-error:not([hidden]),
.setup-error:not(.hidden),
.player-alert:not(.hidden),
#wicket-form-error:not(.hidden),
#add-player-error:not([hidden]) {
  scroll-margin-top: 96px;
  scroll-margin-bottom: 160px;
}

.drawer-group-label {
  display: block;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.82);
  margin-top: 2px;
}

.group-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.group-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.group-list-item.is-entering {
  animation: group-list-enter 0.45s ease-out;
}

@keyframes group-list-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .group-list-item.is-entering {
    animation: none;
  }
}

.group-list-item:last-child {
  border-bottom: none;
}

.group-list-item.is-active {
  background: #f0fdf4;
  margin: 0 -12px;
  padding: 12px;
  border-radius: 10px;
  border-bottom: none;
}

.group-list-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.group-list-code {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.group-list-access-link {
  display: inline;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.group-list-access-row {
  display: block;
  font-size: 0.8125rem;
  margin-top: 2px;
}

.group-list-owner {
  color: var(--text-muted);
  font-weight: 500;
}

.group-list-access-link:hover,
.group-list-access-link:focus-visible {
  text-decoration: underline;
}

.group-access-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.group-access-item:last-child {
  border-bottom: none;
}

.group-access-name {
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.25;
  flex: 1;
  min-width: 0;
  padding-right: 8px;
}

.group-access-role-editor {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
  width: auto;
}

.group-access-role-select.custom-input,
.group-access-role-select {
  width: 7.5rem;
  min-width: 7.5rem;
  max-width: 7.5rem;
  height: 32px;
  min-height: 32px;
  padding: 0 1.75rem 0 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  border-radius: 999px;
  background-color: #fff;
  border: 1.5px solid var(--border-pill);
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23166534' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 0.75rem;
  color: #166534;
  cursor: pointer;
  flex-shrink: 0;
}

.group-access-role-select.custom-input:focus,
.group-access-role-select:focus {
  border-color: var(--primary);
  outline: none;
}

.group-access-role-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-height: 32px;
  min-width: 7.5rem;
  padding: 0 0.75rem;
  border-radius: 999px;
  background: #f0fdf4;
  color: #166534;
  font-size: 0.8125rem;
  font-weight: 600;
  box-sizing: border-box;
  flex-shrink: 0;
}

.group-access-role-actions {
  display: flex;
  gap: 6px;
  width: auto;
  justify-content: flex-end;
}

.group-access-role-btn {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 0.75rem;
  width: auto;
}

.group-access-scoring-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.group-access-score-link {
  flex: 1 1 140px;
  text-align: center;
  text-decoration: none;
}

.group-access-back-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding: 0 16px;
}

.group-access-leave-btn {
  flex: 0 0 auto;
  width: auto;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.group-access-back-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.group-access-back-link:hover,
.group-access-back-link:focus-visible {
  text-decoration: underline;
}

.group-access-role-note {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.group-access-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.group-access-role-muted {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.group-list-live {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 2px;
}

#group-access-root[aria-busy="true"] > .app-brand-loader,
#group-access-root[aria-busy="true"] .app-brand-loader {
  display: flex;
}

#group-access-root[aria-busy="false"] > .app-brand-loader {
  display: none;
}

body[data-page="group-access"] .drawer-link[data-nav="home"],
body[data-page="group-access"] #header-home-btn {
  display: none !important;
}

.group-select-loading-text {
  margin: 0 0 12px;
  padding: 8px 4px 0;
  color: var(--text-muted);
}

.group-select-loading-shell {
  padding: 8px 4px 16px;
}

.group-select-loading-shell .app-brand-loader {
  padding: 24px 16px 8px;
}

.group-select-skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.group-select-skeleton-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.group-select-skeleton-item:last-child {
  border-bottom: none;
}

.group-select-skeleton-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.group-select-skeleton-line,
.group-select-skeleton-btn {
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06) 0%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.06) 100%
  );
  background-size: 200% 100%;
  animation: groupSelectSkeletonPulse 1.2s ease-in-out infinite;
}

.group-select-skeleton-line {
  height: 14px;
}

.group-select-skeleton-line--title {
  width: min(180px, 70%);
  height: 16px;
}

.group-select-skeleton-line--meta {
  width: min(120px, 45%);
}

.group-select-skeleton-btn {
  flex: 0 0 5.75rem;
  width: 5.75rem;
  height: 34px;
}

body.teams-loading #teams-panels {
  display: none !important;
}

body:not(.teams-loading) #teams-loading {
  display: none !important;
}

.teams-loading-shell {
  padding: 0 4px 16px;
}

.teams-skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.teams-skeleton-row {
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06) 0%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.06) 100%
  );
  background-size: 200% 100%;
  animation: groupSelectSkeletonPulse 1.2s ease-in-out infinite;
}

@keyframes groupSelectSkeletonPulse {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.group-toggle-btn {
  flex: 0 0 5.75rem;
  width: 5.75rem;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 0.8125rem;
  line-height: 1.2;
  white-space: nowrap;
}

.group-form .btn-primary,
.group-form .btn-secondary {
  width: 100%;
  margin-top: 8px;
}

.personal-group-card + .personal-group-card {
  margin-top: 12px;
}

.personal-stats-match-count {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.personal-group-card .records-tabs-wrap {
  margin-top: 4px;
}

.live-score-card {
  width: 100%;
  text-align: left;
  cursor: pointer;
  border: none;
  font: inherit;
}

.live-score-card .home-action-body,
.live-score-card.home-live-card .home-action-body {
  align-items: flex-start;
  text-align: left;
}

#live-scores-list.home-live-groups {
  align-items: stretch;
  text-align: left;
  width: 100%;
}

.home-actions.hidden {
  display: none !important;
}

body[data-page="home"] .page-banner--home.hidden,
body[data-page="home"] .tagline.hidden {
  display: none !important;
}

html.home-live-view-boot body[data-page="home"] .home-actions,
html.home-live-view-boot body[data-page="home"] .page-banner--home,
html.home-live-view-boot body[data-page="home"] .tagline {
  display: none !important;
}

html.home-live-view-boot body[data-page="home"] #home-live-section {
  display: flex !important;
}

.home-live-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  text-align: left;
  width: 100%;
}

.home-live-section.hidden {
  display: none !important;
}

.home-section-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
  text-align: left;
  align-self: flex-start;
}

.home-live-groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

.home-live-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  align-items: stretch;
}

.home-live-group-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  font-size: 0.9375rem;
  color: var(--text-muted);
  text-align: left;
}

.home-live-group-icon {
  font-size: 1.125rem;
  line-height: 1;
}

.home-live-group-cards {
  display: grid;
  gap: 12px;
  width: 100%;
}

.home-live-card {
  align-items: center;
  width: 100%;
  text-align: left;
  cursor: pointer;
  border: none;
  font: inherit;
  justify-content: flex-start;
}

.home-live-card .home-action-body {
  align-items: flex-start;
  text-align: left;
}

.home-live-group-banner {
  display: inline-block;
  align-self: flex-start;
  max-width: 100%;
  margin-bottom: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(22, 101, 52, 0.1);
  color: var(--primary);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-scores-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 16px 24px;
  gap: 8px;
  min-height: 240px;
}

.live-scores-empty.hidden {
  display: none !important;
}

body.live-scores-loading .live-scores-empty {
  display: none !important;
}

.live-scores-loading-text {
  margin: 0;
  padding: 8px 4px 16px;
}

.live-scores-empty-gif {
  display: block;
  max-width: min(280px, 100%);
  width: 100%;
  margin: 0 auto 4px;
  border-radius: 16px;
  overflow: hidden;
  flex-shrink: 0;
}

.live-scores-empty-gif svg {
  display: block;
  width: 100%;
  height: auto;
}

@keyframes liveSleepFloatZ {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-8px);
  }
}

@keyframes liveSleepBreathe {
  0%,
  100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(1.03);
  }
}

@keyframes liveSleepTwinkle {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

.live-scores-empty-gif .live-sleep-zzz {
  animation: liveSleepFloatZ 2.4s ease-in-out infinite;
}

.live-scores-empty-gif .live-sleep-zzz--delay {
  animation-delay: 0.8s;
}

.live-scores-empty-gif .live-sleep-zzz--delay2 {
  animation-delay: 1.2s;
}

.live-scores-empty-gif .live-sleep-breath {
  animation: liveSleepBreathe 3s ease-in-out infinite;
  transform-origin: center bottom;
  transform-box: fill-box;
}

.live-scores-empty-gif .live-sleep-star {
  animation: liveSleepTwinkle 2s ease-in-out infinite;
}

.live-scores-empty-gif .live-sleep-star--delay {
  animation-delay: 1s;
}

.live-scores-empty-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.live-scores-empty-text {
  margin: 0;
  max-width: 22rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* ---------- CricFuego Pro: trial welcome, paywall, profile ---------- */

body.pro-modal-open {
  overflow: hidden;
}

.pro-modal {
  max-width: 380px;
  text-align: center;
}

.pro-modal .modal-title,
.pro-modal .modal-text {
  text-align: center;
}

.pro-modal-badge {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  background: linear-gradient(135deg, #16a34a, #065f46);
  color: #fff;
}

.pro-modal-note {
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
}

.pro-modal-price {
  margin: 4px 0 12px;
  font-size: 1.5rem;
  font-weight: 800;
  color: #16a34a;
}

.pro-feature-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  text-align: left;
  display: grid;
  gap: 8px;
}

.pro-feature-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.pro-feature-list li span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
  font-size: 0.8125rem;
  font-weight: 800;
}

.pro-modal-actions {
  display: flex;
  gap: 10px;
}

.pro-modal-actions .btn-primary,
.pro-modal-actions .btn-secondary {
  flex: 1;
  margin-top: 0;
  min-height: 46px;
}

body.pro-locked .main > *:not(.pro-locked-panel) {
  display: none !important;
}

.pro-locked-panel {
  text-align: center;
}

.pro-locked-panel h2 {
  margin: 0 0 8px;
  font-size: 1.125rem;
  font-weight: 800;
}

.pro-locked-panel p {
  margin: 0 0 16px;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

body.pro-no-ads .app-ad-bar {
  display: none !important;
}

/* Profile page */

#profile-form .login-field {
  margin-bottom: 14px;
}

#profile-plan-card .card-title {
  margin: 0 0 8px;
  font-size: 1.0625rem;
  font-weight: 800;
}

#profile-plan-status {
  margin: 0 0 14px;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.profile-card-actions {
  margin-top: 18px;
}

.profile-details {
  margin: 0;
  display: grid;
  gap: 14px;
}

.profile-detail-row {
  margin: 0;
}

.profile-detail-row dt {
  margin: 0 0 4px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.profile-detail-row dd {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}
