/* ==========================================
   THEME SYSTEM - Light & Dark
   ========================================== */
:root {
    /* Responsive font sizing */
    --font-xs: clamp(0.65rem, 1.5vw, 0.75rem);
    --font-sm: clamp(0.75rem, 2vw, 0.875rem);
    --font-md: clamp(0.875rem, 2.5vw, 1rem);
    --font-lg: clamp(1.1rem, 3vw, 1.3rem);
    --font-xl: clamp(1.3rem, 4vw, 1.6rem);
    --font-2xl: clamp(1.8rem, 5vw, 2.5rem);

    /* Block colors - consistent across themes */
    --color-1: #ff4757;
    --color-2: #ff7f50;
    --color-3: #ffa502;
    --color-4: #ffdd59;
    --color-5: #2ed573;
    --color-6: #1dd1a1;
    --color-7: #54a0ff;
    --color-8: #9b59f6;
    --color-9: #ff6b9d;
    --color-10: #ffffff;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    /* Touch target minimum */
    --touch-min: 44px;
}

/* Dark Theme (default) */
[data-theme="dark"] {
    --bg-deep: #0a0a0f;
    --bg-card: #12121a;
    --bg-elevated: #1a1a25;
    --bg-hover: #252535;
    --bg-overlay: rgba(0, 0, 0, 0.9);
    --bg-modal: #12121a;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.5);
    --glow-color: rgba(255, 255, 255, 0.1);
}

/* Light Theme */
[data-theme="light"] {
    --bg-deep: #f5f5f7;
    --bg-card: #ffffff;
    --bg-elevated: #f0f0f2;
    --bg-hover: #e8e8ec;
    --bg-overlay: rgba(0, 0, 0, 0.6);
    --bg-modal: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a5a;
    --text-muted: #8a8a9a;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --glow-color: rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    height: 100dvh;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    transition: background 0.3s ease, color 0.3s ease;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

/* ==========================================
   SVG ICON SYSTEM
   ========================================== */
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2em;
    height: 1.2em;
}

.icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.icon-heart::before { content: "❤️"; }
.icon-heart-empty::before { content: "🤍"; }

/* ==========================================
   LAYOUT
   ========================================== */
.bg-pattern {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
}

[data-theme="dark"] .bg-pattern {
    background:
        radial-gradient(ellipse at 20% 20%, rgba(155, 89, 246, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(84, 160, 255, 0.1) 0%, transparent 50%);
}

[data-theme="light"] .bg-pattern {
    background:
        radial-gradient(ellipse at 20% 20%, rgba(255, 71, 87, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(84, 160, 255, 0.05) 0%, transparent 50%);
}

.game-container {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
    padding: clamp(6px, 1.5vw, 12px);
    overflow: hidden;
    min-height: 0; /* Important for flex children to shrink */
}

/* ==========================================
   HEADER
   ========================================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: clamp(4px, 1vw, 8px);
    gap: 6px;
    flex-shrink: 0;
}

.logo {
    font-family: 'Space Mono', monospace;
    font-size: var(--font-lg);
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-1), var(--color-3), var(--color-5), var(--color-7), var(--color-8));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    flex-shrink: 0;
    background-clip: text;
    /* animation: gradientShift 4s ease infinite; -- removed for visual clarity */
    letter-spacing: -1px;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ==========================================
   SETTINGS BAR
   ========================================== */
.settings-bar {
    display: flex;
    align-items: center;
    gap: 4px;
}

.settings-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    min-width: 44px;
    min-height: 44px;
    padding: 6px;
    font-size: var(--font-sm);
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.settings-btn:hover {
    background: var(--bg-hover);
}

.settings-btn span {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

/* ==========================================
   ENERGY SYSTEM
   ========================================== */
.energy-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-card);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.energy-hearts {
    display: flex;
    align-items: center;
    gap: 4px;
}

.heart-icon {
    font-size: var(--font-md);
}

.heart-count {
    font-family: 'Space Mono', monospace;
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--color-1);
}

.heart {
    transition: all 0.3s ease;
}

.heart.empty {
    opacity: 0.25;
    filter: grayscale(1);
}

.energy-timer {
    font-family: 'Space Mono', monospace;
    font-size: var(--font-xs);
    color: var(--color-5);
    min-width: 35px;
    display: none;
}

.energy-bar:hover .energy-timer,
.energy-bar.show-timer .energy-timer {
    display: block;
}

/* Hide add button when energy is full */
.energy-add.hidden {
    display: none;
}

.energy-add {
    background: linear-gradient(135deg, var(--color-4), var(--color-3));
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: var(--font-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.energy-add:hover {
    transform: scale(1.1);
}

.energy-add.full {
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: default;
}

.energy-add.full:hover {
    transform: none;
}

/* ==========================================
   DAILY REWARD
   ========================================== */
.daily-reward-banner {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 165, 0, 0.1));
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: var(--radius-sm);
    padding: clamp(6px, 1.5vw, 10px) clamp(10px, 2vw, 14px);
    margin-bottom: clamp(4px, 1vw, 8px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 40px;
    flex-shrink: 0;
}

.daily-reward-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.2);
}

.daily-reward-banner.claimed {
    opacity: 0.5;
    pointer-events: none;
}

.daily-reward-banner.minimized {
    display: none;
}

/* Minimized daily reward indicator in header */
.daily-indicator {
    position: relative;
    cursor: pointer;
}

.daily-indicator::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: var(--color-5);
    border-radius: 50%;
    animation: indicatorPulse 2s ease infinite;
}

.daily-indicator.claimed::after {
    display: none;
}

@keyframes indicatorPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.daily-info {
    display: flex;
    align-items: center;
    gap: clamp(6px, 1.5vw, 10px);
}

.daily-icon {
    font-size: var(--font-xl);
    /* animation: bounce 1s ease infinite; -- removed for visual clarity */
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.daily-title-text {
    font-size: var(--font-sm);
    color: var(--color-4);
    font-weight: 600;
    display: block;
}

.daily-text p {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

.daily-claim {
    background: var(--color-4);
    color: #000;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--font-xs);
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
}

/* ==========================================
   STREAK COUNTER
   ========================================== */
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, var(--color-2), var(--color-1));
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: var(--font-xs);
    font-weight: 700;
    /* animation: streakPulse 2s ease infinite; -- removed for visual clarity */
}

.streak-badge .streak-fire {
    font-size: 1.1em;
}

@keyframes streakPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ==========================================
   LEADERBOARD
   ========================================== */
.leaderboard-btn {
    background: linear-gradient(135deg, var(--color-4), var(--color-3));
    border: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--font-xs);
    color: #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s ease;
}

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

.leaderboard-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 16px 0;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.leaderboard-item.current-user {
    background: linear-gradient(135deg, rgba(46, 213, 115, 0.2), rgba(29, 209, 161, 0.2));
    border: 1px solid var(--color-5);
}

.leaderboard-rank {
    font-weight: 800;
    font-size: var(--font-lg);
    min-width: 30px;
    text-align: center;
}

.leaderboard-rank.gold { color: #ffd700; }
.leaderboard-rank.silver { color: #c0c0c0; }
.leaderboard-rank.bronze { color: #cd7f32; }

.leaderboard-name {
    flex: 1;
    font-weight: 600;
}

.leaderboard-score {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    color: var(--color-4);
}

/* ==========================================
   SHARE BUTTON
   ========================================== */
.share-btn {
    background: linear-gradient(135deg, var(--color-7), var(--color-8));
    color: #fff;
}

.share-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    border: 2px solid var(--border-color);
}

.share-card-title {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.share-card-score {
    font-family: 'Space Mono', monospace;
    font-size: var(--font-2xl);
    font-weight: 800;
    color: var(--color-4);
}

.share-card-streak {
    margin-top: 8px;
}

/* ==========================================
   STATS BAR
   ========================================== */
.stats-bar {
    display: flex;
    justify-content: space-between;
    gap: clamp(4px, 1vw, 8px);
    margin-bottom: clamp(8px, 2vw, 12px);
    flex-shrink: 0;
}

.stat-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: clamp(6px, 1.5vw, 10px);
    text-align: center;
}

.stat-label {
    font-size: var(--font-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.stat-value {
    font-family: 'Space Mono', monospace;
    font-size: var(--font-lg);
    font-weight: 700;
}

.stat-value.score { color: var(--color-4); }
.stat-value.moves { color: var(--color-5); }
.stat-value.level { color: var(--color-7); }

/* ==========================================
   GAME MODE SELECTOR
   ========================================== */
.mode-bar {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--text-muted);
}

.mode-btn.active {
    background: linear-gradient(135deg, #2ed573, #1dd1a1);
    border-color: transparent;
    color: #000;
}

.mode-btn .mode-icon {
    font-size: 1.1em;
}

/* ==========================================
   RACE MODE
   ========================================== */
.race-container {
    display: none;
    gap: 20px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.race-container.active {
    display: flex;
}

.race-player {
    flex: 1;
    text-align: center;
}

.race-player-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
}

.race-player-name {
    font-weight: 700;
    font-size: var(--font-md);
}

.race-player-score {
    font-weight: 800;
    font-size: var(--font-lg);
    color: var(--color-5);
}

.race-board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    padding: 8px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
}

.race-board.bot-board {
    opacity: 0.9;
    pointer-events: none;
}

.race-board .cell {
    aspect-ratio: 1;
    min-width: 0;
}

.race-board .block {
    font-size: var(--font-sm);
}

.race-winner-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.race-winner-overlay.active {
    opacity: 1;
    visibility: visible;
}

.race-winner-content {
    background: var(--bg-modal);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    text-align: center;
    padding: 40px;
    max-width: 360px;
    width: 90%;
}

.race-winner-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.race-winner-title {
    font-size: var(--font-2xl);
    font-weight: 800;
    margin-bottom: 10px;
}

.race-winner-subtitle {
    font-size: var(--font-md);
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* ==========================================
   POWER-UPS
   ========================================== */
.powerups-bar {
    display: flex;
    gap: clamp(4px, 1vw, 8px);
    margin-bottom: clamp(8px, 2vw, 12px);
    padding-bottom: clamp(8px, 2vw, 12px);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.powerup {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: clamp(6px, 1.5vw, 10px);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    min-height: var(--touch-min);
}

.powerup:hover:not(.locked) {
    transform: translateY(-2px);
    border-color: var(--text-muted);
}

.powerup.locked {
    display: none;
}

.powerup.locked.unlocked {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

.powerup.locked::after {
    content: '🔒';
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: var(--font-sm);
}

.powerup-icon {
    font-size: var(--font-xl);
    margin-bottom: 4px;
}

.powerup-name {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

.powerup-count {
    font-family: 'Space Mono', monospace;
    font-size: var(--font-sm);
    color: var(--color-5);
    margin-top: 2px;
}

.powerup.active {
    border-color: var(--color-5);
    box-shadow: 0 0 20px rgba(46, 213, 115, 0.3);
}

/* ==========================================
   GAME BOARD
   ========================================== */
.board-wrapper {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: clamp(6px, 1.5vw, 10px);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 60px var(--shadow-color);
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
}

.board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: clamp(3px, 0.8vw, 5px);
    width: 100%;
    max-width: min(100%, 70vh); /* Limit by viewport height */
    aspect-ratio: 1;
    touch-action: none;
}

.cell {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    position: relative;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cell:active { transform: scale(0.92); }
.cell.selected { transform: scale(1.08); z-index: 10; }
.cell.selected::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid var(--text-primary);
    border-radius: calc(var(--radius-sm) + 4px);
    animation: selectPulse 1s ease infinite;
}

@keyframes selectPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.05); }
}

.cell.hint { animation: hintBounce 0.4s ease; }

@keyframes hintBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.block {
    position: absolute;
    inset: clamp(2px, 0.5vw, 4px);
    border-radius: calc(var(--radius-sm) - 2px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: var(--font-md);
    color: rgba(0, 0, 0, 0.6);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow:
        0 4px 12px 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.2);
}

.block.tier-1 { background: linear-gradient(135deg, var(--color-1), #ff6b7a); }
.block.tier-2 { background: linear-gradient(135deg, var(--color-2), #ff9a7a); }
.block.tier-3 { background: linear-gradient(135deg, var(--color-3), #ffb84d); }
.block.tier-4 { background: linear-gradient(135deg, var(--color-4), #ffeb8a); }
.block.tier-5 { background: linear-gradient(135deg, var(--color-5), #5de095); }
.block.tier-6 { background: linear-gradient(135deg, var(--color-6), #5fe8c4); }
.block.tier-7 { background: linear-gradient(135deg, var(--color-7), #7ab8ff); }
.block.tier-8 { background: linear-gradient(135deg, var(--color-8), #b380f8); }
.block.tier-9 { background: linear-gradient(135deg, var(--color-9), #ff8fb8); }
.block.tier-10 {
    background: linear-gradient(135deg, #ffffff, #f0f0ff);
    color: rgba(0, 0, 0, 0.4);
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.4);
}

.block.merging { animation: mergeIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.block.chemistry-merge { animation: chemistryMerge 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes mergeIn {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes chemistryMerge {
    0% { transform: scale(0) rotate(0deg); opacity: 0; filter: hue-rotate(0deg); }
    25% { transform: scale(1.4) rotate(10deg); filter: hue-rotate(90deg); }
    50% { transform: scale(0.9) rotate(-10deg); filter: hue-rotate(180deg); }
    75% { transform: scale(1.2) rotate(5deg); filter: hue-rotate(270deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; filter: hue-rotate(360deg); }
}

.block.removing { animation: removeOut 0.25s ease forwards; }

@keyframes removeOut { to { transform: scale(0); opacity: 0; } }

/* Swipe animations */
.cell.swipe-left .block { animation: swipeLeft 0.2s ease; }
.cell.swipe-right .block { animation: swipeRight 0.2s ease; }
.cell.swipe-up .block { animation: swipeUp 0.2s ease; }
.cell.swipe-down .block { animation: swipeDown 0.2s ease; }

@keyframes swipeLeft {
    0% { transform: translateX(100%); }
    100% { transform: translateX(0); }
}
@keyframes swipeRight {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(0); }
}
@keyframes swipeUp {
    0% { transform: translateY(100%); }
    100% { transform: translateY(0); }
}
@keyframes swipeDown {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(0); }
}

/* ==========================================
   PARTICLES
   ========================================== */
.particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ==========================================
   FOOTER
   ========================================== */
.footer {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 8px;
    background: var(--bg-deep);
    flex-shrink: 0;
}

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-xs);
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
}

.footer a:hover {
    color: var(--text-primary);
}

/* ==========================================
   AD BANNER
   ========================================== */
.ad-banner {
    height: 60px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ad-placeholder {
    background: repeating-linear-gradient(
        45deg,
        var(--bg-elevated),
        var(--bg-elevated) 10px,
        var(--bg-card) 10px,
        var(--bg-card) 20px
    );
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 320px;
    height: 50px;
}

/* ==========================================
   MODALS
   ========================================== */
.modal {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 200;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: clamp(20px, 4vw, 28px);
    text-align: center;
    max-width: 360px;
    width: 100%;
    border: 1px solid var(--border-color);
}

.modal-icon {
    font-size: var(--font-2xl);
    margin-bottom: 12px;
}

.modal-title {
    font-size: var(--font-lg);
    font-weight: 800;
    margin-bottom: 8px;
}

.modal-desc {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: var(--font-sm);
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
    width: 100%;
    padding: clamp(12px, 3vw, 16px) 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Outfit', sans-serif;
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--touch-min);
}

.btn:last-child { margin-bottom: 0; }

.btn-primary {
    background: linear-gradient(135deg, var(--color-8), var(--color-7));
    color: white;
}

.btn-reward {
    background: linear-gradient(135deg, var(--color-4), var(--color-3));
    color: rgba(0, 0, 0, 0.8);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-green {
    background: linear-gradient(135deg, var(--color-5), var(--color-6));
    color: rgba(0, 0, 0, 0.8);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================
   LANGUAGE SELECTOR
   ========================================== */
.lang-selector {
    position: relative;
}

.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
    z-index: 100;
}

.lang-dropdown.active {
    display: flex;
}

.lang-option {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s ease;
    min-height: 36px;
}

.lang-option:hover {
    background: var(--bg-hover);
}

.lang-option.active {
    background: var(--bg-elevated);
    font-weight: 600;
}

/* ==========================================
   SETTINGS MENU (Consolidated)
   ========================================== */
.settings-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    min-width: 180px;
    z-index: 100;
    box-shadow: 0 8px 24px var(--shadow-color);
}

.settings-menu.active {
    display: flex;
}

.settings-menu-item {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s ease;
    min-height: var(--touch-min);
    color: var(--text-primary);
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
}

.settings-menu-item:hover {
    background: var(--bg-hover);
}

.settings-menu-item .menu-icon {
    font-size: 1.2em;
    min-width: 24px;
    text-align: center;
}

.settings-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.settings-menu-footer {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 8px 0 4px;
    font-size: var(--font-xs);
}

.settings-menu-footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.settings-menu-footer a:hover {
    color: var(--text-secondary);
}

/* Settings wrapper for positioning */
.settings-wrapper {
    position: relative;
}

/* Lang options inside settings menu */
.lang-menu-item {
    cursor: default;
    color: var(--text-muted);
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 14px !important;
    min-height: auto !important;
}

.lang-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 8px;
    max-height: 300px;
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.lang-options.collapsed {
    max-height: 0;
    padding: 0;
}

.lang-arrow {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.lang-arrow.expanded {
    transform: rotate(90deg);
}

.lang-options .lang-option {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s ease;
    min-height: 40px;
}

.lang-options .lang-option:hover {
    background: var(--bg-hover);
}

.lang-options .lang-option.active {
    background: var(--bg-elevated);
    font-weight: 600;
}

/* ==========================================
   PROGRESSIVE REVEAL
   ========================================== */
.mode-btn.locked {
    display: none;
}

.mode-btn.unlocked {
    display: flex;
}

/* ==========================================
   TUTORIAL
   ========================================== */
.tutorial-modal {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 300;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.tutorial-modal.active { display: flex; }

.tutorial-content {
    max-width: 360px;
    width: 100%;
    text-align: center;
}

.tutorial-slide {
    display: none;
}

.tutorial-slide.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.tutorial-icon {
    font-size: clamp(3rem, 8vw, 4rem);
    margin-bottom: 20px;
}

.tutorial-title {
    font-size: var(--font-xl);
    font-weight: 800;
    margin-bottom: 12px;
}

.tutorial-desc {
    color: var(--text-secondary);
    margin-bottom: 30px;
    line-height: 1.6;
    font-size: var(--font-sm);
}

.tutorial-demo {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 30px;
}

.tutorial-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.tutorial-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-elevated);
    transition: all 0.2s ease;
}

.tutorial-dot.active {
    background: var(--color-7);
    transform: scale(1.2);
}

/* ==========================================
   GAME OVER & OTHER MODALS
   ========================================== */
.game-over-score {
    font-family: 'Space Mono', monospace;
    font-size: var(--font-2xl);
    font-weight: 700;
    color: var(--color-4);
    margin: 16px 0;
}

.new-record {
    display: inline-block;
    background: linear-gradient(135deg, var(--color-4), var(--color-3));
    color: rgba(0, 0, 0, 0.8);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: var(--font-xs);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 16px;
    animation: pulse 1s ease infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.game-over-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.game-over-stat {
    background: var(--bg-elevated);
    padding: 12px;
    border-radius: var(--radius-md);
}

.game-over-stat-label {
    font-size: var(--font-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
}

.game-over-stat-value {
    font-family: 'Space Mono', monospace;
    font-size: var(--font-md);
    font-weight: 700;
}

.combo-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Space Mono', monospace;
    font-size: var(--font-xl);
    font-weight: 700;
    color: var(--color-4);
    text-shadow: 0 0 20px var(--color-4);
    pointer-events: none;
    z-index: 100;
    opacity: 0;
}

.combo-popup.active {
    animation: comboPopup 0.8s ease forwards;
}

@keyframes comboPopup {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

.level-up {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    z-index: 120;
}

.level-up.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.level-up-text {
    font-size: var(--font-2xl);
    font-weight: 900;
    color: var(--color-7);
    text-shadow: 0 0 40px var(--color-7);
    animation: levelUpPop 1s ease forwards;
}

@keyframes levelUpPop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    80% { transform: scale(1); }
    100% { opacity: 0; }
}

.ad-progress {
    width: 100%;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 16px;
}

.ad-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-5), var(--color-6));
    width: 0%;
    transition: width 0.1s linear;
}

.energy-options, .shop-items {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.energy-option, .shop-item {
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    text-align: left;
    min-height: var(--touch-min);
}

.energy-option:hover, .shop-item:hover {
    border-color: var(--color-5);
}

.energy-option-icon, .shop-item-icon {
    font-size: var(--font-xl);
}

.energy-option-info, .shop-item-info { flex: 1; }

.energy-option-title, .shop-item-name {
    font-weight: 600;
    font-size: var(--font-sm);
}

.energy-option-desc, .shop-item-desc {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

.shop-item-price {
    background: var(--color-4);
    color: #000;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: var(--font-xs);
    font-weight: 600;
}
