 @import url('');

        /* --- THEME VARIABLES --- */
        :root {
            --bg-color: #050505;
            --text-color: #e0e0e0;
            --panel-bg: rgba(20, 20, 20, 0.95);
            --navbar-bg: rgba(10, 10, 10, 0.95);
            --accent-color: #d4af37;
            --secondary-color: #b0b0b0;
            --border-color: rgba(255, 255, 255, 0.1);
            --input-bg: #0f0f0f;
            --btn-bg: #1a1a1a;
            --btn-hover: #252525;
            --shadow-color: rgba(0,0,0,0.8);
        }

        * {
            box-sizing: border-box;
            user-select: none; /* Prevent selection on mobile taps */
        }

        body {
            margin: 0;
            padding: 0;
            width: 100vw;
            height: 100vh;
            display: flex;
            flex-direction: column;
            background-color: var(--bg-color);
            font-family: 'Montserrat', sans-serif;
            color: var(--text-color);
            overflow: hidden;
            transition: background-color 0.5s ease, color 0.5s ease;
        }

        canvas {
            display: block; /* Prevents scrollbars */
        }

        /* --- SPLASH SCREEN --- */
        #splash-screen {
            position: fixed;
            top: 0; left: 0;
            width: 100vw; height: 100vh;
            background-color: var(--bg-color);
            z-index: 9999;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            transition: opacity 0.8s ease-out, visibility 0.8s;
        }

        .splash-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            animation: fadeIn 1s ease-in;
        }

        .game-logo-container {
            width: 150px;
            height: 150px;
            background: radial-gradient(circle, #222, #000); 
            border: 3px solid var(--accent-color);
            border-radius: 25px;
            display: flex;
            justify-content: center;
            align-items: center;
            margin-bottom: 25px;
            box-shadow: 0 0 40px rgba(212, 175, 55, 0.2);
            animation: pulseLogo 2s infinite;
            overflow: hidden;
            padding: 10px;
        }

        .game-logo-img {
            width: 100%;
            height: 100%;
            object-fit: contain;
        }

        /* Fallback if image fails */
        .game-logo-img:after {
            content: '\f447'; /* FontAwesome Chess Knight */
            font-family: "Font Awesome 6 Free";
            font-weight: 900;
            font-size: 80px;
            color: var(--accent-color);
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0; left: 0;
            background: #000;
        }

        .splash-title {
            font-family: 'Playfair Display', serif;
            font-size: 32px;
            color: var(--accent-color);
            margin-bottom: 5px;
            text-transform: uppercase;
            letter-spacing: 2px;
            text-align: center;
        }

        .splash-subtitle {
            font-size: 14px;
            color: var(--secondary-color);
            margin-bottom: 30px;
            letter-spacing: 1px;
            text-align: center;
        }

        .loading-bar-container {
            width: 220px;
            height: 6px;
            background: #222;
            border-radius: 3px;
            overflow: hidden;
            position: relative;
        }

        .loading-bar {
            position: absolute;
            left: 0; top: 0;
            height: 100%;
            width: 0%;
            background: var(--accent-color);
            border-radius: 3px;
            animation: loadProgress 2.2s ease-in-out forwards;
        }

        @keyframes loadProgress {
            0% { width: 0%; }
            50% { width: 60%; }
            100% { width: 100%; }
        }

        @keyframes pulseLogo {
            0% { transform: scale(1); box-shadow: 0 0 20px rgba(212, 175, 55, 0.2); }
            50% { transform: scale(1.05); box-shadow: 0 0 50px rgba(212, 175, 55, 0.5); }
            100% { transform: scale(1); box-shadow: 0 0 20px rgba(212, 175, 55, 0.2); }
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* --- TOP NAVBAR --- */
        #top-navbar {
            height: 60px;
            background: var(--navbar-bg);
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 20px;
            border-bottom: 1px solid var(--accent-color);
            box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(10px);
            z-index: 20;
            transition: background 0.5s ease;
            flex-shrink: 0; 
        }

        .logo-section {
            font-family: 'Playfair Display', serif;
            font-size: 20px;
            color: var(--accent-color);
            display: flex;
            align-items: center;
            gap: 8px;
            text-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
            letter-spacing: 1px;
        }

        .nav-actions {
            display: flex;
            gap: 10px;
            align-items: center;
        }

        .nav-btn {
            background: linear-gradient(145deg, var(--btn-bg), #222);
            border: 1px solid var(--border-color);
            color: var(--secondary-color);
            padding: 6px 12px;
            border-radius: 6px;
            cursor: pointer;
            font-weight: 600;
            transition: all 0.3s ease;
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            white-space: nowrap;
        }
        .nav-btn:hover {
            border-color: var(--accent-color);
            color: var(--accent-color);
        }

        .wallet-box {
            background: rgba(0, 0, 0, 0.3);
            padding: 6px 15px;
            border-radius: 50px;
            border: 1px solid #27ae60;
            color: #2ecc71;
            font-weight: 800;
            font-size: 14px;
            display: flex;
            align-items: center;
            gap: 5px;
        }

        /* --- GAME LAYOUT (RESPONSIVE) --- */
        #game-layout {
            display: flex;
            width: 100%;
            height: calc(100vh - 60px); 
            flex-direction: row; 
            overflow: hidden;
        }

        #canvas-target {
            flex-grow: 1;
            height: 100%;
            background-color: #1e5128;
            position: relative;
            overflow: hidden;
            box-shadow: inset 0 0 100px rgba(0,0,0,0.9);
            min-height: 200px; /* Ensure minimum height */
        }

        /* --- SIDEBAR PANEL --- */
        #ui-panel {
            width: 360px;
            height: 100%;
            background: var(--panel-bg);
            backdrop-filter: blur(15px);
            padding: 15px;
            display: flex;
            flex-direction: column;
            gap: 15px;
            box-sizing: border-box;
            border-left: 1px solid var(--border-color);
            box-shadow: -10px 0 50px var(--shadow-color);
            z-index: 10;
            overflow-y: auto;
            transition: background 0.5s ease;
            flex-shrink: 0;
        }

        #ui-panel::-webkit-scrollbar { width: 4px; }
        #ui-panel::-webkit-scrollbar-track { background: var(--bg-color); }
        #ui-panel::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

        /* --- RESPONSIVE MEDIA QUERIES --- */
        @media (max-width: 900px) {
            #game-layout {
                flex-direction: column; 
            }

            #canvas-target {
                width: 100%;
                height: 50%; 
                flex-grow: 1;
            }

            #ui-panel {
                width: 100%;
                height: 50%;
                border-left: none;
                border-top: 1px solid var(--border-color);
                box-shadow: 0 -10px 50px var(--shadow-color);
                padding: 10px;
                gap: 10px;
                flex-shrink: 0;
                min-height: 320px;
                /* Enables smooth scrolling on mobile */
                overflow-y: auto; 
                -webkit-overflow-scrolling: touch;
            }

            /* Ensures history section is visible and causes scroll */
            #history-section {
                min-height: 200px;
                flex-shrink: 0;
            }

            .control-group {
                padding: 8px;
                gap: 5px;
            }
            
            label { font-size: 10px; margin-bottom: 2px; }
            .horse-btn { width: 35px; height: 35px; font-size: 14px; }
            input[type="number"] { padding: 8px; font-size: 16px; }
            .quick-bet-btn { padding: 6px 0; font-size: 10px; }
            .action-btn { padding: 12px; font-size: 14px; }

            .nav-btn span { display: none; }
            .nav-btn i { margin: 0; }
        }

        .control-group {
            width: 100%;
            background: rgba(255,255,255,0.03);
            padding: 12px;
            border-radius: 12px;
            border: 1px solid var(--border-color);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
            box-sizing: border-box;
        }

        label {
            font-size: 11px;
            color: var(--secondary-color);
            text-transform: uppercase;
            letter-spacing: 2px;
            font-weight: 700;
            margin-bottom: 5px;
            width: 100%;
            text-align: left;
            padding-left: 5px;
        }

        #horse-selector {
            display: flex;
            gap: 10px;
            justify-content: center;
            width: 100%;
        }
        .horse-btn {
            width: 45px;
            height: 45px;
            border-radius: 10px;
            border: 1px solid var(--border-color);
            font-weight: 800;
            font-size: 18px;
            cursor: pointer;
            background: var(--btn-bg);
            color: var(--secondary-color);
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            overflow: hidden;
        }
        .horse-btn:hover { 
            background: var(--btn-hover); 
            color: var(--text-color); 
            transform: translateY(-2px);
        }
        .horse-btn.selected {
            background-color: var(--accent-color);
            color: #000;
            border-color: #fff;
            box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
            transform: translateY(-3px) scale(1.05);
        }

        input[type="number"] {
            padding: 12px;
            border-radius: 8px;
            border: 1px solid #333;
            width: 100%;
            text-align: center;
            font-size: 20px;
            font-weight: 700;
            color: var(--text-color);
            background: var(--input-bg);
            font-family: 'Montserrat', sans-serif;
            transition: border 0.3s;
        }
        input[type="number"]:focus {
            outline: none;
            border-color: var(--accent-color);
        }
        
        .quick-bet-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 8px;
            width: 100%;
            margin-top: 5px;
        }
        .quick-bet-btn {
            background: rgba(255,255,255,0.05);
            border: 1px solid var(--border-color);
            color: var(--secondary-color);
            padding: 8px 0;
            font-size: 11px;
            font-weight: 600;
            cursor: pointer;
            border-radius: 6px;
            transition: all 0.2s;
        }
        .quick-bet-btn:hover {
            background: var(--accent-color);
            color: #000;
            border-color: var(--accent-color);
        }

        .action-btn {
            width: 100%;
            padding: 16px;
            font-size: 16px;
            cursor: pointer;
            border: none;
            border-radius: 8px;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 2px;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .btn-start {
            background: linear-gradient(135deg, var(--accent-color) 0%, #b8860b 100%);
            color: #000;
            box-shadow: 0 10px 20px -5px rgba(212, 175, 55, 0.4);
        }
        .btn-start:hover { 
            transform: translateY(-2px); 
            box-shadow: 0 15px 25px -5px rgba(212, 175, 55, 0.5);
            filter: brightness(1.1);
        }
        .btn-start:active { transform: translateY(1px); }
        .btn-start:disabled { 
            background: var(--btn-bg); 
            color: #555; 
            box-shadow: none; 
            cursor: not-allowed; 
        }

        .btn-play-again {
            background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
            color: #fff;
            box-shadow: 0 10px 20px -5px rgba(46, 204, 113, 0.4);
            display: none; /* Hidden by default */
        }
        .btn-play-again:hover {
            transform: translateY(-2px);
            box-shadow: 0 15px 25px -5px rgba(46, 204, 113, 0.5);
            filter: brightness(1.1);
        }

        #history-section {
            width: 100%;
            flex-grow: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border-top: 1px solid var(--border-color);
            padding-top: 15px;
            min-height: 0; 
        }
        .history-list {
            flex-grow: 1;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 8px;
            padding-right: 5px;
        }
        .history-item {
            padding: 12px;
            border-radius: 8px;
            font-size: 12px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-weight: 600;
            transition: all 0.2s;
            flex-shrink: 0;
        }
        
        .history-item.win { 
            background: rgba(46, 204, 113, 0.1); 
            border: 1px solid rgba(46, 204, 113, 0.3);
            color: #2ecc71; 
        }
        .history-item.loss { 
            background: rgba(231, 76, 60, 0.1); 
            border: 1px solid rgba(231, 76, 60, 0.3);
            color: #e74c3c; 
        }

        .badge {
            padding: 4px 8px;
            border-radius: 4px;
            font-weight: 800;
            font-size: 11px;
        }
        .badge-win { background: #2ecc71; color: #000; }
        .badge-loss { background: rgba(255,255,255,0.1); color: #e74c3c; }

        #status-msg {
            font-size: 13px;
            font-weight: 600;
            color: var(--text-color);
            text-align: center;
            padding: 12px;
            background: rgba(255,255,255,0.05);
            border-radius: 8px;
            border: 1px solid var(--border-color);
            margin-bottom: 5px;
        }

        /* --- GENERAL MODAL STYLES --- */
        .modal {
            display: none;
            position: fixed;
            top: 0; left: 0;
            width: 100vw; height: 100vh;
            background: rgba(0,0,0,0.9);
            z-index: 2000;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            backdrop-filter: blur(5px);
            animation: fadeIn 0.3s ease;
        }

        .modal-content {
            background: var(--btn-bg);
            border: 1px solid var(--accent-color);
            border-radius: 15px;
            padding: 30px;
            max-width: 500px;
            width: 90%;
            text-align: center;
            box-shadow: 0 0 50px rgba(212, 175, 55, 0.2);
            position: relative;
        }

        .modal-title {
            font-family: 'Playfair Display', serif;
            font-size: 28px;
            color: var(--accent-color);
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
        }

        /* Rules List Styles */
        .rules-list {
            text-align: left;
            padding-left: 20px;
            color: var(--secondary-color);
            font-size: 14px;
            line-height: 1.8;
            margin-bottom: 25px;
        }
        .rules-list li { margin-bottom: 8px; }
        .rules-list b { color: var(--text-color); }

        .modal-close-btn {
            background: linear-gradient(135deg, var(--accent-color), #b8860b);
            color: #000;
            border: none;
            padding: 12px 30px;
            border-radius: 50px;
            font-weight: 800;
            cursor: pointer;
            font-size: 16px;
            transition: transform 0.2s;
        }
        .modal-close-btn:hover { transform: scale(1.05); }

        /* Ad Content Specifics */
        .ad-box {
            height: 250px;
            background: rgba(255,255,255,0.05);
            border-radius: 8px;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            margin-bottom: 20px;
            border: 1px dashed var(--border-color);
        }
        .timer-display { font-size: 24px; color: #fff; margin-bottom: 10px; font-weight: 800; }
        .ad-warning { font-size: 12px; color: #888; }

        /* Reward Popup Specifics */
        .reward-icon { font-size: 50px; color: #2ecc71; margin-bottom: 15px; animation: bounce 1s infinite; }
        .reward-amount { color: #2ecc71; margin: 10px 0; font-size: 32px; font-weight: 800; }

        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
        @keyframes popUp { to { transform: scale(1); } }
        @keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
/* Casino: narrow embedded viewport */
@media (max-width: 600px) {

#top-navbar { flex-wrap: wrap; height: auto; min-height: 60px; padding: 8px; gap: 6px; }
.nav-actions { flex-wrap: wrap; max-width: 100%; gap: 6px; }
}
