/* ========================================
   FONTS & RESET
   ======================================== */
@import url('https://fonts.googleapis.com/css2?family=Varela+Round&display=swap');

/* ========================================
   THEME VARIABLES
   To customize colors, override these variables in your own CSS or
   redefine :root with your theme values.
   ======================================== */
:root {
    /* Primary Colors - Buttons, Accents */
    --color-primary: #ffca28;
    --color-primary-dark: #ff8f00;
    --color-primary-text: #5d4037;

    /* Secondary Colors - Links, Highlights */
    --color-secondary: #4A90E2;
    --color-secondary-dark: #357ABD;

    /* Danger Colors - Destructive Actions */
    --color-danger: #ef5350;
    --color-danger-dark: #c62828;

    /* Neutral Colors - Text, Backgrounds */
    --color-text: #5d4037;
    --color-text-light: #777;
    --color-text-muted: #555;
    --color-bg-body: #1a1a2e;
    --color-bg-overlay: rgba(0, 0, 0, 0.6);
    --color-bg-card: rgba(255, 255, 255, 0.95);
    --color-bg-muted: rgba(0, 0, 0, 0.05);

    /* Gradient for animated background */
    --gradient-bg-1: #667eea;
    --gradient-bg-2: #764ba2;
    --gradient-bg-3: #f093fb;
    --gradient-bg-4: #4facfe;
    --gradient-bg-5: #00f2fe;

    /* Splash screen gradient */
    --gradient-splash-1: #667eea;
    --gradient-splash-2: #764ba2;

    /* Rank colors */
    --color-rank-1-start: #FFD700;
    --color-rank-1-end: #FFA500;
    --color-rank-2-start: #E0E0E0;
    --color-rank-2-end: #BDBDBD;
    --color-rank-3-start: #CD7F32;
    --color-rank-3-end: #A0522D;

    /* Ad button gradient */
    --color-ad-start: #FFD700;
    --color-ad-end: #FFA500;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'Varela Round', 'Segoe UI', sans-serif;
    background-color: var(--color-bg-body);
    /* Fallback for background */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    width: 100vw;
    height: 100dvh;
}

/* ========================================
   APP ROOT & BACKGROUND
   ======================================== */
/* The full-screen background layer */
#bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(135deg,
            var(--gradient-bg-1) 0%,
            var(--gradient-bg-2) 25%,
            var(--gradient-bg-3) 50%,
            var(--gradient-bg-4) 75%,
            var(--gradient-bg-5) 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* ========================================
   DEBUG CONTROLS
   ======================================== */
#debug-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 8px;
}

#debug-controls button {
    font-size: 16px;
    padding: 10px 20px;
}

/* ========================================
   GAME CONTAINER (The "Shell")
   ======================================== */
/* 
   This element is controlled by GameShell.js 
   It will be strictly sized to the aspect ratio (9:16)
   and centered on screen.
*/
#game-container {
    position: absolute;
    /* Dimensions set by JS handlesResize */
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    /* Slight tint for game area */
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    /* Shadow to separate from letterbox */
    z-index: 10;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* 
    The dedicated layer for the game content.
    Allows easy replacement of the game without affecting UI.
*/
#game-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* ========================================
   UI LAYER
   ======================================== */
/* Sits exactly on top of the game canvas within the container */
#ui-layer {
    position: absolute;
    top: 20px;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
    text-align: center;
}

/* Game Logo */
#game-logo {
    position: relative;
    margin: 0 auto 10px auto;
    font-size: 32px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    display: inline-block;
}

/* Score Display */
#score-display {
    position: relative;
    margin: 0 auto;
    font-size: 56px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    padding: 0;
    margin-top: -5px;
    background: transparent;
    backdrop-filter: none;
}

/* ========================================
   CONTROLS & BUTTONS
   ======================================== */
/* Enable pointer events for buttons */
button,
.control-btn,
.leaderboard-button,
.ad-button {
    pointer-events: auto;
}

/* Top Buttons */
.control-btn {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: all 0.2s ease;
    color: #333;
}

.control-btn:hover {
    transform: scale(1.1);
    background: #fff;
}

.control-btn:active {
    transform: scale(0.95);
}

#fullscreen-btn {
    top: 20px;
    left: 20px;
}

body.is-capacitor #fullscreen-btn {
    display: none !important;
}

#pause-btn {
    top: 20px;
    right: 20px;
}

#main-help-btn {
    top: 80px;
    right: 20px;
}

/* Bottom Action Buttons */
.icon-btn-large {
    position: absolute;
    top: 77%;
    /* left: 0; removed to avoid conflict with right-positioned buttons */
    transform: translateY(-50%);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: transform 0.2s ease;
}

.icon-btn-large:hover {
    transform: translateY(-50%) scale(1.1);
}

.icon-btn-large:active {
    transform: translateY(-50%) scale(0.95);
}

/* Leaderboard Button */
#leaderboard-button {
    right: 20px;
    background: linear-gradient(135deg, #4A90E2, #357ABD);
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* Ad Button */
#ad-button {
    left: 20px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    box-shadow: 0 4px 15px rgba(255, 165, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    /* Pure CSS animation with initial delay */
    animation: adButtonPulse 3s ease-in-out infinite;
    animation-delay: 3s;
}

@keyframes adButtonPulse {

    0%,
    100% {
        transform: translateY(-50%) scale(1);
    }

    10% {
        transform: translateY(-50%) scale(1.1);
    }

    20% {
        transform: translateY(-50%) scale(1);
    }

    30% {
        transform: translateY(-50%) scale(1.05);
    }

    40% {
        transform: translateY(-50%) scale(1);
    }
}

#ad-button.hidden {
    display: none;
}

.btn-icon {
    font-size: 28px;
    line-height: 1;
}

.btn-badge {
    position: absolute;
    bottom: -6px;
    background: #FF4500;
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Button Animations */
.btn-shake {
    animation: btnShake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes btnShake {

    10%,
    90% {
        transform: translateY(-50%) translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translateY(-50%) translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translateY(-50%) translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translateY(-50%) translate3d(4px, 0, 0);
    }
}

.btn-bounce {
    animation: btnBounce 1.2s ease;
}

@keyframes btnBounce {
    0% {
        transform: translateY(-50%);
    }

    20% {
        transform: translateY(-100%);
    }

    /* Big Jump */
    40% {
        transform: translateY(-50%);
    }

    /* Land */
    55% {
        transform: translateY(-75%);
    }

    /* Small Jump */
    70% {
        transform: translateY(-50%);
    }

    /* Land */
    85% {
        transform: translateY(-60%);
    }

    /* Micro Jump */
    100% {
        transform: translateY(-50%);
    }

    /* Settle */
}

.btn-grow {
    animation: btnGrow 0.6s ease;
}

@keyframes btnGrow {

    0%,
    100% {
        transform: translateY(-50%) scale(1);
    }

    50% {
        transform: translateY(-50%) scale(1.2);
    }
}


/* ========================================
   OVERLAYS (Pause, Leaderboard, etc)
   ======================================== */
/* 
   Overlays are constrained to the game container 
   so they don't look massive on desktop 
*/
.overlay-screen {
    position: absolute;
    inset: -5px;
    /* Overlap slightly to ensure no gaps at edges */
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 25000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    /* Ensure it is truly hidden */
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    /* Delay visibility change until opacity done */
}

.overlay-screen.active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
    /* Instant visibility */
}

.overlay-content {
    background: rgba(255, 255, 255, 0.95);
    width: 90%;
    /* max-height: 90%; removed to let it shrink */
    max-height: 90vh;
    /* Cap it */
    min-height: auto;
    /* Allow shrinking */
    height: auto;
    /* Fit content */
    border-radius: 24px;
    padding: 24px 24px 12px 24px;
    /* Reduced bottom padding */
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

@media (max-width: 600px) {

    /* 
       Keep generic overlays (Pause, etc) centered or full screen as before.
       Only modify ACCOUNT screen to be bottom/top aligned.
    */
    .overlay-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        padding: 20px;
    }

    /* Account Screen: Special handling for keyboard */
    #account-screen .overlay-content {
        height: auto;
        /* Allow height to fit content */
        max-height: 60vh;
        /* Restrict height */
        border-radius: 16px;
        position: absolute;
        top: 10%;
        /* Move to top 10% of screen */
        bottom: auto;
        overflow-y: auto;
    }
}

/* Force Leaderboard to be full screen always */
#leaderboard-screen .overlay-content {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
}



/* Text & Headings */
h2 {
    color: #5d4037;
    margin: 0 0 20px 0;
    font-size: 32px;
}

.help-text {
    text-align: left;
    margin-bottom: 20px;
    color: #5d4037;
    font-size: 18px;
    line-height: 1.5;
}

/* Pause Menu toggles & rows */
.settings-group {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    padding: 16px;
    margin: 16px 0;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: bold;
    color: #5d4037;
}

.setting-row:last-child {
    margin-bottom: 0;
}

/* Menus buttons stack */
.account-menu-section {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    padding: 16px;
    margin: 16px 0;
    text-align: center;
}

.account-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
}

.account-info {
    margin-bottom: 0;
    text-align: left;
    flex-grow: 1;
    color: #5d4037;
}

.account-name {
    font-weight: bold;
    font-size: 18px;
    display: block;
}

.account-id {
    font-size: 12px;
    opacity: 0.7;
    display: block;
}

/* Sign Out Button (X) */
.sign-out-btn {
    position: relative;
    width: 48px;
    height: 48px;
    min-width: 48px;
    /* Prevent shrink */
    border: 2px solid #ef5350;
    border-radius: 50%;
    color: #c62828;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    overflow: hidden;
    /* Background setup for progress */
    background-color: #ffebee;
    /* Light red base */
    background-image: linear-gradient(rgba(239, 83, 80, 0.3), rgba(239, 83, 80, 0.3));
    /* Progress fill */
    background-size: 0% 100%;
    background-repeat: no-repeat;
    background-position: left center;
    transition: background-size 0s, transform 0.1s;
    /* Instant reset */
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    padding: 0;
}

.sign-out-btn:active {
    transform: scale(0.95);
}

.sign-out-btn.holding {
    background-size: 100% 100%;
    transition: background-size 2.5s linear;
    /* 2.5s fill */
}

.hold-tooltip {
    position: absolute;
    right: 60px;
    top: 50%;
    transform: translateY(-50%);
    background: #c62828;
    /* Dark red background */
    color: white;
    /* White text */
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
}

.hold-tooltip.visible {
    opacity: 1;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.menu-buttons:last-child {
    margin-top: auto;
}

button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.1s;
    /* Default is secondary style */
    background: #e0e0e0;
    color: #555;
    box-shadow: 0 4px 0 #bdbdbd;
}

button:active {
    transform: translateY(4px);
    box-shadow: none;
}

.primary-btn {
    background: linear-gradient(to bottom, #ffca28, #ffb300);
    color: #5d4037;
    box-shadow: 0 4px 0 #ff8f00;
}

.primary-btn:active {
    box-shadow: none;
}

.danger-btn {
    background: linear-gradient(to bottom, #ef5350, #e53935);
    color: white;
    box-shadow: 0 4px 0 #c62828;
}

/* Helper for Header with Close Btn */
.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.overlay-header h2 {
    margin: 0;
}

.close-icon-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #5d4037;
    padding: 4px 8px;
    border-radius: 50%;
    transition: background 0.2s;
    width: auto;
    height: auto;
    min-width: 0;
    margin: 0;
}

.close-icon-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Toggle Switch Styling */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border-radius: 34px;
    transition: .4s;
    cursor: pointer;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}

input:checked+.slider {
    background-color: #ffb300;
}

input:checked+.slider:before {
    transform: translateX(22px);
}

/* ========================================
   LEADERBOARD SPECIFIC
   ======================================== */
.leaderboard-list {
    text-align: left;
    padding-bottom: 20px;
}

.leaderboard-row,
.leaderboard-row-header {
    display: grid;
    grid-template-columns: 40px 1fr 90px;
    /* Rank, Name, Score */
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.leaderboard-row-header {
    font-weight: bold;
    color: #5d4037;
    background: rgba(0, 0, 0, 0.1);
    font-size: 14px;
}

.leaderboard-row {
    background: rgba(30, 30, 40, 0.08);
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.leaderboard-row:hover {
    transform: translateX(2px);
}

/* Alignment */
.leaderboard-row span,
.leaderboard-row-header span {
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-row .name,
.leaderboard-row-header span:nth-child(2) {
    text-align: left;
}

/* Rank cell with emoji */
.leaderboard-row .rank {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.rank-emoji {
    position: absolute;
    left: -4px;
    font-size: 16px;
    z-index: 1;
}

/* Prevent emoji from being clipped */
.leaderboard-row {
    overflow: visible;
}

/* Top 3 - Gold themed border */
.top-3 {
    border: 2px solid #FFD700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

.rank-1 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #fff;
    font-weight: bold;
}

.rank-2 {
    background: linear-gradient(135deg, #E0E0E0, #BDBDBD);
    color: #333;
}

.rank-3 {
    background: linear-gradient(135deg, #CD7F32, #A0522D);
    color: #fff;
}

/* "You" rows - themed colored border */
.self-row {
    border: 2px solid var(--color-secondary, #4A90E2);
    box-shadow: 0 0 10px rgba(74, 144, 226, 0.4);
    background: rgba(74, 144, 226, 0.1);
}

/* Temporary row (mid-game, not submitted) */
.temporary-row {
    border-style: dashed;
    opacity: 0.9;
}

.empty {
    text-align: center;
    padding: 20px;
    color: #777;
    font-style: italic;
}

.final-score-text {
    font-size: 24px;
    font-weight: bold;
    color: #4A90E2;
    margin: 10px 0 20px 0;
}

/* Badges */
.lb-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: bold;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.new-best {
    background: linear-gradient(135deg, #FFD700, #FFA000);
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: pulseBadge 1.5s infinite;
}

.you-badge {
    background: #4A90E2;
    color: white;
}

.your-best {
    background: linear-gradient(135deg, #9C27B0, #7B1FA2);
    color: white;
}

@keyframes pulseBadge {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7);
    }

    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 5px rgba(255, 215, 0, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
    }
}

.temporary-row {
    background-color: rgba(74, 144, 226, 0.05);
    border: 2px dashed #4A90E2 !important;
    /* Override self-row */
}

/* Drag-to-scroll for desktop */
#leaderboard-content {
    cursor: grab;
}

#leaderboard-content.dragging {
    cursor: grabbing;
    user-select: none;
}

#leaderboard-content.dragging * {
    pointer-events: none;
}


/* ========================================
   INPUTS & FORMS
   ======================================== */
input[type="text"] {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 18px;
    font-family: inherit;
    outline: none;
    text-align: center;
    transition: border-color 0.2s;
}

input[type="text"]::placeholder {
    color: #ccc;
    opacity: 1;
    /* Firefox */
    transition: opacity 0.2s ease;
}

input[type="text"]:focus::placeholder {
    opacity: 0;
}

input[type="text"]:focus {
    border-color: #4A90E2;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.button-group button {
    flex: 1;
}

/* Account/Name Input Specific Overrides */
#name-input-screen .overlay-content {
    min-height: auto;
    /* Don't stretch */
    height: auto;
    max-width: 400px;
    /* Compact */
    margin: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Spacing between elements */
    border-radius: 32px;
    /* More Rounded */
}

#name-input-screen h2 {
    margin-bottom: 8px;
    font-size: 28px;
}

#name-input-field {
    margin: 0;
    /* Let gap handle spacing */
    background: #f9f9f9;
}

#name-input-screen .button-group {
    margin-top: 8px;
}

/* ========================================
   UTILITIES
   ======================================== */
.hidden {
    display: none !important;
}

.loader-msg {
    margin: 20px auto;
    text-align: center;
    color: #555;
    font-weight: bold;
}

.error-msg {
    color: #ef5350;
    text-align: center;
    margin: 20px 0;
    font-weight: bold;
}

.error-message {
    color: #ef5350;
    font-size: 14px;
    margin-top: 5px;
    display: none;
    /* Hidden by default, toggled via JS or .active/.hidden */
}

.error-message.active {
    display: block;
}

/* ========================================
   AD OVERLAY SPECIFIC
   ======================================== */
.ad-card {
    background: white !important;
    /* Override default overlay-content background */
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    max-width: 90%;
    /* width: 320px; removed fixed width to allow flex if needed, but 320 is standard ad size */
    width: 320px;
    min-height: auto;
    /* Fix whitespace */
    height: auto;
    margin: auto;
}

.ad-header {
    background: #eee;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ad-timer-text {
    font-size: 12px;
    color: #666;
    font-weight: bold;
}

.ad-close-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    line-height: 30px;
    border-radius: 50%;
    background: #ccc;
    font-size: 14px;
    opacity: 0.5;
    cursor: not-allowed;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

.ad-placeholder {
    background: #4A90E2;
    height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

.ad-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.ad-title {
    color: white;
    margin: 0;
}

.ad-footer {
    padding: 15px;
    text-align: center;
    color: #666;
    font-size: 12px;
}

/* Rotate Prompt */
#rotate-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1a1a;
    z-index: 9999;
    display: none;
    /* JS will toggle flex */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

.rotate-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.rotate-text {
    font-size: 24px;
}

/* Splash Screen & Animations */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    z-index: 20000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.splash-icon {
    font-size: 64px;
    margin-bottom: 10px;
    animation: bounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.splash-title {
    color: white;
    font-size: 36px;
    /* Slightly reduced to help fit */
    margin: 0;
    margin-bottom: 20px;
    white-space: nowrap;
    /* Prevent line break */
    animation: fadeIn 0.5s ease 0.2s backwards;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    80% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Splash Animations --- */

/* 1. Fade Out */
.splash-fade-out {
    animation: fadeOut 0.8s forwards;
    pointer-events: none;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* 2. Slide Up */
.splash-slide-up {
    animation: slideUp 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    pointer-events: none;
}

@keyframes slideUp {
    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

/* 3. Bounce Out */
.splash-bounce-out {
    animation: bounceOut 0.8s ease-in-out forwards;
    pointer-events: none;
}

@keyframes bounceOut {
    20% {
        transform: scale(0.9);
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* --- Entrance Animations --- */
.splash-fade-in {
    animation: fadeInSplash 0.5s ease forwards;
}

@keyframes fadeInSplash {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.splash-slide-down {
    animation: slideDownSplash 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes slideDownSplash {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.splash-zoom-in {
    animation: zoomInSplash 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes zoomInSplash {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-top: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Utility class for success messages */
.success-text {
    color: #4caf50 !important;
}

/* ========================================
   LOADING VIEW
   ======================================== */
.loading-view {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 30000;
    pointer-events: auto;
    /* Block interactions while loading */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    background-color: rgba(0, 0, 0, 0.6);
    /* Full screen dim */
    backdrop-filter: blur(5px);
}

.loading-view.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--color-primary);
    animation: spin 1s ease-in-out infinite;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.loading-text {
    margin-top: 15px;
    color: white;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 16px;
    border-radius: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}