/* Stack Tower Premium Theme - v4.5 Web Edition */
:root {
    --bg-deep: #06040f;
    --bg-mid: #0d0820;
    --cyan: #00e5ff;
    --purple: #9b30ff;
    --purple-light: #c880ff;
    --pink: #ff2d78;
    --gold: #ffd700;
    --green: #00ff88;
    --orange: #ff9800;
    --text-muted: #554d6e;
    --text-secondary: #7a6a9a;
    --glass-bg: rgba(6, 4, 15, 0.65);
    --glass-border: rgba(200, 128, 255, 0.15);
    --font-primary: 'Outfit', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-drag: none;
    outline: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-deep);
    font-family: var(--font-primary);
    color: #ffffff;
}

/* App Wrapper Centering */
#app-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Background Canvas & Filters */
#bg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 30%, rgba(0,0,0,0.85) 100%);
    z-index: 2;
    pointer-events: none;
}

/* Screens Structure */
.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, transform 0.5s ease;
    transform: scale(1.03);
    pointer-events: none;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    pointer-events: auto;
}

/* 3D Extruded Text helper */
.text-3d {
    text-shadow: 
        0 1px 0 #ccc,
        0 2px 0 #c5c5c5,
        0 3px 0 #bbb,
        0 4px 0 #b0b0b0,
        0 5px 0 #a5a5a5,
        0 6px 1px rgba(0,0,0,.1),
        0 0 5px rgba(0,0,0,.1),
        0 1px 3px rgba(0,0,0,.3),
        0 3px 5px rgba(0,0,0,.2),
        0 6px 10px rgba(0,0,0,.25),
        0 10px 10px rgba(0,0,0,.2),
        0 20px 20px rgba(0,0,0,.15);
}

/* 1. SPLASH / LOADING SCREEN styling */
#splash-screen {
    background-color: var(--bg-deep);
    z-index: 20;
}

.logo-3d-container {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 800px;
    margin-bottom: 20px;
}

/* Pure CSS 3D Cube Stack */
.cube-stack {
    position: relative;
    width: 80px;
    height: 150px;
    transform-style: preserve-3d;
    transform: rotateX(-22deg) rotateY(45deg);
    animation: floatingLogo 4s ease-in-out infinite;
}

.cube {
    position: absolute;
    width: 60px;
    height: 32px;
    transform-style: preserve-3d;
    left: 10px;
}

.cube.c1 { bottom: 0; }
.cube.c2 { bottom: 38px; }
.cube.c3 { bottom: 76px; }

.face {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid;
    box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.1);
}

.face.top {
    height: 60px;
    transform: rotateX(90deg) translateZ(30deg);
}

.face.left {
    width: 60px;
    transform: rotateY(-90deg) translateZ(30deg);
}

.face.right {
    transform: translateZ(30deg);
}

/* Custom Cube Coloring & Glows */
.c1 .face { border-color: var(--pink); background: rgba(255, 45, 120, 0.25); }
.c1 .face.top { background: rgba(255, 45, 120, 0.35); }
.c2 .face { border-color: var(--cyan); background: rgba(0, 229, 255, 0.25); }
.c2 .face.top { background: rgba(0, 229, 255, 0.35); }
.c3 .face { border-color: var(--purple); background: rgba(155, 48, 255, 0.25); }
.c3 .face.top { background: rgba(155, 48, 255, 0.35); }

@keyframes floatingLogo {
    0%, 100% { transform: rotateX(-22deg) rotateY(45deg) translateY(0); }
    50% { transform: rotateX(-22deg) rotateY(45deg) translateY(-12px); }
}

.logo-title {
    font-size: 2.4rem;
    font-weight: 900;
    color: var(--cyan);
    letter-spacing: 0.15em;
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.5), 0 4px 0 #0091ea;
    margin-top: 10px;
    text-align: center;
}

.logo-subtitle {
    font-size: 0.85rem;
    color: #e0e0e0;
    letter-spacing: 0.22em;
    margin-top: 4px;
    margin-bottom: 40px;
    text-align: center;
}

#splash-loading-container {
    width: 260px;
    text-align: center;
}

.progress-bar-wrapper {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.06);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--purple), var(--cyan));
    box-shadow: 0 0 10px var(--cyan);
    border-radius: 4px;
    transition: width 0.1s linear;
}

#tv-loading-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.15em;
    margin-top: 10px;
}

/* 2. MAIN MENU styling */
.menu-header {
    width: 100%;
    max-width: 380px;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    margin-bottom: 24px;
}

.icon-button {
    width: 48px;
    height: 48px;
    border: none;
    background: transparent;
    color: #ffffff;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    transition: transform 0.1s ease, text-shadow 0.15s ease;
}

.icon-button:active {
    transform: scale(0.9);
}

.icon-button.circular {
    background: rgba(6, 4, 15, 0.55);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    backdrop-filter: blur(10px);
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
}

.best-score-badge {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid var(--gold);
    border-radius: 4px;
    padding: 6px 20px;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--gold);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.15);
    margin-bottom: 24px;
    text-align: center;
}

.menu-buttons-list {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 20px;
}

/* Menu Custom 3D Buttons */
.menu-button, .go-button {
    position: relative;
    width: 100%;
    height: 50px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 900;
    color: #ffffff;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.menu-button::after, .go-button::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(255,255,255,0.15), transparent);
    pointer-events: none;
}

.menu-button:active, .go-button:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.btn-purple {
    background: linear-gradient(135deg, #7b1fa2, #9b30ff);
    border: 1px solid #c880ff;
    box-shadow: 0 0 10px rgba(155, 48, 255, 0.3);
}
.btn-pink {
    background: linear-gradient(135deg, #c2185b, #ff2d78);
    border: 1px solid #ff80ab;
    box-shadow: 0 0 10px rgba(255, 45, 120, 0.3);
}
.btn-blue {
    background: linear-gradient(135deg, #0288d1, #00e5ff);
    border: 1px solid #80deea;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}
.btn-green {
    background: linear-gradient(135deg, #00796b, #00ff88);
    border: 1px solid #a7ffeb;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}
.btn-gold {
    background: linear-gradient(135deg, #f57c00, #ffd700);
    border: 1px solid #ffe082;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}
.btn-muted {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #e0e0e0;
}

.brand-footer {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.12em;
    margin-top: 30px;
    font-family: var(--font-mono);
}

/* 3. GAMEPLAY SCREEN styling */
#gameplay-screen {
    justify-content: flex-start;
}

.game-sound-controls {
    position: absolute;
    top: 10px;
    right: 15px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

#gameplay-area {
    display: flex;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Dual Canvas Layout for Solo/2P modes */
.player-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 440px;
    height: 100%;
    position: relative;
    z-index: 5;
    background: rgba(6, 4, 15, 0.25);
    transition: width 0.3s ease;
}

.player-panel.hidden {
    display: none !important;
}

/* Game Canvas container */
.canvas-container {
    position: relative;
    width: 100%;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.canvas-container canvas {
    width: 100%;
    height: 100%;
    background: transparent;
    display: block;
}

/* HUD styles */
.player-hud {
    display: flex;
    width: 100%;
    height: 64px;
    padding: 0 16px;
    background: rgba(6, 4, 15, 0.7);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    align-items: center;
    justify-content: space-between;
    z-index: 50;
    backdrop-filter: blur(8px);
}

.btn-pause {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease;
}

.btn-pause:active {
    transform: scale(0.9);
}

.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hud-label {
    font-size: 0.6rem;
    font-family: var(--font-mono);
    color: var(--cyan);
    letter-spacing: 0.15em;
    font-weight: bold;
}

.hud-score {
    font-size: 1.6rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1;
    margin-top: 1px;
}

.hud-level {
    font-size: 0.55rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

.hud-lives {
    font-size: 1.15rem;
    color: var(--pink);
    letter-spacing: 2px;
}

#gameplay-divider {
    display: none;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--cyan), var(--pink));
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
    z-index: 50;
}

/* Widescreen 2P Split Layout logic */
@media(min-width: 800px) {
    #gameplay-area:has(#player2-panel:not(.hidden)) {
        max-width: 960px;
    }
    #gameplay-area:has(#player2-panel:not(.hidden)) #gameplay-divider {
        display: block;
    }
    #gameplay-area:has(#player2-panel:not(.hidden)) .player-panel {
        max-width: 460px;
    }
}

/* Portrait / Mobile 2P Split Layout logic */
@media(max-width: 799px) {
    #gameplay-area:has(#player2-panel:not(.hidden)) {
        flex-direction: column;
    }
    #gameplay-area:has(#player2-panel:not(.hidden)) #gameplay-divider {
        display: block;
        width: 100%;
        height: 4px;
        background: linear-gradient(90deg, var(--cyan), var(--pink));
    }
    #gameplay-area:has(#player2-panel:not(.hidden)) .player-panel {
        height: 50%;
        max-width: 100%;
    }
}

/* Simulated banner ads positioning */
.ad-banner {
    width: 100%;
    height: 50px;
    background: rgba(6, 4, 15, 0.85);
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    z-index: 40;
    pointer-events: auto;
}

.ad-badge {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 3px;
    padding: 2px 6px;
    font-family: var(--font-mono);
    color: #ffffff;
}

.ad-banner.hidden {
    display: none !important;
}

/* 4. GAME OVER SCREEN styling */
.go-title {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    color: #ffffff;
    text-align: center;
}

.go-winner {
    font-size: 1.4rem;
    font-family: var(--font-mono);
    margin-top: 4px;
    letter-spacing: 0.08em;
    text-align: center;
}

.go-best {
    margin-top: 12px;
    margin-bottom: 12px;
}

.score-cards-container {
    display: flex;
    width: 100%;
    max-width: 360px;
    gap: 12px;
    padding: 0 20px;
    margin-bottom: 20px;
}

.score-card {
    flex: 1;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
}

.card-title {
    font-size: 0.65rem;
    font-weight: bold;
    letter-spacing: 0.1em;
}

.card-score {
    font-size: 2.2rem;
    font-family: var(--font-mono);
    font-weight: bold;
    line-height: 1.2;
}

.card-level {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.card-combo {
    font-size: 0.65rem;
    color: var(--gold);
    margin-top: 4px;
}

.go-buttons-list {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 20px;
}

.go-button {
    height: 48px;
}

/* 5. DIALOGS / MODAL WINDOWS */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-card {
    width: 90%;
    max-width: 320px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(13, 8, 32, 0.85);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(15px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-title {
    font-size: 1.15rem;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-weight: bold;
    text-align: center;
}

.modal-body {
    padding: 20px;
    font-size: 0.85rem;
    color: #e0e0e0;
    line-height: 1.5;
    text-align: center;
}

.modal-body p {
    margin-bottom: 12px;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.modal-body .app-info, .modal-body .ad-info {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    padding: 12px 16px 16px;
    gap: 8px;
}

.modal-button {
    flex: 1;
    height: 40px;
    border: none;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: bold;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.1s ease;
}

.modal-button:active {
    transform: scale(0.96);
}

/* Achievement modal rows layout */
.achievement-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.achievement-row:last-child {
    border-bottom: none;
}

.ach-label {
    color: #b0b0b0;
}

.ach-value {
    font-weight: bold;
    font-family: var(--font-mono);
}

/* Toast Messages styling */
.toast {
    position: absolute;
    bottom: 72px;
    background: rgba(6, 4, 15, 0.85);
    border: 1px solid var(--purple-light);
    color: #ffffff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.8rem;
    z-index: 300;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.toast.active {
    opacity: 1;
    transform: translateY(0);
}

/* Text coloring shortcuts */
.cyan-text { color: var(--cyan); }
.pink-text { color: var(--pink); }
.gold-text { color: var(--gold); }
.green-text { color: var(--green); }
.purple-text { color: var(--purple-light); }
.hidden { display: none !important; }
