:root {
    --primary: #ff4500; /* Orange-Red Fire */
    --accent: #8b0000; /* Dark Red Dragon */
    --gold: #ffcf40;
    --bg-dark: #0d0606;
    --glass: rgba(13, 6, 6, 0.7);
    --glass-border: rgba(255, 69, 0, 0.2);
    --text-light: #ffdada;
}

/* Scrollbar styles (Thin & Elegant) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Firefox Support */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    overflow: hidden;
    height: 100vh;
}

#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    z-index: -1;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0 10px;
    z-index: 1;
    box-sizing: border-box;
}

.glass-header {
    text-align: center;
    padding: 5px 15px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border-radius: 0 0 20px 20px;
    border: 1px solid var(--glass-border);
    border-top: none;
    margin-bottom: 5px;
}

.glass-header h1 {
    font-size: 1rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.glass-header h1 small {
    font-size: 0.8rem;
    color: var(--gold);
    opacity: 0.8;
}

.game-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    width: 100%;
    max-width: 1200px;
    padding: 5px;
    justify-content: center;
    align-content: center;
}

.card {
    aspect-ratio: 2/3;
    perspective: 1000px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border-radius: 12px;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-back {
    background: linear-gradient(135deg, #1a0808, #050202);
    background-image: url('card_back.png');
    background-size: 85%;
    background-repeat: no-repeat;
    background-position: center;
    border: 2px solid var(--glass-border);
    box-shadow: inset 0 0 20px rgba(255, 69, 0, 0.1);
}

.card-front {
    background: radial-gradient(circle, #2a0808, #0d0606);
    transform: rotateY(180deg);
    border: 2px solid var(--primary);
    box-shadow: 0 0 20px rgba(255, 69, 0, 0.3);
}

.card-front img {
    width: 80%;
    height: 80%;
    object-fit: contain;
    filter: drop-shadow(0 0 5px var(--primary));
}

.game-footer {
    display: flex;
    justify-content: center;
    padding-bottom: 5px;
    margin-top: auto;
}

.floating-dock {
    display: flex;
    gap: 8px;
    padding: 4px 12px;
    border-radius: 25px;
    background: var(--glass);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.6);
}

.floating-dock button {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.floating-dock button:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 5px 20px rgba(255, 69, 0, 0.4);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(5px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.show { display: flex; }

.modal-content {
    width: min(90%, 600px);
    padding: 30px;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.close-btn {
    position: absolute;
    top: 15px; right: 20px;
    font-size: 1.5rem; cursor: pointer;
    color: var(--gold);
}

#history-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.history-item {
    background: rgba(255,255,255,0.05);
    padding: 10px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
}

.history-item img { width: 40px; }
.history-item p { font-size: 0.8rem; margin-top: 5px; }

/* Floating Dock */
.floating-dock {
    display: flex; gap: 15px; padding: 10px 20px; border-radius: 30px;
}
.floating-dock button {
    background: transparent; border: none; color: var(--text-light);
    font-size: 1.2rem; cursor: pointer;
}

/* AI Elements */
.ai-text { margin-top: 20px; line-height: 1.6; font-size: 1.1rem; }
.spinner-wrap { text-align: center; padding: 20px; }
.spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(255, 69, 0, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

@media (max-width: 600px) {
    #game-board { 
        grid-template-columns: repeat(10, 1fr); 
        gap: 4px; 
    }
    .card-front img { width: 100%; height: 100%; }
    .glass-header h1 { font-size: 0.9rem; letter-spacing: 0.5px; margin-bottom: 5px; }
    .glass-header { padding: 8px; margin-bottom: 5px; }
    .app-container { padding: 5px; }
    .modal-content { padding: 10px; width: 98%; }
    .card { aspect-ratio: 2/3; }
}

@media (max-width: 450px) {
    #game-board { 
        grid-template-columns: repeat(6, 1fr); 
        gap: 3px;
    }
}