:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #122033;
  --muted: #61738d;
  --line: #dfe7f3;
  --green: #1f9d62;
  --green-dark: #157a4f;
  --white: #ffffff;
  --gold: #f0b429;
  --red: #c8414e;
  --chart-mean: #2563eb;
  --chart-median: #c2660c;
  --shadow: 0 10px 30px rgba(18, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #ecf3ff 0%, var(--bg) 100%);
  color: var(--ink);
}

body {
  min-height: 100vh;
}

button, input {
  font: inherit;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.hamburger-btn {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 0 12px;
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(18, 32, 51, 0.08);
}

.hamburger-btn span {
  display: block;
  width: 100%;
  height: 3px;
  background: var(--ink);
  border-radius: 999px;
}

.menu-panel {
  position: absolute;
  top: 56px;
  left: 0;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(18, 32, 51, 0.14);
  z-index: 20;
}

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

.menu-panel a {
  color: var(--ink);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 700;
}

.menu-panel a:hover {
  background: #f3f6fb;
}

.menu-panel a.disabled-link {
  color: #8a98ae;
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.menu-panel a.disabled-link:hover {
  background: transparent;
}

.menu-divider {
  height: 1px;
  background: var(--line);
  margin: 6px 4px;
}

.profile-value {
  margin: 4px 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.profile-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.profile-name-row .profile-value {
  margin: 0;
}

.password-update-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.password-update-row .inline-input {
  flex: 1;
  min-width: 160px;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
}

.game-toggle-btn,
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.stage-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.game-toggle-btn {
  background: #1f9d62;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(31, 157, 98, 0.2);
}

.primary-btn {
  background: #123b66;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(18, 59, 102, 0.18);
}

.game-toggle-btn:hover,
.primary-btn:hover {
  transform: translateY(-1px);
}

.game-toggle-btn:active,
.primary-btn:active {
  transform: translateY(0);
}

.game-toggle-btn.resume {
  background: #0f6c56;
}

.game-toggle-btn.ended {
  background: var(--red);
  color: #ffffff;
  cursor: not-allowed;
  opacity: 0.85;
  box-shadow: none;
}

.game-toggle-btn.ended:hover,
.game-toggle-btn.ended:active {
  transform: none;
}

.end-quarter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d7b6bb;
  border-radius: 12px;
  background: #fff5f5;
  color: #8a2831;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.end-quarter-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #ffe9ea;
}

.end-quarter-btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.game-countdown-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.game-countdown-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.game-countdown {
  font-size: 60px;
  line-height: 1;
  font-weight: 800;
  color: #e6949b;
  font-variant-numeric: tabular-nums;
}

.game-form-panel {
  margin-bottom: 22px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.game-form {
  display: flex;
  gap: 16px;
  align-items: end;
  flex-wrap: wrap;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}

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

.field-group input,
.field-group select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  background: #ffffff;
}

.date-group {
  min-width: 280px;
}

.date-selects {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.game-meta-label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.page-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.auth-card {
  width: min(440px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.auth-card h1 {
  margin-bottom: 10px;
}

.auth-logo {
  display: block;
  max-width: 260px;
  width: 100%;
  height: auto;
  margin: 0 auto 20px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

.auth-form .field-group {
  width: 100%;
}

.auth-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.auth-links {
  margin-top: 16px;
  text-align: center;
  color: var(--muted);
}

.auth-links a {
  color: #123b66;
  font-weight: 700;
  text-decoration: none;
}

.auth-message {
  margin-top: 14px;
  min-height: 22px;
  font-size: 0.9rem;
  font-weight: 700;
}

.auth-message.error {
  color: var(--red);
}

.auth-message.success {
  color: var(--green-dark);
}

.content-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 220px;
  text-align: center;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 20px;
}

.empty-state p {
  margin: 0;
  max-width: 420px;
  line-height: 1.5;
}

.game-history-footer {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.roster-chart-card {
  padding: 18px 20px 10px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fbff;
}

.chart-header h2 {
  margin-bottom: 14px;
  font-size: 1.1rem;
}

.chart-layout {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.roster-pie-chart {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
}

.chart-legend {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
  flex: 1;
}

.chart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.chart-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chart-label {
  flex: 1;
  min-width: 0;
}

.chart-value {
  color: var(--muted);
  font-weight: 700;
}

.chart-empty {
  color: var(--muted);
  font-weight: 700;
}

.goal-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.goal-bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 160px) 1fr 28px;
  align-items: center;
  gap: 10px;
}

.goal-bar-label {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.goal-bar-track {
  height: 14px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}

.goal-bar-fill {
  height: 100%;
  min-width: 4px;
  border-radius: 999px;
  background: var(--gold);
  transition: width 0.3s ease;
}

.goal-bar-value {
  text-align: right;
  font-weight: 700;
  color: var(--muted);
}

.average-chart {
  padding: 4px 4px 0;
}

.average-chart-plot {
  position: relative;
  width: 100%;
}

.average-chart-bars {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  height: 100%;
  padding: 0 4px;
}

.average-chart-bar-wrap {
  flex: 1 1 0;
  min-width: 0;
  max-width: 64px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 100%;
}

.average-chart-bar {
  position: relative;
  width: 28px;
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  transition: height 0.3s ease;
}

.average-chart-value {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.average-chart-line {
  position: absolute;
  left: 4px;
  right: 4px;
  z-index: 1;
  border-top: 2px dashed;
}

.average-chart-line--mean {
  border-top-color: color-mix(in srgb, var(--chart-mean) 50%, white 50%);
}

.average-chart-line--median {
  border-top-color: color-mix(in srgb, var(--chart-median) 50%, white 50%);
}

.average-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}

.average-chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.average-chart-legend-swatch {
  display: inline-block;
  width: 18px;
  height: 0;
  border-top: 2px dashed;
}

.average-chart-legend-item--mean .average-chart-legend-swatch {
  border-top-color: var(--chart-mean);
}

.average-chart-legend-item--median .average-chart-legend-swatch {
  border-top-color: var(--chart-median);
}

.average-chart-legend-value {
  color: var(--muted);
  font-weight: 700;
}

.average-chart-names {
  display: flex;
  gap: 16px;
  padding: 0 4px;
  width: 100%;
  margin-top: 8px;
}

.average-chart-name-wrap {
  flex: 1 1 0;
  min-width: 0;
  max-width: 64px;
  position: relative;
  height: 100%;
}

.average-chart-name {
  position: absolute;
  top: 4px;
  right: 50%;
  transform-origin: top right;
  transform: rotate(-45deg);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.roster-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.page-header {
  margin-bottom: 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.secondary-btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #dfeeff;
  color: var(--ink);
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

 a.secondary-btn,
 a.secondary-btn:hover,
 a.secondary-btn:visited,
 a.secondary-btn:active {
  text-decoration: none;
 }

.bug-report-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #ffffff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(18, 32, 51, 0.18);
  cursor: pointer;
  z-index: 45;
  transition: transform 0.15s ease, color 0.15s ease;
}

.bug-report-btn:hover {
  transform: translateY(-2px);
  color: var(--red);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 32, 51, 0.45);
}

.modal-dialog {
  position: relative;
  width: min(460px, calc(100vw - 32px));
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.icon-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 32px;
  height: 32px;
  background: #ffffff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.player-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view-toggle {
  position: relative;
  display: flex;
  background: #eaf1fb;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
}

.view-toggle-option {
  position: relative;
  z-index: 1;
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
  transition: color 0.2s ease;
}

.view-toggle-option.active {
  color: #ffffff;
}

.view-toggle-slider {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: #123b66;
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(18, 59, 102, 0.25);
  transition: transform 0.2s ease;
}

.view-toggle[data-active="join"] .view-toggle-slider {
  transform: translateX(100%);
}

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

.hidden {
  display: none !important;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  white-space: nowrap;
}

.small-btn {
  padding: 8px 12px;
  font-size: 0.8rem;
}

.danger-btn {
  border: 1px solid #d7b6bb;
  border-radius: 10px;
  background: #fff5f5;
  color: #8a2831;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.inline-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.team-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #ffffff;
}

.team-row-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px 10px 18px;
}

.team-row-name-btn {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 6px 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.team-row-name-btn:hover .team-row-name {
  text-decoration: underline;
}

.team-row-name {
  font-weight: 700;
  color: var(--ink);
}

.team-row-summary-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.team-row-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
}

.team-row-toggle:hover {
  background: #f5f8fc;
}

.team-row-chevron {
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.team-row[data-expanded="true"] .team-row-chevron {
  transform: rotate(180deg);
}

.team-row-details {
  display: grid;
  grid-template-rows: 0fr;
  min-height: 0;
  transition: grid-template-rows 0.2s ease;
}

.team-row[data-expanded="true"] .team-row-details {
  grid-template-rows: 1fr;
}

.team-row-details-inner {
  min-height: 0;
  overflow: hidden;
}

.team-row-details .field-group,
.team-row-details .team-row-stats,
.team-row-details .row-actions {
  padding: 0 18px 16px;
}

.team-row-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.team-row-details .row-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

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

.game-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #ffffff;
}

.game-row-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px 10px 18px;
}

.game-row-name-btn {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 6px 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.game-row-name-btn:hover .game-row-name {
  text-decoration: underline;
}

.game-row-name {
  font-weight: 700;
  color: var(--ink);
}

.game-row-summary-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.game-status-badge {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.game-status-badge--active {
  background: rgba(31, 157, 98, 0.12);
  color: var(--green-dark);
  border: 1px solid rgba(31, 157, 98, 0.15);
}

.game-status-badge--ended {
  background: rgba(200, 65, 78, 0.1);
  color: var(--red);
  border: 1px solid rgba(200, 65, 78, 0.15);
}

.game-status-badge--paused {
  background: rgba(240, 180, 41, 0.18);
  color: #8a5a00;
  border: 1px solid rgba(240, 180, 41, 0.35);
}

.game-row-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
}

.game-row-toggle:hover {
  background: #f5f8fc;
}

.game-row-chevron {
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.game-row[data-expanded="true"] .game-row-chevron {
  transform: rotate(180deg);
}

.game-row-details {
  display: grid;
  grid-template-rows: 0fr;
  min-height: 0;
  transition: grid-template-rows 0.2s ease;
}

.game-row[data-expanded="true"] .game-row-details {
  grid-template-rows: 1fr;
}

.game-row-details-inner {
  min-height: 0;
  overflow: hidden;
}

.game-row-details .field-group,
.game-row-details .game-row-info,
.game-row-details .row-actions {
  padding: 0 18px 16px;
}

.game-row-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.game-row-info-item {
  display: flex;
  gap: 8px;
  font-size: 14px;
}

.game-row-info-label {
  color: var(--muted);
  min-width: 70px;
  font-weight: 600;
}

.game-row-details .row-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.data-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

.data-table--fit {
  min-width: 0;
}

.name-edit-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.name-edit-fields .inline-input {
  min-width: 0;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.data-table th {
  background: #f5f8fc;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

.sort-btn {
  border: none;
  background: transparent;
  padding: 2px 4px;
  margin-left: 4px;
  cursor: pointer;
  border-radius: 6px;
  line-height: 1;
  vertical-align: middle;
}

.sort-btn:hover {
  background: rgba(18, 32, 51, 0.08);
}

.sort-arrow {
  font-size: 11px;
  color: #a3b1c6;
}

.sort-arrow.active {
  color: var(--ink);
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--muted);
}

.game-name-label {
  margin-top: 6px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}

.game-id-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 24px;
}

.roster-panel {
  order: 2;
}

.stage-panel {
  order: 1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  min-height: 500px;
}

.player-card,
.stage-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 30px;
  height: 30px;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f8fc;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.drag-handle:hover {
  background: rgba(18, 32, 51, 0.06);
  border-color: #b7c9ea;
  color: var(--ink);
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-source-active {
  opacity: 0.35;
}

.drag-ghost {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.04);
  box-shadow: 0 16px 32px rgba(18, 32, 51, 0.28);
  opacity: 0.96;
}

.drag-target-active {
  outline: 3px dashed rgba(31, 157, 98, 0.6);
  outline-offset: -3px;
}

.player-card:hover,
.stage-player:hover {
  transform: translateY(-1px);
  border-color: #b7c9ea;
  box-shadow: 0 8px 18px rgba(18, 32, 51, 0.05);
}

.player-card.active {
  border-color: rgba(31, 157, 98, 0.5);
  background: #ecfaf3;
}

.player-card.play-low,
.stage-player.play-low {
  background: #fdecec;
}

.player-card.play-medium,
.stage-player.play-medium {
  background: #fff2e3;
}

.stage-player {
  background: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 22px rgba(11, 45, 31, 0.18);
}

.stage-player .status-pill.active {
  background: #dff7ea;
  color: #0d5d38;
}

.stage-player.paused {
  opacity: 0.5;
}

.player-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-name {
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-pill.inactive {
  background: #eef2f7;
  color: var(--muted);
}

.status-pill.active {
  background: rgba(31, 157, 98, 0.12);
  color: var(--green-dark);
}

.time-box {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.metric-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.time-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.time-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stage-panel {
  display: flex;
  flex-direction: column;
  min-height: 500px;
}

.stage {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-content: flex-start;
  padding: 20px;
  min-height: 420px;
  background:
    linear-gradient(90deg, transparent 0%, transparent 12%, rgba(255,255,255,0.18) 12%, rgba(255,255,255,0.18) 12.5%, transparent 12.5%, transparent 87.5%, rgba(255,255,255,0.18) 87.5%, rgba(255,255,255,0.18) 88%, transparent 88%, transparent 100%),
    linear-gradient(180deg, transparent 0%, transparent 18%, rgba(255,255,255,0.1) 18%, rgba(255,255,255,0.1) 18.5%, transparent 18.5%, transparent 81.5%, rgba(255,255,255,0.1) 81.5%, rgba(255,255,255,0.1) 82%, transparent 82%, transparent 100%),
    linear-gradient(90deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.12) 2%, transparent 2%, transparent 98%, rgba(255,255,255,0.12) 98%, rgba(255,255,255,0.12) 100%),
    linear-gradient(180deg, #2a9b5d 0%, #1d7f49 100%);
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%;
  border-radius: 0 0 18px 18px;
  overflow: hidden;
}

.stage::before,
.stage::after {
  content: "";
  position: absolute;
  inset: 18px;
  pointer-events: none;
}

.stage::before {
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 14px;
  border-left: 3px solid rgba(255, 255, 255, 0.8);
  border-right: 3px solid rgba(255, 255, 255, 0.8);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.12);
}

.stage::after {
  left: 50%;
  top: 18px;
  bottom: 18px;
  width: 0;
  border-left: 3px solid rgba(255, 255, 255, 0.8);
  transform: translateX(-50%);
}

.stage.is-empty {
  align-items: center;
  justify-content: center;
}

.quarter-progress {
  display: flex;
  gap: 8px;
  padding: 14px 20px 20px;
}

.quarter-segment {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f3f6fb;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.quarter-segment--active {
  background: rgba(31, 157, 98, 0.14);
  border-color: rgba(31, 157, 98, 0.4);
  color: var(--green-dark);
  box-shadow: 0 0 0 2px rgba(31, 157, 98, 0.12);
}

.quarter-segment--paused {
  background: rgba(240, 180, 41, 0.18);
  border-color: rgba(240, 180, 41, 0.45);
  color: #8a5a00;
}

.quarter-segment--completed {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  width: 100%;
  border: 2px dashed rgba(18, 32, 51, 0.2);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.25);
}

.empty-state-paused {
  color: var(--red);
}

.stage-player {
  min-width: 180px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(18, 32, 51, 0.08);
}

.goal-btn {
  flex: none;
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.goal-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(240, 180, 41, 0.45);
}

.goal-btn:active {
  transform: translateY(0);
}

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

.stars-btn {
  flex: none;
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  background: var(--green);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.stars-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(31, 157, 98, 0.45);
}

.stars-btn:active {
  transform: translateY(0);
}

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

.scoreboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 20px 12px;
}

.scoreboard.hidden {
  display: none;
}

.scoreboard-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.scoreboard-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.scorer-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  background: rgba(240, 180, 41, 0.16);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.scorer-pill:hover {
  background: rgba(240, 180, 41, 0.3);
  transform: translateY(-1px);
}

.scorer-pill .scorer-count {
  color: var(--green-dark);
}

.stars-tally-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  background: rgba(31, 157, 98, 0.14);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.stars-tally-pill:hover {
  background: rgba(31, 157, 98, 0.28);
  transform: translateY(-1px);
}

.stars-tally-star {
  color: var(--gold);
  font-size: 12px;
}

.stars-tally-count {
  color: var(--green-dark);
}

.stars-explosion {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  z-index: 1000;
  pointer-events: none;
}

.stars-explosion-particle {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--gold);
  font-size: 28px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
  animation: stars-explosion-burst 0.7s ease-out forwards;
}

@keyframes stars-explosion-burst {
  0% {
    transform: translate(-50%, -50%) scale(0.3) rotate(0deg);
    opacity: 1;
  }
  60% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.15) rotate(var(--rot));
    opacity: 0;
  }
}

.popup-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 1000;
  border-radius: 18px;
  background: rgba(18, 32, 51, 0.92);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.popup-overlay.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.goal-popup {
  padding: 24px 40px;
  color: var(--gold);
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.03em;
  text-align: center;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.confirm-popup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 28px 32px;
  max-width: min(90vw, 360px);
}

.confirm-popup.visible {
  pointer-events: auto;
}

.confirm-popup-message {
  margin: 0;
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
}

.confirm-popup-actions {
  display: flex;
  gap: 12px;
}

.confirm-btn {
  padding: 8px 24px;
  border: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.confirm-btn:hover {
  transform: translateY(-1px);
}

.confirm-btn:active {
  transform: translateY(0);
}

.confirm-yes {
  background: var(--green);
  color: #ffffff;
}

.confirm-no {
  background: var(--red);
  color: #ffffff;
}

.stars-popup {
  max-width: min(90vw, 320px);
}

.stars-popup-fields {
  display: flex;
  gap: 16px;
  width: 100%;
}

.stars-popup-field {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
}

.stars-popup-field-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.stars-popup-select {
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.stars-popup-select-stars {
  color: var(--gold);
  font-size: 16px;
  letter-spacing: 0.1em;
}

.stars-popup-placeholder-option {
  font-style: italic;
}

.stars-popup-select--placeholder {
  font-style: italic;
}

.manage-bench-btn {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.manage-bench-popup {
  width: min(90vw, 420px);
}

.manage-bench-popup-title {
  margin: 0;
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
}

.manage-bench-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.manage-bench-list {
  width: 100%;
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.manage-bench-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.manage-bench-row-name {
  flex: 1;
  min-width: 0;
}

.manage-bench-checkbox {
  flex: none;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.stars-popup-error {
  margin: 0;
  color: var(--red);
  background: rgba(255, 255, 255, 0.9);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

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

@media (max-width: 600px) {
  .page-shell,
  .app-shell {
    padding: 14px;
  }

  h1 {
    font-size: clamp(1.5rem, 7vw, 2rem);
  }

  .header-actions {
    width: 100%;
  }

  .header-actions .primary-btn,
  .header-actions .secondary-btn {
    width: 100%;
  }

  .content-panel {
    padding: 14px;
  }

  .modal-dialog {
    padding: 18px;
  }

  .stage-header .game-toggle-btn {
    width: 100%;
  }
}
