/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #8b1a1a;
    --primary-dark: #6b1414;
    --accent: #c0842a;
    --success: #2e7d32;
    --warning: #c0842a;
    --danger: #8b1a1a;

    --bg: #1c1410;
    --panel-bg: #241a12;
    --glass-bg: rgba(36, 26, 18, 0.97);
    --glass-border: rgba(192, 132, 42, 0.3);
    --glass-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);

    --text-main: #f0e6d3;
    --text-muted: #9e8a72;
}

body {
    font-family: 'DM Mono', monospace;
    background: var(--bg);
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 40px,
            rgba(192,132,42,0.04) 40px,
            rgba(192,132,42,0.04) 41px
        );
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.6;
    background-attachment: fixed;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    background: var(--panel-bg);
    border-bottom: 2px solid var(--accent);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-family: 'DM Serif Display', serif;
    font-style: italic;
    font-size: 2.5rem;
    font-weight: 400;
    color: var(--accent);
    text-shadow: 0 2px 8px rgba(192, 132, 42, 0.25);
    letter-spacing: 0;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-family: 'DM Mono', monospace;
}

/* ============================================
   GLASSMORPHISM CARDS
   ============================================ */
.card {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 30px;
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
    border-color: rgba(255, 255, 255, 0.3);
}

.card h2 {
    color: var(--text-main);
    margin-bottom: 25px;
    font-size: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 15px;
}

/* ============================================
   CONTROLS & INPUTS
   ============================================ */
.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-weight: 500;
}

.input-group {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 5px;
    border: 1px solid var(--glass-border);
}

.input-group input {
    background: transparent;
    border: none;
    color: white;
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    width: 60px;
}

.btn-sm {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sm:hover {
    background: var(--primary);
}

/* ============================================
   MAIN BUTTONS
   ============================================ */
.btn-primary {
    background: var(--primary);
    color: #f0e6d3;
    border: 1px solid rgba(192,132,42,0.3);
    padding: 15px 40px;
    border-radius: 4px;
    font-family: 'DM Mono', monospace;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    width: 100%;
}

.btn-primary:hover {
    transform: none;
    background: #a82020;
    box-shadow: 0 0 16px rgba(192, 132, 42, 0.2);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   GAME BOARD
   ============================================ */
.game-board {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 30px;
    margin-top: 30px;
}

.track-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    padding: 20px;
    border: 1px solid var(--glass-border);
    overflow-x: auto;
}

.track-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.3s;
}

.track-row:hover {
    background: rgba(255, 255, 255, 0.07);
}

/* ============================================
   CARDS
   ============================================ */
.playing-card {
    width: 60px;
    height: 90px;
    background: white;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    position: relative;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.playing-card.red { color: #ef4444; }
.playing-card.black { color: #1f2937; }

.playing-card:hover {
    transform: scale(1.1) rotate(3deg);
    z-index: 10;
}

/* Side Cards (Hidden) */
.side-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.side-card-slot {
    width: 80px;
    height: 110px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card-back {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid #334155;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(255,255,255,0.1);
    font-size: 2rem;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.winner-highlight {
    animation: float 2s ease-in-out infinite;
    box-shadow: 0 0 30px #fbbf24;
    border: 2px solid #fbbf24;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .game-board {
        grid-template-columns: 1fr;
    }
    
    .side-cards {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
}
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
}

/* ============================================
   GAME CONTAINER
   ============================================ */
.game-container {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 20px;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card h2, .card h3 {
    margin-bottom: 20px;
    color: var(--dark);
}

.card h2 i, .card h3 i {
    margin-right: 10px;
    color: var(--primary);
}

/* ============================================
   SETTINGS PANEL
   ============================================ */
.settings-panel {
    max-width: 600px;
    margin: 0 auto;
}

.setting-group {
    margin-bottom: 25px;
}

.setting-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--dark);
}

.input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-group input {
    flex: 1;
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    padding: 10px;
    border: 2px solid var(--light);
    border-radius: 8px;
    background: var(--light);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 1em;
    font-weight: bold;
    border-radius: 6px;
    min-width: 40px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* Horse color buttons */
.btn-horse {
    font-size: 2em;
    padding: 15px 30px;
    background: white;
    border: 3px solid;
    margin: 5px;
}

.btn-horse.spade {
    border-color: var(--spade);
    color: var(--spade);
}

.btn-horse.heart {
    border-color: var(--heart);
    color: var(--heart);
}

.btn-horse.diamond {
    border-color: var(--diamond);
    color: var(--diamond);
}

.btn-horse.club {
    border-color: var(--club);
    color: var(--club);
}

.btn-horse:hover {
    transform: scale(1.1);
}

/* ============================================
   RULES CARD
   ============================================ */
.rules-card {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.rules-list {
    list-style: none;
    padding-left: 0;
}

.rules-list li {
    padding: 10px 0;
    padding-left: 30px;
    position: relative;
}

.rules-list li::before {
    content: "🏇";
    position: absolute;
    left: 0;
}

.rules-list strong {
    color: var(--primary-dark);
}

/* ============================================
   GAME BOARD
   ============================================ */
.game-board {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .game-board {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   RACE TRACK
   ============================================ */
.race-track-container {
    min-height: 500px;
}

.race-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.race-info {
    display: flex;
    gap: 15px;
}

.info-badge {
    background: var(--light);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
}

.info-badge strong {
    color: var(--primary);
}

.race-track {
    background: linear-gradient(to right, #dcfce7 0%, #86efac 100%);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    min-height: 400px;
}

.horse-lane {
    display: grid;
    grid-template-columns: 60px repeat(auto-fit, minmax(60px, 1fr));
    gap: 5px;
    margin-bottom: 15px;
    align-items: center;
}

.horse-icon {
    font-size: 2.5em;
    text-align: center;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

.slot {
    background: white;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    transition: all 0.3s ease;
}

.slot.finish-line {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 3px solid var(--warning);
    font-weight: bold;
}

.slot.active {
    background: #fef3c7;
    border-color: var(--warning);
    border-style: solid;
    transform: scale(1.1);
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0%, 100% { transform: scale(1.1); }
    50% { transform: scale(1.2); }
}

.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   BETTING PANEL
   ============================================ */
.betting-panel {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.player-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.player-tab {
    flex: 1;
    min-width: 80px;
    padding: 10px;
    background: var(--light);
    border: 2px solid transparent;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    transition: all 0.3s ease;
}

.player-tab:hover {
    background: #e5e7eb;
}

.player-tab.active {
    background: white;
    border-color: var(--primary);
    border-bottom: 2px solid white;
    color: var(--primary);
}

.betting-content {
    padding: 20px 0;
}

.bet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 15px;
    background: var(--light);
    border-radius: 8px;
}

.bet-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2em;
    font-weight: 600;
}

.bet-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.bet-value {
    min-width: 40px;
    text-align: center;
    font-weight: bold;
    font-size: 1.1em;
}

.sips-remaining {
    text-align: center;
    margin-top: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.1em;
}

.bonus-section {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 10px;
    text-align: center;
}

.bonus-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

/* ============================================
   STATISTICS
   ============================================ */
.stats-card {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-weight: 600;
}

.stat-value {
    font-weight: bold;
    color: var(--primary);
}

.stat-horses {
    margin-top: 15px;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 600px;
    text-align: center;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.winner-horse {
    font-size: 5em;
    margin: 20px 0;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.winner-details {
    font-size: 1.2em;
    margin: 20px 0;
    line-height: 1.8;
}

.winner-details strong {
    color: var(--primary);
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    background: var(--darker);
    color: white;
    text-align: center;
    padding: 20px;
    margin-top: 50px;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.warning {
    margin-top: 10px;
    color: var(--warning);
    font-weight: bold;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2em;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .horse-lane {
        grid-template-columns: 40px repeat(auto-fit, minmax(40px, 1fr));
    }
    
    .horse-icon {
        font-size: 1.8em;
    }
    
    .slot {
        height: 40px;
        font-size: 1.2em;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 0.9em;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .controls .btn {
        width: 100%;
    }
}
