/* Bocce Pals — Happy Days-inspired retro Americana.
   Cherry red + cream, bouncy "Chewy" display type (closest Google Font to the
   Happy Days logo's Balloon lettering), friendly rounded Nunito for body.
   Nonna-proof tokens still rule: ≥18px body, ≥56px tap targets. */

:root {
  --page-max: 480px;  /* the phone-width column every page sits in */
  --pals-red: #d2342c;
  --pals-red-dark: #a32420;
  --pals-green: #2f9e44;
  --pals-green-dark: #268038;
  --pals-cream: #fff6e5;
  --pals-ink: #2b2421;
  /* Neutrals + surfaces (one source for greys, lines, card backgrounds) */
  --muted: #8a7f76;
  --line: rgba(43, 36, 33, 0.10);
  --surface: #ffffff;
  --surface-alt: #fbf3e2;
  /* Scales */
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.06);
}

body {
  font-family: 'Nunito', system-ui, sans-serif;
  font-size: 1.125rem; /* ≥18px body text */
  background-color: var(--pals-cream);
  color: var(--pals-ink);
}

/* The Happy Days wordmark: stacked two-tone sticker letters — colored fill,
   thick white outline, dark offset shadow, slight tilt. Outline is built from
   layered text-shadows (rendering-safe everywhere, unlike text-stroke). */
.logo-stack {
  display: inline-flex;
  flex-direction: column;
  line-height: 0.95;
  text-decoration: none;
  transform: rotate(-2deg);
}
.logo-word {
  display: inline-block; /* transforms don't apply to inline text */
  font-family: 'Chewy', cursive;
  font-size: 2.6rem;
  letter-spacing: 2px;
  text-shadow:
    /* white sticker outline, 8 directions */
    3px 0 0 #fff, -3px 0 0 #fff, 0 3px 0 #fff, 0 -3px 0 #fff,
    2px 2px 0 #fff, -2px 2px 0 #fff, 2px -2px 0 #fff, -2px -2px 0 #fff,
    3px 3px 0 #fff, -3px 3px 0 #fff, 3px -3px 0 #fff, -3px -3px 0 #fff,
    /* dark offset shadow beyond the outline */
    5px 6px 0 #20242b, 6px 5px 0 #20242b, 6px 7px 0 #20242b, 7px 6px 0 #20242b;
}
.logo-red { color: #e03a30; }
.logo-green {
  color: #2f9e44;
  margin-top: -0.3rem;
  transform: rotate(1.5deg);
}
.logo-sm .logo-word, .logo-word.logo-sm { font-size: 1.7rem; }

/* The "o" in Bocce is a bocce ball: shaded sphere with engraved arc lines,
   white ring + dark offset shadow to match the lettering treatment. */
.logo-ball {
  display: inline-block;
  width: 0.58em;
  height: 0.58em;
  margin: 0 0.03em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f0655c, #e03a30 55%, #a8231c);
  box-shadow: 0 0 0 3px #fff, 5px 6px 0 #20242b;
  position: relative;
  overflow: hidden;
}
/* Groove rings: two perpendicular great circles seen at an angle, so each
   renders as a thin full ellipse wrapping the sphere (clipped by the ball). */
.logo-ball::before,
.logo-ball::after {
  content: '';
  position: absolute;
  border: 0.045em solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
}
.logo-ball::before {
  /* near-horizontal equator groove */
  width: 96%;
  height: 52%;
  left: 2%;
  top: 24%;
  transform: rotate(-16deg);
}
.logo-ball::after {
  /* perpendicular meridian groove */
  width: 52%;
  height: 96%;
  left: 24%;
  top: 2%;
  transform: rotate(-16deg);
}

h1, .h1 {
  font-family: 'Chewy', cursive;
  font-size: 2rem;
  color: var(--pals-red);
  letter-spacing: 0.5px;
}
h2, .h2 { font-size: 1.4rem; font-weight: 700; }

a { color: var(--pals-red); }

.btn-primary {
  --bs-btn-bg: var(--pals-red);
  --bs-btn-border-color: var(--pals-red);
  --bs-btn-hover-bg: var(--pals-red-dark);
  --bs-btn-hover-border-color: var(--pals-red-dark);
  --bs-btn-active-bg: var(--pals-red-dark);
  --bs-btn-active-border-color: var(--pals-red-dark);
}

/* Brand-green buttons (matches the "Pals" lettering) */
.btn-success {
  --bs-btn-bg: var(--pals-green);
  --bs-btn-border-color: var(--pals-green);
  --bs-btn-hover-bg: var(--pals-green-dark);
  --bs-btn-hover-border-color: var(--pals-green-dark);
  --bs-btn-active-bg: var(--pals-green-dark);
  --bs-btn-active-border-color: var(--pals-green-dark);
}
.btn-outline-success {
  --bs-btn-color: var(--pals-green);
  --bs-btn-border-color: var(--pals-green);
  --bs-btn-hover-bg: var(--pals-green);
  --bs-btn-hover-border-color: var(--pals-green);
  --bs-btn-active-bg: var(--pals-green-dark);
  --bs-btn-active-border-color: var(--pals-green-dark);
}

/* One big obvious action per screen: full width, ≥56px tall. Flex-center so the
   label sits dead-center vertically and horizontally (icon + text as a unit). */
.btn-big {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 16px;
}

/* Taps on buttons never trigger iOS double-tap zoom (quick +/+ taps were
   zooming the page). Pinch-zoom still works. */
button, .btn, a { touch-action: manipulation; }

/* Score steppers: giant +/- targets, no typing needed */
.stepper {
  min-width: 56px;
  min-height: 56px;
  font-size: 1.5rem;
  font-weight: 700;
  border-radius: 14px;
}

/* The number between − and +: a tappable box that opens the number keypad
   (inputmode=numeric) and selects on tap so typing replaces it. Accent
   border says "you can tap this". */
.num-entry {
  max-width: 90px;
  min-height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  border: 2px solid var(--pals-red);
}
/* Score picker (U1f, _score_pick.html): a native <select> between − and +.
   iPhone opens its spinning wheel, a laptop a dropdown. Same look as
   .num-entry; the chevron stays as the "tap me" hint. Its row is
   flex-wrap with − / picker / + in one ms-auto group, so in a narrow card
   (captain page) or beside a long team name the controls drop under the
   name instead of overflowing. */
.num-pick {
  width: 96px;
  flex: 0 0 auto;
  padding-right: 1.75rem;
  background-position: right 0.5rem center;
  min-height: 56px;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  text-align-last: center;
  padding-left: 0.5rem;
  border: 2px solid var(--pals-red);
}

/* Form fields sized for older eyes and thumbs */
.form-control, .form-select {
  min-height: 56px;
  font-size: 1.125rem;
  border-radius: 12px;
}
.form-label { font-weight: 700; }

.card {
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background-color: var(--surface);
  box-shadow: var(--shadow-card);
}

/* Status pill — one vocabulary for Draft/Active/Final/Archived across the app.
   A muted tinted chip with a leading dot in the same hue. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.6rem 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.4;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}
.pill-active { color: var(--pals-green-dark); background: rgba(47, 158, 68, 0.13); }
.pill-draft { color: var(--pals-red); background: rgba(210, 52, 44, 0.11); }
.pill-final { color: #6b6158; background: rgba(43, 36, 33, 0.08); }
.pill-archive { color: var(--muted); background: rgba(43, 36, 33, 0.05); }

/* Accent card: the primary action on a page gets a green left rail. */
.card-accent { border-left: 4px solid var(--pals-green); }

/* Inset panel: a nested container inside a card, no shadow — avoids the heavy
   double-shadow of card-in-card (e.g. score-entry rows in the report form). */
.inset {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-alt);
}

/* QR codes render as inline SVG; keep them crisp and centered */
.qr-box svg { width: 100%; max-width: 280px; height: auto; display: block; margin: 0 auto; }

/* Numbered game cards on the manage page — each game a distinct row so
   adjacent games are easy to tell apart. */
.game-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.6rem;
}
/* The page column (base.html main/header/footer, the brand logo rows). */
.page-col {
  max-width: var(--page-max);
}
/* "Enter score" / "Fix" — the most-tapped button of the night (organizer and
   helper): hold the 56px tap-target floor even in the compact card. */
.game-card > .btn {
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* games currently in play get a green border */
.game-card.live {
  border-color: var(--pals-green);
}
.game-num {
  flex: 0 0 auto;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--pals-red);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-card-body {
  flex: 1;
  min-width: 0;
}
.game-card-match {
  font-weight: 600;
  font-size: 1.05rem;
}
.game-card-meta {
  font-size: 0.8rem;
  color: var(--muted);
}
/* A card carrying players' names needs the width: its button drops to a
   full-width row underneath instead of squeezing the names. */
.game-card:has(.team-roster) {
  flex-wrap: wrap;
}
.game-card:has(.team-roster) > .btn {
  flex: 1 0 100%;
}
/* E3 court controls (_court_tools.html): a <details> under a game on a
   court; the card wraps so the score button and the panel each get a full row. */
.game-card:has(.court-tools) {
  flex-wrap: wrap;
}
.game-card:has(.court-tools) > .btn,
.game-card > .court-tools {
  flex: 1 0 100%;
}
.court-tools-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-top: 0.75rem;
}
/* Players' names under a drawn team's "Team 3" (draft mode, TECH_DESIGN §4e).
   Partials: _team_name.html (one team) and _matchup_rosters.html (A vs B). */
.team-roster {
  display: block;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.25;
  color: var(--muted);
  white-space: normal;
}

/* Graphical bracket: rounds as columns left-to-right, games centered between
   their feeders, horizontally scrollable on small screens. */
.bracket {
  display: flex;
  gap: 2rem;
  padding-bottom: 0.5rem;
  /* No inner scroll window: the bracket sizes to its content (max-content) and
     the whole page pans to reveal it — easier to grab than a
     scroll-within-a-scroll, especially for older users on phones. It must not
     sit inside a fixed-width card, or the card edge clips it. */
  width: max-content;
  max-width: none;
}
.br-round {
  display: flex;
  flex-direction: column;
  min-width: 9.5rem;
  flex: 0 0 auto;
}
.br-round-title {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--pals-red);
  text-align: center;
  margin-bottom: 0.5rem;
  white-space: nowrap;
}
.br-games {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 1rem;
}
.br-game {
  position: relative;
  border: 2px solid rgba(163, 36, 32, 0.15);
  border-radius: 10px;
  background: #fffdf7;
  overflow: hidden;
}
/* a game currently in play gets a green border */
.br-game.br-live {
  border-color: #2f9e44;
  border-width: 3px;
}
/* live pool games ("Now playing") get a green left accent */
.live-item {
  border-left: 4px solid #2f9e44;
}
/* short connector stub linking a game toward the next round */
.br-round:not(:last-child) .br-game::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  width: 2rem;
  height: 2px;
  background: rgba(163, 36, 32, 0.2);
}
.br-team {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  font-size: 1rem;
}
.br-team + .br-team {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.br-team.winner {
  font-weight: 700;
  background: rgba(47, 158, 68, 0.13);
}
.br-team .nm {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Pool spot "A1" before a team name in pooled formats (TECH_DESIGN §4f).
   Partials: _team_name.html (chip), _pool_row.html (Pools card). Matchup
   lines ("A1 vs A3") use plain text via _matchup.html. */
.pool-code {
  display: inline-block;
  min-width: 2.1em;
  padding: 0 0.3em;
  border-radius: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  color: var(--pals-ink);
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pool-code-lg {
  min-width: 5.5rem;
  min-height: 56px;
  line-height: 54px;
  font-size: 1.125rem;
  border-radius: 12px;
}
.pool-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.pool-pick {
  flex: 0 0 5.5rem;
  width: 5.5rem;
  font-weight: 800;
}
.pool-row-name {
  font-weight: 600;
  min-width: 0;
}
.br-team .team-roster {
  max-width: 11rem;
  font-size: 0.8rem;
}
.br-tbd .nm, .br-tbd {
  color: #9a8f86;
}
.br-court {
  font-size: 0.75rem;
  color: #9a8f86;
  padding: 0.15rem 0.55rem;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

/* Burger menu: a native <details> dropdown — no JS framework needed. */
details.menu {
  position: relative;
}
details.menu > summary {
  list-style: none; /* hide the disclosure triangle */
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.4rem 0.65rem; /* comfortable tap target */
  border-radius: 10px;
  user-select: none;
}
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary {
  background: rgba(163, 36, 32, 0.08);
}
details.menu > summary .badge { font-size: 0.7rem; vertical-align: middle; }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 1000;
  min-width: 230px;
  background: #fffdf7;
  border: 2px solid rgba(163, 36, 32, 0.15);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(32, 36, 43, 0.15);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
}
.menu-panel a, .menu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem; /* ≥44px rows for older thumbs */
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: 10px;
  text-decoration: none;
}
.menu-panel a:hover, .menu-panel button:hover {
  background: rgba(163, 36, 32, 0.08);
}
.menu-user {
  padding: 0.65rem 0.75rem 0.25rem;
  font-size: 0.85rem;
  color: #9a8f86;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  margin-top: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* League standings — give the table some Happy Days pop */
.table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}
.data-table thead th {
  background: var(--pals-red);
  color: var(--pals-cream);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.65rem 0.5rem;
}
.data-table thead th.team-col { text-align: left; padding-left: 0.9rem; }
.data-table tbody td {
  padding: 0.5rem 0.5rem;
  text-align: center;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
}
.data-table tbody tr.alt { background: var(--surface-alt); }
.data-table td.team-col {
  text-align: left;
  padding-left: 0.9rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--pals-ink);
}
.data-table td.wins { color: var(--pals-green-dark); font-weight: 700; }
.data-table td.dim { color: var(--muted); }
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #ece0c9;
  color: var(--pals-ink);
  font-weight: 800;
  font-size: 0.95rem;
}
.rank-badge.gold { background: #ffd23f; color: #6b4e00; }
.rank-badge.silver { background: #d3d8dd; color: #394049; }
.rank-badge.bronze { background: #e6ac74; color: #573310; }
.data-table tr.leader { background: #fff1c9 !important; }
.data-table tr.leader td.team-col { color: var(--pals-red); }
.data-table tr.playoff-in td:first-child { box-shadow: inset 4px 0 0 var(--pals-green); }
.data-table tr.standings-cutoff td {
  padding: 0.15rem 0.5rem 0.3rem;
  border-top: 0;
  background: #fff;
}
.data-table tr.standings-cutoff .cutoff-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--pals-green-dark);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.data-table tr.standings-cutoff .cutoff-label::before,
.data-table tr.standings-cutoff .cutoff-label::after {
  content: "";
  flex: 1;
  border-top: 2px dashed var(--pals-green);
  opacity: 0.45;
}

/* Persistent bottom tab bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  max-width: var(--page-max);
  margin: 0 auto;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.5rem 0 0.55rem;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}
.bottom-nav a span { font-size: 1.35rem; line-height: 1; }
.bottom-nav a.active { color: var(--pals-red); }
body.has-bottom-nav main { padding-bottom: 5.5rem; }

/* Top-bar inbox bell */
.bell {
  position: relative;
  font-size: 1.3rem;
  line-height: 1;
}
.bell-badge {
  position: absolute;
  top: -6px;
  right: -9px;
  background: var(--pals-red);
  color: #fff;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  min-width: 1.05rem;
  text-align: center;
  padding: 0 0.2rem;
}

/* Dashboard section headers + action rows */
.section-head {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.25rem 0 0.6rem;
}
.needs-row {
  color: var(--pals-ink);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.needs-row:first-child { border-top: 0; }
.needs-row:hover { background: var(--surface-alt); }

@media print {
  footer, .no-print { display: none !important; }
  body { background: #fff; }
}

/* E8: "You have unsaved changes" bar on the organizer setup page. Pinned to
   the bottom of the phone column, above the bottom nav when logged in. */
.unsaved-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 110;
  max-width: var(--page-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 2px solid var(--pals-red);
  box-shadow: var(--shadow-card);
}
.unsaved-bar[hidden] { display: none; }
.unsaved-bar-text { flex: 1; font-weight: 700; line-height: 1.25; }
.unsaved-bar .btn-big { width: auto; flex: 0 0 auto; margin: 0; }
body.has-bottom-nav .unsaved-bar {
  bottom: calc(3.6rem + env(safe-area-inset-bottom));
  padding-bottom: 0.75rem;
}
/* E8r: tapping an instant action with unsaved changes flashes the bar
   (its text becomes "Save your changes first…"). */
.unsaved-bar-nudge { animation: unsaved-nudge 0.9s ease-out; }
.unsaved-bar-nudge .unsaved-bar-text { color: var(--pals-red-dark); }
@keyframes unsaved-nudge {
  0%, 40% { background: var(--surface-alt); border-top-width: 6px; }
  100% { background: var(--surface); }
}
body.has-unsaved-bar main { padding-bottom: 7rem; }
body.has-bottom-nav.has-unsaved-bar main { padding-bottom: 11rem; }

/* A card heading with a small Show/Hide button on the right (the organizer's
   "N teams entered" card). The button keeps the 56px tap floor. */
.card-head-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.btn-toggle {
  flex: 0 0 auto;
  min-width: 88px;
  min-height: 56px;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 16px;
}
