:root {
    --bg: #1a2332;
    --bg2: #212d3b;
    --bg3: #2a3847;
    --bg4: #354555;
    --text: #f0f4f8;
    --text2: #a8bdd0;
    --text3: #6b8299;
    --accent: #5b9cf6;
    --accent-dim: rgba(91, 156, 246, 0.12);
    --green: #34d399;
    --green-dim: rgba(52, 211, 153, 0.1);
    --gold: #fbbf24;
    --gold-dim: rgba(251, 191, 36, 0.12);
    --blue: #67d4ff;
    --red: #f87171;
    --border: #334155;
    --radius: 8px;
    --font: 'Inter', -apple-system, sans-serif;
    --mono: 'IBM Plex Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

.screen { display: none; min-height: 100vh; width: 100%; }
.screen.active { display: flex; }
#draft-screen.active { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ===== LANDING ===== */
#landing-screen { align-items: center; justify-content: center; }
.landing-wrap { text-align: center; padding: 2rem; max-width: 380px; }
.landing-logo { font-size: 4.5rem; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 0.6rem; }
.landing-desc { font-size: 0.85rem; color: var(--text2); line-height: 1.6; margin-bottom: 2rem; }
.landing-modes { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; }
.mode-row {
    display: flex; align-items: center; gap: 0.8rem;
    padding: 1rem 1.4rem; background: var(--bg3);
    border: 1px solid var(--border); border-radius: var(--radius);
    cursor: pointer; transition: background 0.12s, transform 0.1s;
}
.mode-row:hover { background: var(--bg4); transform: translateY(-1px); }
.mode-row strong { display: block; font-size: 1rem; font-weight: 500; color: var(--text); }
.mode-row span { font-size: 0.7rem; color: var(--text3); }
.mode-arrow { color: var(--text3); font-size: 0.65rem; }
.text-link { background: none; border: none; color: var(--text3); font-size: 0.75rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-family: var(--font); }
.text-link:hover { color: var(--text2); }

/* ===== TOPBAR ===== */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.8rem 1.2rem;
    background: var(--bg2); border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-logo { font-weight: 700; font-size: 1.1rem; }
.topbar-round { font-family: var(--mono); font-size: 0.75rem; color: var(--text2); }
.topbar-center { display: flex; gap: 0.5rem; align-items: center; }
.pill { font-family: var(--font); font-size: 1rem; font-weight: 600; padding: 0.4rem 1rem; border-radius: 20px; }
.pill-team { background: #3b82f6; color: white; }
.pill-era { background: #8b5cf6; color: white; }
.topbar-right { display: flex; align-items: center; gap: 0.4rem; }
.skip-btn {
    font-family: var(--mono); font-size: 0.62rem;
    padding: 0.3rem 0.5rem; background: var(--bg3);
    border: 1px solid var(--border); border-radius: 4px;
    color: var(--text2); cursor: pointer;
}
.skip-btn:hover:not(:disabled) { background: var(--bg4); }
.skip-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.skip-btn span { opacity: 0.6; }
.icon-btn {
    width: 26px; height: 26px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--bg3);
    color: var(--text2); font-size: 0.75rem; font-style: italic;
    font-weight: 600; cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--text3); }

/* ===== DRAFT BODY ===== */
.draft-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ===== PLAYER PANEL (left) ===== */
.player-panel {
    display: flex; flex-direction: column;
    border-right: 1px solid var(--border);
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.panel-controls {
    padding: 0.7rem 0.8rem 0.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.filter-tabs { display: flex; gap: 0.15rem; margin-bottom: 0.4rem; flex-wrap: wrap; }
.ftab {
    font-family: var(--mono); font-size: 0.6rem;
    padding: 0.25rem 0.5rem; border-radius: 4px;
    border: none; background: none;
    color: var(--text3); cursor: pointer;
}
.ftab:hover { color: var(--text2); }
.ftab.active { background: var(--accent); color: white; }

.panel-row2 { display: flex; gap: 0.3rem; margin-bottom: 0.3rem; }
.search-input {
    flex: 1; font-family: var(--font); font-size: 0.75rem;
    padding: 0.35rem 0.6rem; background: var(--bg2);
    border: 1px solid var(--border); border-radius: 4px;
    color: var(--text); outline: none;
}
.search-input::placeholder { color: var(--text3); }
.search-input:focus { border-color: var(--text3); }
.sort-select {
    font-family: var(--mono); font-size: 0.65rem;
    padding: 0.3rem 0.4rem; background: var(--bg2);
    border: 1px solid var(--border); border-radius: 4px;
    color: var(--text2); cursor: pointer;
}
.player-count { font-size: 0.65rem; color: var(--text3); }

/* Spin overlay */
.spin-overlay {
    position: absolute;
    top: 90px; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    z-index: 10;
}
.spin-overlay.hidden { display: none; }
.spin-btn {
    font-family: var(--font); font-size: 1rem; font-weight: 500;
    padding: 0.9rem 3rem; background: var(--accent); color: white;
    border: none; border-radius: var(--radius); cursor: pointer;
    letter-spacing: 0.05em;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: 0 2px 12px rgba(91, 156, 246, 0.25);
}
.spin-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(91, 156, 246, 0.35); }
.spin-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Player list */
.player-list { flex: 1; overflow-y: auto; min-height: 0; }
.player-list::-webkit-scrollbar { width: 4px; }
.player-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.p-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.55rem 0.8rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background 0.08s;
}
.p-row:hover { background: var(--bg2); }
.p-row.selected { background: var(--bg3); border-left: 3px solid var(--accent); }

.p-info { display: flex; flex-direction: column; gap: 0.05rem; }
.p-name { font-size: 0.82rem; font-weight: 600; }
.p-meta { font-family: var(--mono); font-size: 0.6rem; color: var(--text3); }
.p-badges { display: flex; gap: 0.2rem; margin-top: 0.15rem; }

.p-stats { display: flex; gap: 0.6rem; }
.p-stat { text-align: center; }
.p-stat-val { font-size: 0.78rem; font-weight: 600; display: block; }
.p-stat-label { font-size: 0.5rem; color: var(--text3); font-family: var(--mono); }

.badge { font-family: var(--mono); font-size: 0.5rem; padding: 0.1rem 0.3rem; border-radius: 3px; }
.b-hof { background: var(--gold-dim); color: var(--gold); }
.b-mvp { background: var(--green-dim); color: var(--green); }
.b-dpoy { background: rgba(79, 195, 247, 0.12); color: var(--blue); }
.b-ap { background: rgba(255,255,255,0.05); color: var(--text2); }

/* ===== FIELD PANEL (right) ===== */
.field-panel {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 1.5rem;
    overflow: hidden;
}

.field-wrap {
    width: 100%; max-width: 600px;
    aspect-ratio: 4/5;
    position: relative;
    background: linear-gradient(180deg, #0d3320 0%, #0a2a1a 100%);
    border-radius: var(--radius);
    border: 2px solid #1a4a35;
}

/* Yard lines */
.field-wrap::before {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent calc(20% - 1px),
        rgba(255,255,255,0.04) 20%
    );
    pointer-events: none;
}

.field { position: relative; width: 100%; height: 100%; }

.field-slot {
    position: absolute;
    width: 70px; height: 56px;
    border: 2px dashed rgba(232, 93, 42, 0.5);
    border-radius: var(--radius);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.12s;
    background: rgba(0,0,0,0.3);
}
.field-slot:hover { border-color: var(--accent); background: var(--accent-dim); }
.field-slot.highlight { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-dim); animation: pulse-slot 1s ease infinite; }
.field-slot.filled { border-style: solid; border-color: var(--green); background: var(--green-dim); cursor: default; }
.field-slot.filled .slot-label { color: var(--green); }

@keyframes pulse-slot { 0%,100%{opacity:1} 50%{opacity:0.7} }

.slot-label { font-family: var(--mono); font-size: 0.55rem; color: var(--text2); }
.slot-name { font-size: 0.55rem; font-weight: 500; text-align: center; margin-top: 0.1rem; max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Football formation - defense top, offense bottom */
#slot-DB   { top: 5%; left: 50%; transform: translate(-50%, 0); }
#slot-EDGE { top: 22%; left: 50%; transform: translate(-50%, 0); }
#slot-OL   { top: 37%; left: 50%; transform: translate(-50%, 0); }
#slot-WR1  { top: 37%; left: 4%; }
#slot-WR2  { top: 37%; right: 4%; left: auto; }
#slot-TE   { top: 45%; left: 18%; }
#slot-QB   { top: 58%; left: 50%; transform: translate(-50%, 0); }
#slot-RB   { top: 76%; left: 50%; transform: translate(-50%, 0); }

.placement-msg {
    margin-top: 0.8rem;
    font-family: var(--mono); font-size: 0.7rem;
    color: var(--accent); text-align: center;
}

/* ===== SIM ===== */
#sim-screen { align-items: center; justify-content: center; }
.sim-wrap { text-align: center; padding: 2rem; max-width: 450px; width: 100%; }
.sim-title { font-family: var(--mono); font-size: 0.8rem; color: var(--text2); letter-spacing: 0.15em; margin-bottom: 1.5rem; animation: pulse 1.2s ease infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.sim-bar-outer { width: 100%; height: 2px; background: var(--bg3); margin-bottom: 2rem; overflow: hidden; }
.sim-bar { height: 100%; width: 0%; background: var(--accent); transition: width 0.1s linear; }
.sim-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 0.3rem; }
.sim-wk { font-family: var(--mono); font-size: 0.6rem; padding: 0.35rem; background: var(--bg2); border: 1px solid var(--border); border-radius: 4px; opacity: 0; transition: all 0.15s; }
.sim-wk.show { opacity: 1; }
.sim-wk.W { border-color: rgba(39,201,123,0.35); color: var(--green); }
.sim-wk.L { border-color: rgba(239,83,80,0.35); color: var(--red); }

/* ===== RESULTS ===== */
#results-screen { align-items: center; justify-content: center; }
.results-wrap { text-align: center; padding: 2rem; max-width: 420px; width: 100%; }
.result-record { font-size: 5.5rem; font-weight: 700; letter-spacing: -0.04em; line-height: 1; margin-bottom: 0.3rem; opacity: 0; transform: scale(0.85); animation: pop 0.5s ease forwards 0.2s; }
@keyframes pop { 0%{opacity:0;transform:scale(0.85)} 70%{transform:scale(1.03)} 100%{opacity:1;transform:scale(1)} }
.rr-w { color: var(--green); }
.rr-d { color: var(--text3); margin: 0 0.05em; }
.rr-l { color: var(--red); }
.result-record.perfect .rr-w, .result-record.perfect .rr-d, .result-record.perfect .rr-l { color: var(--gold); text-shadow: 0 0 25px var(--gold-dim); }
.result-sub { font-family: var(--mono); font-size: 0.7rem; color: var(--text3); letter-spacing: 0.2em; margin-bottom: 2rem; opacity: 0; animation: fadein 0.3s ease forwards 0.6s; }
@keyframes fadein { to { opacity: 1; } }
.result-roster { text-align: left; margin-bottom: 1rem; opacity: 0; animation: fadein 0.3s ease forwards 0.8s; }
.rr-item { display: flex; align-items: center; padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.8rem; }
.rr-item:last-child { border-bottom: none; }
.rr-pos { font-family: var(--mono); font-size: 0.65rem; color: var(--accent); width: 3.5rem; }
.rr-name { flex: 1; font-weight: 500; }
.rr-meta { font-family: var(--mono); font-size: 0.6rem; color: var(--text3); }
.result-bonuses { margin-bottom: 1.5rem; opacity: 0; animation: fadein 0.3s ease forwards 1s; }
.bonus-line { font-family: var(--mono); font-size: 0.65rem; padding: 0.2rem 0; color: var(--green); }
.bonus-line.neg { color: var(--red); }
.result-btns { display: flex; gap: 0.6rem; justify-content: center; opacity: 0; animation: fadein 0.3s ease forwards 1.2s; }
.btn-main { font-family: var(--font); font-size: 0.82rem; font-weight: 500; padding: 0.7rem 1.8rem; border-radius: var(--radius); background: var(--accent); border: none; color: white; cursor: pointer; box-shadow: 0 2px 10px rgba(91, 156, 246, 0.2); }
.btn-main:hover { background: #4a8be0; }
.btn-sec { font-family: var(--font); font-size: 0.82rem; font-weight: 500; padding: 0.7rem 1.8rem; border-radius: var(--radius); background: var(--bg2); border: 1px solid var(--border); color: var(--text); cursor: pointer; }
.btn-sec:hover { background: var(--bg3); }

/* ===== MODALS ===== */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.modal.active { display: flex; }
.modal-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.8rem; max-width: 480px; width: 90%; max-height: 80vh; overflow-y: auto; position: relative; }
.modal-box h3 { font-size: 1rem; margin-bottom: 1rem; }
.modal-x { position: absolute; top: 0.8rem; right: 1rem; background: none; border: none; color: var(--text3); font-size: 1.3rem; cursor: pointer; }
.modal-x:hover { color: var(--text); }
.modal-body p { font-size: 0.78rem; color: var(--text2); line-height: 1.6; margin-bottom: 0.8rem; }
.modal-body ul { list-style: none; margin-bottom: 0.8rem; }
.modal-body li { font-size: 0.78rem; color: var(--text2); line-height: 1.6; padding: 0.3rem 0; }
.modal-body li strong { color: var(--text); }
.modal-note { font-size: 0.7rem !important; color: var(--text3) !important; border-top: 1px solid var(--border); padding-top: 0.8rem; margin-top: 0.5rem; }

/* ===== CONFETTI / TOAST ===== */
#confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 9999; }
.toast { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(60px); background: var(--bg3); border: 1px solid var(--border); padding: 0.6rem 1.2rem; border-radius: var(--radius); font-family: var(--mono); font-size: 0.7rem; color: var(--green); z-index: 10000; transition: transform 0.25s ease; }
.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .draft-body { grid-template-columns: 1fr; }
    .field-panel { min-height: 300px; border-top: 1px solid var(--border); }
    .player-panel { min-height: 50vh; border-right: none; }
    .topbar { flex-wrap: wrap; gap: 0.4rem; }
}
