:root {
  --bg: #0e1117;
  --panel: #161b24;
  --panel-2: #1d2530;
  --line: #2a3340;
  --text: #e6edf3;
  --muted: #8b97a7;
  --accent: #2f81f7;
  --accent-2: #f7b32f;
  --win: #2ecc71;
  --lose: #e74c3c;
  --star: #f7b32f;
  --radius: 12px;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h2, h3 { margin: 0; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 18px;
  background: rgba(14, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-size: 20px; font-weight: 800; letter-spacing: 0.5px; }
.brand span { color: var(--accent-2); }
.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent; color: var(--muted);
  border: 1px solid transparent; border-radius: 999px;
  padding: 8px 14px; font-weight: 600; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.pill {
  background: var(--accent); color: #fff; border-radius: 999px;
  padding: 1px 8px; font-size: 12px; margin-left: 4px;
}

main { max-width: 1200px; margin: 0 auto; padding: 18px; }
.view { display: none; }
.view.is-active { display: block; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-weight: 700; cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:hover { background: #232c38; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #4691ff; }
.btn-ghost { background: transparent; }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.btn-spin {
  background: linear-gradient(180deg, #f7b32f, #e09b16);
  border: none; color: #1a1300; font-size: 18px; padding: 12px 26px;
  border-radius: 12px; box-shadow: var(--shadow);
}

/* ---------- draft layout ---------- */
.draft-layout {
  display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start;
}
.roster {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; position: sticky; top: 78px;
}
.roster-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.progress { color: var(--accent-2); font-weight: 800; }
.roster-board { display: flex; flex-direction: column; gap: 14px; }
.pos-group { }
.pos-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 6px; }
.pos-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.slot {
  border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; min-height: 64px;
  background: var(--panel-2);
}
.slot.is-backup { opacity: 0.78; border-style: dotted; }
.slot-role { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.slot-empty { display: flex; flex-direction: column; justify-content: center; align-items: center; color: var(--muted); }
.slot-placeholder { font-size: 13px; }
.slot-filled { border-style: solid; border-color: var(--accent); }
.slot.is-backup.slot-filled { border-color: #3d5a7a; }
.slot-name { font-weight: 700; margin-top: 2px; }
.slot-meta { font-size: 11px; color: var(--muted); }
.slot-mini { font-size: 11px; color: var(--star); margin-top: 3px; }

/* ---------- slot machine ---------- */
.draft-main { min-width: 0; }
.machine {
  display: flex; gap: 14px; align-items: stretch; margin-bottom: 12px; flex-wrap: wrap;
}
.reel {
  flex: 1; min-width: 200px; min-height: 78px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px;
  font-size: 22px; font-weight: 800; overflow: hidden;
}
.reel small { font-size: 13px; color: var(--muted); font-weight: 600; }
.reel.spinning { animation: reelpulse 0.3s infinite alternate; }
.reel-final { color: var(--accent-2); }
@keyframes reelpulse { from { background: var(--panel); } to { background: #20262f; } }
.pool-hint { color: var(--muted); margin: 6px 0 12px; }

/* ---------- cards / pool ---------- */
.pool { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; position: relative; transition: border-color 0.15s, transform 0.05s;
}
.card.is-selectable { cursor: pointer; }
.card.is-selectable:hover { border-color: var(--accent); transform: translateY(-2px); }
.card.is-disabled { opacity: 0.4; filter: grayscale(0.6); }
.card-name { font-weight: 800; font-size: 15px; padding-right: 20px; }
.card-team { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.card-stats { display: flex; flex-direction: column; gap: 4px; }
.stat { display: flex; align-items: center; gap: 8px; }
.stat .lbl { font-size: 10px; width: 28px; color: var(--muted); letter-spacing: 1px; }
.stars { letter-spacing: 1px; }
.stars .on { color: var(--star); }
.stars .off { color: #3a434f; }
.stars.muted { color: var(--muted); }
.def { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.def-high { background: rgba(46, 204, 113, 0.15); color: var(--win); border: 1px solid rgba(46,204,113,.4); }
.def-normal { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
/* flag pill (Drafted / ×N) lives bottom-right in a reserved band so it never
   overlaps the name, stats, or slogan */
.card-flag {
  position: absolute; bottom: 8px; right: 8px; z-index: 3;
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--line); padding: 2px 6px; border-radius: 6px;
}
.card-flag.owned { color: var(--accent-2); }
.card.has-flag { padding-bottom: 30px; }
/* "in your collection" check — small, top-right so it never obscures the name */
.card-collected {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 15px; height: 15px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 900; line-height: 1;
  color: #0e1117; background: var(--win);
  border: 1px solid rgba(46,204,113,.6);
}
/* partial/in-progress season marker (e.g. 2026*) */
.card-team .partial { color: var(--accent-2); cursor: help; }

/* ---------- shiny cards (rare gold variants — decision D20) ---------- */
.card-shiny {
  overflow: hidden;
  border-color: #e9c349;
  background:
    linear-gradient(135deg, rgba(247,201,72,0.16), rgba(247,201,72,0.04) 48%, rgba(247,201,72,0.13));
  box-shadow: 0 0 0 1px rgba(247,201,72,0.35), 0 6px 20px rgba(247,201,72,0.14);
}
.card-shiny.is-selectable:hover { border-color: #ffd86b; }
.card-shiny .card-name { color: #ffd86b; }
.shiny-spark { margin-right: 3px; }
/* sweeping diagonal sheen */
.card-shiny::before {
  content: ""; position: absolute; top: -60%; left: -75%;
  width: 45%; height: 220%; transform: rotate(18deg);
  pointer-events: none; z-index: 2;
  background: linear-gradient(
    100deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.30) 50%,
    rgba(255,255,255,0) 100%
  );
  animation: shinySheen 3.4s ease-in-out infinite;
}
@keyframes shinySheen {
  0%   { left: -75%; }
  55%  { left: 135%; }
  100% { left: 135%; }
}
@media (prefers-reduced-motion: reduce) {
  .card-shiny::before { animation: none; }
}
/* slogan pill — gold-on-grey with a gold border, matching the card */
.card-slogan {
  position: relative; z-index: 2; margin-top: 10px;
  padding: 5px 9px; border-radius: 8px;
  font-size: 11px; font-style: italic; line-height: 1.3; color: #ffd86b;
  background: rgba(247,201,72,0.08);
  border: 1px solid rgba(247,201,72,0.5);
}
/* shiny roster slot */
.slot.is-shiny.slot-filled {
  border-color: #e9c349;
  background: linear-gradient(180deg, rgba(247,201,72,0.15), rgba(247,201,72,0.05));
}
.slot.is-shiny .slot-name { color: #ffd86b; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px;
}
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.slot-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.slot-choice {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; text-align: left;
}
.slot-choice:hover { border-color: var(--accent); }
.slot-choice span { font-size: 11px; color: var(--muted); }

/* ---------- series / bracket ---------- */
.series-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.series-actions { display: flex; gap: 8px; }
.bracket {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.bcol { display: flex; flex-direction: column; gap: 18px; }
.bcol-head { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); text-align: center; }
.bmatch { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.bmatch-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.bteam {
  position: relative; padding: 8px 10px; border-radius: 8px; border: 1px solid transparent;
  background: var(--panel); margin-bottom: 6px;
}
.bteam:last-child { margin-bottom: 0; }
.bteam-name { font-weight: 700; }
.bteam-sub { font-size: 11px; color: var(--muted); }
.bteam.is-you { box-shadow: inset 3px 0 0 var(--accent-2); }
.bteam.is-winner { border-color: var(--win); background: rgba(46,204,113,0.08); }
.bteam.is-loser { opacity: 0.5; }
.bteam.is-tbd { color: var(--muted); text-align: center; }
.bteam-pct { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 800; color: var(--muted); }
.bteam.is-winner .bteam-pct { color: var(--win); }
.champ-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 120px; border: 2px dashed var(--line); border-radius: 12px; font-size: 34px;
}
.champ-box.has-champ { border-style: solid; border-color: var(--accent-2); background: rgba(247,179,47,0.06); }
.champ-name { font-size: 18px; font-weight: 800; margin-top: 4px; }
.series-result { margin-top: 18px; }
.result-banner { padding: 16px; border-radius: 12px; font-weight: 700; text-align: center; }
.result-banner.win { background: rgba(46,204,113,0.12); border: 1px solid var(--win); color: var(--win); }
.result-banner.lose { background: rgba(231,76,60,0.10); border: 1px solid var(--lose); color: #ff8d80; }

/* ---------- almanac ---------- */
.almanac { display: flex; flex-direction: column; gap: 30px; margin-top: 16px; }
.alm-year { display: flex; flex-direction: column; gap: 16px; }
.alm-year-head {
  position: sticky; top: 56px; z-index: 10;
  display: flex; align-items: baseline; gap: 12px;
  padding: 8px 0; background: rgba(14, 17, 23, 0.92); backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--accent-2);
}
.alm-year-title { font-size: 30px; font-weight: 900; letter-spacing: 0.5px; color: var(--accent-2); }
.alm-year-meta { font-size: 12px; color: var(--muted); }
.alm-year-note { font-size: 12px; color: var(--accent-2); margin: -4px 0 0; }
.alm-team { display: flex; flex-direction: column; gap: 10px; }
.alm-team-head { display: flex; align-items: baseline; gap: 10px; }
.alm-team-name { font-size: 17px; font-weight: 800; }
.alm-team-count { font-size: 12px; color: var(--muted); }

/* ---------- help ---------- */
.help-lead { max-width: 760px; font-size: 15px; line-height: 1.55; margin: 6px 0 20px; }
.help { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 980px; align-items: start; }
.help-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
}
.help-card h3 { font-size: 16px; margin-bottom: 10px; }
.help-card p { margin: 0 0 10px; line-height: 1.5; }
.help-card p:last-child { margin-bottom: 0; }
.help-card ul { margin: 0; padding-left: 18px; }
.help-card li { margin-bottom: 7px; line-height: 1.45; }
.help-card li:last-child { margin-bottom: 0; }
.help-card .def { vertical-align: middle; }
.help .partial { color: var(--accent-2); }
.help-card-shiny {
  border-color: #e9c349;
  background: linear-gradient(135deg, rgba(247,201,72,0.10), rgba(247,201,72,0.03));
}
.help-card-shiny h3 { color: #ffd86b; }
@media (max-width: 700px) { .help { grid-template-columns: 1fr; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 20px; border-radius: 999px; box-shadow: var(--shadow); z-index: 60; font-weight: 600;
}
.toast[hidden] { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .draft-layout { grid-template-columns: 1fr; }
  .roster { position: static; }
  .bracket { grid-template-columns: 1fr; }
  .bcol-final, .bcol-champ { border-top: 1px solid var(--line); padding-top: 16px; }
}
@media (max-width: 480px) {
  .pos-slots { grid-template-columns: 1fr 1fr; }
  .pool { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .slot-choices { grid-template-columns: 1fr; }
}
