:root {
  --bg: #f0eeea;
  --bg-panel: #faf9f7;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f3ef;
  --line: #d9d3c8;
  --text: #1c2a3a;
  --text-dim: #6b7a8d;
  --accent: #9B3D36;
  --accent-light: #B85C52;
  --accent-dim: #ddc0bd;
  --accent-warm: #b8924a;
  --win: #3f7a4a;
  --loss: #8a332c;
  --legend: #b8924a;
  --shadow-sm: 0 1px 3px rgba(28, 42, 58, 0.06);
  --shadow-md: 0 4px 16px rgba(28, 42, 58, 0.08);
  --radius: 14px;
  --max-w: 480px;
  --font-display: 'Lora', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
}

#app {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: 24px;
}

.hidden { display: none !important; }

.screen { padding: 20px 16px 12px; }

/* The draft screen breaks out of the phone-width frame on wider viewports
   so the pick pane (left) and squad pane (right) can sit side by side, like
   the reference games. Falls back to a stacked single column on phones. */
.wide-screen {
  width: 100vw;
  max-width: 980px;
  margin-left: calc(-50vw + 50%);
  box-sizing: border-box;
}

.draft-columns {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-top: 12px;
}
.pick-pane {
  flex: 1 1 58%;
  min-width: 0;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.squad-pane {
  flex: 1 1 42%;
  min-width: 0;
  position: sticky;
  top: 16px;
}
@media (max-width: 760px) {
  .draft-columns { flex-direction: column; }
  .squad-pane { position: static; width: 100%; }
  .pick-pane { width: 100%; }
}

/* HOME */
.home-inner {
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
}
.logo {
  font-family: var(--font-display);
  font-size: 2.4rem;
  letter-spacing: 1px;
  margin: 0;
  font-weight: 700;
}
.logo span { color: var(--accent); }
.tagline {
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0 0 12px;
}

/* Stats / no-stats toggle — a real choice made before the draft starts, not
   a settings checkbox, so it reads as a pill switch rather than a form field. */
.stats-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 4px;
  user-select: none;
}
.stats-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.stats-toggle-track {
  width: 42px;
  height: 24px;
  background: var(--line);
  border-radius: 999px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.stats-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--bg-card);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}
.stats-toggle input:checked ~ .stats-toggle-track { background: var(--accent); }
.stats-toggle input:checked ~ .stats-toggle-track .stats-toggle-thumb { transform: translateX(18px); }
.stats-toggle-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
}

.btn {
  font-family: var(--font-body);
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  max-width: 320px;
}
.btn-primary {
  background: var(--accent);
  color: #fdfaf6;
}
.btn-primary:disabled {
  background: var(--accent-dim);
  color: #9a7c79;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
}
.btn-gold {
  background: linear-gradient(135deg, #d8b877, var(--accent-warm));
  color: #2a1f0d;
}
.btn-spin {
  font-size: 1.05rem;
  box-shadow: 0 0 0 3px rgba(155, 61, 54, 0.14);
}
.spin-era-heading {
  text-align: center;
  padding: 4px 2px 14px;
}
.spin-era-heading .se-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}
.spin-era-heading .se-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.btn-ghost-small {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-body);
}
.ratings-list {
  max-height: 80vh;
  margin-top: 12px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.how-list {
  color: var(--text-dim);
  line-height: 1.6;
  padding-left: 20px;
}
.how-list strong { color: var(--text); }
#screen-how .btn { margin-top: 14px; }

/* DRAFT */
.draft-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.draft-header h2 { margin: 0; font-family: var(--font-display); }
.draft-progress {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 700;
  color: var(--accent);
  font-size: 0.9rem;
  font-family: var(--font-body);
}

/* Squad pane: a real team-sheet layout — front row, second row, back row,
   half-backs, centre/wing, fullback — not a flat list. Each .squad-row is
   one "line" of the sheet, holding 1 or 2 slot cards side by side. */
.slots-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.squad-row {
  display: flex;
  gap: 6px;
}
.squad-row .slot-row {
  flex: 1;
  min-width: 0;
}
.slot-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  min-height: 30px;
  box-shadow: var(--shadow-sm);
}
.slot-row:active { background: var(--bg-card-hover); }
.slot-row.filled { border-color: var(--accent-light); }
.slot-row .sr-pos {
  font-size: 0.66rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.slot-row .sr-body { max-width: 100%; }
.slot-row .sr-name {
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slot-row .sr-empty {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
}
.slot-row .sr-rating {
  font-family: var(--font-display);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
}

.squad-footer {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.team-preview {
  color: var(--text-dim);
  font-size: 0.82rem;
  text-align: center;
  min-height: 18px;
}
.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mode-buttons .btn { max-width: none; }

/* PICK PANE */
.spin-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.spin-controls .btn {
  flex: 1;
  min-width: 120px;
  max-width: none;
  padding: 12px 10px;
  font-size: 0.85rem;
}
.pick-content { min-height: 160px; }
.pick-empty {
  color: var(--text-dim);
  text-align: center;
  padding: 50px 10px;
}
.pick-row .pr-meta .squad-tag {
  color: var(--legend);
}
.picker-search {
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-body);
}
.picker-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pick-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.pick-row:active { background: var(--bg-card-hover); }
.pick-row .pr-left {
  display: flex;
  flex-direction: column;
}
.pick-row .pr-name { font-weight: 700; font-size: 0.9rem; }
.pick-row .pr-meta { font-size: 0.72rem; color: var(--text-dim); }
.pick-row .pr-rating {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  font-size: 1.05rem;
}
.pick-row.taken {
  opacity: 0.4;
  cursor: not-allowed;
}

/* RESULT LOG (used by the end screen's full match log) */
.result-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 40vh;
  overflow-y: auto;
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--win);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  box-shadow: var(--shadow-sm);
}
.result-row.loss { border-left-color: var(--loss); }
.result-row .rr-tag {
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
}
.log-narrative {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
  padding: 4px 4px 0;
}
.log-narrative:first-child { padding-top: 0; }
.result-row.win .rr-tag { color: var(--win); }
.result-row.loss .rr-tag { color: var(--loss); }

/* END */
.end-panel { text-align: center; }
#end-title { font-family: var(--font-display); font-size: 1.6rem; margin-bottom: 4px; }
#end-subtitle { color: var(--text-dim); margin-bottom: 16px; }
.end-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

@media (min-width: 400px) {
  .slots { grid-template-columns: repeat(3, 1fr); }
}
