:root {
    --bg-dark: #121212;
    --text-light: #f0f0f0;
    --pack-border: #a2c8c8;
    --pack-shadow: #a2c8c8;
    --uncollected-card-bg: #1f1f1f;
    --uncollected-card-border: #444;
    --selected-card-border: #00ff00; /* Green for selected cards */
    --game-ui-bg: #2a2a2a;
    --nav-bg: #1a1a1a;
    --nav-icon-color: #888;
    --nav-icon-active-color: #a2c8c8;
    --coin-color: #ffd700; /* Gold color for coins */

    /* Rarity Colors */
    --common-color: #a0aec0; /* Gray */
    --rare-color: #3b82f6; /* Blue */
    --legendary-color: #eab308; /* Yellow/Gold */
    --mythic-color: #dc3545; /* Red for the new Mythic rarity */

    --victory-color: #28a745; /* Green for victory */
    --defeat-color: #dc3545; /* Red for defeat */
}

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent scrollbars on the body */
}

body {
    background: var(--bg-dark);
    color: var(--text-light);
    font-family: 'Segoe UI', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
}

#game-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    flex-grow: 1; 
    overflow: hidden; 
}

/* --- Background Image for Main Views --- */
#packView, #collectionView, #deckBuilderView, #gameView, #settingsView {
    background-image: linear-gradient(rgba(18, 18, 18, 0.8), rgba(18, 18, 18, 0.8)), url('photos/background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    padding-bottom: 80px;
    overflow-y: auto;
}

#homeView {
    width: 100%;
    height: 100%;
    background-image: url('photos/title_screen_169.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    justify-content: flex-end;
    padding-bottom: 10vh;
    cursor: pointer;
}

@media (orientation: portrait) {
    #homeView {
        background-image: url('photos/title_screen_mobile.png');
    }
}

#authView {
    background-image: linear-gradient(rgba(18, 18, 18, 0.7), rgba(18, 18, 18, 0.7)), url('photos/title_screen_169.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

h1 {
    margin-bottom: 20px;
    font-size: 2rem;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
    text-align: center;
}

.btn {
    background: linear-gradient(135deg, #444, #666);
    border: 2px solid #a2c8c8;
    border-radius: 8px;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 0 8px rgba(162, 200, 200, 0.5);
    margin: 0 5px;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(162, 200, 200, 0.7);
}

.btn:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn.btn-danger {
    background: linear-gradient(135deg, #a03d3d, #dc3545);
    border-color: #dc3545;
    box-shadow: 0 0 8px rgba(220, 53, 69, 0.5);
}

.btn.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.7);
}

.currency-display {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--coin-color);
    margin-bottom: 20px;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.pack {
    background: linear-gradient(135deg, #333, #555);
    border: 3px solid var(--pack-border);
    border-radius: 15px;
    padding: 20px 30px;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: bold;
    transition: transform 0.3s ease, box-shadow 0.6s ease-in-out;
    box-shadow: 0 0 15px var(--pack-shadow);
    position: relative;
    overflow: hidden;
    z-index: 1;
    text-align: center;
    letter-spacing: 1px;
    color: var(--text-light);
    margin-top: 15px;
}

.pack::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: pack-pulse 2s infinite alternate;
    opacity: 0.7;
    z-index: -1;
}

@keyframes pack-pulse {
    0% { transform: scale(1); opacity: 0.7; }
    100% { transform: scale(1.05); opacity: 0.9; }
}

.pack:hover {
    transform: scale(1.05);
    box-shadow: 0 0 25px var(--pack-shadow), 0 0 50px rgba(162, 200, 200, 0.4);
}

.cards-container {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
    justify-content: center;
    perspective: 1000px;
    transform-style: preserve-3d;
    padding-bottom: 30px;
}

/* --- CARD STYLES --- */
.card-wrapper {
    width: 120px;
    height: 180px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s, filter 0.5s;
    border-radius: 12px;
    z-index: 1;
}

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

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

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    overflow: hidden;
}

.card-back {
    background-image: url("photos/back_of_card.png");
    background-size: cover;
    background-position: center;
}

.card-front {
    transform: rotateY(180deg);
    background-size: cover;
    background-position: center;
}

.card-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
}

.stat-display {
    position: absolute;
    top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 1rem;
    font-weight: bold;
    padding: 3px 6px;
    text-shadow: 0 0 5px black, 0 0 3px black;
}

.stat-display svg {
    width: 18px;
    height: 18px;
    filter: drop-shadow(0 0 2px black);
}

.hp-display { left: 5px; }
.attack-display { right: 5px; }

.name-plate {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    color: white;
}

/* --- VIEW MANAGEMENT --- */
.view {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex-grow: 1;
    padding: 15px;
    box-sizing: border-box;
}

.view.active {
    display: flex;
}

#homeView, #authView {
    justify-content: center;
    padding-top: 0;
}

/* --- COLLECTION & DECK BUILDER --- */
#collectionView .cards-container, #deckBuilderView .cards-container {
    margin-top: 15px;
    padding: 0;
    gap: 15px;
    max-width: 100%;
    width: 100%;
    justify-content: center;
}
#collectionView .cards-container {
    flex-direction: column;
}
.collection-rarity-group {
    width: 100%;
    margin-bottom: 20px;
    text-align: center;
}
.collection-rarity-group h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.1);
}
.collection-rarity-group.mythic h2 { color: var(--mythic-color); }
.collection-rarity-group.legendary h2 { color: var(--legendary-color); }
.collection-rarity-group.rare h2 { color: var(--rare-color); }
.collection-rarity-group.common h2 { color: var(--common-color); }
.cards-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding: 10px 0;
}
.deck-builder-controls {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
.deck-builder-card.selected .card-inner {
    border: 3px solid var(--selected-card-border);
    box-shadow: 0 0 15px var(--selected-card-border);
}

/* --- GAME VIEW STYLES --- */
#gameView {
    justify-content: center;
    align-items: center;
    padding: 1vw;
    overflow: hidden;
}

.game-board {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: auto;
    max-width: 1400px;
    aspect-ratio: 16 / 9;
    gap: 1%;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    padding: 1%;
    box-sizing: border-box;
}

.player-side {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 2%;
    min-height: 0;
}

.bot-side {
    flex-direction: column-reverse;
}

.field-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1%;
    width: 100%;
    flex: 1;
}

.hand-zone, .bench-zone, .active-zone {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1%;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 1%;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

.hand-zone { flex: 0 0 35%; align-items: flex-end;}
.bench-zone { flex: 1; }
.active-zone { flex: 1.5; }

.hand-zone .card-wrapper,
.bench-zone .card-wrapper,
.active-zone .card-wrapper {
    height: 95%;
    width: auto;
    max-width: 100%;
}
.hand-zone .card-wrapper {
    cursor: pointer;
}

.hand-zone .card-wrapper:hover {
    transform: translateY(-10px) scale(1.05);
    z-index: 100;
}

.field-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    color: #aaa;
    font-weight: bold;
    font-size: 0.9rem;
    flex: 0 0 120px;
}

.deck-pile, .discard-pile {
    width: 70px;
    height: 105px;
    border: 2px dashed #555;
    border-radius: 8px;
    background-color: rgba(0,0,0,0.4);
    position: relative;
}

.deck-pile {
    background-image: url("photos/back_of_card.png");
    background-size: cover;
    background-position: center;
    border: 2px solid #888;
}

.card-count {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background-color: var(--bg-dark);
    color: var(--text-light);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: bold;
    border: 1px solid #888;
}
.discard-pile .card-wrapper{
    width: 100%;
    height: 100%;
}

.game-center-info {
    text-align: center;
    padding: 5px 0;
    flex: 0 0 auto;
}
.game-center-info h1 {
    font-size: 1.5rem;
    margin: 0 0 5px 0;
}
.game-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.game-message {
    font-size: 1rem;
    font-weight: bold;
    color: #f1c40f;
    min-height: 1.2em;
    margin-bottom: 5px;
}

@keyframes card-play-animation {
    from {
        transform: scale(0.5) translateY(100%);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.card-wrapper.is-playing {
    animation: card-play-animation 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.card-wrapper.concealed .card-inner {
    transform: rotateY(0deg) !important;
}


/* --- MODALS & MESSAGES --- */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100dvh;
    background-color: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 0.3s, opacity 0.3s ease;
}
.modal.show {
    visibility: visible;
    opacity: 1;
    transition: visibility 0s, opacity 0.3s ease;
}
.modal-content {
    background-color: var(--bg-dark);
    margin: auto;
    padding: 25px;
    border: 2px solid var(--pack-border);
    border-radius: 15px;
    width: 85%;
    max-width: 350px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}
.modal.show .modal-content {
    transform: scale(1);
    opacity: 1;
}
.modal-buttons {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}
.global-message {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    color: #121212;
    padding: 15px 25px;
    border-radius: 8px;
    z-index: 2000;
    font-size: 1.1rem;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, top 0.3s ease;
}
.global-message.show { opacity: 1; visibility: visible; top: 30px; }
.global-message.error { background-color: rgba(220, 53, 69, 0.95); color: white; }
.global-message.success { background-color: rgba(40, 167, 69, 0.95); color: white; }
.global-message.warning { background-color: rgba(241, 196, 15, 0.95); color: #121212; }

/* --- BOTTOM NAV --- */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px;
    background-color: var(--nav-bg);
    display: none;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.5);
    z-index: 500;
}
.nav-btn {
    background: transparent;
    border: none;
    color: var(--nav-icon-color);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}
.nav-btn svg { width: 28px; height: 28px; fill: currentColor; }
.nav-btn.active { color: var(--nav-icon-active-color); }

/* --- AUTH & SETTINGS --- */
.auth-container, .settings-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 350px;
    padding: 20px;
    background-color: rgba(42, 42, 42, 0.9);
    border-radius: 10px;
}
.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background-color: #fff;
    color: #444;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
}
.settings-container { max-width: 400px; text-align: left; }

/* --- PRE-LOADER --- */
#pre-loader {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-dark); z-index: 2000; display: flex;
    flex-direction: column; justify-content: center; align-items: center;
    perspective: 1000px;
}

.loading-text { 
    color: white; 
    margin-top: 20px; 
    font-size: 1.2rem; 
    transition: opacity 0.4s ease;
}

#pre-loader .card-container {
    position: relative;
}

#pre-loader .card {
    width: 120px;
    height: 168px;
    position: relative;
    transform-style: preserve-3d;
    animation: classic-flip 3s infinite linear; /* Changed to linear for consistent speed */
}

#pre-loader .card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    overflow: hidden;
}

#pre-loader .card-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#pre-loader .card-front {
    transform: rotateY(0deg);
}

#pre-loader .card-back {
    transform: rotateY(180deg);
}

@keyframes classic-flip {
    0% {
        transform: rotateY(0deg);
    }
    80% {
        transform: rotateY(360deg);
    }
    100% {
        transform: rotateY(360deg);
    }
}

/* This class is added after landing to trigger the zoom */
#pre-loader.zooming .card {
    animation: zoom-in 0.7s ease-in forwards;
}
#pre-loader.zooming .loading-text {
    opacity: 0;
}

@keyframes zoom-in {
    from {
        transform: scale(1) rotateY(360deg); /* Start from the landed position */
        opacity: 1;
    }
    to {
        transform: scale(15) rotateY(360deg);
        opacity: 0;
    }
}

@media (min-width: 769px) {
    .modal-buttons { flex-direction: row; }
    
    .player-side {
        flex-direction: row;
    }
    .bot-side {
        flex-direction: row-reverse;
    }
    .field-row {
        flex-direction: column;
        flex: 1;
    }
    .hand-zone {
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
    }
    .bench-zone {
      flex: 1.5;
    }
    .active-zone {
      flex: 2;
    }
    .field-zone {
        justify-content: center;
        flex: 0 0 100px;
    }
    .game-board {
        flex-direction: row;
        aspect-ratio: auto;
        height: 100%;
    }
    .game-center-info {
        writing-mode: vertical-rl;
        transform: rotate(180deg);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .game-center-info h1 {
        margin: 0;
    }
}
