:root {
  --bg: #f4efe4;
  --panel: rgba(255, 251, 245, 0.92);
  --panel-strong: #fff9ef;
  --ink: #16231f;
  --muted: #5f6f68;
  --line: rgba(22, 35, 31, 0.12);
  --brand: #dd5f2f;
  --brand-deep: #b1441c;
  --accent: #0d8b6f;
  --accent-soft: rgba(13, 139, 111, 0.12);
  --shadow: 0 22px 50px rgba(70, 43, 13, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

.is-hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(221, 95, 47, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(13, 139, 111, 0.18), transparent 24%),
    linear-gradient(180deg, #efe3cb 0%, var(--bg) 42%, #e6f1ec 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.82rem 1.2rem;
  background: var(--brand);
  color: #fffdf8;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--brand-deep);
}

.ghost-button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.ghost-button:hover {
  background: rgba(22, 35, 31, 0.05);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.82rem 0.9rem;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 0.45rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.page-shell {
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

/* ── Gate / Landing page ── */
.gate-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  background: rgba(255, 251, 245, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  padding: 2.5rem 2.8rem;
  width: min(420px, 100%);
}

.gate-logo {
  width: 220px;
  height: 220px;
  object-fit: contain;
}

.gate-brand {
  display: grid;
  gap: 0.2rem;
}

.gate-brand .brand-name {
  font-size: clamp(2rem, 8vw, 3rem);
}

.gate-form {
  width: 100%;
  display: grid;
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.gate-label {
  width: 100%;
  text-align: left;
}

.gate-enter-button {
  width: 100%;
  padding: 0.9rem;
  font-size: 1rem;
}

.gate-error {
  width: 100%;
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: rgba(221, 95, 47, 0.12);
  border: 1px solid rgba(221, 95, 47, 0.25);
  color: var(--brand-deep);
  font-size: 0.9rem;
  text-align: left;
}

.gate-footer-copy {
  margin: 0.25rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

/* ── Inline link button ── */
.link-button {
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  color: var(--accent);
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-button:hover {
  background: none;
  transform: none;
  color: var(--brand);
}

/* ── Auth visitor label ── */
.auth-visitor-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.hero {
  display: flex;
  align-items: center;
  margin-bottom: 0.35rem;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-home-button {
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  justify-content: flex-start;
}

.brand-home-button:hover {
  transform: none;
  background: transparent;
}

.brand-logo {
  width: 180px;
  height: 180px;
  object-fit: contain;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.brand-text {
  display: grid;
  gap: 0.25rem;
}

.brand-name {
  margin: 0;
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1;
  text-transform: uppercase;
}

.eyebrow,
.section-tag {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  color: var(--accent);
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 0;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.nav-button {
  background: none;
  color: var(--ink);
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 0.5rem 0.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: color 160ms ease, border-color 160ms ease;
}

.nav-button:hover {
  color: var(--brand);
  border-bottom-color: var(--brand);
  transform: none;
  background: none;
}

.nav-button.active {
  background: none;
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.nav-button.is-locked::after {
  content: " Locked";
  font-size: 0.8em;
}

.auth-status {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 950;
}

.profile-menu {
  position: relative;
}

.profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ink);
  color: #fffdf8;
  border: none;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: box-shadow 160ms ease;
}

.profile-avatar:hover {
  box-shadow: 0 0 0 3px var(--accent-soft);
  transform: none;
  background: var(--ink);
}

.profile-avatar-guest {
  background: var(--muted);
  color: #fffdf8;
}

.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(70, 43, 13, 0.15);
  padding: 0.85rem 1rem;
  min-width: 200px;
  z-index: 900;
}

.profile-dropdown-name {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
}

.profile-dropdown-email {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.profile-dropdown-role {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  color: var(--accent);
  text-transform: capitalize;
}

.profile-dropdown-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0.65rem 0;
}

.profile-dropdown-signout {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  color: var(--brand);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.profile-dropdown-signout:hover {
  background: none;
  transform: none;
  color: var(--brand-deep);
  text-decoration: underline;
}

.page-view.is-hidden {
  display: none;
}

/* ── Collapsible panels ── */
.collapsible-toggle {
  cursor: pointer;
  user-select: none;
}

.collapsible-toggle:hover h2 {
  color: var(--accent);
}

.collapse-chevron {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform 250ms ease;
}

.collapse-chevron::before {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  margin: 4px auto 0;
  border-right: 2.5px solid var(--muted);
  border-bottom: 2.5px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 250ms ease;
}

.collapsible.is-collapsed .collapse-chevron::before {
  transform: rotate(-45deg);
  margin-top: 6px;
}

.collapsible-body {
  overflow: visible;
  transition: max-height 300ms ease, opacity 200ms ease;
  max-height: none;
  opacity: 1;
}

.collapsible.is-collapsed > .collapsible-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

#editorView {
  align-items: start;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 1.35rem;
}

.span-12 { grid-column: span 12; }
.span-7 { grid-column: span 7; }
.span-5 { grid-column: span 5; }

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-heading h2 {
  margin: 0.18rem 0 0;
  font-size: 1.55rem;
}

.inline-form,
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.stack-form {
  display: grid;
  gap: 0.9rem;
}

.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.team-card,
.list-card,
.game-card,
.stats-panel,
.auth-card {
  border-radius: 22px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.team-card {
  padding: 1rem;
}

.team-card > .roster-list {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 2px solid var(--line);
}

.team-card-header,
.roster-row,
.schedule-card-header,
.stats-topline,
.award-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.team-logo {
  display: block;
  height: 135px;
  width: auto;
  margin: 0.5rem auto 0.25rem;
}

.team-name,
.list-card h3,
.game-card h3 {
  margin: 0;
}

.team-meta,
.meta-line,
.score-line,
.empty-copy {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.roster-list,
.card-list,
.schedule-board,
.stats-groups {
  display: grid;
  gap: 0.85rem;
}

.roster-row {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.roster-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.player-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.player-actions select {
  min-width: 132px;
}

.list-card,
.game-card,
.stats-panel {
  padding: 1rem;
}

.tournament-edit-form {
  display: grid;
  gap: 0.85rem;
}

.game-edit-form {
  display: grid;
  gap: 0.85rem;
}

.team-overview-card {
  gap: 0.85rem;
}

.player-stat-row {
  align-items: flex-start;
}

.team-totals-row {
  background: var(--surface-raised, rgba(22, 35, 31, 0.04));
  border-radius: 0.4rem;
  padding: 0.45rem 0.6rem;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.team-totals-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted, #6b7c74);
}

.editor-player-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.35rem 0.75rem;
  align-items: center;
}

.editor-player-copy {
  grid-column: 1;
  grid-row: 1;
}

.editor-player-actions {
  display: contents;
}

.editor-player-actions select {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
}

.editor-player-buttons {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  gap: 0.35rem;
  white-space: nowrap;
}

.editor-player-buttons button {
  white-space: nowrap;
  padding: 0.5rem 0.7rem;
  font-size: 0.82rem;
}

.manual-stat-editor {
  display: grid;
  gap: 0.85rem;
  padding: 0.9rem 0 0.2rem;
  border-bottom: 1px solid var(--line);
}

.manual-stat-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.stat-choice-button {
  white-space: nowrap;
}

.stat-choice-button.active {
  background: var(--ink);
  color: #fffdf8;
}

.manual-stat-entry {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  flex-wrap: wrap;
}

.manual-stat-entry label {
  max-width: 220px;
  flex: 1 1 180px;
}

.manual-stat-entry .player-actions {
  flex-wrap: wrap;
}

.player-stat-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.player-stat-summary span {
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: rgba(13, 139, 111, 0.1);
  color: var(--ink);
  font-size: 0.82rem;
}

.home-game-list,
.home-stat-list {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.85rem;
}

.auth-panel {
  display: grid;
  gap: 1rem;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.admin-account-form {
  display: grid;
  gap: 0.9rem;
}

.auth-card h3 {
  margin: 0.2rem 0 0;
}

.auth-notice {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: rgba(221, 95, 47, 0.12);
  border: 1px solid rgba(221, 95, 47, 0.24);
  color: var(--brand-deep);
}

.auth-notice.is-hidden {
  display: none;
}

.home-game-line {
  display: grid;
  gap: 0.15rem;
  padding: 0.8rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.home-game-line span {
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-summary-card {
  gap: 0.9rem;
}

.leader-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.leader-grid p {
  margin: 0;
  padding: 0.75rem;
  border-radius: 14px;
  background: rgba(13, 139, 111, 0.08);
}

.leader-grid strong,
.leader-grid span {
  display: inline;
}

.leader-grid strong {
  font-size: 1.25rem;
  margin-right: 0.35rem;
}

.leader-grid span {
  color: var(--muted);
  font-size: 0.85rem;
}

.list-card.active {
  outline: 2px solid var(--accent);
  background: #f5fff9;
}

.schedule-board {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.game-card {
  position: relative;
  overflow: hidden;
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, var(--brand), var(--accent));
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.82rem;
  background: var(--accent-soft);
  color: var(--accent);
}

.stats-editor.empty-state {
  padding: 2rem;
  border: 1px dashed var(--line);
  border-radius: 18px;
  text-align: center;
  color: var(--muted);
}

.stats-panel {
  display: grid;
  gap: 1rem;
}

.stats-groups {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.stat-player-row {
  display: grid;
  grid-template-columns: 1.6fr 0.7fr 0.7fr;
  gap: 0.6rem;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.stat-player-row:last-child {
  border-bottom: 0;
}

.stat-grid-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.filter-label {
  min-width: 220px;
}

/* ── Table scroll wrapper (mobile horizontal scroll) ── */
.table-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Standings table ── */
.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

.standings-table th,
.standings-table td {
  padding: 0.65rem 0.75rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.standings-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 500;
}

.standings-table td:first-child,
.standings-table th:first-child {
  text-align: left;
}

.standings-table tbody tr:last-child td {
  border-bottom: 0;
}

.standings-table tbody tr:hover td {
  background: rgba(13, 139, 111, 0.04);
}

.standings-pts {
  font-weight: 700;
  color: var(--accent);
}

/* ── Leaderboard table ── */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 0.65rem 0.75rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.leaderboard-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 500;
}

.leaderboard-table td:nth-child(2),
.leaderboard-table td:nth-child(3),
.leaderboard-table th:nth-child(2),
.leaderboard-table th:nth-child(3) {
  text-align: left;
}

.leaderboard-table tbody tr:last-child td {
  border-bottom: 0;
}

.leaderboard-table tbody tr:hover td {
  background: rgba(13, 139, 111, 0.04);
}

.leaderboard-rank {
  color: var(--muted);
  font-size: 0.82rem;
}

.leaderboard-rank.top-three {
  color: var(--brand);
  font-weight: 700;
}

/* ── Rules grid ── */
.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.rules-card {
  padding: 1.2rem 1.3rem;
}

.rules-card h3 {
  margin: 0.2rem 0 0.85rem;
}

.rules-list {
  margin: 0;
  padding: 0 0 0 1.15rem;
  display: grid;
  gap: 0.55rem;
  color: var(--ink);
  font-size: 0.93rem;
  line-height: 1.55;
}

.rules-list li::marker {
  color: var(--accent);
}

.rules-content h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
  color: var(--ink);
}

.rules-content h3:first-child {
  margin-top: 0;
}

.rules-content p {
  margin: 0.4rem 0;
  color: var(--ink);
  font-size: 0.93rem;
  line-height: 1.55;
}

.rules-editor-box {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.rules-editor-textarea {
  background: #fff;
  width: 100%;
  min-height: 300px;
  padding: 0.85rem 1rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
  box-sizing: border-box;
}

.rules-editor-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ─── Player Card Modal ─────────────────────────────────────────────────── */

.player-card-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(22, 35, 31, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.player-card-overlay.is-hidden {
  display: none;
}

.player-card-modal {
  position: relative;
  background: var(--panel-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
}

.player-card-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}

.player-card-close:hover {
  color: var(--ink);
}

.player-card-body {
  display: flex;
  gap: 1.5rem;
}

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

.player-card-name {
  margin: 0 0 0.15rem;
  font-size: 1.5rem;
}

.player-card-position {
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.player-card-team {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.player-card-team-logo {
  width: 28px;
  height: auto;
}

.player-card-team-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.player-card-bio-section {
  margin-bottom: 1.25rem;
}

.player-card-bio {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.player-card-stats-section .section-tag {
  margin-bottom: 0.5rem;
}

.player-card-stats {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.player-card-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.player-card-stat-row:last-child {
  border-bottom: none;
}

.player-card-stat-label {
  color: var(--muted);
}

.player-card-stat-value {
  font-weight: 700;
}

.player-card-right {
  flex: 0 0 200px;
}

.player-card-photo {
  width: 200px;
  height: 280px;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

.player-card-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.player-card-photo-placeholder {
  width: 100%;
  height: 100%;
  background: rgba(22, 35, 31, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
  border-radius: var(--radius-md);
}

/* ─── Player Name Links ─────────────────────────────────────────────────── */

.player-name-link {
  cursor: pointer;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 140ms ease;
}

.player-name-link:hover {
  border-bottom-color: var(--accent);
}

/* ─── Player Editor ─────────────────────────────────────────────────────── */

.player-editor-form .stack-form {
  max-width: 500px;
}

.player-editor-form textarea {
  width: 100%;
  min-height: 100px;
  padding: 0.75rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface, rgba(255, 255, 255, 0.72));
  color: var(--ink);
  resize: vertical;
  box-sizing: border-box;
}

/* ─── Game Calendar ──────────────────────────────────────────────────────── */

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calendar-month-label {
  font-weight: 700;
  font-size: 1rem;
  min-width: 160px;
  text-align: center;
}

.calendar-header-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  margin-bottom: 2px;
}

.calendar-day-header {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0.4rem 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calendar-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.calendar-cell {
  background: var(--panel-strong);
  min-height: 80px;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.calendar-empty {
  background: rgba(255, 251, 245, 0.5);
}

.calendar-today {
  background: rgba(13, 139, 111, 0.07);
}

.calendar-today .calendar-date {
  color: var(--accent);
  font-weight: 700;
}

.calendar-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.1rem;
}

.calendar-game-chip {
  font-size: 0.65rem;
  line-height: 1.3;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  text-decoration: none;
  display: block;
}

.calendar-game-chip:hover {
  filter: brightness(0.92);
}

.calendar-game-scheduled {
  background: var(--accent-soft);
  color: var(--accent);
}

.calendar-game-live {
  background: rgba(221, 95, 47, 0.15);
  color: var(--brand);
  font-weight: 700;
}

.calendar-game-final {
  background: rgba(22, 35, 31, 0.06);
  color: var(--ink);
}

@media (max-width: 600px) {
  .calendar-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .calendar-header-row,
  .calendar-body {
    min-width: 520px;
  }
  .calendar-cell {
    min-height: 64px;
    padding: 0.25rem;
  }
  .calendar-game-chip {
    font-size: 0.6rem;
  }
}

/* ─── Calendar Game Popup ─────────────────────────────────────────────── */
.calendar-popup {
  position: absolute;
  z-index: 800;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(70, 43, 13, 0.18);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  min-width: 140px;
}

.calendar-popup-option {
  background: none;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  text-align: left;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: background 120ms ease;
}

.calendar-popup-option:hover {
  background: var(--accent-soft);
  color: var(--accent);
  transform: none;
}

/* ─── Game Editor Modal ──────────────────────────────────────────────── */
.game-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(22, 35, 31, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.game-editor-modal {
  background: var(--panel-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 22px 60px rgba(70, 43, 13, 0.2);
  padding: 1.5rem;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.game-editor-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  line-height: 1;
}

.game-editor-close:hover {
  background: rgba(22, 35, 31, 0.06);
  transform: none;
}

.game-editor-title {
  margin: 0 0 1rem;
  font-size: 1.3rem;
}

.game-editor-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.25rem;
}

/* ─── Photo Editor / Crop ────────────────────────────────────────────────── */

.photo-editor-section {
  margin-top: 0.5rem;
}

.photo-editor-current {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.photo-editor-thumb {
  width: 60px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
}

.photo-file-label {
  display: inline-block;
  cursor: pointer;
  padding: 0.5rem 1rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 140ms ease;
}

.photo-file-label:hover {
  background: rgba(13, 139, 111, 0.18);
}

.photo-file-input {
  display: none;
}

.photo-crop-area {
  margin-top: 0.75rem;
}

.photo-crop-viewport {
  border-radius: var(--radius-md);
  overflow: hidden;
  display: inline-block;
  border: 2px solid var(--line);
  cursor: grab;
  touch-action: none;
}

.photo-crop-viewport:active {
  cursor: grabbing;
}

#photoCropCanvas {
  display: block;
}

.photo-crop-controls {
  margin-top: 0.5rem;
  max-width: 300px;
}

.photo-zoom-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.photo-zoom-label input[type="range"] {
  flex: 1;
}

#photoUploadStatus {
  margin-top: 0.5rem;
  font-weight: 600;
}

@media (max-width: 600px) {
  .player-card-body {
    flex-direction: column-reverse;
  }
  .player-card-right {
    flex: none;
    align-self: center;
  }
}

@media (max-width: 980px) {
  .span-7,
  .span-5 {
    grid-column: span 12;
  }

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

  .manual-stat-entry {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .manual-stat-entry label,
  .manual-stat-entry .player-actions {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 1rem, 1280px);
    padding-top: 0.75rem;
  }

  .hero-copy,
  .hero-panel,
  .panel {
    border-radius: 24px;
    padding: 0.75rem;
  }

  .brand-lockup {
    align-items: center;
  }

  .brand-logo {
    width: 100px;
    height: 100px;
  }

  .auth-status {
    position: absolute;
    top: 0.75rem;
    right: 0.5rem;
  }

  .team-card-header,
  .roster-row,
  .schedule-card-header,
  .stats-topline,
  .award-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .player-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .stat-player-row {
    grid-template-columns: 1fr;
  }

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

  .team-logo {
    height: 80px;
  }

  button {
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
  }

  input,
  select,
  textarea {
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    font-size: 0.9rem;
  }

  label {
    font-size: 0.85rem;
  }

  .panel-heading h2 {
    font-size: 1.25rem;
  }

  /* Tighten roster/editor rows */
  .roster-list,
  .card-list,
  .stats-groups {
    gap: 0;
  }

  .roster-row {
    padding: 0.4rem 0;
  }

  .editor-player-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
  }

  .editor-player-copy {
    margin: 0;
  }

  .editor-player-actions {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    width: 100%;
  }

  .editor-player-buttons {
    display: flex;
    gap: 0.25rem;
  }

  .editor-player-buttons button {
    flex: 1 1 0;
    padding: 0.35rem 0.4rem;
    font-size: 0.75rem;
    text-align: center;
  }

  .editor-player-actions select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    font-size: 0.82rem;
  }

  /* Manual stat editor */
  .manual-stat-entry {
    gap: 0.5rem;
  }

  .manual-stat-entry label {
    max-width: none;
    flex: 1 1 100%;
  }

  /* Stats groups */
  .stats-groups {
    grid-template-columns: 1fr;
  }

  /* Filter labels */
  .filter-label {
    min-width: 0;
    width: 100%;
  }

  /* Panel heading tighter */
  .panel-heading {
    gap: 0.5rem;
  }

  .collapsible-toggle {
    gap: 0.5rem;
  }

  /* Player stat summary pills */
  .player-stat-summary {
    justify-content: flex-start;
  }

  .player-stat-summary span {
    padding: 0.25rem 0.5rem;
    font-size: 0.78rem;
  }

  /* Stack form tighter */
  .stack-form {
    gap: 0.65rem;
  }

  .inline-form,
  .field-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .game-editor-modal .field-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .brand-logo {
    width: 80px;
    height: 80px;
  }

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

  .eyebrow {
    font-size: 0.6rem;
    letter-spacing: 0.12em;
  }
}
