:root {
  --bg: #f4efe5;
  --paper: rgba(255, 251, 245, 0.78);
  --paper-strong: #fffaf2;
  --text: #172319;
  --muted: #5e6a5f;
  --line: rgba(23, 35, 25, 0.1);
  --green: #1f5c3f;
  --green-soft: #d8e7da;
  --gold: #b07a21;
  --shadow: 0 18px 40px rgba(39, 43, 24, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(176, 122, 33, 0.18), transparent 30%),
    radial-gradient(circle at right, rgba(31, 92, 63, 0.18), transparent 28%),
    linear-gradient(180deg, #f6f1e7 0%, #ece4d6 100%);
}

body.overlay-open {
  overflow: hidden;
}

button,
select,
input {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.hero {
  display: grid;
  gap: 18px;
  padding: 24px;
  border-radius: 34px;
  background:
    linear-gradient(135deg, rgba(18, 63, 41, 0.95), rgba(28, 93, 63, 0.88)),
    linear-gradient(180deg, #214f39, #1f5c3f);
  color: #fefaf2;
  box-shadow: var(--shadow);
}

.hero-copy h1 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(2.8rem, 7vw, 5rem);
  line-height: 0.95;
}

.eyebrow,
.section-kicker,
.hero-card-label,
.market-type {
  margin: 0 0 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 700;
}

.hero-text {
  max-width: 32rem;
  margin: 14px 0 0;
  color: rgba(254, 250, 242, 0.82);
  font-size: 1.05rem;
}

.market-option,
.status-pill,
.pill,
.trend {
  border-radius: 999px;
  padding: 10px 14px;
}

.hero-card {
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 250, 242, 0.1);
  border: 1px solid rgba(255, 250, 242, 0.12);
  backdrop-filter: blur(14px);
}

.round-summary,
.markets-list,
.pick-groups,
.grading-grid,
.leaderboard,
.ledger,
.books-list,
.stats-grid {
  display: grid;
  gap: 14px;
}

.book-card,
.stat-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
}

.tab-bar {
  display: flex;
  gap: 10px;
  padding: 10px;
  margin: 18px 0;
  border-radius: 20px;
  background: rgba(255, 251, 245, 0.7);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow-x: auto;
}

.tab-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.tab-button.active {
  background: var(--green);
  color: #fffaf2;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.app-grid {
  display: grid;
  gap: 16px;
}

.panel-span-full {
  grid-column: 1 / -1;
}

.panel {
  padding: 20px;
  border-radius: var(--radius-xl);
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.52);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel-muted {
  background: rgba(236, 232, 224, 0.86);
}

.panel-muted .book-card {
  background: rgba(247, 243, 236, 0.92);
  border-color: rgba(23, 35, 25, 0.06);
}

.panel-muted .book-card h3,
.panel-muted .book-card p,
.panel-muted .pill {
  color: #667066;
}

.helper-copy {
  margin: 0;
  color: var(--muted);
}

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

.editor-actions {
  display: grid;
  gap: 10px;
}

.danger-button {
  background: #f6e4df;
  color: #8a3d22;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 1.8rem;
}

.ghost-button,
.primary-button,
.secondary-button {
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.ghost-button:hover,
.primary-button:hover,
.secondary-button:hover,
.book-card:hover {
  transform: translateY(-1px);
}

.ghost-button {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(23, 35, 25, 0.06);
  color: var(--text);
}

.hero .ghost-button {
  background: rgba(255, 250, 242, 0.12);
  color: #fefaf2;
  border: 1px solid rgba(255, 250, 242, 0.18);
}

.primary-button {
  width: 100%;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, #1f5c3f, #3d7f56);
  color: #fffaf2;
  font-weight: 700;
  box-shadow: 0 14px 22px rgba(31, 92, 63, 0.2);
}

.secondary-button {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  background: #e4efe6;
  color: var(--green);
  font-weight: 700;
}

.summary-card,
.market-card,
.pick-card,
.grading-card,
.leader-card,
.ledger-card,
.book-card,
.stat-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--paper-strong);
  border: 1px solid var(--line);
}

.summary-card h3,
.market-title,
.pick-card h3,
.grading-card h3,
.leader-card h3,
.ledger-card h3,
.book-card h3,
.stat-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.summary-card p,
.market-caption,
.pick-card p,
.grading-card p,
.leader-card p,
.ledger-card p,
.book-card p,
.stat-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.book-card {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.book-card.active {
  border-color: rgba(31, 92, 63, 0.28);
  background: #edf6ef;
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.overlay-shell[hidden] {
  display: none;
}

.overlay-shell {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: auto;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 18, 0.52);
  backdrop-filter: blur(4px);
}

.overlay-panel {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  margin: 12px auto;
  padding: 20px;
  overflow: auto;
  border-radius: 30px;
  background: rgba(255, 251, 245, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 24px 60px rgba(19, 23, 15, 0.28);
}

.auth-backdrop {
  background: rgba(17, 24, 18, 0.68);
}

.auth-panel {
  width: min(520px, calc(100% - 24px));
  margin-top: 8vh;
}

.pill {
  background: #f0ebdf;
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
}

.signed-in-pill {
  width: fit-content;
  padding: 10px 14px;
  border-radius: 999px;
  background: #edf6ef;
  color: var(--green);
  font-weight: 700;
}

.betting-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 4px 10px;
}

.market-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.market-stake {
  align-self: start;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 700;
}

.market-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.market-option {
  background: #f0ebdf;
  border: 1px solid rgba(23, 35, 25, 0.08);
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.pick-card legend,
.grading-card legend {
  font-size: 0.92rem;
  font-weight: 700;
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf9;
  color: var(--text);
}

input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf9;
  color: var(--text);
}

.admin-form {
  margin-bottom: 16px;
}

.admin-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.field-wide {
  grid-column: 1 / -1;
}

.compact {
  margin-bottom: 10px;
}

.overlay-panel .panel-header.compact {
  margin-top: 14px;
}

.pick-card fieldset,
.grading-card fieldset {
  margin: 14px 0 0;
  padding: 0;
  border: 0;
}

.radio-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.radio-item {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  padding: 12px;
  border-radius: 14px;
  background: #f8f4eb;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
}

.radio-item input {
  display: none;
}

.radio-item.selected {
  border-color: rgba(31, 92, 63, 0.28);
  background: #edf6ef;
  color: var(--green);
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  width: fit-content;
  margin-top: 14px;
  font-size: 0.88rem;
  font-weight: 700;
}

.status-pill.saved {
  background: #edf6ef;
  color: var(--green);
}

.status-pill.pending {
  background: #fbf1dc;
  color: #7f6215;
}

.leaderboard {
  margin-bottom: 14px;
}

.leader-card,
.ledger-card,
.stat-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

button.leader-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  cursor: pointer;
}

.results-detail-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.leader-card strong,
.ledger-card strong,
.stat-card strong {
  font-size: 1.15rem;
}

.trend {
  padding: 8px 10px;
  border-radius: 999px;
  background: #edf6ef;
  color: var(--green);
  font-weight: 700;
}

.trend.down {
  background: #fbe9dd;
  color: #8d4e1f;
}

@media (min-width: 860px) {
  .hero {
    grid-template-columns: 1.4fr 0.9fr;
    align-items: stretch;
  }

  .app-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-book-detail {
    grid-column: 1 / -1;
  }

  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .player-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .panel,
  .hero,
  .market-card,
  .pick-card,
  .grading-card,
  .leader-card,
  .ledger-card,
  .book-card,
  .stat-card {
    animation: rise-in 480ms ease backwards;
  }

  .market-card:nth-child(2),
  .pick-card:nth-child(2),
  .grading-card:nth-child(2),
  .leader-card:nth-child(2),
  .ledger-card:nth-child(2),
  .book-card:nth-child(2),
  .stat-card:nth-child(2) {
    animation-delay: 60ms;
  }

  .market-card:nth-child(3),
  .pick-card:nth-child(3),
  .grading-card:nth-child(3),
  .leader-card:nth-child(3),
  .ledger-card:nth-child(3),
  .book-card:nth-child(3),
  .stat-card:nth-child(3) {
    animation-delay: 120ms;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
