/* ══════════════════════════════════════════════════════════
   BLACKJACK BASEBALL — ALLEN & GINTER EDITION
   Inspired by T206 tobacco cards & Topps Allen & Ginter minis
   ══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=UnifrakturMaguntia&family=Special+Elite&display=swap');

:root {
    /* Tobacco card palette */
    --card-cream: #f0e6cf;
    --card-aged: #e8d9b8;
    --card-dark: #d4c49a;
    --card-border: #8b7355;
    --card-border-dark: #5c4a32;

    /* Rich accent colors from the T206 backs */
    --tobacco-green: #2d5a3d;
    --tobacco-green-dark: #1a3625;
    --tobacco-red: #8b2332;
    --tobacco-red-light: #a83242;
    --tobacco-navy: #1e2d4a;
    --tobacco-gold: #c4a24e;
    --tobacco-gold-light: #d4b86a;
    --tobacco-ink: #2a1f14;

    --paper-noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

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

body {
    font-family: 'Libre Baskerville', 'Georgia', serif;
    background-color: #1c1812;
    background-image:
        radial-gradient(ellipse at 30% 50%, rgba(44, 36, 22, 0.8) 0%, transparent 70%),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px);
    min-height: 100vh;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: hidden;
    color: var(--tobacco-ink);
}

/* ══════════════════════════════════════
   SPLASH SCREEN
   ══════════════════════════════════════ */
#splash-screen {
    position: fixed;
    inset: 0;
    background: rgba(12, 10, 6, 0.92);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease;
}

.splash-content {
    background: var(--card-cream);
    background-image: var(--paper-noise);
    border: 3px solid var(--card-border-dark);
    outline: 2px solid var(--card-border);
    outline-offset: 4px;
    padding: 50px 60px;
    max-width: 700px;
    text-align: center;
    box-shadow:
        0 0 0 8px var(--card-cream),
        0 0 0 10px var(--card-border),
        0 20px 60px rgba(0,0,0,0.7);
    position: relative;
}

.splash-content::before,
.splash-content::after {
    content: '◆';
    position: absolute;
    font-size: 1rem;
    color: var(--tobacco-red);
    opacity: 0.7;
}
.splash-content::before { top: 12px; left: 12px; }
.splash-content::after { bottom: 12px; right: 12px; }

.splash-title {
    font-family: 'UnifrakturMaguntia', cursive;
    font-size: 3.8rem;
    color: var(--tobacco-ink);
    margin-bottom: 5px;
    line-height: 1.1;
}

.splash-subtitle {
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    font-style: italic;
    color: var(--card-border);
    margin-bottom: 25px;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.splash-divider {
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--card-border-dark), transparent);
    margin: 0 auto 25px;
}

.splash-pick {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--tobacco-ink);
    margin-bottom: 20px;
}

.team-select-container {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 10px;
}

.team-btn {
    background: var(--card-aged);
    color: var(--tobacco-ink);
    border: 2px solid var(--card-border);
    padding: 14px 28px;
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: 1.15rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
}

.team-btn:hover {
    background: var(--card-cream);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transform: translateY(-2px);
}

.team-btn.nyy { border-bottom: 4px solid var(--tobacco-navy); color: var(--tobacco-navy); }
.team-btn.sea { border-bottom: 4px solid var(--tobacco-green); color: var(--tobacco-green); }

/* ══════════════════════════════════════
   LEFT SIDEBAR — SCOREBOARD
   ══════════════════════════════════════ */
#green-monster {
    width: 370px;
    min-height: 100vh;
    background: var(--tobacco-green-dark);
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 1px, rgba(0,0,0,0.08) 1px, rgba(0,0,0,0.08) 2px);
    border-right: 4px solid var(--card-border-dark);
    box-shadow: 4px 0 20px rgba(0,0,0,0.6);
    color: var(--card-cream);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

#green-monster::after {
    content: '';
    position: absolute;
    top: 8px; right: 8px; bottom: 8px; left: 8px;
    border: 2px dotted rgba(255,255,255,0.15);
    border-radius: 2px;
    pointer-events: none;
}

.monster-title {
    text-align: center;
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: 1.2rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--tobacco-gold-light);
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.monster-series {
    text-align: center;
    font-family: 'Libre Baskerville', serif;
    font-size: 0.75rem;
    font-style: italic;
    color: rgba(255,255,255,0.4);
    letter-spacing: 2px;
    margin-top: -14px;
    margin-bottom: 18px;
}

.line-score {
    display: grid;
    gap: 1px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    margin-bottom: 24px;
    overflow-x: auto;
}

.ls-cell {
    background: var(--tobacco-green-dark);
    text-align: center;
    padding: 4px 0;
    font-family: 'Special Elite', monospace;
    font-size: 1.05rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 24px;
}

.ls-header { color: rgba(255,255,255,0.45); font-size: 0.85rem; font-family: 'Libre Baskerville', serif; }
.ls-team { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 1rem; text-align: left; padding-left: 6px; letter-spacing: 1px; color: var(--tobacco-gold-light); }
.ls-runs { background: rgba(0,0,0,0.3); color: var(--tobacco-gold); font-weight: bold; }

.outs-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 24px;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.6);
}

.out-light {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.4);
    border: 2px solid rgba(255,255,255,0.25);
    transition: all 0.3s;
}

.out-light.lit {
    background: var(--tobacco-red);
    border-color: var(--tobacco-red-light);
    box-shadow: 0 0 12px rgba(139, 35, 50, 0.8), inset 0 1px 2px rgba(255,255,255,0.3);
}

.player-plate {
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.12);
    padding: 10px 12px;
    margin-bottom: 12px;
    position: relative;
}

.player-plate::before {
    content: '';
    position: absolute;
    top: 2px; right: 2px; bottom: 2px; left: 2px;
    border: 1px dotted rgba(255,255,255,0.08);
    pointer-events: none;
}

.plate-label {
    font-family: 'Playfair Display', serif;
    font-size: 0.7rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    margin-bottom: 4px;
}

.plate-name {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: 1.5rem;
    letter-spacing: 1px;
    color: var(--card-cream);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plate-stat {
    font-family: 'Special Elite', monospace;
    font-size: 1.1rem;
    color: var(--tobacco-gold);
    float: right;
}

.plate-stats-row {
    margin-top: 6px;
    font-family: 'Libre Baskerville', serif;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.45);
    letter-spacing: 1px;
}

.plate-stats-row span {
    color: var(--tobacco-gold-light);
    font-family: 'Special Elite', monospace;
    font-size: 0.9rem;
}

/* ══════════════════════════════════════
   CENTER — ACTION AREA
   ══════════════════════════════════════ */
#action-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    min-width: 500px;
}

#parchment-board {
    background: var(--card-cream);
    background-image: var(--paper-noise);
    width: 100%;
    max-width: 620px;
    border: 3px solid var(--card-border-dark);
    box-shadow:
        0 0 0 1px var(--card-border),
        0 0 0 5px var(--card-aged),
        0 0 0 6px var(--card-border),
        0 12px 40px rgba(0,0,0,0.6);
    padding: 28px;
    position: relative;
    color: var(--tobacco-ink);
}

#parchment-board::before {
    content: '';
    position: absolute;
    top: 6px; right: 6px; bottom: 6px; left: 6px;
    border: 2px dotted var(--card-border);
    opacity: 0.4;
    pointer-events: none;
}

/* ══════ DIAMOND ══════ */
#diamond {
    position: relative;
    width: 90px; height: 90px;
    transform: rotate(45deg);
    border: 2px solid var(--tobacco-ink);
    margin: 0 auto 28px auto;
}

.base {
    position: absolute;
    width: 18px; height: 18px;
    background: var(--card-cream);
    border: 2px solid var(--tobacco-ink);
}

#base-h { bottom: -9px; right: -9px; border-radius: 50% 50% 0 50%; }
#base-1 { top: -9px; right: -9px; }
#base-2 { top: -9px; left: -9px; }
#base-3 { bottom: -9px; left: -9px; }

.runner {
    background: var(--tobacco-red);
    width: 10px; height: 10px;
    border-radius: 50%;
    position: absolute;
    top: 2px; left: 2px;
    display: none;
    box-shadow: 0 0 6px rgba(139, 35, 50, 0.6);
}

/* ══════ CARD TABLE ══════ */
.card-table { display: flex; flex-direction: column; gap: 16px; margin-bottom: 18px; }

.hand-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(90, 74, 50, 0.06);
    padding: 14px;
    border: 1px solid var(--card-border);
}

.hand-label {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--card-border-dark);
    margin-bottom: 10px;
}

.cards-container { display: flex; gap: 8px; min-height: 90px; justify-content: center; flex-wrap: wrap; }

.playing-card {
    width: 62px; height: 92px;
    background: var(--card-cream);
    border: 2px solid var(--card-border);
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px;
    font-family: 'Libre Baskerville', serif;
    font-size: 1.05rem;
    font-weight: bold;
    box-shadow: 1px 2px 6px rgba(0,0,0,0.25);
    position: relative;
}

.playing-card::after {
    content: '';
    position: absolute;
    top: 3px; right: 3px; bottom: 3px; left: 3px;
    border: 1px dotted rgba(139, 115, 85, 0.3);
    pointer-events: none;
}

.playing-card.red { color: var(--tobacco-red); }
.playing-card.black { color: var(--tobacco-ink); }

.playing-card.hidden {
    background: var(--tobacco-green-dark);
    border-color: var(--card-border-dark);
    background-image:
        repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(255,255,255,0.05) 4px, rgba(255,255,255,0.05) 8px);
    color: transparent;
}

.playing-card.hidden::after { border-color: rgba(255,255,255,0.1); }

.card-top { align-self: flex-start; font-size: 0.85rem; }
.card-center { align-self: center; font-size: 1.6rem; }
.card-bottom { align-self: flex-end; transform: rotate(180deg); font-size: 0.85rem; }

.hand-value {
    font-family: 'Special Elite', monospace;
    font-size: 1.4rem;
    margin-top: 8px;
    color: var(--tobacco-red);
    font-weight: bold;
}

/* ══════ BUTTONS ══════ */
.btn-group { display: flex; gap: 12px; margin-top: 12px; width: 100%; }

button.action-btn {
    background: var(--tobacco-ink);
    color: var(--card-cream);
    border: 2px solid var(--tobacco-ink);
    padding: 13px 10px;
    flex-grow: 1;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
}

button.action-btn:hover:not(:disabled) { background: var(--tobacco-red); border-color: var(--tobacco-red); }

button.action-btn:disabled {
    background: #444;
    color: #888;
    border-color: #444;
    cursor: not-allowed;
    display: none;
}

/* ══════ GAME LOG ══════ */
#game-log {
    height: 130px;
    overflow-y: auto;
    border-top: 1px solid var(--card-border);
    margin-top: 18px;
    padding-top: 10px;
    font-family: 'Special Elite', monospace;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--tobacco-ink);
}

#game-log::-webkit-scrollbar { width: 6px; }
#game-log::-webkit-scrollbar-track { background: var(--card-aged); }
#game-log::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 3px; }

/* ══════════════════════════════════════
   RIGHT SIDEBAR — RULES
   ══════════════════════════════════════ */
#rules-panel {
    width: 300px;
    background: var(--card-aged);
    background-image: var(--paper-noise);
    border-left: 4px solid var(--card-border-dark);
    padding: 22px 16px;
    color: var(--tobacco-ink);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 15px rgba(0,0,0,0.4);
    position: relative;
    overflow-y: auto;
}

#rules-panel::before {
    content: '';
    position: absolute;
    top: 8px; right: 8px; bottom: 8px; left: 8px;
    border: 2px solid var(--card-border);
    opacity: 0.3;
    pointer-events: none;
}

.rules-title {
    font-family: 'UnifrakturMaguntia', cursive;
    font-size: 1.6rem;
    text-align: center;
    color: var(--tobacco-ink);
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}

.rules-series-label {
    font-family: 'Playfair Display', serif;
    font-size: 0.65rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    text-align: center;
    color: var(--card-border-dark);
    margin-bottom: 16px;
}

.rules-divider {
    width: 80%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--card-border-dark), transparent);
    margin: 0 auto 14px;
}

.rules-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Libre Baskerville', serif;
    font-size: 0.8rem;
    background: var(--card-cream);
    box-shadow: 1px 2px 5px rgba(0,0,0,0.15);
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.rules-table th, .rules-table td { border: 1px solid var(--card-border); padding: 7px 6px; text-align: left; }

.rules-table th {
    background: var(--tobacco-ink);
    color: var(--card-cream);
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.7rem;
}

.rules-table tr:nth-child(even) { background-color: rgba(139, 115, 85, 0.06); }
.rules-table strong { font-family: 'Playfair Display', serif; font-size: 0.9rem; }
.rules-table .rule-detail { font-size: 0.7rem; color: var(--card-border-dark); font-style: italic; }

.rules-note {
    margin-top: 12px;
    font-size: 0.8rem;
    font-style: italic;
    border-top: 1px solid var(--card-border);
    padding-top: 10px;
    color: var(--card-border-dark);
    position: relative;
    z-index: 1;
}

.rules-note strong { font-family: 'Playfair Display', serif; font-style: normal; color: var(--tobacco-ink); }

/* ══════════════════════════════════════
   RESULT FLASH
   ══════════════════════════════════════ */
#result-flash {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: 4rem;
    color: white;
    text-transform: uppercase;
    text-align: center;
    padding: 18px 36px;
    border: 6px solid white;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    text-shadow: 3px 3px 0 #000;
    box-shadow: 0 15px 40px rgba(0,0,0,0.7);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    letter-spacing: 3px;
}

#result-flash.show { transform: translate(-50%, -50%) scale(1) rotate(-5deg); opacity: 1; }

.flash-out { background: var(--tobacco-red); }
.flash-hit { background: var(--tobacco-green); }
.flash-hr { background: var(--tobacco-navy); color: var(--tobacco-gold); border-color: var(--tobacco-gold); }
.flash-walk { background: var(--tobacco-gold); color: var(--tobacco-ink); text-shadow: none; border-color: var(--tobacco-ink); }

/* ══════════════════════════════════════
   STAT CHECK MODAL
   ══════════════════════════════════════ */
#stat-check-modal {
    position: absolute;
    inset: 0;
    background: rgba(12, 10, 6, 0.92);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#stat-check-modal.active { opacity: 1; pointer-events: auto; }

.check-title {
    font-family: 'UnifrakturMaguntia', cursive;
    font-size: 2.6rem;
    color: var(--card-cream);
    margin-bottom: 8px;
    text-shadow: 2px 2px 8px black;
}

.check-subtitle {
    font-family: 'Special Elite', monospace;
    font-size: 1.2rem;
    color: var(--tobacco-gold);
    margin-bottom: 20px;
    text-align: center;
}

.flip-container { perspective: 1000px; width: 120px; height: 180px; margin-bottom: 20px; }
.flipper { width: 100%; height: 100%; transition: transform 0.8s; transform-style: preserve-3d; position: relative; }
.flip-container.flipped .flipper { transform: rotateY(180deg); }

.front, .back {
    width: 100%; height: 100%;
    position: absolute;
    backface-visibility: hidden;
    border-radius: 4px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
}

.front {
    background: var(--tobacco-green-dark);
    border: 3px solid var(--card-border-dark);
    background-image: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(255,255,255,0.04) 8px, rgba(255,255,255,0.04) 16px);
    position: relative;
}

.front::after {
    content: '';
    position: absolute;
    top: 6px; right: 6px; bottom: 6px; left: 6px;
    border: 1px dotted rgba(255,255,255,0.15);
}

.back {
    background: var(--card-cream);
    border: 3px solid var(--card-border);
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px;
    font-family: 'Libre Baskerville', serif;
    font-weight: bold;
    font-size: 1.6rem;
}

.back.red { color: var(--tobacco-red); }
.back.black { color: var(--tobacco-ink); }
.back .card-center { font-size: 3.2rem; text-align: center; }

.hit-meter-wrapper {
    width: 360px;
    background: rgba(0,0,0,0.5);
    border: 2px solid var(--card-border);
    border-radius: 4px;
    position: relative;
    height: 36px;
    margin-bottom: 18px;
    overflow: hidden;
    display: none;
    box-shadow: inset 0 4px 10px rgba(0,0,0,0.6);
}

.hit-meter-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--tobacco-red) 0%, var(--tobacco-gold) 50%, var(--tobacco-green) 80%, var(--tobacco-navy) 100%);
    transition: width 1.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.hit-meter-markers {
    position: absolute;
    inset: 0;
    display: flex;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: rgba(255,255,255,0.65);
    text-shadow: 1px 1px 2px black;
    font-size: 1rem;
    letter-spacing: 1px;
}

.hit-meter-markers div {
    border-right: 1px dashed rgba(255,255,255,0.25);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 5px;
}

.m-1b { width: 46%; }
.m-2b { width: 20%; }
.m-3b { width: 14%; }
.m-hr { width: 20%; border-right: none !important; }

.check-result-text {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: 2.4rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateY(20px);
    text-align: center;
}

.check-result-text.show { opacity: 1; transform: translateY(0); }
.text-success { color: #5a9e6f; text-shadow: 2px 2px 0px rgba(0,0,0,0.3); }
.text-fail { color: var(--tobacco-red-light); text-shadow: 2px 2px 0px rgba(0,0,0,0.3); }
.text-neutral { color: var(--tobacco-gold); text-shadow: 2px 2px 0px rgba(0,0,0,0.3); }

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */
@media (max-width: 1100px) {
    body { flex-wrap: wrap; }
    #rules-panel { width: 100%; border-left: none; border-top: 4px solid var(--card-border-dark); }
}
