/* ==========================================================================
   2048 Doge Edition - Modern all2048.com/doge Stylesheet
   Authentic Animated Shiba Inu GIFs, Comic Sans floating memes & audio
   ========================================================================== */

.g2048-wrapper.theme-doge {
    --doge-yellow: #f59e0b;
    --doge-bg: #fefce8;
    --doge-border: #fde047;
    max-width: 530px;
    margin: 0 auto;
    font-family: "Comic Sans MS", "Comic Neue", "Chalkboard SE", cursive, sans-serif;
}

.theme-doge .g2048-badge {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    color: #451a03;
    font-weight: 900;
    border: none;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.85rem;
}

.theme-doge .doge-intro-banner {
    margin: 0.2rem 0 0.8rem;
    text-align: center;
    font-size: clamp(1rem, 2.8vw, 1.25rem);
    color: #78350f;
    font-weight: 700;
}

.theme-doge .doge-intro-banner strong {
    color: #d97706;
}

/* Header (Badge + Score Cards) positioned right above board */
.theme-doge .g2048-header {
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

/* Toolbar positioned directly below the board */
.theme-doge .g2048-toolbar {
    margin-top: 0.85rem;
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* Hints below the toolbar */
.theme-doge .g2048-mobile-hints {
    margin-top: 0.4rem;
}

/* Doge Score Cards */
.theme-doge .score-card {
    background: #ffffff;
    border: 2px solid #fde047;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
    border-radius: 12px;
}

/* Board Container */
.theme-doge .g2048-board-container {
    background: #fef9c3 !important;
    border: 6px solid #fde047 !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.25), inset 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    touch-action: none !important;
    overscroll-behavior: contain !important;
}

.theme-doge .grid-cell {
    background: rgba(254, 240, 138, 0.45) !important;
    border-radius: 10px !important;
}

/* Doge Tile Inner with Animated GIF */
.theme-doge .doge-tile-inner {
    position: absolute;
    inset: 0;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
    border: 2px solid rgba(245, 158, 11, 0.3);
    background: #ffffff;
}

/* GIF / Image Artwork Layer */
.theme-doge .doge-art-img {
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    z-index: 1;
}

/* Optional Overlay Labels (Toggleable) */
.theme-doge .doge-badge-strip {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 5px;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.theme-doge .doge-val-pill {
    background: rgba(69, 26, 3, 0.85);
    color: #fef08a;
    font-size: clamp(0.6rem, 1.8vw, 0.72rem);
    font-weight: 900;
    padding: 1px 5px;
    border-radius: 4px;
}

.theme-doge .doge-phrase-bar {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 2px 4px;
    font-size: clamp(0.62rem, 1.8vw, 0.74rem);
    font-weight: 900;
    color: #451a03;
    background: rgba(254, 240, 138, 0.9);
    backdrop-filter: blur(2px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* When labels are hidden (pure all2048 mode) */
.theme-doge.labels-hidden .doge-badge-strip,
.theme-doge.labels-hidden .doge-phrase-bar {
    display: none !important;
}

/* Floating Comic Sans Meme Text on Move & Merge */
.doge-floating-meme {
    position: absolute;
    pointer-events: none;
    font-weight: 900;
    font-size: clamp(1rem, 3.5vw, 1.5rem);
    text-shadow: 1px 1px 0 #ffffff, -1px -1px 0 #ffffff, 1px -1px 0 #ffffff, -1px 1px 0 #ffffff, 0 2px 4px rgba(0,0,0,0.25);
    z-index: 20;
    animation: dogeFloat 1.2s forwards ease-out;
}

@keyframes dogeFloat {
    0% {
        opacity: 0;
        transform: scale(0.6) translateY(0);
    }
    20% {
        opacity: 1;
        transform: scale(1.1) translateY(-10px);
    }
    80% {
        opacity: 0.9;
        transform: scale(1) translateY(-35px);
    }
    100% {
        opacity: 0;
        transform: scale(0.9) translateY(-50px);
    }
}

/* Doge Gallery Modal */
.doge-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(69, 26, 3, 0.65);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    font-family: "Comic Sans MS", "Comic Neue", cursive, sans-serif;
}

.doge-modal-backdrop.is-open {
    display: flex;
}

.doge-modal {
    background: #fefce8;
    color: #451a03;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    border-radius: 18px;
    border: 4px solid #f59e0b;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    padding: 1.5rem;
}

.doge-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #fde047;
    padding-bottom: 0.8rem;
    margin-bottom: 1rem;
}

.doge-modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    color: #b45309;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.doge-modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: #92400e;
    line-height: 1;
    padding: 0 0.3rem;
}

.doge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.75rem;
}

.doge-item {
    background: #ffffff;
    border: 2px solid #fde047;
    border-radius: 12px;
    padding: 0.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.15s ease;
}

.doge-item:hover {
    transform: translateY(-2px);
    border-color: #f59e0b;
    background: #fef9c3;
}

.doge-item img {
    width: 65px;
    height: 65px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 0.25rem;
}

.doge-item .doge-item-phrase {
    font-size: 0.75rem;
    font-weight: 900;
    color: #d97706;
}

.doge-item .doge-item-val {
    font-size: 0.8rem;
    font-weight: 900;
    color: #451a03;
    background: #fef08a;
    padding: 1px 8px;
    border-radius: 999px;
    margin-top: 3px;
}

/* ==========================================================================
   Dark Mode Overrides for 2048 Doge
   ========================================================================== */
[data-theme="dark"] .g2048-wrapper.theme-doge {
    --doge-yellow: #f59e0b;
    --doge-bg: #0b1328;
    --doge-border: #334155;
}

[data-theme="dark"] .theme-doge .doge-intro-banner {
    color: #fde047;
}

[data-theme="dark"] .theme-doge .doge-intro-banner strong {
    color: #f59e0b;
}

/* Fix Dark Mode Score Cards (SCORE & BEST: #1E293B background with bright high-contrast text) */
[data-theme="dark"] .theme-doge .score-card {
    background: #1e293b !important;
    border: 1px solid #334155 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

[data-theme="dark"] .theme-doge .score-card .score-label {
    color: #94a3b8 !important;
    font-weight: 700;
}

[data-theme="dark"] .theme-doge .score-card.current-score .score-val,
[data-theme="dark"] .theme-doge .score-card.best-score .score-val {
    color: #f8fafc !important;
    font-weight: 900;
}

[data-theme="dark"] .theme-doge .g2048-board-container {
    background: #0f172a !important;
    border: 5px solid #1e293b !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 2px 8px rgba(0, 0, 0, 0.4) !important;
}

[data-theme="dark"] .theme-doge .grid-cell {
    background: rgba(30, 41, 59, 0.75) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4) !important;
}

[data-theme="dark"] .doge-modal {
    background: #0f172a;
    color: #f8fafc;
    border-color: #f59e0b;
}

[data-theme="dark"] .doge-modal-header {
    border-bottom-color: #334155;
}

[data-theme="dark"] .doge-modal-header h3 {
    color: #f59e0b;
}

[data-theme="dark"] .doge-modal-close {
    color: #94a3b8;
}

[data-theme="dark"] .doge-item {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .doge-item:hover {
    background: #334155;
    border-color: #f59e0b;
}

[data-theme="dark"] .doge-item .doge-item-phrase {
    color: #fbbf24;
}

[data-theme="dark"] .doge-item .doge-item-val {
    background: rgba(245, 158, 11, 0.25);
    color: #fef08a;
}

/* ==========================================================================
   Mobile Responsive Layout (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* 1. Reorder Sections so Board sits cleanly in the center of the mobile viewport */
    .g2048-wrapper.theme-doge {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        padding: 0 0.25rem;
    }

    /* Intro banner sits above stats compactly */
    .theme-doge .doge-intro-banner {
        order: 1;
        font-size: 0.85rem;
        margin: 0.15rem 0 0.4rem;
        line-height: 1.35;
        max-width: 440px;
        padding: 0 0.5rem;
    }

    /* Move top stats/badge section down right above the board */
    .theme-doge .g2048-header {
        order: 2;
        width: 100%;
        max-width: 440px;
        margin-bottom: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.45rem;
    }

    .theme-doge .g2048-title-area {
        flex-shrink: 0;
    }

    .theme-doge .g2048-badge {
        font-size: 0.72rem;
        padding: 0.28rem 0.65rem;
        white-space: nowrap;
    }

    .theme-doge .g2048-scores {
        gap: 0.35rem;
        flex: 1;
        justify-content: flex-end;
    }

    .theme-doge .score-card {
        min-width: 0;
        flex: 1;
        padding: 0.3rem 0.35rem;
        border-radius: 9px;
    }

    .theme-doge .score-label {
        font-size: 0.58rem;
    }

    .theme-doge .score-val {
        font-size: 1.05rem;
    }

    /* 4x4 Game Grid cleanly centered in viewport */
    .theme-doge .g2048-board-container {
        order: 3;
        width: 100%;
        max-width: min(92vw, 420px);
        margin: 0 auto 0.55rem;
        touch-action: none !important;
        overscroll-behavior: contain !important;
        border-width: 4px !important;
        border-radius: 14px !important;
    }

    /* Move action buttons bar to below the game board */
    .theme-doge .g2048-toolbar {
        order: 4;
        width: 100%;
        max-width: min(92vw, 420px);
        margin: 0.2rem auto 0.45rem;
        display: flex;
        justify-content: space-between;
        gap: 0.35rem;
    }

    .theme-doge .btn-game-tool {
        padding: 0.45rem 0.3rem;
        font-size: 0.78rem;
        border-radius: 8px;
        gap: 0.25rem;
    }

    .theme-doge .btn-game-tool svg {
        width: 15px;
        height: 15px;
    }

    /* Hints banner at bottom */
    .theme-doge .g2048-mobile-hints {
        order: 5;
        margin-top: 0.15rem;
        margin-bottom: 0.5rem;
        font-size: 0.8rem;
        padding: 0.45rem 0.75rem;
        max-width: min(92vw, 420px);
    }

    /* 3. Clean Mobile Tiles: Hide text phrase bar, Doge GIF artwork fills tile cleanly with small right-down corner numeric badge */
    .theme-doge .doge-phrase-bar {
        display: none !important;
    }

    .theme-doge .doge-badge-strip {
        position: absolute;
        inset: 0;
        padding: 0;
        pointer-events: none;
        justify-content: flex-end;
        align-items: flex-end;
        display: flex !important;
    }

    .theme-doge .doge-val-pill {
        position: absolute;
        bottom: 4px;
        right: 4px;
        background: rgba(69, 26, 3, 0.88);
        color: #fef08a;
        font-size: 0.68rem;
        font-weight: 900;
        padding: 2px 5px;
        border-radius: 4px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
        display: inline-block !important;
    }

    .theme-doge.labels-hidden .doge-badge-strip {
        display: flex !important;
    }

    .theme-doge.labels-hidden .doge-phrase-bar {
        display: none !important;
    }

    .theme-doge.labels-hidden .doge-val-pill {
        display: inline-block !important;
    }
}
