/**
 * lights.css - Lights Out game styles
 */

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    transition: background 0.5s;
}

/* World Themes */
body.world-1 {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
body.world-2 {
    background: linear-gradient(135deg, #1a2e1a 0%, #163e22 100%);
}
body.world-3 {
    background: linear-gradient(135deg, #2e1a1a 0%, #3e1616 100%);
}
body.world-4 {
    background: linear-gradient(135deg, #2e2a1a 0%, #3e3416 100%);
}
body.world-5 {
    background: linear-gradient(135deg, #1a1a2e 0%, #2e163e 100%);
}

.header {
    width: 100%;
    max-width: 500px;
    margin-bottom: 10px;
}

h1 {
    color: #ffd700;
    font-size: 1.4rem;
    text-shadow: 0 0 20px rgba(255,215,0,0.5);
}

.back-btn {
    background: rgba(255,255,255,0.1);
    border-color: #ffd700;
    padding: 8px 16px;
    font-size: 0.85rem;
    color: #ffd700;
}

.back-btn:hover, .back-btn:active {
    background: #ffd700;
    color: #1a1a2e;
}

.stats {
    gap: 8px;
    margin-bottom: 10px;
}

.stat-box {
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 6px 14px;
    border: 1px solid rgba(255,215,0,0.3);
}

.stat-box .label {
    font-size: 0.6rem;
    opacity: 0.7;
    color: #ffd700;
}

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

.stat-box.warning .value {
    color: #ff6b6b;
    animation: lights-pulse 0.5s infinite;
}

@keyframes lights-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.world-indicator {
    background: rgba(255,215,0,0.2);
    border-radius: 20px;
    padding: 4px 12px;
    color: #ffd700;
    font-size: 0.75rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.game-container {
    background: rgba(0,0,0,0.3);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 0 40px rgba(255,215,0,0.2);
    border: 2px solid rgba(255,215,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-grid {
    display: grid;
    gap: 6px;
    justify-content: center;
}

.cell {
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 2px solid rgba(255,255,255,0.2);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.cell.off {
    background: linear-gradient(135deg, #2d2d44 0%, #1a1a2e 100%);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
}

.cell.on {
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    box-shadow: 0 0 25px rgba(255,215,0,0.6), inset 0 -2px 10px rgba(255,255,255,0.3);
    border-color: #ffee88;
}

/* World 2 - Green theme */
body.world-2 .cell.on {
    background: linear-gradient(135deg, #50fa7b 0%, #2ecc71 100%);
    box-shadow: 0 0 25px rgba(80,250,123,0.6), inset 0 -2px 10px rgba(255,255,255,0.3);
    border-color: #90ffab;
}

/* World 3 - Red theme */
body.world-3 .cell.on {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    box-shadow: 0 0 25px rgba(255,107,107,0.6), inset 0 -2px 10px rgba(255,255,255,0.3);
    border-color: #ffaaaa;
}

/* World 4 - Orange theme */
body.world-4 .cell.on {
    background: linear-gradient(135deg, #ffa500 0%, #ff8c00 100%);
    box-shadow: 0 0 25px rgba(255,165,0,0.6), inset 0 -2px 10px rgba(255,255,255,0.3);
    border-color: #ffcc66;
}

/* World 5 - Purple theme */
body.world-5 .cell.on {
    background: linear-gradient(135deg, #bd93f9 0%, #9b59b6 100%);
    box-shadow: 0 0 25px rgba(189,147,249,0.6), inset 0 -2px 10px rgba(255,255,255,0.3);
    border-color: #d4b8ff;
}

/* Special cell types */
.cell.frozen {
    background: linear-gradient(135deg, #5a6e7f 0%, #3d4f5f 100%) !important;
    border-color: #8faabe !important;
    cursor: not-allowed;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.3);
}

.cell.frozen::after {
    content: '\1F9CA';
    font-size: 0.7em;
}

.cell.double {
    position: relative;
}

.cell.double.on::before {
    content: '2';
    position: absolute;
    font-size: 0.65em;
    font-weight: bold;
    color: rgba(0,0,0,0.5);
    top: 2px;
    right: 4px;
}

.cell.double.half::before {
    content: '1';
}

.cell.diagonal {
    position: relative;
}

.cell.diagonal::after {
    content: '\26A1';
    position: absolute;
    font-size: 0.5em;
    bottom: 1px;
    left: 2px;
    opacity: 0.7;
}

.cell:active:not(.frozen) {
    transform: scale(0.95);
}

.cell.flash {
    animation: cellFlash 0.2s ease;
}

.cell.hint-glow {
    animation: hintGlow 1s infinite;
}

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

@keyframes hintGlow {
    0%, 100% { box-shadow: 0 0 5px #fff, 0 0 15px #ffd700; }
    50% { box-shadow: 0 0 20px #fff, 0 0 40px #ffd700; }
}

.cell.solver-hint {
    animation: solverHintGlow 1.2s infinite;
    overflow: visible;
    z-index: 10;
}

@keyframes solverHintGlow {
    0%, 100% { box-shadow: 0 0 8px #ffd700, 0 0 20px rgba(255, 215, 0, 0.6); }
    50% { box-shadow: 0 0 25px #ffd700, 0 0 50px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 165, 0, 0.3); }
}

.cell.solver-hint::after {
    content: attr(data-hint-count);
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ffd700;
    color: #1a1a2e;
    font-size: 11px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
    z-index: 11;
}

.hint-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(26, 26, 46, 0.95);
    color: #ffd700;
    padding: 16px 28px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: bold;
    border: 2px solid #ffd700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
    z-index: 200;
    animation: hintMessagePop 0.3s ease;
    pointer-events: none;
}

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

.solve-btn {
    background: linear-gradient(135deg, #ffd700 0%, #ff8c00 100%);
    border: none;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: bold;
    color: #1a1a2e;
    border-radius: 25px;
    cursor: pointer;
    animation: solveBtnPulse 2s infinite;
}

.solve-btn:hover {
    filter: brightness(1.2);
}

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

@keyframes solveBtnPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 215, 0, 0.5); }
    50% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }
}

.controls {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.control-btn {
    background: linear-gradient(135deg, #4a4a6a 0%, #3a3a5a 100%);
    border: 2px solid rgba(255,215,0,0.3);
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: bold;
    color: #ffd700;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:hover, .control-btn:active {
    background: linear-gradient(135deg, #5a5a7a 0%, #4a4a6a 100%);
    border-color: #ffd700;
}

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

.lights-remaining {
    text-align: center;
    margin-top: 10px;
    color: rgba(255,255,255,0.6);
    font-size: 0.85rem;
}

.lights-remaining span {
    color: #ffd700;
    font-weight: bold;
}

.feature-unlock {
    background: rgba(255,215,0,0.15);
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: 10px;
    padding: 8px 12px;
    margin-top: 10px;
    color: #ffd700;
    font-size: 0.8rem;
    text-align: center;
    max-width: 300px;
}

.feature-unlock strong {
    display: block;
    margin-bottom: 3px;
}

.overlay {
    background: rgba(0,0,0,0.9);
    overflow-y: auto;
}

.overlay h2 {
    color: #ffd700;
    font-size: 1.8rem;
    margin-bottom: 12px;
    text-align: center;
    text-shadow: 0 0 20px rgba(255,215,0,0.5);
}

.overlay p {
    font-size: 1rem;
    margin-bottom: 15px;
}

.overlay .stars {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.play-btn {
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    padding: 12px 30px;
    font-size: 1.1rem;
    color: #1a1a2e;
    border-radius: 30px;
    margin: 5px;
    box-shadow: 0 0 20px rgba(255,215,0,0.4);
}

.play-btn.secondary {
    background: linear-gradient(135deg, #4a4a6a 0%, #3a3a5a 100%);
    color: #ffd700;
    box-shadow: none;
}

.back-link {
    margin-top: 12px;
    color: rgba(255,255,255,0.5);
    font-size: 0.95rem;
}

.back-link:hover, .back-link:active {
    color: #ffd700;
}

.world-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.world-tab {
    padding: 8px 16px;
    border-radius: 20px;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.6);
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.world-tab.active {
    border-color: #ffd700;
    color: #ffd700;
    background: rgba(255,215,0,0.1);
}

.world-tab.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.level-select {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-width: 280px;
    margin-bottom: 15px;
}

.level-btn {
    width: 45px;
    height: 45px;
    border-radius: 10px;
    border: 2px solid transparent;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.level-btn.unlocked {
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    color: #1a1a2e;
}

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

.level-btn.current {
    border-color: #fff;
    box-shadow: 0 0 15px rgba(255,215,0,0.5);
}

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

.level-btn .stars-mini {
    font-size: 0.4rem;
    line-height: 1;
}

.legend {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    max-width: 320px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255,255,255,0.7);
    font-size: 0.7rem;
}

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

.legend-icon.frozen {
    background: linear-gradient(135deg, #5a6e7f 0%, #3d4f5f 100%);
}

.legend-icon.double {
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
}

.legend-icon.diagonal {
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
}

.legend-icon.chain {
    background: linear-gradient(135deg, #00bcd4 0%, #0097a7 100%);
}

.new-feature {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: white;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: bold;
    margin-left: 5px;
    animation: lights-bounce 1s infinite;
}

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

/* Easter Egg: Disco Mode */
.disco-mode .cell.on {
    animation: discoFlash 0.3s infinite;
}

@keyframes discoFlash {
    0% { background: linear-gradient(135deg, #ff0000 0%, #ff6b6b 100%); box-shadow: 0 0 30px rgba(255,0,0,0.8); }
    16% { background: linear-gradient(135deg, #ff8800 0%, #ffaa00 100%); box-shadow: 0 0 30px rgba(255,136,0,0.8); }
    33% { background: linear-gradient(135deg, #ffff00 0%, #ffff88 100%); box-shadow: 0 0 30px rgba(255,255,0,0.8); }
    50% { background: linear-gradient(135deg, #00ff00 0%, #88ff88 100%); box-shadow: 0 0 30px rgba(0,255,0,0.8); }
    66% { background: linear-gradient(135deg, #0088ff 0%, #00aaff 100%); box-shadow: 0 0 30px rgba(0,136,255,0.8); }
    83% { background: linear-gradient(135deg, #8800ff 0%, #aa00ff 100%); box-shadow: 0 0 30px rgba(136,0,255,0.8); }
    100% { background: linear-gradient(135deg, #ff0088 0%, #ff00aa 100%); box-shadow: 0 0 30px rgba(255,0,136,0.8); }
}

.disco-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 90;
    pointer-events: none;
}

.disco-text {
    font-size: 3rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 20px #ff00ff, 0 0 40px #00ffff;
    animation: discoText 0.5s infinite;
}

@keyframes discoText {
    0%, 100% { color: #ff00ff; transform: scale(1) rotate(-5deg); }
    25% { color: #00ffff; transform: scale(1.1) rotate(5deg); }
    50% { color: #ffff00; transform: scale(1) rotate(-5deg); }
    75% { color: #00ff00; transform: scale(1.1) rotate(5deg); }
}

/* Easter Egg: Sparky Light */
.cell.sparking {
    animation: sparkFlicker 0.08s infinite !important;
    position: relative;
    z-index: 100;
}

@keyframes sparkFlicker {
    0% { opacity: 1; filter: brightness(3) saturate(2); box-shadow: 0 0 30px #fff, 0 0 60px #ff0; }
    20% { opacity: 0.2; filter: brightness(0.3); box-shadow: none; }
    40% { opacity: 1; filter: brightness(4) saturate(3); box-shadow: 0 0 40px #fff, 0 0 80px #0ff; }
    60% { opacity: 0.4; filter: brightness(0.5); box-shadow: 0 0 10px #ff0; }
    80% { opacity: 1; filter: brightness(3.5); box-shadow: 0 0 50px #fff, 0 0 100px #f0f; }
    100% { opacity: 0.6; filter: brightness(1); box-shadow: 0 0 20px #ff0; }
}

/* Persistent damaged/flickering state */
.cell.damaged {
    animation: damagedFlicker 0.3s infinite !important;
}

@keyframes damagedFlicker {
    0%, 100% { opacity: 1; filter: brightness(1.2); }
    30% { opacity: 0.7; filter: brightness(0.8); }
    60% { opacity: 1; filter: brightness(1.5); }
    80% { opacity: 0.85; filter: brightness(1); }
}

.spark {
    position: absolute;
    font-size: 2rem;
    animation: sparkFly 0.6s ease-out forwards;
    pointer-events: none;
    z-index: 150;
    text-shadow: 0 0 10px #fff, 0 0 20px #ff0;
}

@keyframes sparkFly {
    0% { opacity: 1; transform: translate(0, 0) scale(1.5); }
    100% { opacity: 0; transform: translate(var(--spark-x), var(--spark-y)) scale(0); }
}

/* Screen flash for sparky */
.spark-flash {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    pointer-events: none;
    z-index: 200;
    animation: flashBang 0.3s ease-out forwards;
}

@keyframes flashBang {
    0% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* Chain cells */
.cell.chain::after {
    content: '\1F517';
    position: absolute;
    font-size: 0.5em;
    bottom: 1px;
    left: 2px;
    opacity: 0.7;
}

.cell.chain.on {
    background: linear-gradient(135deg, #00bcd4 0%, #0097a7 100%) !important;
    box-shadow: 0 0 25px rgba(0,188,212,0.6), inset 0 -2px 10px rgba(255,255,255,0.3) !important;
    border-color: #4dd0e1 !important;
}

.cell.chain-reacting {
    animation: chainPulse 0.2s ease !important;
}

@keyframes chainPulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.15); filter: brightness(1.5); }
}

@keyframes shakeIt {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-8px) rotate(-1deg); }
    20% { transform: translateX(8px) rotate(1deg); }
    30% { transform: translateX(-6px) rotate(-1deg); }
    40% { transform: translateX(6px) rotate(1deg); }
    50% { transform: translateX(-4px); }
    60% { transform: translateX(4px); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

/* Easter Egg: Rainbow/Party Mode */
.rainbow-mode .cell.on {
    animation: rainbowCycle 1s linear infinite !important;
}

@keyframes rainbowCycle {
    0%, 100% { background: linear-gradient(135deg, #ff0000 0%, #ff6666 100%); box-shadow: 0 0 25px rgba(255,0,0,0.6); }
    14% { background: linear-gradient(135deg, #ff8800 0%, #ffaa44 100%); box-shadow: 0 0 25px rgba(255,136,0,0.6); }
    28% { background: linear-gradient(135deg, #ffff00 0%, #ffff88 100%); box-shadow: 0 0 25px rgba(255,255,0,0.6); }
    42% { background: linear-gradient(135deg, #00ff00 0%, #88ff88 100%); box-shadow: 0 0 25px rgba(0,255,0,0.6); }
    57% { background: linear-gradient(135deg, #00ffff 0%, #88ffff 100%); box-shadow: 0 0 25px rgba(0,255,255,0.6); }
    71% { background: linear-gradient(135deg, #0088ff 0%, #44aaff 100%); box-shadow: 0 0 25px rgba(0,136,255,0.6); }
    85% { background: linear-gradient(135deg, #8800ff 0%, #aa44ff 100%); box-shadow: 0 0 25px rgba(136,0,255,0.6); }
}

.rainbow-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
    pointer-events: none;
}

.rainbow-text {
    font-size: 3rem;
    font-weight: bold;
    background: linear-gradient(90deg, #ff0000, #ff8800, #ffff00, #00ff00, #00ffff, #0088ff, #8800ff);
    background-size: 400% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: rainbowTextWave 1s linear infinite, rainbowPulse 0.5s ease infinite;
}

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

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

/* Easter Egg: Blackout Master */
.blackout-celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 150;
    text-align: center;
    animation: blackoutAppear 0.3s ease-out;
    pointer-events: none;
}

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

.blackout-text {
    font-size: 2rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 20px #ffd700, 0 0 40px #ff8800;
    animation: blackoutGlow 0.3s ease infinite alternate;
}

@keyframes blackoutGlow {
    0% { text-shadow: 0 0 20px #ffd700, 0 0 40px #ff8800; }
    100% { text-shadow: 0 0 30px #ffd700, 0 0 60px #ff8800, 0 0 80px #ff0000; }
}

.blackout-emoji {
    font-size: 4rem;
    animation: slotSpin 0.5s ease-out;
}

@keyframes slotSpin {
    0% { transform: rotateX(720deg); }
    100% { transform: rotateX(0deg); }
}

.hint {
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
    text-align: center;
    margin-top: 10px;
    max-width: 280px;
}

.hint strong {
    color: #ffd700;
}

/* Timer Edge Glow */
.timer-edge-glow::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    box-shadow: inset 0 0 60px rgba(255, 0, 0, 0.3);
    z-index: 50;
    animation: edgeGlowPulse 0.5s ease infinite;
}

@keyframes edgeGlowPulse {
    0%, 100% { box-shadow: inset 0 0 60px rgba(255, 0, 0, 0.3); }
    50% { box-shadow: inset 0 0 80px rgba(255, 0, 0, 0.5); }
}

.timer-critical::before {
    animation: edgeGlowIntense 0.25s ease infinite;
}

@keyframes edgeGlowIntense {
    0%, 100% { box-shadow: inset 0 0 60px rgba(255, 0, 0, 0.4); }
    50% { box-shadow: inset 0 0 100px rgba(255, 0, 0, 0.7); }
}

/* Chain Ripple Effect */
.chain-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border: 2px solid #00bcd4;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: chainRippleExpand 0.4s ease-out forwards;
    pointer-events: none;
}

@keyframes chainRippleExpand {
    0% { width: 10px; height: 10px; opacity: 1; }
    100% { width: 80px; height: 80px; opacity: 0; }
}

/* Level Transition - Cell Appearing */
.cell.appearing {
    animation: cellAppear 0.3s ease forwards;
    opacity: 0;
}

@keyframes cellAppear {
    0% { transform: scale(0) rotate(-10deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Easter Egg: Patience - Dad float */
.patience-dad {
    position: fixed;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    text-align: center;
    pointer-events: none;
    animation: dadDescend 3s ease-in-out forwards;
}

.patience-dad .dad-emoji {
    font-size: 3rem;
}

.patience-dad .dad-speech {
    background: white;
    color: #333;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    margin-top: 4px;
}

.patience-dad .dad-speech::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid white;
}

@keyframes dadDescend {
    0% { top: -80px; opacity: 0; }
    20% { opacity: 1; }
    40% { top: 40%; }
    60% { top: 40%; }
    80% { opacity: 1; }
    100% { top: -80px; opacity: 0; }
}

/* Easter Egg: Speed Demon - Lightning */
.lightning-bolt {
    position: fixed;
    font-size: 2rem;
    pointer-events: none;
    z-index: 200;
    animation: lightningFall 1.5s ease-in forwards;
}

@keyframes lightningFall {
    0% { opacity: 1; transform: translateY(0) rotate(0deg); }
    100% { opacity: 0; transform: translateY(100vh) rotate(360deg); }
}

.lightning-text {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 201;
    font-size: 2rem;
    font-weight: bold;
    color: #ffff00;
    text-shadow: 0 0 20px #ffff00, 0 0 40px #ff8800, 0 0 60px #ff4400;
    pointer-events: none;
    animation: lightningTextPulse 0.3s ease infinite alternate, fadeOut 2s ease forwards;
}

@keyframes lightningTextPulse {
    0% { text-shadow: 0 0 20px #ffff00, 0 0 40px #ff8800; }
    100% { text-shadow: 0 0 40px #ffff00, 0 0 80px #ff8800, 0 0 100px #ff4400; }
}

@keyframes fadeOut {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
}

/* Easter Egg: Undo Addict - Clock spiral */
.undo-clock {
    position: fixed;
    font-size: 2.5rem;
    pointer-events: none;
    z-index: 200;
    animation: clockSpiral 2s ease-out forwards;
}

@keyframes clockSpiral {
    0% { opacity: 1; transform: rotate(0deg) scale(1); }
    50% { transform: rotate(720deg) scale(1.5); }
    100% { opacity: 0; transform: rotate(1440deg) scale(0); }
}

.undo-text {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 201;
    font-size: 1.5rem;
    font-weight: bold;
    color: #00bcd4;
    text-shadow: 0 0 15px #00bcd4, 0 0 30px #0088aa;
    pointer-events: none;
    animation: fadeOut 2.5s ease forwards;
}

.screen-wobble {
    animation: wobble 0.5s ease;
}

@keyframes wobble {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-1deg); }
    50% { transform: rotate(1deg); }
    75% { transform: rotate(-0.5deg); }
}

/* Easter Egg: World Champion - Trophy */
.world-champ-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    text-align: center;
    pointer-events: none;
    animation: champAppear 0.5s ease-out;
}

@keyframes champAppear {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    60% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.champ-trophy {
    font-size: 4rem;
    animation: trophyBounce 0.6s ease infinite alternate;
}

@keyframes trophyBounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-10px); }
}

.champ-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 20px #ffd700, 0 0 40px #ff8800;
    margin-top: 8px;
}

@media (prefers-reduced-motion: reduce) {
    .patience-dad,
    .lightning-bolt,
    .lightning-text,
    .undo-clock,
    .undo-text,
    .screen-wobble,
    .world-champ-overlay,
    .champ-trophy,
    .champ-text {
        animation: none !important;
    }
    .patience-dad { top: 40%; opacity: 1; }
    .lightning-text, .undo-text { opacity: 1; }
    .world-champ-overlay { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@media (max-width: 360px) {
    h1 {
        font-size: 1.2rem;
    }

    .game-container {
        padding: 10px;
    }

    .stat-box {
        padding: 5px 10px;
    }

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