/* ===== CSS VARIABLES ===== */
:root {
    /* Colors */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --accent-primary: #e94560;
    --accent-secondary: #ff6b6b;
    --accent-gold: #ffd700;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #ef4444;

    /* Tile Colors */
    --tile-bg: linear-gradient(145deg, #2d2d4a, #1e1e35);
    --tile-border: #3d3d5c;
    --tile-shadow: rgba(0, 0, 0, 0.4);
    --arrow-up: #22ff66;
    --arrow-down: #ff66aa;
    --arrow-left: #44aaff;
    --arrow-right: #ffdd00;

    /* Sizing */
    --tile-gap: 8px;
    --border-radius: 12px;
    --border-radius-lg: 20px;

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

    /* Safe areas */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* High Contrast Mode */
body.high-contrast {
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --tile-bg: linear-gradient(145deg, #333333, #1a1a1a);
    --tile-border: #ffffff;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(180deg, #0a1628 0%, #1a3a5c 50%, #2d5a87 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* Prevent pull-to-refresh */
body {
    overscroll-behavior: none;
}

/* ===== SCREENS ===== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    display: none;
    flex-direction: column;
    padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
    opacity: 0;
    transform: translateX(100%);
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.screen.active {
    display: flex;
    opacity: 1;
    transform: translateX(0);
}

.screen.exiting {
    opacity: 0;
    transform: translateX(-100%);
}

body.reduced-motion .screen {
    transition: none;
    transform: none;
}

/* ===== MAIN MENU ===== */
.menu-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 30px;
}

.game-title {
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 700;
    text-align: center;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 15px;
}

.title-arrow {
    font-size: 0.8em;
    animation: arrow-pulse 2s ease-in-out infinite;
    -webkit-text-fill-color: var(--accent-gold);
}

.title-arrow:last-child {
    animation-delay: 1s;
}

@keyframes arrow-pulse {
    0%, 100% { opacity: 0.5; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
    text-align: center;
    margin-top: -20px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 280px;
}

.stats-bar {
    display: flex;
    gap: 30px;
    padding: 15px 30px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 600;
}

.stat-icon {
    font-size: 1.3rem;
}

/* ===== BUTTONS ===== */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    min-height: 54px;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.4);
}

.btn-primary:active {
    box-shadow: 0 2px 8px rgba(233, 69, 96, 0.3);
}

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

.btn-danger {
    background: var(--danger);
    color: white;
    margin-top: 30px;
}

.btn-icon {
    font-size: 1.2rem;
}

.icon-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

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

.hint-btn {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #1a1a2e;
}

.hint-btn:hover {
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.hint-btn.used {
    opacity: 0.5;
    pointer-events: none;
}

.back-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 2px solid var(--bg-tertiary);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.3rem;
    cursor: pointer;
}

/* ===== SCREEN HEADERS ===== */
.screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    padding-top: calc(15px + var(--safe-top));
}

.screen-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
}

.header-spacer {
    width: 44px;
}

/* ===== WORLD SELECTION ===== */
.world-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.world-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    border: 2px solid transparent;
}

.world-card:active {
    transform: scale(0.98);
}

.world-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.world-card.current {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.3);
}

.world-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.world-info {
    flex: 1;
}

.world-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.world-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    transition: width var(--transition-normal);
}

.world-stars {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--accent-gold);
}

/* ===== LEVEL SELECTION ===== */
.level-grid {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px 30px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    align-content: start;
}

.level-btn {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--bg-secondary);
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.level-btn:active:not(.locked) {
    transform: scale(0.92);
}

.level-btn.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.level-btn.completed {
    border-color: var(--success);
    background: rgba(74, 222, 128, 0.1);
}

.level-btn.current {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(233, 69, 96, 0.4);
}

.level-number {
    font-size: 1.3rem;
    font-weight: 700;
}

.level-stars {
    display: flex;
    gap: 2px;
    font-size: 0.7rem;
}

.level-stars .star {
    color: var(--text-muted);
}

.level-stars .star.earned {
    color: var(--accent-gold);
}

/* ===== GAME SCREEN ===== */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    padding-top: calc(10px + var(--safe-top));
    background: var(--bg-secondary);
}

.level-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

#current-level-display {
    font-weight: 600;
    font-size: 1rem;
}

.lives-display {
    display: flex;
    gap: 5px;
}

.heart {
    font-size: 1.2rem;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.heart.lost {
    opacity: 0.3;
    transform: scale(0.8);
}

.game-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.combo-display {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-gold);
    min-height: 1.2em;
}

.combo-display.active {
    animation: combo-pulse 0.5s ease;
}

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

.coins-display {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ===== GAME AREA ===== */
.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px;
}

.hidden-picture {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
    filter: blur(15px) grayscale(80%) brightness(0.6);
    transform: scale(1.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    overflow: hidden;
    border-radius: var(--border-radius-lg);
}

.hidden-picture.revealing {
    opacity: 0.7;
    filter: blur(8px) grayscale(50%) brightness(0.75);
}

.hidden-picture.revealed {
    opacity: 1;
    filter: blur(0) grayscale(0%) brightness(1);
}

@keyframes picture-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.hidden-picture svg,
.hidden-picture img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--border-radius-lg);
}

.picture-placeholder {
    font-size: 4rem;
    opacity: 0.5;
}

.game-board {
    position: relative;
}

/* Grid size classes - tiles are absolutely positioned */
.game-board.size-3,
.game-board.size-4,
.game-board.size-5,
.game-board.size-6,
.game-board.size-7,
.game-board.size-8 {
    /* Tiles use absolute positioning */
}

/* ===== PUZZLE SECTION ===== */
.puzzle-section {
    position: relative;
    width: calc(100% - 40px);
    max-width: 400px;
    aspect-ratio: 1;
    margin: 0 auto;
}

.puzzle-section .hidden-picture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.puzzle-section .game-board {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
}

/* ===== PHOTO CHOICES ===== */
.photo-choices-section {
    width: 100%;
    padding: 15px 20px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    margin-top: auto;
}

.choices-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.choices-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.tiles-remaining {
    font-size: 0.9rem;
    color: var(--accent-gold);
    font-weight: 600;
}

.photo-choices {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.photo-choice {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid var(--tile-border);
    transition: all var(--transition-fast);
    position: relative;
    flex-shrink: 0;
}

.photo-choice img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-choice:hover {
    transform: scale(1.05);
    border-color: var(--accent-primary);
}

.photo-choice:active {
    transform: scale(0.95);
}

.photo-choice.selected {
    border-color: var(--accent-gold);
    box-shadow: 0 0 15px var(--accent-gold);
}

.photo-choice.correct {
    border-color: var(--success);
    box-shadow: 0 0 20px var(--success);
}

.photo-choice.wrong {
    border-color: var(--danger);
    opacity: 0.5;
}

.photo-choice .choice-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.7rem;
    padding: 4px;
    text-align: center;
    font-weight: 600;
}

.game-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 10px;
}

/* ===== TILES ===== */
.tile {
    aspect-ratio: 1;
    background: var(--tile-bg);
    border: 2px solid var(--tile-border);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: 0 4px 8px var(--tile-shadow);
}

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

.tile.hint {
    animation: hint-glow 1s ease-in-out infinite;
}

@keyframes hint-glow {
    0%, 100% { box-shadow: 0 0 5px var(--accent-gold); }
    50% { box-shadow: 0 0 20px var(--accent-gold), 0 0 30px var(--accent-gold); }
}

.tile.safe-highlight {
    box-shadow: 0 0 10px var(--success), inset 0 0 10px rgba(74, 222, 128, 0.2);
}

.tile.ghost-active {
    opacity: 0.7;
    border-style: dashed;
}

/* Bonus Tiles */
.tile.bonus {
    position: relative;
}

.tile.bonus-life {
    background: linear-gradient(135deg, var(--tile-bg), rgba(239, 68, 68, 0.3));
    border-color: #ef4444;
    animation: bonus-pulse 2s ease-in-out infinite;
}

.tile.bonus-hint {
    background: linear-gradient(135deg, var(--tile-bg), rgba(59, 130, 246, 0.3));
    border-color: #3b82f6;
    animation: bonus-pulse 2s ease-in-out infinite;
}

.tile.bonus-sound {
    background: linear-gradient(135deg, var(--tile-bg), rgba(34, 197, 94, 0.3));
    border-color: #22c55e;
    animation: bonus-pulse 2s ease-in-out infinite;
}

@keyframes bonus-pulse {
    0%, 100% { box-shadow: 0 0 5px currentColor; }
    50% { box-shadow: 0 0 15px currentColor, 0 0 25px currentColor; }
}

.bonus-icon {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.7rem;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* Floating bonus text animation */
@keyframes float-up {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-60px);
    }
}

/* Tile Sliding Animations */
.tile.sliding-up {
    animation: slide-up 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.tile.sliding-down {
    animation: slide-down 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.tile.sliding-left {
    animation: slide-left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.tile.sliding-right {
    animation: slide-right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes slide-up {
    to { transform: translateY(-150vh); opacity: 0; }
}

@keyframes slide-down {
    to { transform: translateY(150vh); opacity: 0; }
}

@keyframes slide-left {
    to { transform: translateX(-150vw); opacity: 0; }
}

@keyframes slide-right {
    to { transform: translateX(150vw); opacity: 0; }
}

/* Slow motion for Time Dilation ability */
body.time-dilation .tile.sliding-up,
body.time-dilation .tile.sliding-down,
body.time-dilation .tile.sliding-left,
body.time-dilation .tile.sliding-right {
    animation-duration: 0.8s;
}

/* Collision Animation */
.tile.collision {
    animation: collision-shake 0.5s ease;
}

.tile.hint-highlight {
    box-shadow: 0 0 20px #4ade80, 0 0 40px #4ade80, inset 0 0 15px rgba(74, 222, 128, 0.3);
    border-color: #4ade80;
    animation: hint-pulse 1s ease-in-out infinite;
}

@keyframes hint-pulse {
    0%, 100% { box-shadow: 0 0 20px #4ade80, 0 0 40px #4ade80; }
    50% { box-shadow: 0 0 30px #4ade80, 0 0 60px #4ade80; }
}

@keyframes collision-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px) rotate(-2deg); }
    40% { transform: translateX(10px) rotate(2deg); }
    60% { transform: translateX(-6px) rotate(-1deg); }
    80% { transform: translateX(6px) rotate(1deg); }
}

/* Arrow Icons */
.arrow {
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 400;
    transition: transform var(--transition-fast);
    display: flex;
    align-items: center;
    text-shadow: 0 0 3px currentColor;
    justify-content: center;
}

.arrow.up { color: var(--arrow-up); }
.arrow.down { color: var(--arrow-down); transform: rotate(180deg); }
.arrow.left { color: var(--arrow-left); transform: rotate(-90deg); }
.arrow.right { color: var(--arrow-right); transform: rotate(90deg); }

/* Color-blind friendly arrow shapes */
body.high-contrast .arrow::before {
    font-size: 0.5em;
    position: absolute;
    bottom: 2px;
    right: 2px;
}

body.high-contrast .arrow.up::before { content: 'U'; }
body.high-contrast .arrow.down::before { content: 'D'; }
body.high-contrast .arrow.left::before { content: 'L'; }
body.high-contrast .arrow.right::before { content: 'R'; }

/* ===== ABILITIES BAR ===== */
.abilities-bar {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px 15px;
    background: var(--bg-secondary);
}

.ability-btn {
    width: 56px;
    height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: var(--bg-tertiary);
    border: 2px solid var(--tile-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    position: relative;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.ability-btn:active:not(.disabled) {
    transform: scale(0.92);
}

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

.ability-btn.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

.ability-icon {
    font-size: 1.5rem;
}

.ability-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent-primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* ===== GAME FOOTER ===== */
.game-footer {
    padding: 10px 15px;
    padding-bottom: calc(10px + var(--safe-bottom));
    display: flex;
    justify-content: center;
}

.move-counter {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== MODALS ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 30px;
    width: 100%;
    max-width: 340px;
    text-align: center;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

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

.modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Level Complete Modal */
.level-complete .revealed-picture {
    width: 150px;
    height: 150px;
    margin: 0 auto 20px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.level-complete .revealed-picture svg {
    width: 80%;
    height: 80%;
}

.stars-earned {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.stars-earned .star {
    font-size: 2.5rem;
    color: var(--text-muted);
    transition: color var(--transition-normal), transform var(--transition-normal);
}

.stars-earned .star.earned {
    color: var(--accent-gold);
    animation: star-pop 0.4s ease;
}

@keyframes star-pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* World Complete Modal */
.world-complete {
    text-align: center;
}

.world-complete h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.world-complete-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-gold);
    margin-bottom: 20px;
}

.world-complete-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
}

.world-complete-stats .stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.world-complete-stats .stat-icon {
    font-size: 2rem;
}

.world-complete-stats .stat span:last-child {
    font-size: 1.2rem;
    font-weight: bold;
}

.world-complete-message {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.rewards {
    margin-bottom: 20px;
}

.reward-coins {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--accent-gold);
}

/* Instructions Modal */
.modal-content.instructions {
    max-width: 380px;
    max-height: 85vh;
    padding: 25px;
}

.modal-content.instructions h2 {
    text-align: center;
    margin-bottom: 15px;
    color: var(--accent-gold);
}

.instructions-content {
    max-height: 55vh;
    overflow-y: auto;
    margin-bottom: 20px;
    padding-right: 5px;
}

.instruction-section {
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.instruction-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.instruction-section h3 {
    font-size: 1rem;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.instruction-section p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.bonus-label {
    display: inline-block;
    margin-right: 2px;
}

/* ===== ABILITIES SCREEN ===== */
.abilities-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px 30px;
}

.abilities-section {
    margin-bottom: 30px;
}

.abilities-section h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.abilities-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.ability-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 2px solid var(--bg-tertiary);
    transition: border-color var(--transition-fast);
}

.ability-card.locked {
    opacity: 0.5;
}

.ability-card.unlocked {
    border-color: var(--success);
}

.ability-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ability-card-icon {
    font-size: 1.8rem;
}

.ability-card-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.ability-card-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.ability-card-unlock {
    font-size: 0.75rem;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ===== SETTINGS SCREEN ===== */
.settings-content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid var(--bg-tertiary);
}

.toggle {
    position: relative;
    width: 52px;
    height: 28px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border-radius: 28px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.toggle input:checked + .toggle-slider {
    background: var(--accent-primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

/* ===== VOLUME SLIDERS ===== */
.volume-setting {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.volume-icon {
    font-size: 1.2rem;
    width: 28px;
    text-align: center;
}

.volume-slider {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.volume-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.volume-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 45px;
    text-align: right;
}

/* ===== GAME SETTINGS MODAL ===== */
.game-settings {
    max-width: 350px;
}

.game-settings h2 {
    margin-bottom: 20px;
}

.game-settings-content {
    padding: 10px 0;
}

.game-settings-content .setting-item {
    padding: 12px 0;
}

.game-settings-content .volume-setting {
    padding-bottom: 15px;
}

/* ===== PARTICLE CANVAS ===== */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
}

/* ===== SCREEN SHAKE ===== */
body.screen-shake {
    animation: screen-shake 0.5s ease;
}

@keyframes screen-shake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-10px); }
    20% { transform: translateX(10px); }
    30% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    50% { transform: translateX(-5px); }
    60% { transform: translateX(5px); }
    70% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* ===== COMBO BORDER GLOW ===== */
body.combo-active::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    box-shadow: inset 0 0 50px var(--accent-gold);
    animation: combo-border 0.5s ease infinite alternate;
}

@keyframes combo-border {
    from { box-shadow: inset 0 0 30px var(--accent-gold); }
    to { box-shadow: inset 0 0 60px var(--accent-gold); }
}

/* ===== FLOATING TEXT ===== */
.floating-text {
    position: fixed;
    font-weight: 700;
    font-size: 1.5rem;
    pointer-events: none;
    z-index: 150;
    animation: float-up 1s ease-out forwards;
}

@keyframes float-up {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-80px) scale(1.2); }
}

/* ===== RESPONSIVE ===== */

/* Small phones */
@media (max-width: 380px) {
    .game-header {
        padding: 8px 10px;
        padding-top: calc(8px + var(--safe-top));
    }

    .icon-btn {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .photo-choices {
        gap: 6px;
    }

    .photo-choice {
        width: 65px;
        height: 65px;
    }

    .choices-header {
        flex-direction: column;
        gap: 5px;
        align-items: center;
    }

    .modal-content {
        padding: 20px 15px;
        margin: 10px;
    }

    .btn {
        padding: 14px 20px;
        font-size: 1rem;
    }

    .timer-display {
        padding: 8px 25px;
        font-size: 1.6rem;
        top: calc(var(--safe-top) + 55px);
    }

    .level-info {
        font-size: 0.85rem;
    }

    .lives-display .heart {
        font-size: 1rem;
    }
}

/* Standard phones */
@media (max-width: 480px) {
    .photo-choice {
        width: 70px;
        height: 70px;
    }

    .photo-choices-section {
        padding: 12px 15px;
    }

    .puzzle-section {
        width: calc(100% - 20px);
    }

    .settings-content,
    .game-settings-content {
        padding: 15px;
    }

    .setting-item {
        padding: 12px 0;
    }

    .volume-slider {
        height: 10px;
    }

    .volume-slider::-webkit-slider-thumb {
        width: 26px;
        height: 26px;
    }

    .instructions-content {
        max-height: 50vh;
    }
}

/* Tablets and larger */
@media (min-width: 768px) {
    .game-board {
        max-width: 450px;
    }

    .menu-buttons {
        max-width: 320px;
    }

    .level-grid {
        grid-template-columns: repeat(5, 1fr);
        max-width: 500px;
        margin: 0 auto;
    }

    .photo-choice {
        width: 80px;
        height: 80px;
    }

    .modal-content {
        max-width: 450px;
    }

    .timer-display {
        font-size: 2.2rem;
        padding: 15px 45px;
    }
}

/* Landscape phones - reduce vertical spacing */
@media (max-height: 500px) and (orientation: landscape) {
    .game-header {
        padding: 5px 15px;
    }

    .photo-choices-section {
        padding: 8px 15px;
    }

    .puzzle-section {
        max-width: 50vh;
    }

    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }

    .timer-display {
        top: calc(var(--safe-top) + 45px);
        font-size: 1.4rem;
        padding: 8px 25px;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
}

/* ===== SPECIAL TILES ===== */

/* Frozen Tile */
.tile.frozen {
    background: linear-gradient(145deg, #38bdf8, #0ea5e9);
    border-color: #7dd3fc;
    position: relative;
}

.tile.frozen::before {
    content: '❄️';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.8rem;
}

.tile.frozen .arrow {
    opacity: 0.6;
}

/* Bomb Tile */
.tile.bomb {
    background: linear-gradient(145deg, #f97316, #ea580c);
    border-color: #fb923c;
    animation: bomb-pulse 1s ease-in-out infinite;
}

.tile.bomb::before {
    content: '💣';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.8rem;
}

@keyframes bomb-pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(249, 115, 22, 0.5); }
    50% { box-shadow: 0 0 20px rgba(249, 115, 22, 0.8); }
}

/* Rotating Tile */
.tile.rotating {
    background: linear-gradient(145deg, #a855f7, #9333ea);
    border-color: #c084fc;
}

.tile.rotating::before {
    content: '🔄';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.8rem;
    animation: spin 3s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Ghost Tile */
.tile.ghost {
    background: linear-gradient(145deg, rgba(139, 92, 246, 0.5), rgba(124, 58, 237, 0.5));
    border-color: rgba(167, 139, 250, 0.5);
    animation: ghost-fade 2s ease-in-out infinite;
}

.tile.ghost::before {
    content: '👻';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.8rem;
}

@keyframes ghost-fade {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Ghost Hidden State */
.tile.ghost-hidden {
    opacity: 0 !important;
    pointer-events: none;
    transform: scale(0.8);
    transition: all 0.3s ease;
}

/* Exploding Animation */
.tile.exploding {
    animation: explode 0.4s ease-out forwards;
}

@keyframes explode {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.8;
        background: radial-gradient(circle, #ff6b00, #ff0000);
        box-shadow: 0 0 30px #ff6b00, 0 0 60px #ff0000;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* Thawing Animation */
.tile.thawing {
    animation: thaw 0.3s ease-out;
}

@keyframes thaw {
    0% {
        filter: brightness(1.5) saturate(0.5);
    }
    50% {
        filter: brightness(2) saturate(1);
        box-shadow: 0 0 20px #60a5fa;
    }
    100% {
        filter: brightness(1) saturate(1);
    }
}

/* Lock Tile */
.tile.locked-tile {
    background: linear-gradient(145deg, #6b7280, #4b5563);
    border-color: #9ca3af;
}

.tile.locked-tile::before {
    content: '🔒';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.8rem;
}

.tile.locked-tile .arrow {
    opacity: 0.4;
}

/* Wall Obstacle */
.wall {
    background: linear-gradient(145deg, #1f2937, #111827);
    border: 3px solid #374151;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wall::after {
    content: '🧱';
    font-size: 1.5rem;
}

/* ===== TIMER DISPLAY ===== */
.timer-display {
    position: fixed;
    top: calc(var(--safe-top) + 60px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 35px;
    border-radius: 50px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    z-index: 60;
    display: none;
}

.timer-display.active {
    display: block;
}

.timer-display.warning {
    color: var(--warning);
    animation: timer-pulse 0.5s ease infinite;
}

.timer-display.danger {
    color: var(--danger);
    animation: timer-pulse 0.3s ease infinite;
}

@keyframes timer-pulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.1); }
}

/* ===== LEVEL COMPLETE ENHANCEMENTS ===== */
.level-complete .revealed-picture {
    width: 180px;
    height: 180px;
    margin: 0 auto 20px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.level-complete .revealed-picture img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== PICTURE TITLE ===== */
.picture-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-align: center;
}

/* ===== ENHANCED COMBO EFFECTS ===== */
.combo-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 900;
    color: var(--accent-gold);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    pointer-events: none;
    z-index: 200;
    animation: combo-appear 0.8s ease-out forwards;
}

@keyframes combo-appear {
    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%, -50%) scale(1.5) translateY(-50px);
    }
}
