/* ========== CSS RESET & BASE (Mobile-First) ========== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Prevent selection on mobile */
img {
    pointer-events: none;
    -webkit-user-drag: none;
    user-drag: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Fixed base font size (important for iframe) */
html {
    font-size: 16px !important;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html,
body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #b8d4f0 0%, #d4e8fc 50%, #e8f4ff 100%);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

/* Utilities */
.noselect {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.hidden {
    display: none !important;
}

/* ========== CSS VARIABLES ========== */
:root {
    /* === New Light Theme Colors === */
    --bg-light: #d4e8fc;
    --bg-medium: #c0dcf8;
    --bg-dark: #3a4a6b;

    /* Container colors (dark blue like reference) */
    --container-bg: #3d4b6a;
    --container-bg-light: #4a5a7a;
    --container-bg-dark: #2d3b5a;
    --container-inner: #2a3852;

    /* Card/Block colors - vibrant and glossy */
    --purple: #b77dff;
    --purple-dark: #9060dd;
    --purple-light: #d4a8ff;

    --green: #5ce08a;
    --green-dark: #40c070;
    --green-light: #88f0aa;

    --orange: #ffb84d;
    --orange-dark: #f5a030;
    --orange-light: #ffd080;

    --blue: #60c8ff;
    --blue-dark: #40a8e0;
    --blue-light: #90ddff;

    --cyan: #5ce8d8;
    --cyan-dark: #40c8b8;
    --cyan-light: #88f0e8;

    --pink: #ff80b0;
    --pink-dark: #e06090;
    --pink-light: #ffa8c8;

    --yellow: #ffe060;
    --yellow-dark: #e8c840;
    --yellow-light: #fff090;

    --red: #ff6b6b;
    --red-dark: #e05050;
    --red-light: #ff9090;

    /* UI Colors - light theme */
    --ui-text: #ffffff;
    --ui-text-dark: #3a4a6b;
    --ui-shadow: rgba(0, 0, 0, 0.15);
    --ui-shadow-strong: rgba(0, 0, 0, 0.25);

    /* Header UI */
    --header-bg: rgba(255, 255, 255, 0.7);
    --header-accent: #4a90d9;

    /* === Typography === */
    --font-family: 'Nunito', sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 13px;
    --font-size-base: 16px;
    --font-size-md: 18px;
    --font-size-lg: 22px;
    --font-size-xl: 28px;

    /* === Spacing (scalable) === */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* === Element Sizes === */
    --button-min-size: 44px;
    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    --border-radius-full: 50px;

    /* === Shadows === */
    --shadow-soft: 0 4px 15px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 6px 20px rgba(0, 0, 0, 0.15);
    --shadow-strong: 0 8px 30px rgba(0, 0, 0, 0.2);
    --shadow-inset: inset 0 4px 8px rgba(0, 0, 0, 0.4);

    /* === Container === */
    --container-max-width: 600px;

    /* === Animations === */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* === Game Sizing (Mobile-First / Small Screens) === */
    --card-width: 35px;
    --card-height: 50px;
    --card-gap: -38px;
    --lane-width: 48px;
    --collector-width: 40px;
    --collector-height: 80px;
    --collector-slot-height: 10px;
    --collector-slot-gap: 2px;
    --buffer-slot-size: 10px;
}

/* ========== GAME CONTAINER ========== */
#game-container {
    width: 100%;
    max-width: var(--container-max-width);
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 0;
    position: relative;
    overflow: hidden;
    touch-action: none;
}

/* ========== HEADER ========== */
.game-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-xs);
    gap: var(--spacing-sm);
    min-height: 60px;
    /* Ensure height for absolute positioning */
}

.settings-btn {
    width: 40px;
    height: 40px;
    min-width: var(--button-min-size);
    min-height: var(--button-min-size);
    border-radius: 12px;
    background: linear-gradient(145deg, #5a8ec8, #4078b8);
    border: none;
    font-size: 18px;
    cursor: pointer;
    box-shadow:
        0 4px 12px rgba(70, 130, 180, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

.settings-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
}

.settings-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 6px rgba(70, 130, 180, 0.3);
}

.level-info {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: max-content;
    z-index: 5;
}

.level-text {
    color: var(--ui-text-dark);
    font-size: var(--font-size-sm);
    font-weight: 800;
    text-shadow: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.progress-bar {
    width: 120px;
    height: 10px;
    background: rgba(100, 140, 180, 0.2);
    border-radius: 5px;
    margin-top: var(--spacing-xs);
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    width: 50%;
    background: linear-gradient(90deg, #ffc040, #ffdd60);
    border-radius: 5px;
    transition: width var(--transition-normal);
    box-shadow: 0 0 8px rgba(255, 200, 80, 0.5);
}

.coins-display {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: linear-gradient(180deg, #f0f8ff, #e0f0ff);
    padding: 8px 14px;
    border-radius: 25px;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 2px 0 rgba(255, 255, 255, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.coins-display span {
    color: var(--ui-text-dark);
    font-weight: 700;
    font-size: var(--font-size-sm);
}

.coin-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

/* ========== CARD COUNTER ========== */
.card-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px;
    color: var(--ui-text-dark);
    font-size: var(--font-size-base);
    font-weight: 700;
}

.counter-icon {
    font-size: 20px;
}

.counter-item {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 4px;
}

.counter-mini-card {
    width: 14px;
    height: 20px;
    border-radius: 3px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.counter-mini-card::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    height: 40%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), transparent);
    border-radius: 1px;
}

.counter-mini-card.purple {
    background: linear-gradient(180deg, var(--purple-light), var(--purple), var(--purple-dark));
}

.counter-mini-card.green {
    background: linear-gradient(180deg, var(--green-light), var(--green), var(--green-dark));
}

.counter-mini-card.orange {
    background: linear-gradient(180deg, var(--orange-light), var(--orange), var(--orange-dark));
}

.counter-mini-card.blue {
    background: linear-gradient(180deg, var(--blue-light), var(--blue), var(--blue-dark));
}

.counter-mini-card.cyan {
    background: linear-gradient(180deg, var(--cyan-light), var(--cyan), var(--cyan-dark));
}

.counter-mini-card.pink {
    background: linear-gradient(180deg, var(--pink-light), var(--pink), var(--pink-dark));
}

.counter-mini-card.yellow {
    background: linear-gradient(180deg, var(--yellow-light), var(--yellow), var(--yellow-dark));
}

.counter-mini-card.red {
    background: linear-gradient(180deg, var(--red-light), var(--red), var(--red-dark));
}

/* ========== GAME AREA ========== */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    min-height: 0;
    overflow: hidden;
}

/* ========== LANES CONTAINER ========== */
/* Dark blue container like in the reference */
.lanes-container {
    flex: 1 1 0;
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: linear-gradient(145deg, var(--container-bg-light), var(--container-bg), var(--container-bg-dark));
    border-radius: 24px;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.25),
        inset 0 2px 0 rgba(255, 255, 255, 0.1),
        inset 0 -4px 8px rgba(0, 0, 0, 0.2);
    min-height: 80px;
    overflow: hidden;
    border: 3px solid rgba(80, 100, 140, 0.5);
}

.card-lane {
    width: var(--lane-width);
    background: linear-gradient(180deg, var(--container-inner) 0%, #1e2b40 100%);
    border-radius: 14px;
    padding: 8px 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    box-shadow:
        inset 0 4px 12px rgba(0, 0, 0, 0.5),
        inset 0 -2px 0 rgba(255, 255, 255, 0.05),
        0 2px 4px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.card-lane::-webkit-scrollbar {
    display: none;
}

/* ========== CARDS - Glossy Block Style ========== */
.card {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 -4px 0 rgba(0, 0, 0, 0.15),
        inset 0 4px 0 rgba(255, 255, 255, 0.35);
    position: relative;
    margin-top: var(--card-gap);
    overflow: hidden;
}

.card:first-child {
    margin-top: auto;
}

/* Glossy wave highlight effect */
.card::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    height: 40%;
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.5) 0%,
            rgba(255, 255, 255, 0.3) 30%,
            rgba(255, 255, 255, 0.1) 60%,
            transparent 100%);
    border-radius: 6px 6px 50% 50%;
    pointer-events: none;
}

/* Wave/liquid effect overlay */
.card::after {
    content: '';
    position: absolute;
    bottom: 20%;
    left: 5px;
    right: 5px;
    height: 3px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    filter: blur(1px);
    pointer-events: none;
}

.card:active {
    transform: scale(0.95);
}

/* Card Colors - Vibrant gradients */
.card.purple {
    background: linear-gradient(180deg, var(--purple-light), var(--purple), var(--purple-dark));
}

.card.green {
    background: linear-gradient(180deg, var(--green-light), var(--green), var(--green-dark));
}

.card.orange {
    background: linear-gradient(180deg, var(--orange-light), var(--orange), var(--orange-dark));
}

.card.blue {
    background: linear-gradient(180deg, var(--blue-light), var(--blue), var(--blue-dark));
}

.card.cyan {
    background: linear-gradient(180deg, var(--cyan-light), var(--cyan), var(--cyan-dark));
}

.card.pink {
    background: linear-gradient(180deg, var(--pink-light), var(--pink), var(--pink-dark));
}

.card.yellow {
    background: linear-gradient(180deg, var(--yellow-light), var(--yellow), var(--yellow-dark));
}

.card.red {
    background: linear-gradient(180deg, var(--red-light), var(--red), var(--red-dark));
}

/* ========== CARD ANIMATIONS ========== */
.card.animating {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    will-change: transform, opacity;
    /* Начальное состояние */
    opacity: 1;
}

/* Анимация в буфер (плавный полёт с приземлением) */
.card.animating.to-buffer {
    transition:
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.35s ease-out;
}

/* Анимация в коллектор (плавный полёт с приземлением) */
.card.animating.to-collector {
    transition:
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.35s ease-out;
}

/* Анимация из буфера в коллектор */
.card.animating.buffer-to-collector {
    transition:
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.35s ease-out;
}

/* Состояние "приземления" - плавное уменьшение в слоте */
.card.animating.landing {
    opacity: 0;
    transition:
        transform 0.15s ease-out,
        opacity 0.15s ease-out;
}

/* Fallback для карт без специфического класса */
.card.animating:not(.to-buffer):not(.to-collector):not(.buffer-to-collector) {
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Shuffle Animations */
.card.shuffle-out {
    transform: scale(0.1) rotate(180deg) !important;
    opacity: 0.5;
    transition: transform 0.3s ease-in, opacity 0.3s ease-in;
}

.card.shuffle-in {
    animation: shuffleIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes shuffleIn {
    0% {
        transform: scale(0.1) rotate(-180deg);
        opacity: 0;
    }

    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

/* ========== BUFFER ZONE ========== */
/* Buffer styled like reference - dark container */
.buffer-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm);
    background: linear-gradient(145deg, var(--container-bg-light), var(--container-bg), var(--container-bg-dark));
    border-radius: 16px;
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.2),
        inset 0 2px 0 rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    width: 100%;
    border: 3px solid rgba(80, 100, 140, 0.5);
}

.buffer-slots {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    padding: 8px 12px;
    height: auto;
    background: var(--container-inner);
    border-radius: 12px;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.4);
    margin-right: 15px;
    flex-grow: 1;
    overflow: hidden;
}

.buffer-slot {
    width: 10px;
    height: 40px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: none;
    margin-left: 0;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
    box-shadow:
        inset 2px 0 4px rgba(0, 0, 0, 0.3),
        inset -1px 0 0 rgba(255, 255, 255, 0.05);
}

.buffer-slot:first-child {
    margin-left: 0;
}

.buffer-slot.filled:active {
    transform: translateY(2px);
}

.buffer-slot.filled {
    border: none;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 -3px 0 rgba(0, 0, 0, 0.15),
        inset 0 3px 0 rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    animation: slotFillIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Анимация появления заполненного слота буфера */
@keyframes slotFillIn {
    0% {
        opacity: 0;
        transform: scaleY(0.3) scaleX(0.8);
    }

    60% {
        opacity: 1;
        transform: scaleY(1.05) scaleX(1);
    }

    100% {
        opacity: 1;
        transform: scaleY(1) scaleX(1);
    }
}

/* Vertical strip highlight (Long vertical glare on left) */
.buffer-slot.filled::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 4px;
    bottom: 4px;
    width: 3px;
    height: auto;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.2) 100%);
    border-radius: 2px;
}

/* Wave effect on filled buffer slots */


.buffer-slot.filled.purple {
    background: linear-gradient(180deg, var(--purple-light), var(--purple), var(--purple-dark));
}

.buffer-slot.filled.green {
    background: linear-gradient(180deg, var(--green-light), var(--green), var(--green-dark));
}

.buffer-slot.filled.orange {
    background: linear-gradient(180deg, var(--orange-light), var(--orange), var(--orange-dark));
}

.buffer-slot.filled.blue {
    background: linear-gradient(180deg, var(--blue-light), var(--blue), var(--blue-dark));
}

.buffer-slot.filled.cyan {
    background: linear-gradient(180deg, var(--cyan-light), var(--cyan), var(--cyan-dark));
}

.buffer-slot.filled.pink {
    background: linear-gradient(180deg, var(--pink-light), var(--pink), var(--pink-dark));
}

.buffer-slot.filled.yellow {
    background: linear-gradient(180deg, var(--yellow-light), var(--yellow), var(--yellow-dark));
}

.buffer-slot.filled.red {
    background: linear-gradient(180deg, var(--red-light), var(--red), var(--red-dark));
}

.buffer-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.action-btn {
    width: 48px;
    height: 40px;
    min-width: var(--button-min-size);
    min-height: var(--button-min-size);
    border-radius: 12px;
    border: none;
    font-size: 15px;
    font-weight: 800;
    color: var(--ui-text);
    cursor: pointer;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.2),
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.action-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.action-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(100%);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.add-slots-btn {
    background: linear-gradient(145deg, #60c8ff, #40a8e0);
}

.cost-indicator {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    color: var(--ui-text);
}

.cost-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

/* Clean up original .collectors-container styles if they conflict */
/* Currently:
.collectors-container {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-sm) var(--spacing-xs) var(--spacing-sm);
    flex-shrink: 0;
}
*/
/* The override above for .collectors-container handles it */
/* Collectors styled like colorful blocks in the reference */
.collectors-wrapper {
    display: flex;
    justify-content: space-between;
    /* Push buttons to sides */
    align-items: center;
    /* Vertically center items */
    padding: 0 var(--spacing-md);
    /* Match padding of lanes-container presumably */
    flex-shrink: 0;
    gap: var(--spacing-xs);
    /* Use small gap as they are pushed to sides anyway */
    width: 100%;
    margin-top: auto;
    position: relative;
    box-sizing: border-box;
}

.collectors-container {
    flex: 1;
    /* Allow it to take space */
    justify-content: center;
    /* Keep collectors centered */
    display: flex;
    gap: var(--spacing-sm);
    /* Remove padding that might interfere */
    padding: var(--spacing-sm) 0;
}

.side-controls {
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Remove padding-bottom to center vertically properly */
    padding-bottom: 0;
    z-index: 10;
}

/* Ensure buttons themselves are centered in their flex column */
.action-btn-large {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.15),
        inset 0 2px 0 rgba(255, 255, 255, 1);
    cursor: pointer;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s, box-shadow 0.1s;
    margin: 0;
    /* Clear margins */
}

.action-btn-large:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.action-btn-large img {
    width: 60%;
    height: 60%;
    object-fit: contain;
}

/* Price Tag Style */
.btn-price-tag {
    position: absolute;
    bottom: -12px;
    background: #333;
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 2px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

.price-icon {
    width: 10px !important;
    height: 10px !important;
}

/* Skip/Ad Badge Style */
.icon-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.badge-icon {
    position: absolute;
    top: auto;
    bottom: -5px;
    right: -5px;
    width: 26px !important;
    height: 26px !important;
    background: #fff;
    border-radius: 50%;
    padding: 3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    z-index: 5;
}

/* Disabled State */
.action-btn-large.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(100%);
    cursor: not-allowed;
}


.collectors-container {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-sm) var(--spacing-xs) var(--spacing-sm);
    flex-shrink: 0;
}

.collector-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
}

.next-collector-box {
    width: var(--collector-width);
    height: 22px;
    border-radius: 10px;
    opacity: 0.5;
    box-shadow:
        0 3px 8px var(--ui-shadow),
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.next-collector-box.purple {
    background: linear-gradient(180deg, var(--purple), var(--purple-dark));
}

.next-collector-box.green {
    background: linear-gradient(180deg, var(--green), var(--green-dark));
}

.next-collector-box.orange {
    background: linear-gradient(180deg, var(--orange), var(--orange-dark));
}

.next-collector-box.blue {
    background: linear-gradient(180deg, var(--blue), var(--blue-dark));
}

.next-collector-box.cyan {
    background: linear-gradient(180deg, var(--cyan), var(--cyan-dark));
}

.next-collector-box.pink {
    background: linear-gradient(180deg, var(--pink), var(--pink-dark));
}

.next-collector-box.yellow {
    background: linear-gradient(180deg, var(--yellow), var(--yellow-dark));
}

.next-collector-box.red {
    background: linear-gradient(180deg, var(--red), var(--red-dark));
}

.collector-box {
    width: var(--collector-width);
    height: var(--collector-height);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.3),
        inset 0 4px 0 rgba(255, 255, 255, 0.35),
        inset 0 -4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

/* Glossy highlight on collector */
.collector-box::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    height: 35%;
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.45) 0%,
            rgba(255, 255, 255, 0.2) 40%,
            transparent 100%);
    border-radius: 8px 8px 50% 50%;
    pointer-events: none;
}

.collector-box.purple {
    background: linear-gradient(180deg, var(--purple-light) 0%, var(--purple) 30%, var(--purple-dark) 100%);
}

.collector-box.green {
    background: linear-gradient(180deg, var(--green-light) 0%, var(--green) 30%, var(--green-dark) 100%);
}

.collector-box.orange {
    background: linear-gradient(180deg, var(--orange-light) 0%, var(--orange) 30%, var(--orange-dark) 100%);
}

.collector-box.blue {
    background: linear-gradient(180deg, var(--blue-light) 0%, var(--blue) 30%, var(--blue-dark) 100%);
}

.collector-box.cyan {
    background: linear-gradient(180deg, var(--cyan-light) 0%, var(--cyan) 30%, var(--cyan-dark) 100%);
}

.collector-box.pink {
    background: linear-gradient(180deg, var(--pink-light) 0%, var(--pink) 30%, var(--pink-dark) 100%);
}

.collector-box.yellow {
    background: linear-gradient(180deg, var(--yellow-light) 0%, var(--yellow) 30%, var(--yellow-dark) 100%);
}

.collector-box.red {
    background: linear-gradient(180deg, var(--red-light) 0%, var(--red) 30%, var(--red-dark) 100%);
}

.collector-slots {
    display: flex;
    flex-direction: column;
    gap: var(--collector-slot-gap);
    width: 100%;
    position: relative;
    z-index: 1;
}

.collector-slot {
    width: 100%;
    height: var(--collector-slot-height);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.25),
        inset 0 -1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.collector-slot.filled {
    background: rgba(255, 255, 255, 0.35);
    box-shadow:
        inset 0 -2px 0 rgba(0, 0, 0, 0.15),
        inset 0 2px 0 rgba(255, 255, 255, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.1);
    animation: collectorSlotFillIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Анимация появления заполненного слота коллектора */
@keyframes collectorSlotFillIn {
    0% {
        opacity: 0;
        transform: scaleX(0.5);
    }

    70% {
        opacity: 1;
        transform: scaleX(1.08);
    }

    100% {
        opacity: 1;
        transform: scaleX(1);
    }
}

.collector-slot.filled::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    right: 5px;
    height: 2px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 2px;
}

/* Liquid wave effect on filled slots */
.collector-slot.filled::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 10%;
    right: 10%;
    height: 1px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}

.collector-fill {
    display: none;
}

.collector-count {
    display: none;
}

.collector-box.complete {
    animation: collectComplete 0.5s ease;
}

@keyframes collectComplete {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
        filter: brightness(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* ========== FOOTER ========== */
.game-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-sm);
}

.undo-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 12px 22px;
    min-width: var(--button-min-size);
    min-height: var(--button-min-size);
    background: linear-gradient(145deg, var(--green-light), var(--green), var(--green-dark));
    border: none;
    border-radius: 30px;
    color: var(--ui-text);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow:
        0 6px 16px rgba(80, 200, 120, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.undo-btn:active {
    transform: scale(0.95);
    box-shadow: 0 3px 8px rgba(80, 200, 120, 0.3);
}

.undo-icon {
    font-size: 18px;
}

.locked-features {
    display: flex;
    gap: var(--spacing-sm);
}

.locked-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 10px 14px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
    border-radius: 14px;
    color: var(--ui-text-dark);
    font-size: 10px;
    opacity: 0.7;
    backdrop-filter: blur(4px);
}

.lock-icon {
    font-size: 16px;
}

/* ========== ANIMATIONS ========== */
@keyframes cardPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    70% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.card-pop {
    animation: cardPop 0.3s ease forwards;
}

.shake {
    animation: shake 0.3s ease;
}

/* ========== GAME OVERLAY ========== */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.game-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.overlay-title {
    color: var(--ui-text);
    font-size: var(--font-size-xl);
    font-weight: 800;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.overlay-btn {
    padding: 16px 40px;
    font-size: 18px;
    font-weight: 800;
    color: var(--ui-text);
    border: none;
    border-radius: 35px;
    cursor: pointer;
    min-width: var(--button-min-size);
    min-height: var(--button-min-size);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.overlay-btn:active {
    transform: scale(0.95);
}

.overlay-btn.primary {
    background: linear-gradient(145deg, var(--green-light), var(--green), var(--green-dark));
}

/* ========== EXTRA SMALL DEVICES (≤ 374px) ========== */
@media (max-width: 374px) {
    :root {
        --card-width: 30px;
        --card-height: 45px;
        --card-gap: -34px;
        --lane-width: 42px;
        --collector-width: 35px;
        --collector-height: 70px;
        --collector-slot-height: 8px;
        --font-size-sm: 11px;
        --font-size-base: 14px;
        --spacing-sm: 6px;
        --spacing-md: 12px;
    }

    .lanes-container {
        gap: 6px;
        padding: 10px;
        border-radius: 18px;
    }

    .buffer-slots {
        min-width: 120px;
        height: 40px;
        padding: 0 10px;
    }



    .collectors-container {
        gap: 6px;
        padding: 6px;
    }

    .overlay-title {
        font-size: var(--font-size-lg);
    }
}

/* ========== SMALL DEVICES (375px - 767px) ========== */
@media (min-width: 375px) and (max-width: 767px) {
    :root {
        --card-width: 40px;
        --card-height: 60px;
        --card-gap: -48px;
        --lane-width: 55px;
        --collector-width: 45px;
        --collector-height: 90px;
        --collector-slot-height: 12px;
    }

    .lanes-container {
        gap: 12px;
        padding: 14px;
        border-radius: 22px;
    }

    .buffer-slots {
        min-width: 180px;
        height: 55px;
    }


}

/* ========== MEDIUM DEVICES / TABLETS (768px - 1023px) ========== */
@media (min-width: 768px) {
    :root {
        --container-max-width: 480px;
        --card-width: 42px;
        --card-height: 62px;
        --card-gap: -50px;
        --lane-width: 58px;
        --collector-width: 48px;
        --collector-height: 95px;
        --collector-slot-height: 12px;
        --font-size-sm: 14px;
        --font-size-base: 16px;
        --font-size-md: 18px;
        --font-size-lg: 22px;
        --font-size-xl: 28px;
        --spacing-sm: 10px;
        --spacing-md: 16px;
        --spacing-lg: 22px;
    }

    .settings-btn {
        width: 46px;
        height: 46px;
        font-size: 20px;
        border-radius: 14px;
    }

    .progress-bar {
        height: 12px;
    }

    .coins-display {
        padding: 10px 16px;
    }

    .coin-icon {
        font-size: 20px;
    }

    .lanes-container {
        gap: 14px;
        padding: 16px;
        border-radius: 26px;
    }

    .card-lane {
        border-radius: 16px;
        padding: 10px 10px 14px;
    }

    .card {
        border-radius: 12px;
    }

    .buffer-zone {
        padding: var(--spacing-sm) var(--spacing-md);
        border-radius: 18px;
    }

    .buffer-slots {
        min-width: 200px;
        height: 58px;
        padding: 0 18px;
        border-radius: 12px;
    }

    .buffer-slot {
        border-radius: 10px;
    }

    .action-btn {
        width: 52px;
        height: 44px;
        font-size: 16px;
        border-radius: 14px;
    }

    .collectors-container {
        gap: 12px;
        padding: 12px;
    }

    .collector-box {
        border-radius: 16px;
        padding: 6px;
    }

    .next-collector-box {
        height: 24px;
        border-radius: 12px;
    }

    .overlay-title {
        font-size: 32px;
    }

    .overlay-btn {
        padding: 16px 42px;
        font-size: 20px;
    }
}

/* ========== LARGE DEVICES / DESKTOP (≥ 1024px) ========== */
@media (min-width: 1024px) {
    :root {
        --container-max-width: 1000px;
        --card-width: 45px;
        --card-height: 66px;
        --card-gap: -52px;
        --lane-width: 62px;
        --collector-width: 52px;
        --collector-height: 100px;
        --collector-slot-height: 13px;
        --font-size-sm: 14px;
        --font-size-base: 16px;
        --font-size-lg: 24px;
        --font-size-xl: 30px;
        --spacing-sm: 10px;
        --spacing-md: 18px;
        --spacing-lg: 24px;
    }

    .settings-btn {
        width: 48px;
        height: 48px;
        font-size: 22px;
    }

    .settings-btn:hover {
        transform: scale(1.05);
        box-shadow:
            0 6px 18px rgba(70, 130, 180, 0.5),
            inset 0 2px 0 rgba(255, 255, 255, 0.3);
    }

    .card:hover {
        transform: scale(1.05);
        box-shadow:
            0 6px 12px rgba(0, 0, 0, 0.35),
            inset 0 -4px 0 rgba(0, 0, 0, 0.15),
            inset 0 4px 0 rgba(255, 255, 255, 0.4);
    }


    .action-btn:hover {
        transform: scale(1.05);
    }

    .undo-btn:hover {
        transform: scale(1.05);
    }

    .overlay-btn:hover {
        transform: scale(1.05);
    }

    .levels-grid {
        grid-template-columns: repeat(7, 1fr);
        max-width: 900px;
        gap: 20px;
    }


}

/* ========== LARGE TABLETS / iPad Pro 11" (834px+) ========== */
@media (min-width: 834px) and (min-height: 1000px) {
    :root {
        --container-max-width: 580px;
        --card-width: 52px;
        --card-height: 76px;
        --card-gap: -62px;
        --lane-width: 72px;
        --collector-width: 60px;
        --collector-height: 115px;
        --collector-slot-height: 15px;
        --collector-slot-gap: 3px;
        --buffer-slot-size: 14px;
        --font-size-sm: 16px;
        --font-size-base: 18px;
        --font-size-md: 20px;
        --font-size-lg: 26px;
        --font-size-xl: 34px;
        --spacing-sm: 12px;
        --spacing-md: 20px;
        --spacing-lg: 28px;
    }

    .settings-btn {
        width: 54px;
        height: 54px;
        font-size: 24px;
        border-radius: 16px;
    }

    .level-info {
        padding: 12px 28px;
        border-radius: 30px;
    }

    .progress-bar {
        height: 14px;
        border-radius: 7px;
    }

    .coins-display {
        padding: 12px 20px;
        border-radius: 30px;
    }

    .coin-icon {
        font-size: 24px;
    }

    .card-counter {
        font-size: var(--font-size-md);
        gap: 8px;
        padding: 8px;
    }

    .counter-icon {
        font-size: 24px;
    }

    .lanes-container {
        gap: 18px;
        padding: 22px;
        border-radius: 30px;
        border-width: 4px;
    }

    .card-lane {
        border-radius: 18px;
        padding: 12px 12px 16px;
    }

    .card {
        border-radius: 14px;
    }

    .buffer-zone {
        padding: var(--spacing-md);
        border-radius: 22px;
        border-width: 4px;
    }

    .buffer-slots {
        min-width: 260px;
        height: 70px;
        padding: 10px 22px;
        border-radius: 16px;
        gap: 6px;
    }

    .buffer-slot {
        width: 14px;
        height: 55px;
        border-radius: 10px;
    }

    .action-btn {
        width: 60px;
        height: 52px;
        font-size: 18px;
        border-radius: 16px;
    }

    .collectors-container {
        gap: 16px;
        padding: 16px;
    }

    .collector-column {
        gap: var(--spacing-md);
    }

    .collector-box {
        border-radius: 20px;
        padding: 8px;
    }

    .collector-slot {
        height: var(--collector-slot-height);
        border-radius: 8px;
    }

    .next-collector-box {
        height: 30px;
        border-radius: 14px;
    }

    .overlay-title {
        font-size: 38px;
    }

    .overlay-btn {
        padding: 20px 50px;
        font-size: 22px;
        border-radius: 40px;
    }
}

/* ========== EXTRA LARGE TABLETS / iPad Pro 12.9" & 13" (1024px+ width, tall screens) ========== */
@media (min-width: 1024px) and (min-height: 1200px) {
    :root {
        --container-max-width: 650px;
        --card-width: 60px;
        --card-height: 88px;
        --card-gap: -72px;
        --lane-width: 82px;
        --collector-width: 70px;
        --collector-height: 135px;
        --collector-slot-height: 18px;
        --collector-slot-gap: 3px;
        --buffer-slot-size: 16px;
        --font-size-sm: 18px;
        --font-size-base: 20px;
        --font-size-md: 22px;
        --font-size-lg: 30px;
        --font-size-xl: 40px;
        --spacing-sm: 14px;
        --spacing-md: 24px;
        --spacing-lg: 32px;
    }

    .settings-btn {
        width: 60px;
        height: 60px;
        font-size: 28px;
        border-radius: 18px;
    }

    .level-info {
        padding: 14px 32px;
        border-radius: 35px;
    }

    .progress-bar {
        height: 16px;
        border-radius: 8px;
    }

    .coins-display {
        padding: 14px 24px;
        border-radius: 35px;
    }

    .coin-icon {
        font-size: 28px;
    }

    .card-counter {
        font-size: var(--font-size-lg);
        gap: 10px;
        padding: 10px;
    }

    .counter-icon {
        font-size: 28px;
    }

    .lanes-container {
        gap: 22px;
        padding: 28px;
        border-radius: 36px;
        border-width: 5px;
    }

    .card-lane {
        border-radius: 22px;
        padding: 14px 14px 20px;
    }

    .card {
        border-radius: 16px;
    }

    .buffer-zone {
        padding: var(--spacing-md) var(--spacing-lg);
        border-radius: 26px;
        border-width: 5px;
    }

    .buffer-slots {
        min-width: 320px;
        height: 80px;
        padding: 12px 26px;
        border-radius: 18px;
        gap: 7px;
    }

    .buffer-slot {
        width: 16px;
        height: 65px;
        border-radius: 12px;
    }

    .action-btn {
        width: 68px;
        height: 58px;
        font-size: 20px;
        border-radius: 18px;
    }

    .collectors-container {
        gap: 20px;
        padding: 20px;
    }

    .collector-column {
        gap: var(--spacing-lg);
    }

    .collector-box {
        border-radius: 24px;
        padding: 10px;
    }

    .collector-slot {
        height: var(--collector-slot-height);
        border-radius: 10px;
    }

    .next-collector-box {
        height: 36px;
        border-radius: 16px;
    }

    .overlay-title {
        font-size: 44px;
    }

    .overlay-btn {
        padding: 24px 56px;
        font-size: 26px;
        border-radius: 45px;
    }

    .undo-btn {
        padding: 16px 30px;
        font-size: 18px;
        border-radius: 35px;
    }

    .undo-icon {
        font-size: 24px;
    }
}

/* ========== LANDSCAPE ORIENTATION ========== */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --spacing-sm: 4px;
        --spacing-md: 8px;
        --card-width: 30px;
        --card-height: 45px;
        --card-gap: -34px;
        --lane-width: 42px;
        --collector-width: 35px;
        --collector-height: 65px;
        --collector-slot-height: 8px;
    }

    .game-header {
        padding: 4px 6px;
    }

    .card-counter {
        padding: 4px;
    }

    .game-area {
        gap: 4px;
    }

    .lanes-container {
        padding: 8px;
        gap: 6px;
        border-radius: 14px;
    }

    .card-lane {
        padding: 4px 4px 8px;
        border-radius: 10px;
    }

    .buffer-zone {
        padding: 4px 8px;
    }

    .buffer-slots {
        height: 38px;
        min-width: 100px;
    }

    .collectors-container {
        gap: 6px;
        padding: 4px;
    }

    .collector-column {
        gap: 4px;
    }

    .next-collector-box {
        height: 16px;
    }
}

/* ========== HEIGHT-BASED ADJUSTMENTS ========== */
/* Collectors maintain fixed height - only lanes-container adjusts */
@media (max-height: 700px) {
    .game-area {
        gap: 4px;
    }

    .lanes-container {
        padding: 8px;
    }
}

@media (max-height: 600px) {
    .game-area {
        gap: 3px;
    }

    .lanes-container {
        padding: 6px;
        min-height: 60px;
    }

    .buffer-zone {
        padding: 4px 8px;
    }
}

/* ========== TOUCH DEVICE OPTIMIZATIONS ========== */
@media (hover: none) and (pointer: coarse) {

    /* Minimum tappable element size (Apple/Google recommendation: 44x44px) */
    button,
    .clickable,
    .tappable,
    .card {
        min-width: 44px;
        min-height: 44px;
    }

    /* Disable hover effects on touch devices */
    .settings-btn:hover,
    .card:hover,
    .action-btn:hover,
    .buffer-slot:hover,
    .undo-btn:hover,
    .overlay-btn:hover,
    .collector-box:hover {
        transform: none;
    }

    /* Quick touch response */
    .interactive {
        touch-action: manipulation;
    }
}

/* ========== HIGH DPI / RETINA ========== */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    /* Enhanced shadows for Retina displays */
    .card {
        box-shadow:
            0 3px 6px rgba(0, 0, 0, 0.25),
            inset 0 -3px 0 rgba(0, 0, 0, 0.12),
            inset 0 3px 0 rgba(255, 255, 255, 0.3);
    }

    .collector-box {
        box-shadow:
            0 5px 14px rgba(0, 0, 0, 0.25),
            inset 0 3px 0 rgba(255, 255, 255, 0.3),
            inset 0 -3px 6px rgba(0, 0, 0, 0.15);
    }
}

/* ========== SCREEN MANAGEMENT ========== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 10;
    background: linear-gradient(180deg, #b8d4f0 0%, #d4e8fc 50%, #e8f4ff 100%);
    opacity: 1;
    transition: opacity 0.3s ease;
    overflow: hidden;
    padding: var(--spacing-sm) var(--spacing-sm) 0 var(--spacing-sm);
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

/* Specific Screen Styles */
#game-screen {
    background: transparent;
}

/* ========== BUTTONS ========== */
.btn {
    min-width: 140px;
    height: 50px;
    border-radius: 25px;
    border: none;
    font-family: 'Nunito', sans-serif;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: linear-gradient(180deg, #5ce08a 0%, #40c070 100%);
}

.btn-secondary {
    background: linear-gradient(180deg, #8ba0b9 0%, #6d829b 100%);
}

.btn-large {
    min-width: 200px;
    height: 60px;
    font-size: 24px;
}

.btn-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(145deg, #5a8ec8, #4078b8);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-icon img {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

/* ========== MAIN MENU ========== */
#main-menu .menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 40px;
}

.logo-container {
    text-align: center;
}

.game-title {
    font-size: 48px;
    color: #3d4b6a;
    text-shadow: 2px 2px 0px rgba(255, 255, 255, 0.5);
    margin-bottom: 20px;
}

.logo-icon-placeholder {
    width: 120px;
    height: 100px;
    position: relative;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: float 3s ease-in-out infinite;
}

.menu-card {
    width: 50px;
    height: 80px;
    border-radius: 10px;
    position: absolute;
    box-shadow:
        0 4px 10px rgba(0, 0, 0, 0.2),
        inset 0 2px 0 rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.menu-card::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    height: 30%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.1) 100%);
    border-radius: 6px 6px 30px 30px;
}

.menu-card-1 {
    transform: rotate(-20deg) translate(-15px, 5px);
    background: linear-gradient(180deg, var(--purple-light), var(--purple), var(--purple-dark));
    z-index: 1;
}

.menu-card-2 {
    transform: rotate(0deg) translate(0, -10px);
    background: linear-gradient(180deg, var(--green-light), var(--green), var(--green-dark));
    z-index: 2;
}

.menu-card-3 {
    transform: rotate(20deg) translate(15px, 5px);
    background: linear-gradient(180deg, var(--orange-light), var(--orange), var(--orange-dark));
    z-index: 3;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

/* ========== LEVEL SELECTION ========== */
.screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    flex-shrink: 0;
}

.screen-header h2 {
    color: #3d4b6a;
    font-size: 24px;
}

.header-spacer {
    width: 44px;
    /* Balance the back button */
}

.levels-grid-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    justify-content: center;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    width: 100%;
    max-width: 340px;
    align-content: start;
    padding: 10px;
}

.level-btn {
    aspect-ratio: 1;
    min-width: 60px;
    min-height: 60px;
    background: linear-gradient(145deg, #ffffff, #e6f0ff);
    border-radius: 15px;
    border: none;
    font-family: 'Nunito', sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: #3d4b6a;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
}

.level-btn:active {
    transform: scale(0.95);
}

.level-btn.locked {
    background: #cfd8e3;
    color: #8c9ba5;
    pointer-events: none;
}

.level-btn.completed {
    background: linear-gradient(145deg, #e0ffe8, #c0fdd0);
    color: #2e7d32;
    border: 2px solid #5ce08a;
}

/* Lock icon styling */
.level-btn.locked .lock-icon {
    width: 24px;
    height: 24px;
}



/* ========== POPUPS (Win/Lose) ========== */
.popup-container {
    background: white;
    padding: 30px;
    border-radius: 30px;
    width: 85%;
    max-width: 350px;
    margin: auto;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    animation: popupPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popupPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}



.popup-title {
    font-size: 28px;
    color: #3d4b6a;
    margin: 0;
}

.reward-box {
    background: #f0f7ff;
    padding: 10px 20px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
    font-weight: bold;
    color: #3d4b6a;
}

.reward-icon {
    width: 30px;
}

.popup-buttons {
    display: flex;
    gap: 15px;
    width: 100%;
    justify-content: center;
}

.lose-icon {
    width: 80px;
    margin-bottom: 10px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 374px) {
    .levels-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        max-width: 260px;
    }

    .level-btn {
        font-size: 16px;
        border-radius: 12px;
    }

    .game-title {
        font-size: 36px;
    }
}

/* ========== RESPONSIVE WIDTH ADJUSTMENTS (From Guide) ========== */
@media (min-width: 768px) {
    :root {
        --container-max-width: 480px;
    }
}

@media (min-width: 1024px) {
    :root {
        --container-max-width: 1000px;
    }
}

/* ========== MENU BALANCE DISPLAY ========== */
.menu-balance-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 120px;
    height: 40px;
    background: linear-gradient(145deg, #f0f8ff, #e0f0ff);
    border-radius: 16px;
    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: var(--ui-text-dark);
    font-size: 18px;
    font-weight: 800;
    margin-top: 5px;
}

.menu-balance-container .coin-icon {
    width: 20px;
    height: 20px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

@media (min-width: 768px) {
    .menu-balance-container {
        height: 48px;
        font-size: 20px;
        min-width: 140px;
    }

    .menu-balance-container .coin-icon {
        width: 24px;
        height: 24px;
    }
}

/* ========== TUTORIAL ========== */
.tutorial-cursor {
    position: fixed;
    width: 60px;
    height: 60px;
    background-image: url('Icons/cursor.png');
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 2000;
    transition: all 0.5s ease;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.tutorial-cursor.tapping {
    animation: fingerTap 1.5s infinite;
}

@keyframes fingerTap {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-10px, -10px) scale(0.9);
    }
}

.tutorial-highlight {
    position: relative;
    z-index: 1001 !important;
    /* Removed darkening shadow, kept subtle glow */
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 5px rgba(74, 144, 217, 0.6) !important;
    transition: box-shadow 0.3s ease;
}

.tutorial-highlight:hover {
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 5px rgba(74, 144, 217, 0.6) !important;
}

.tutorial-mask-layer {
    display: none !important;
}

/* ========== MODALS ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.btn-icon-inline {
    width: 24px;
    height: 24px;
    margin-left: 8px;
    vertical-align: middle;
}

/* Locked Button State */
.action-btn-large.locked {
    background: #e0e0e0;
    cursor: default;
    pointer-events: none;
    opacity: 0.9;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.locked-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.lock-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    margin-bottom: 2px;
    opacity: 0.6;
}

.lock-text {
    font-size: 10px;
    color: #777;
    font-weight: 800;
    text-transform: uppercase;
}