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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

.screen-content {
    text-align: center;
    padding: 12px;
    max-width: min(460px, 86vw);
    animation: slideUp 0.6s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Start Screen Styles */
.game-title {
    font-size: clamp(1.8rem, 6vw, 3rem);
    font-weight: 900;
    color: #fff;
    text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.game-subtitle {
    font-size: clamp(0.9rem, 4vw, 1.2rem);
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 30px;
    font-weight: 500;
}

/* Fruit row hidden in iframe start view */
.preview-fruits { display: none; }

.fruit-icon {
    font-size: 4rem;
    animation: bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.fruit-icon:nth-child(1) { animation-delay: 0s; }
.fruit-icon:nth-child(2) { animation-delay: 0.2s; }
.fruit-icon:nth-child(3) { animation-delay: 0.4s; }
.fruit-icon:nth-child(4) { animation-delay: 0.6s; }

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

.instructions {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    padding: clamp(14px, 4vw, 20px);
    margin: clamp(12px, 3vh, 20px) 0;
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.instructions p {
    color: #fff;
    font-size: clamp(0.85rem, 3.4vw, 1rem);
    margin: 12px 0;
    font-weight: 500;
}

/* Button Styles */
.btn {
    padding: clamp(10px, 3vw, 14px) clamp(26px, 9vw, 36px);
    font-size: clamp(0.9rem, 3.5vw, 1.05rem);
    font-weight: 700;
    border: none;
    border-radius: 36px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    margin: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(245, 87, 108, 0.4);
}

.btn-replay {
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
    color: white;
}

.btn-replay:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 30px rgba(108, 92, 231, 0.4);
}

.btn-download {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    font-size: 1.6rem;
}

.btn-download:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 35px rgba(79, 172, 254, 0.4);
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

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

/* Game Screen Styles */
#gameScreen {
    flex-direction: column;
    padding: 20px;
}

.game-header {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(6px, 1.2vw, 12px);
    margin-bottom: clamp(8px, 2vh, 12px);
    width: min(340px, 84vw);
    justify-items: center;
}

.stat-box {
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(8px);
    border-radius: 14px;
    padding: clamp(10px, 2vw, 14px) clamp(14px, 3vw, 20px);
    flex: 1;
    border: 1.5px solid rgba(255, 255, 255, 0.26);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.moves-box {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
}

.timer-box {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

/* Circular Timer */
.circular-timer {
    position: relative;
    width: 70px;
    height: 70px;
}

.timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: white;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.timer-number {
    display: block;
    font-size: 1.8rem;
    font-weight: 900;
    color: white;
    line-height: 1;
}

.timer-label {
    display: block;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    margin-top: 2px;
}

.target-box {
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
}

.stat-label {
    display: block;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.stat-value {
    display: block;
    color: white;
    font-size: 1.8rem;
    font-weight: 900;
    margin-top: 5px;
}


.hud-hidden{ display:none; }
/* Game Board */
.game-board {
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: clamp(20px, 4vw, 28px);
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: clamp(9px, 1.4vw, 12px);
    max-width: 560px;
    width: min(560px, 98vw);
    border: 3px solid rgba(255, 255, 255, 0.32);
    box-shadow: 0 22px 56px rgba(0, 0, 0, 0.32);
    position: relative;
}

.cell {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.cell::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.3s ease;
    border-radius: 50%;
}

.cell:hover::before {
    transform: translate(-50%, -50%) scale(1);
}

.cell span {
    animation: breathe 3s ease-in-out infinite;
    display: inline-block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

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

.cell:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.cell.selected {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 0 30px rgba(253, 203, 110, 0.9);
    animation: selectedPulse 0.6s ease-in-out infinite;
}

@keyframes selectedPulse {
    0%, 100% { 
        box-shadow: 0 0 30px rgba(253, 203, 110, 0.9);
        transform: scale(1.15) rotate(5deg);
    }
    50% { 
        box-shadow: 0 0 40px rgba(253, 203, 110, 1);
        transform: scale(1.2) rotate(-5deg);
    }
}

.cell.swapping {
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 10;
}

.cell.success-flash {
    animation: successFlash 0.5s ease;
}

@keyframes successFlash {
    0%, 100% { 
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    50% { 
        background: linear-gradient(135deg, #55efc4 0%, #00b894 100%);
        box-shadow: 0 0 30px rgba(0, 184, 148, 0.8);
        transform: scale(1.1);
    }
}

.cell.error-shake {
    animation: errorShake 0.5s ease;
}

@keyframes errorShake {
    0%, 100% { 
        transform: translateX(0);
        background: rgba(255, 255, 255, 0.9);
    }
    10%, 30%, 50%, 70%, 90% { 
        transform: translateX(-8px);
        background: linear-gradient(135deg, #ff7675 0%, #d63031 100%);
    }
    20%, 40%, 60%, 80% { 
        transform: translateX(8px);
        background: linear-gradient(135deg, #ff7675 0%, #d63031 100%);
    }
}

.cell.matching {
    animation: matchPop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 20;
}

@keyframes matchPop {
    0% { 
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    30% {
        transform: scale(1.4) rotate(15deg);
        opacity: 1;
    }
    60% {
        transform: scale(1.2) rotate(-10deg);
        opacity: 0.8;
    }
    100% { 
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
}

.cell.falling {
    animation: fall 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fall {
    from {
        transform: translateY(-200%) scale(0.5) rotate(-180deg);
        opacity: 0;
    }
    60% {
        transform: translateY(10%) scale(1.1) rotate(10deg);
    }
    to {
        transform: translateY(0) scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Particle Effects */
.particle {
    position: absolute;
    pointer-events: none;
    font-size: 1.5rem;
    animation: particleFloat 0.8s ease-out forwards;
    z-index: 100;
}

@keyframes particleFloat {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0) rotate(360deg);
        opacity: 0;
    }
}

/* Combo Indicator */
.combo-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px rgba(245, 87, 108, 0.8);
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
}

.combo-indicator.show {
    animation: comboShow 1s ease;
}

@keyframes comboShow {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8) translateY(-50px); }
}

/* Score Popup */
.score-popup-item {
    position: fixed;
    font-size: 2.5rem;
    font-weight: 900;
    color: #f39c12;
    text-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(243, 156, 18, 0.8);
    pointer-events: none;
    z-index: 1001;
    animation: scoreFloat 1s ease-out forwards;
    transform: translate(-50%, 0);
}

@keyframes scoreFloat {
    0% {
        opacity: 1;
        transform: translate(-50%, 0) scale(0.5);
    }
    50% {
        transform: translate(-50%, -60px) scale(1.3);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -120px) scale(0.8);
    }
}

/* End Screen Styles */
.result-icon {
    font-size: 3.5rem;
    margin-bottom: 8px;
    animation: iconBounce 0.8s ease infinite;
}

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

.result-title {
    font-size: 2rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.3);
    margin-bottom: 5px;
    animation: titlePulse 1.5s ease-in-out infinite;
}

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

.result-subtitle {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 12px;
    font-weight: 600;
}

.final-score-container {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 15px;
    margin: 12px 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.final-score-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.final-score {
    font-size: 2.8rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: scoreCount 1s ease;
}

@keyframes scoreCount {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.achievement-badge {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 50px;
    background: #f39c12;
    color: #fff;
    font-weight: 900;
    font-size: 1rem;
    margin-top: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: badgeShine 2s ease-in-out infinite;
}

@keyframes badgeShine {
    0%, 100% { box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 8px 30px rgba(243, 156, 18, 0.6); }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 12px 0;
}

.stat-item {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.stat-number {
    display: block;
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 3px;
}

.stat-text {
    display: block;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.75rem;
    font-weight: 600;
}

.cta-section {
    margin-top: 15px;
}

.cta-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

/* Screen Shake Effect */
@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-5px, 0); }
    20%, 40%, 60%, 80% { transform: translate(5px, 0); }
}

.game-board.shake {
    animation: screenShake 0.5s ease;
}

/* Success Ripple Effect */
.success-ripple {
    position: absolute;
    border-radius: 50%;
    border: 3px solid #00b894;
    animation: ripple 0.6s ease-out forwards;
    pointer-events: none;
    z-index: 50;
}

@keyframes ripple {
    from {
        width: 20px;
        height: 20px;
        opacity: 1;
    }
    to {
        width: 100px;
        height: 100px;
        opacity: 0;
    }
}

/* Responsive Design */
/* Tablet (landscape) */
@media (max-width: 1024px) and (min-width: 769px) {
    .game-board {
        max-width: 520px;
    }
    
    .game-header {
        max-width: 300px;
    }
}

/* Tablet (portrait) */
@media (max-width: 768px) and (min-width: 481px) {
    .game-title {
        font-size: 2.8rem;
    }
    
    .game-board {
        max-width: 480px;
        gap: 7px;
    }
    
    .game-header {
        max-width: 320px;
        gap: 8px;
    }
    
    .stat-box {
        padding: 10px 15px;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .stat-value {
        font-size: 1.6rem;
    }
    
    .cell {
        font-size: 2.2rem;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .game-title {
        font-size: 2.2rem;
    }
    
    .game-header {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        max-width: 360px;
    }
    
    .stat-box {
        padding: 10px 12px;
    }
    
    .stat-label {
        font-size: 0.65rem;
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    .game-board {
        gap: 6px;
        padding: 12px;
        max-width: 320px;
    }
    
    .cell {
        font-size: 1.8rem;
        border-radius: 10px;
    }
    
    .btn {
        padding: 14px 35px;
        font-size: 1.1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .stat-item {
        padding: 12px;
    }
    
    .stat-number {
        font-size: 1.8rem;
    }
    
    .result-icon {
        font-size: 4rem;
    }
    
    .result-title {
        font-size: 2.5rem;
    }
    
    .final-score {
        font-size: 3.2rem;
    }
}

/* Small Mobile */
@media (max-width: 360px) {
    .game-title {
        font-size: 1.8rem;
    }
    
    .game-header {
        gap: 6px;
        max-width: 320px;
    }
    
    .stat-box {
        padding: 8px 10px;
    }
    
    .stat-label {
        font-size: 0.6rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .cell {
        font-size: 1.5rem;
    }
    
    .game-board {
        max-width: 320px;
        gap: 4px;
        padding: 8px;
    }
    
    .result-title {
        font-size: 2rem;
    }
    
    .final-score {
        font-size: 2.8rem;
    }
    
    .btn {
        padding: 12px 30px;
        font-size: 1rem;
    }
}
