:root {
  --dd-forest: #0f2419;
  --dd-forest-light: #16331f;
  --dd-lime: #8dc63f;
  --dd-lime-dark: #6ea62c;
  --dd-lime-light: #b4d65b;
  --dd-cream: #fbfaf5;
  --dd-white: #ffffff;
  --dd-ink: #142313;
  --dd-ink-soft: #4c5a4a;
  --dd-border: #e1e6da;
  --dd-card: #f4f7ef;
  --dd-danger: #c0392b;
  --dd-warning: #b8860b;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --tap-min: 48px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--dd-cream);
  color: var(--dd-ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */

.site-header {
  background: var(--dd-forest);
  color: var(--dd-white);
  padding: 14px 16px;
}

.site-header__inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.brand__mark {
  font-size: 1.3rem;
  margin-right: 2px;
}

.brand__word {
  color: var(--dd-white);
}

.brand__word--accent {
  color: var(--dd-lime);
}

.brand__tld {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--dd-lime-light);
}

.brand__tagline {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--dd-lime-light);
}

/* ---------- Ad slots ----------
   Hidden site-wide until AdSense is approved and real ad code is dropped in
   (see index.html / about.html / etc. for the placeholder divs, and ads.txt).
   To go live: delete the "display: none !important;" line right below.
*/

.ad-slot {
  display: none !important;
  max-width: 728px;
  margin: 10px auto;
  min-height: 60px;
  border: 1px dashed var(--dd-border);
  border-radius: var(--radius-sm);
  background: repeating-linear-gradient(45deg, #eef1e8, #eef1e8 10px, #e7ebe0 10px, #e7ebe0 20px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dd-ink-soft);
  font-size: 0.75rem;
}

.ad-slot__label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- Hero logo (setup screen) ---------- */

.hero-logo {
  display: block;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1 / 1;
  height: auto;
  margin: 4px auto 12px;
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 18px rgba(15, 36, 25, 0.18);
}

/* ---------- App shell ---------- */

.app {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 16px 40px;
}

/* ---------- Partner promo card ---------- */

.promo-card {
  max-width: 640px;
  margin: 8px auto;
  padding: 20px;
  background: var(--dd-card);
  border: 1px solid var(--dd-border);
  border-radius: var(--radius-md);
}
.promo-card__label {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--dd-ink-soft);
  background: var(--dd-border);
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.promo-card__title {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--dd-ink);
}
.promo-card__desc {
  margin: 0 0 14px;
  color: var(--dd-ink-soft);
  font-size: 0.9rem;
  line-height: 1.5;
}
.promo-card .btn {
  width: auto;
  display: inline-flex;
}

/* ---------- Site footer ---------- */

.site-footer {
  color: var(--dd-white);
  background: var(--dd-forest);
  padding: 32px 16px 20px;
  margin-top: 12px;
}
.footer-inner {
  max-width: 640px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 24px;
}
.footer-brand {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--dd-white);
  margin-bottom: 8px;
}
.footer-desc {
  color: var(--dd-lime-light);
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 0;
}
.footer-col__title {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--dd-lime-light);
  margin-bottom: 10px;
}
.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer-links li {
  margin-bottom: 8px;
}
.footer-links a {
  color: var(--dd-white);
  text-decoration: none;
  font-size: 0.88rem;
}
.footer-links a:hover {
  color: var(--dd-lime);
}
.footer-link--disabled {
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.88rem;
  display: inline-block;
}
.footer-link--disabled em {
  font-style: normal;
  font-size: 0.78rem;
}
.footer-bottom {
  max-width: 640px;
  margin: 24px auto 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.72rem;
}

@media (max-width: 480px) {
  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }
  .footer-col--brand {
    grid-column: 1 / -1;
  }
}

/* ---------- Static content pages (About / Privacy / Terms / Contact) ---------- */

.content-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 8px;
}
.content-page h1 {
  font-size: 1.7rem;
  font-weight: 800;
  margin: 0 0 6px;
}
.content-page .updated {
  color: var(--dd-ink-soft);
  font-size: 0.8rem;
  margin: 0 0 24px;
}
.content-page h2 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 28px 0 8px;
}
.content-page p {
  line-height: 1.65;
  margin: 0 0 14px;
  color: var(--dd-ink);
}
.content-page ul {
  line-height: 1.65;
  margin: 0 0 14px;
  padding-left: 22px;
}
.content-page a {
  color: var(--dd-lime-dark);
  font-weight: 600;
}
.content-page .back-link {
  display: inline-block;
  margin-bottom: 16px;
  font-weight: 700;
  color: var(--dd-forest);
  text-decoration: none;
}

/* ---------- Generic building blocks ---------- */

.section {
  margin-bottom: 20px;
}

.section__title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--dd-ink-soft);
  margin: 0 0 8px 2px;
}

.card {
  background: var(--dd-card);
  border-radius: var(--radius-md);
  padding: 16px;
}

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

.how-it-works {
  margin: 28px 0 20px;
}
.how-it-works__list {
  margin: 0;
  padding-left: 20px;
}
.how-it-works__list li {
  line-height: 1.55;
  color: var(--dd-ink);
  margin-bottom: 10px;
}
.how-it-works__list li:last-child {
  margin-bottom: 0;
}
.how-it-works__list strong {
  color: var(--dd-forest);
}

.page-title {
  font-size: 1.7rem;
  font-weight: 800;
  margin: 12px 2px 16px;
  color: var(--dd-ink);
}

/* ---------- Buttons & inputs ---------- */

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 1rem;
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--dd-lime);
  color: var(--dd-ink);
  width: 100%;
}
.btn-primary:disabled {
  background: #d7ddc9;
  color: #93998a;
  cursor: not-allowed;
}
.btn-primary:not(:disabled):active {
  background: var(--dd-lime-dark);
}

.btn-secondary {
  background: var(--dd-white);
  color: var(--dd-ink);
  border: 1px solid var(--dd-border);
}

.btn-danger {
  background: var(--dd-white);
  color: var(--dd-danger);
  border: 1px solid var(--dd-border);
}

.btn-icon {
  background: var(--dd-white);
  border: 1px solid var(--dd-border);
  border-radius: 50%;
  width: var(--tap-min);
  height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--dd-forest);
  flex-shrink: 0;
}

.btn-icon.plus {
  background: var(--dd-lime);
  color: var(--dd-ink);
  border: none;
}
.btn-icon.plus:disabled {
  background: #d7ddc9;
  color: #93998a;
}

.btn-link {
  background: none;
  border: none;
  color: var(--dd-lime-dark);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 6px 0;
}

.text-input {
  width: 100%;
  border: 1px solid var(--dd-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 1rem;
  min-height: var(--tap-min);
  background: var(--dd-white);
  color: var(--dd-ink);
}
.text-input:focus {
  outline: 2px solid var(--dd-lime);
  outline-offset: -1px;
}

.field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.field-row .text-input {
  flex: 1;
}

/* ---------- Player list ---------- */

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--dd-border);
}
.player-row:last-child {
  border-bottom: none;
}
.player-row .text-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 4px 0;
  min-height: unset;
}
.player-row .text-input:focus {
  outline: none;
  background: var(--dd-white);
}

.remove-btn {
  background: none;
  border: none;
  color: var(--dd-danger);
  font-size: 1.3rem;
  line-height: 1;
  padding: 6px;
  flex-shrink: 0;
}

.suggestion-row {
  width: 100%;
  text-align: left;
  background: var(--dd-white);
  border: 1px dashed var(--dd-lime-dark);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 6px;
  color: var(--dd-forest);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.footnote {
  font-size: 0.8rem;
  color: var(--dd-ink-soft);
  margin: 6px 2px 0;
}

.warning-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--dd-warning);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 8px;
}

/* ---------- Segmented control ---------- */

.segmented {
  display: flex;
  background: var(--dd-white);
  border: 1px solid var(--dd-border);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
}
.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--dd-ink-soft);
  min-height: 40px;
}
.segmented button.active {
  background: var(--dd-forest);
  color: var(--dd-white);
}

.select-input {
  width: 100%;
  border: 1px solid var(--dd-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 1rem;
  min-height: var(--tap-min);
  background: var(--dd-white);
  color: var(--dd-ink);
  font-weight: 600;
}

/* ---------- Chips (fixed team pairing) ---------- */

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.chip {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--dd-ink);
  font-weight: 600;
}
.chip.selected {
  background: var(--dd-lime);
  color: var(--dd-ink);
}

.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--dd-border);
}
.team-row:last-child {
  border-bottom: none;
}

/* ---------- Courts stepper ---------- */

.stepper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stepper {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--dd-white);
  border-radius: 999px;
  padding: 4px 6px;
  border: 1px solid var(--dd-border);
}
.stepper button {
  border: none;
  background: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--dd-forest);
}
.stepper button:disabled {
  color: #c7cdbc;
}
.stepper__value {
  min-width: 20px;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
}

/* ---------- Tabs ---------- */

.tab-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  background: var(--dd-white);
  border-radius: 999px;
  border: 1px solid var(--dd-border);
  padding: 4px;
  gap: 4px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(15, 36, 25, 0.06);
}
.tab-bar button {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 10px 8px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--dd-ink-soft);
  min-height: 44px;
}
.tab-bar button.active {
  background: var(--dd-forest);
  color: var(--dd-white);
}

.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.session-header h1 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
}

/* ---------- Court cards ---------- */

.court-card {
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--dd-card);
  cursor: pointer;
}
.court-card.active {
  background: #eaf5db;
  border: 1px solid var(--dd-lime);
}
.court-card__header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.court-card__title {
  font-weight: 700;
  color: var(--dd-ink-soft);
  font-size: 0.95rem;
}
.court-card__closing {
  font-size: 0.75rem;
  color: var(--dd-warning);
  font-weight: 600;
}
.side-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}
.side-row__name {
  font-weight: 800;
  font-size: 1.15rem;
}
.side-row__score {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--dd-ink-soft);
  font-variant-numeric: tabular-nums;
}
.vs-label {
  text-align: center;
  font-size: 0.75rem;
  color: var(--dd-ink-soft);
  margin: 2px 0;
}
.tap-hint {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--dd-lime-dark);
  font-weight: 700;
}
.king-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--dd-warning);
}
.muted {
  color: var(--dd-ink-soft);
}

.bye-card {
  background: #fff6d8;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}
.bye-card__title {
  font-weight: 700;
  color: var(--dd-ink-soft);
  margin-bottom: 4px;
}
.bye-card__names {
  font-weight: 700;
}

.results-card {
  background: var(--dd-card);
  border-radius: var(--radius-md);
  padding: 16px;
}
.results-card__title {
  font-weight: 700;
  color: var(--dd-ink-soft);
  margin-bottom: 8px;
}
.result-row {
  padding: 8px 0;
}
.result-row + .result-row {
  border-top: 1px solid var(--dd-border);
}
.result-row__court {
  font-size: 0.75rem;
  color: var(--dd-ink-soft);
  margin-bottom: 2px;
}
.result-row__line {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  padding: 1px 0;
}
.result-row__line.winner {
  font-weight: 800;
}

.complete-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #e2f3d3;
  color: #3f6b1c;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

/* ---------- Standings table ---------- */

.standings-header,
.standings-row {
  display: grid;
  grid-template-columns: 28px 1fr 56px 48px 48px;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
}
.standings-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--dd-ink-soft);
  font-weight: 700;
  border-bottom: 1px solid var(--dd-border);
}
.standings-row {
  border-bottom: 1px solid var(--dd-border);
}
.standings-row .rank {
  color: var(--dd-ink-soft);
  font-weight: 700;
}
.standings-row .name {
  font-weight: 700;
}
.standings-row .stat,
.standings-header .stat {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Queue list ---------- */

.queue-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--dd-border);
}
.queue-row .rank {
  color: var(--dd-ink-soft);
  font-weight: 700;
  width: 24px;
}
.queue-row .name {
  font-weight: 700;
}

/* ---------- Dialogs (sheets) ---------- */

dialog.sheet {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(420px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--dd-white);
  color: var(--dd-ink);
}
dialog.sheet::backdrop {
  background: rgba(15, 36, 25, 0.55);
}
.sheet__inner {
  padding: 20px;
}
.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.sheet__title {
  font-weight: 800;
  font-size: 1.05rem;
}

.score-block {
  background: var(--dd-card);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  margin-bottom: 16px;
}
.score-block__name {
  font-weight: 800;
  font-size: 1.15rem;
  margin-bottom: 12px;
}
.score-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.score-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--dd-lime);
  color: var(--dd-ink);
  font-size: 1.6rem;
  font-weight: 800;
  flex-shrink: 0;
}
.score-input {
  width: 90px;
  text-align: center;
  font-size: 2.4rem;
  font-weight: 800;
  border: none;
  background: transparent;
  color: var(--dd-ink);
  font-variant-numeric: tabular-nums;
}
.score-input:focus {
  outline: none;
}

.manage-players-list {
  max-height: 40vh;
  overflow-y: auto;
}

@media (max-width: 420px) {
  .standings-header,
  .standings-row {
    grid-template-columns: 22px 1fr 50px 40px 40px;
    font-size: 0.85rem;
  }
}
