/**
 * ice.css - Ice Cream Catch game styles
 */

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    overflow: hidden;
}

.header {
    width: 100%;
    max-width: 400px;
    margin-bottom: 15px;
}

h1 {
    font-size: 1.6rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.back-btn:hover, .back-btn:active {
    color: #667eea;
}

.stats {
    margin-bottom: 15px;
}

.stat-box .label {
    font-size: 0.7rem;
}

.stat-box .value {
    font-size: 1.2rem;
}

.world-badge {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    margin-bottom: 10px;
}

.world-badge.world-2 {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
}

.world-badge.world-3 {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.world-badge.world-4 {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.world-badge.world-5 {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.world-badge.world-6 {
    background: linear-gradient(135deg, #ec4899 0%, #be185d 100%);
}

.game-container {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    transition: box-shadow 0.3s, border 0.3s;
}

.game-container.hard-mode {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.5), 0 10px 40px rgba(0,0,0,0.3);
    border: 2px solid #ef4444;
}

.stat-box .value.last-move-warning {
    color: #ef4444;
    animation: warningPulse 0.5s ease-in-out infinite;
}

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

#hardModeBtn {
    min-width: 50px;
}

.patrol-enemy {
    position: absolute;
    font-size: 1.4rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    animation: patrolBob 1s ease-in-out infinite;
    z-index: 5;
}

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

.cell {
    position: relative;
}

.game-grid {
    display: grid;
    gap: 2px;
    background: #334;
    padding: 2px;
    border-radius: 10px;
}

.cell {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.cell.ice {
    background: linear-gradient(135deg, #e0f7ff 0%, #b3e5fc 100%);
}

.cell.wall {
    background: linear-gradient(135deg, #5d4e6d 0%, #3d3a50 100%);
}

.cell.goal {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    animation: goalPulse 1s ease-in-out infinite;
}

@keyframes goalPulse {
    0%, 100% { box-shadow: inset 0 0 10px rgba(255,255,255,0.5); }
    50% { box-shadow: inset 0 0 20px rgba(255,255,255,0.8); }
}

.cell.hole {
    background: linear-gradient(135deg, #1a1a2e 0%, #0a0a15 100%);
    border-radius: 50%;
}

.cell.rock {
    background: linear-gradient(135deg, #8b7355 0%, #6b5344 100%);
}

.cell.cracked {
    background: linear-gradient(135deg, #e0f7ff 0%, #b3e5fc 100%);
    position: relative;
}

.cell.cracked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='1.5'%3E%3Cpath d='M12 2L8 8L2 12L8 14L12 22L14 14L22 12L14 8Z'/%3E%3C/svg%3E") center/contain no-repeat;
    opacity: 0.6;
}

.player {
    font-size: 1.6rem;
    transition: transform 0.15s ease-out;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.player.goal-reached {
    filter: drop-shadow(0 0 8px gold) drop-shadow(0 0 16px rgba(255, 215, 0, 0.6));
    animation: goalReached 0.3s ease-out forwards;
}

.goal-collected {
    background: radial-gradient(circle, rgba(255,215,0,0.3), transparent);
}

@keyframes goalReached {
    0% { transform: scale(1); filter: drop-shadow(0 0 4px gold); }
    50% { transform: scale(1.2); filter: drop-shadow(0 0 16px gold); }
    100% { transform: scale(1.15); filter: drop-shadow(0 0 12px gold); }
}

@keyframes starBurstParticle {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

.star-particle {
    position: fixed;
    pointer-events: none;
    font-size: 0.8rem;
    z-index: 10;
    animation: starBurstParticle 0.6s ease-out forwards;
}

.player.sliding {
    animation: wiggle 0.1s ease-in-out;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

/* Easter Egg: Frustration Shake (rapid wall hits) */
.frustration-shake {
    animation: frustrationShake 0.5s ease !important;
}

@keyframes frustrationShake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-15px) rotate(-2deg); }
    20% { transform: translateX(15px) rotate(2deg); }
    30% { transform: translateX(-12px) rotate(-2deg); }
    40% { transform: translateX(12px) rotate(2deg); }
    50% { transform: translateX(-8px) rotate(-1deg); }
    60% { transform: translateX(8px) rotate(1deg); }
    70% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
    90% { transform: translateX(-2px); }
}

.frustration-text {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 3rem;
    font-weight: bold;
    color: #ff4444;
    text-shadow: 0 0 20px #ff0000, 0 0 40px #ff6600, 2px 2px 0 #fff;
    z-index: 1000;
    animation: textPop 1s ease forwards;
    pointer-events: none;
}

@keyframes textPop {
    0% { transform: translateX(-50%) scale(0); opacity: 0; }
    20% { transform: translateX(-50%) scale(1.3); opacity: 1; }
    40% { transform: translateX(-50%) scale(1); }
    80% { transform: translateX(-50%) scale(1); opacity: 1; }
    100% { transform: translateX(-50%) scale(0.8); opacity: 0; }
}

.impact-emoji {
    position: fixed;
    font-size: 2.5rem;
    z-index: 999;
    animation: impactFly 0.8s ease-out forwards;
    pointer-events: none;
}

@keyframes impactFly {
    0% { transform: scale(0) rotate(0deg); opacity: 1; }
    50% { transform: scale(1.5) rotate(180deg); opacity: 1; }
    100% { transform: scale(0.5) rotate(360deg) translateY(-50px); opacity: 0; }
}

/* Easter Egg: Friendly Wave */
.speech-bubble {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    animation: bubbleFloat 1.5s ease-out forwards;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    pointer-events: none;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

@keyframes bubbleFloat {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

@keyframes waveAnimation {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-15deg); }
    40% { transform: rotate(15deg); }
    60% { transform: rotate(-10deg); }
    80% { transform: rotate(10deg); }
}

.player.waving {
    animation: waveAnimation 0.8s ease-in-out;
}

.controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.control-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: bold;
    color: white;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

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

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

.overlay h2 {
    font-size: 2rem;
    text-align: center;
}

.overlay .stars {
    font-size: 3rem;
    margin-bottom: 20px;
}

.play-btn {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    padding: 15px 40px;
    font-size: 1.2rem;
    border-radius: 30px;
    margin: 5px;
}

.play-btn.secondary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.level-select {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-width: 320px;
    margin-bottom: 20px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
}

.level-btn {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    border: none;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
}

.level-btn.unlocked {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
}

.level-btn.locked {
    background: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.5);
    cursor: not-allowed;
}

.level-btn.current {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
}

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

.level-btn .stars-mini {
    font-size: 0.5rem;
    display: block;
}

.world-header {
    grid-column: 1 / -1;
    color: white;
    font-size: 0.9rem;
    font-weight: bold;
    text-align: center;
    padding: 8px;
    margin-top: 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
}

.world-header:first-child {
    margin-top: 0;
}

.instructions {
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    text-align: center;
    margin-top: 15px;
}

.swipe-hint {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    padding: 10px 20px;
    border-radius: 20px;
    color: white;
    font-size: 0.9rem;
}

.help-content {
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 20px;
    max-width: 320px;
}

.help-content p {
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-size: 0.85rem;
}

.legend-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border-radius: 4px;
}

.legend-icon.wall-icon {
    background: linear-gradient(135deg, #5d4e6d 0%, #3d3a50 100%);
}

.legend-icon.cracked-icon {
    background: linear-gradient(135deg, #e0f7ff 0%, #b3e5fc 100%);
    position: relative;
}

.legend-icon.cracked-icon::after {
    content: '\2744';
    font-size: 0.8rem;
    opacity: 0.6;
}

/* Cracking animation */
.cell.cracking {
    animation: iceBreak 0.4s ease-out forwards;
}

@keyframes iceBreak {
    0% {
        background: linear-gradient(135deg, #e0f7ff 0%, #b3e5fc 100%);
        transform: scale(1);
    }
    30% {
        background: linear-gradient(135deg, #c5e8f7 0%, #8fd4f5 100%);
        transform: scale(1.05);
    }
    60% {
        background: linear-gradient(135deg, #87ceeb 0%, #5bb5e0 100%);
        transform: scale(0.95);
    }
    100% {
        background: linear-gradient(135deg, #1a1a2e 0%, #0a0a15 100%);
        transform: scale(1);
        border-radius: 50%;
    }
}

/* Show crack more clearly when player is on it */
.cell.cracked-standing {
    animation: crackedPulse 0.8s ease-in-out infinite;
}

@keyframes crackedPulse {
    0%, 100% {
        background: linear-gradient(135deg, #e0f7ff 0%, #b3e5fc 100%);
        box-shadow: inset 0 0 10px rgba(100, 150, 200, 0.3);
    }
    50% {
        background: linear-gradient(135deg, #cceeff 0%, #99d6ff 100%);
        box-shadow: inset 0 0 20px rgba(100, 150, 200, 0.6);
    }
}

/* Teleporter A - Blue Portal */
.cell.teleporter-a {
    background: radial-gradient(circle, #3b82f6 0%, #1e40af 100%);
    animation: portalPulse 1.5s ease-in-out infinite;
}

/* Teleporter B - Orange Portal */
.cell.teleporter-b {
    background: radial-gradient(circle, #f97316 0%, #c2410c 100%);
    animation: portalPulse 1.5s ease-in-out infinite;
}

@keyframes portalPulse {
    0%, 100% { box-shadow: inset 0 0 10px rgba(255,255,255,0.3); }
    50% { box-shadow: inset 0 0 20px rgba(255,255,255,0.6); }
}

/* Teleport visual effect */
.teleport-flash {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, transparent 70%);
    animation: teleportFlash 0.3s ease-out forwards;
    pointer-events: none;
}

@keyframes teleportFlash {
    0% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0; transform: scale(1.5); }
}

/* Arrow tiles - ice background with arrow overlay */
.cell.arrow-up, .cell.arrow-down, .cell.arrow-left, .cell.arrow-right {
    background: linear-gradient(135deg, #d0f0ff 0%, #a8e0fc 100%);
    font-size: 1.5rem;
    position: relative;
}

.cell.arrow-up::before, .cell.arrow-down::before,
.cell.arrow-left::before, .cell.arrow-right::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    background: rgba(100, 150, 200, 0.2);
    border-radius: 50%;
}

/* Thin Ice - very fragile looking */
.cell.thin-ice {
    background: linear-gradient(135deg, #f0faff 0%, #e8f6ff 100%);
    border: 1px dashed rgba(100, 150, 200, 0.4);
    position: relative;
}

.cell.thin-ice::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='0.5'%3E%3Cpath d='M12 2L8 8L2 12L8 14L12 22L14 14L22 12L14 8Z'/%3E%3C/svg%3E") center/contain no-repeat;
    opacity: 0.3;
}

/* Thin ice cracking animation (rapid) */
.cell.thin-ice-cracking {
    animation: thinIceCrack 0.25s ease-out forwards;
}

@keyframes thinIceCrack {
    0% {
        background: linear-gradient(135deg, #f0faff 0%, #e8f6ff 100%);
        transform: scale(1);
    }
    30% {
        background: linear-gradient(135deg, #c5e8f7 0%, #8fd4f5 100%);
        transform: scale(1.02);
    }
    100% {
        background: linear-gradient(135deg, #1a1a2e 0%, #0a0a15 100%);
        transform: scale(1);
        border-radius: 50%;
    }
}

/* Legend icons for new tiles */
.legend-icon.teleporter-icon {
    background: radial-gradient(circle, #3b82f6 0%, #1e40af 100%);
}

.legend-icon.arrow-icon {
    background: linear-gradient(135deg, #d0f0ff 0%, #a8e0fc 100%);
}

.legend-icon.thin-ice-icon {
    background: linear-gradient(135deg, #f0faff 0%, #e8f6ff 100%);
    border: 1px dashed rgba(100, 150, 200, 0.6);
}

/* Fish tile (collectible) */
.cell.fish {
    background: linear-gradient(135deg, #e0f7ff 0%, #b3e5fc 100%);
    animation: fishShimmer 2s ease-in-out infinite;
}

@keyframes fishShimmer {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.15); }
}

/* Fish collection effect */
.fish-collect-effect {
    position: absolute;
    font-size: 1.5rem;
    pointer-events: none;
    animation: fishFloat 0.5s ease-out forwards;
    z-index: 10;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes fishFloat {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, calc(-50% - 40px)) scale(1.3); opacity: 0; }
}

.legend-icon.fish-icon {
    background: linear-gradient(135deg, #e0f7ff 0%, #b3e5fc 100%);
}

/* Fish indicator on level select */
.fish-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.6rem;
}

/* Fish rain celebration */
.fish-rain {
    position: fixed;
    font-size: 2rem;
    animation: fishRain 1.5s ease-in forwards;
    pointer-events: none;
    z-index: 1000;
}

@keyframes fishRain {
    0% { transform: translateY(-50px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0.5; }
}

.all-fish-text {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.5rem;
    font-weight: bold;
    color: #fbbf24;
    text-shadow: 0 0 20px #f59e0b, 2px 2px 0 #fff;
    z-index: 1001;
    animation: textPop 2s ease forwards;
    pointer-events: none;
}

/* Easter Egg: Konami Code */
.konami-dance {
    animation: konamiWiggle 0.3s ease-in-out infinite;
}

@keyframes konamiWiggle {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.konami-rainbow {
    animation: rainbowPulse 0.5s ease-in-out infinite;
}

@keyframes rainbowPulse {
    0% { background: rgba(255, 0, 0, 0.9); }
    16% { background: rgba(255, 165, 0, 0.9); }
    33% { background: rgba(255, 255, 0, 0.9); }
    50% { background: rgba(0, 255, 0, 0.9); }
    66% { background: rgba(0, 0, 255, 0.9); }
    83% { background: rgba(128, 0, 128, 0.9); }
    100% { background: rgba(255, 0, 0, 0.9); }
}

.konami-text {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px black, 0 0 20px gold;
    z-index: 1002;
    animation: textBounce 0.5s ease-in-out infinite;
    pointer-events: none;
}

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

.konami-confetti {
    position: fixed;
    top: -50px;
    font-size: 2rem;
    z-index: 1001;
    animation: confettiFall 2s ease-out forwards;
    pointer-events: none;
}

/* Easter Egg: Speedrunner */
.speedrunner-text {
    position: fixed;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.5rem;
    font-weight: bold;
    color: #ff6b35;
    text-shadow: 0 0 20px #ff4500, 2px 2px 0 #fff;
    z-index: 1000;
    animation: textPop 2s ease forwards;
    pointer-events: none;
}

/* Easter Egg: Perfect Streak */
.golden-glow {
    filter: drop-shadow(0 0 10px gold) drop-shadow(0 0 20px gold);
    animation: goldPulse 0.5s ease-in-out infinite;
}

@keyframes goldPulse {
    0%, 100% { filter: drop-shadow(0 0 10px gold) drop-shadow(0 0 20px gold); }
    50% { filter: drop-shadow(0 0 20px gold) drop-shadow(0 0 40px gold); }
}

.streak-text {
    position: fixed;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.5rem;
    font-weight: bold;
    color: gold;
    text-shadow: 0 0 20px gold, 2px 2px 0 #fff;
    z-index: 1000;
    animation: textPop 3s ease forwards;
    pointer-events: none;
}

.sparkle {
    position: fixed;
    font-size: 1.5rem;
    z-index: 999;
    animation: sparkleFade 1s ease-out forwards;
    pointer-events: none;
}

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

/* Easter Egg: Fish Master */
.fish-master-rain {
    position: fixed;
    top: -50px;
    font-size: 2.5rem;
    z-index: 1001;
    animation: fishMasterFall 2s ease-in forwards;
    pointer-events: none;
}

@keyframes fishMasterFall {
    0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg) scale(0.5); opacity: 0.7; }
}

.happy-dance {
    animation: happyDance 0.3s ease-in-out infinite;
}

@keyframes happyDance {
    0%, 100% { transform: rotate(-10deg) translateY(0); }
    25% { transform: rotate(10deg) translateY(-5px); }
    50% { transform: rotate(-10deg) translateY(0); }
    75% { transform: rotate(10deg) translateY(-5px); }
}

.fish-master-text {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 3rem;
    font-weight: bold;
    color: #3b82f6;
    text-shadow: 0 0 20px #60a5fa, 2px 2px 0 #fff, 0 0 40px gold;
    z-index: 1002;
    animation: textPop 4s ease forwards;
    pointer-events: none;
}

@media (max-width: 400px) {
    .cell {
        width: 38px;
        height: 38px;
        font-size: 1.5rem;
    }

    .player {
        font-size: 1.3rem;
    }

    h1 {
        font-size: 1.3rem;
    }
}
