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

body {
    font-family: 'Nunito', sans-serif;
    min-height: 100vh;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #ffffff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* ===== FLOATING PARTICLES ===== */
.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    font-size: 1.6rem;
    animation: floatParticle linear infinite;
    opacity: 0.5;
}

@keyframes floatParticle {
    0% { transform: translateY(110vh) rotate(0deg); opacity: 0; }
    10% { opacity: 0.5; }
    90% { opacity: 0.5; }
    100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}

/* ===== FLASH OVERLAY ===== */
.flash-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
}

.flash-overlay.flash-correct {
    background: radial-gradient(circle, rgba(0,230,118,0.2), transparent 70%);
    animation: flashFade 0.5s ease forwards;
}

.flash-overlay.flash-wrong {
    background: radial-gradient(circle, rgba(255,23,68,0.2), transparent 70%);
    animation: flashFade 0.5s ease forwards;
}

@keyframes flashFade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* ===== APP CONTAINER ===== */
#app {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ===== SCREEN MANAGEMENT ===== */
.screen {
    display: none;
    width: 100%;
    max-width: 600px;
    padding: 1.5rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: screenIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.screen.active {
    display: flex;
}

.screen#gameScreen {
    max-width: 100%;
    height: 100vh;
    padding: 0;
    justify-content: flex-start;
}

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

/* ===== GLASSMORPHISM CARD ===== */
.glass-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}

/* ===== HOME SCREEN ===== */
.home-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #e17055, #0984e3, #a29bfe);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease infinite;
    line-height: 1.2;
}

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

.home-subtitle {
    text-align: center;
    font-size: 1.1rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 2.5rem;
    font-weight: 600;
}

.home-emoji-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 2.5rem;
    margin-bottom: 2rem;
}

.home-emoji-row span {
    animation: emojiFloat 3s ease-in-out infinite;
    display: inline-block;
}
.home-emoji-row span:nth-child(2) { animation-delay: 0.3s; }
.home-emoji-row span:nth-child(3) { animation-delay: 0.6s; }
.home-emoji-row span:nth-child(4) { animation-delay: 0.9s; }
.home-emoji-row span:nth-child(5) { animation-delay: 1.2s; }

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

/* ===== INPUT ===== */
.input-group {
    width: 100%;
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: rgba(255,255,255,0.8);
}

.input-group input {
    width: 100%;
    padding: 1rem 1.2rem;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    background: rgba(255,255,255,0.06);
    color: #fff;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    outline: none;
    transition: all 0.3s ease;
}

.input-group input::placeholder { color: rgba(255,255,255,0.3); }

.input-group input:focus {
    border-color: #0984e3;
    background: rgba(255,255,255,0.1);
    box-shadow: 0 0 20px rgba(9,132,227,0.15);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before { left: 100%; }

.btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 30px rgba(0,0,0,0.3);
}

.btn:active { transform: translateY(-1px) scale(0.98); }

.btn-primary {
    background: linear-gradient(135deg, #0984e3, #6c5ce7);
    color: #fff;
    box-shadow: 0 4px 15px rgba(9,132,227,0.3);
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.2);
}

.btn-secondary:hover { background: rgba(255,255,255,0.18); }

.btn-full { width: 100%; }

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

/* ===== MODE SELECTION ===== */
.mode-title {
    font-family: 'Fredoka One', cursive;
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 0.3rem;
}

.mode-welcome {
    text-align: center;
    color: rgba(255,255,255,0.6);
    font-weight: 600;
    margin-bottom: 2rem;
    font-size: 1rem;
}

.mode-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.mode-card {
    width: 100%;
    padding: 2rem;
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.mode-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 18px;
    padding: 2px;
    background: linear-gradient(135deg, #e17055, #0984e3, #a29bfe);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.mode-card.survival::after {
    background: linear-gradient(135deg, #ff5252, #e17055, #ff1744);
}

.mode-card:hover::after { opacity: 1; }

.mode-card:hover {
    transform: translateY(-5px) scale(1.02);
    background: rgba(255,255,255,0.12);
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
}

.mode-card-icon { font-size: 3rem; margin-bottom: 0.8rem; }
.mode-card-title { font-family: 'Fredoka One', cursive; font-size: 1.4rem; margin-bottom: 0.4rem; }
.mode-card-desc { color: rgba(255,255,255,0.6); font-size: 0.95rem; font-weight: 600; }

.mode-card-badge {
    display: inline-block;
    padding: 0.25rem 0.8rem;
    background: linear-gradient(135deg, #0984e3, #6c5ce7);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-top: 0.8rem;
}

.mode-card.survival .mode-card-badge {
    background: linear-gradient(135deg, #ff1744, #ff5252);
}

/* ===== GAME HUD ===== */
.game-hud {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.2rem;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    font-size: 0.95rem;
}

.hud-timer-value {
    font-family: 'Fredoka One', cursive;
    font-size: 1.3rem;
    color: #00d2ff;
    min-width: 30px;
    text-align: center;
    transition: color 0.3s ease;
}

.hud-timer-value.warning { color: #ff9100; }
.hud-timer-value.danger { color: #ff1744; animation: timerPulse 0.3s ease infinite; }

.hud-lives-value {
    font-family: 'Fredoka One', cursive;
    font-size: 1.3rem;
    color: #ff5252;
    min-width: 30px;
    text-align: center;
    transition: transform 0.3s ease, color 0.3s ease;
}

.hud-lives-value.danger { color: #ff1744; animation: timerPulse 0.3s ease infinite; }

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

.hud-score-value {
    font-family: 'Fredoka One', cursive;
    font-size: 1.3rem;
    color: #ffd700;
}

.hud-score-value.bounce {
    animation: scoreBounce 0.4s ease;
}

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

/* ===== TIMER BAR ===== */
.timer-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.08);
    z-index: 10;
}

.timer-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00d2ff, #6c5ce7);
    transition: width 0.1s linear;
}

.timer-bar-fill.warning { background: linear-gradient(90deg, #ff9100, #ffab40); }
.timer-bar-fill.danger { background: linear-gradient(90deg, #ff1744, #ff5252); }

/* ===== GAME ARENA ===== */
.game-arena {
    flex: 1;
    width: 100%;
    position: relative;
    overflow: hidden;
    z-index: 5;
}

/* ===== FALLING ITEM ===== */
.falling-item {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.6rem 0.8rem;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(8px);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 16px;
    cursor: grab;
    z-index: 20;
    touch-action: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    animation: itemSway 3s ease-in-out infinite;
}

.falling-item:hover {
    border-color: rgba(255,255,255,0.4);
}

.falling-item.dragging {
    cursor: grabbing;
    transform: scale(1.18);
    box-shadow: 0 10px 40px rgba(0,0,0,0.4), 0 0 20px rgba(9,132,227,0.3);
    border-color: rgba(9,132,227,0.6);
    z-index: 100;
    animation: none;
    transition: none;
}

.falling-item.correct-drop {
    animation: correctDrop 0.4s ease forwards;
}

.falling-item.wrong-drop {
    animation: wrongDrop 0.5s ease forwards;
}

.falling-item.missed {
    animation: missedItem 0.5s ease forwards;
}

@keyframes itemSway {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(6px); }
}

@keyframes correctDrop {
    0% { transform: scale(1.18); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes wrongDrop {
    0% { transform: scale(1.18); opacity: 1; }
    20% { transform: scale(1.18) translateX(-10px); }
    40% { transform: scale(1.18) translateX(10px); }
    60% { transform: scale(1.18) translateX(-6px); }
    80% { transform: scale(0.8); opacity: 0.5; }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes missedItem {
    0% { opacity: 0.6; }
    100% { opacity: 0; transform: translateY(30px); }
}

.falling-item-emoji {
    font-size: 2.2rem;
    line-height: 1;
}

.falling-item-name {
    font-size: 0.7rem;
    font-weight: 800;
    color: rgba(255,255,255,0.9);
    text-align: center;
    white-space: nowrap;
}

/* ===== DROP ZONES ===== */
.drop-zones {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.6rem;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    z-index: 10;
    width: 100%;
}

.drop-zone {
    flex: 1;
    padding: 0.8rem 0.5rem;
    border-radius: 16px;
    text-align: center;
    border: 3px dashed rgba(255,255,255,0.25);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 13px;
    opacity: 0.15;
    transition: opacity 0.3s ease;
}

#dropKati { border-color: rgba(225,112,85,0.5); }
#dropKati::before { background: #e17055; }
#dropSivi { border-color: rgba(9,132,227,0.5); }
#dropSivi::before { background: #0984e3; }
#dropGaz { border-color: rgba(162,155,254,0.5); }
#dropGaz::before { background: #a29bfe; }

.drop-zone.highlight {
    transform: scale(1.08);
    border-style: solid;
}

#dropKati.highlight { border-color: #e17055; box-shadow: 0 0 25px rgba(225,112,85,0.4); }
#dropKati.highlight::before { opacity: 0.35; }
#dropSivi.highlight { border-color: #0984e3; box-shadow: 0 0 25px rgba(9,132,227,0.4); }
#dropSivi.highlight::before { opacity: 0.35; }
#dropGaz.highlight { border-color: #a29bfe; box-shadow: 0 0 25px rgba(162,155,254,0.4); }
#dropGaz.highlight::before { opacity: 0.35; }

.drop-zone.correct-flash {
    animation: zoneCorrect 0.5s ease;
}

.drop-zone.wrong-flash {
    animation: zoneWrong 0.5s ease;
}

@keyframes zoneCorrect {
    0% { box-shadow: 0 0 0 rgba(0,230,118,0); }
    50% { box-shadow: 0 0 40px rgba(0,230,118,0.6); transform: scale(1.1); }
    100% { box-shadow: 0 0 0 rgba(0,230,118,0); }
}

@keyframes zoneWrong {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.drop-zone-emoji {
    font-size: 1.8rem;
    margin-bottom: 0.2rem;
    position: relative;
    z-index: 1;
}

.drop-zone-label {
    font-family: 'Fredoka One', cursive;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    position: relative;
    z-index: 1;
}

/* ===== RESULT SCREEN ===== */
.result-icon {
    font-size: 5rem;
    text-align: center;
    margin-bottom: 1rem;
    animation: resultBounce 1s ease;
}

@keyframes resultBounce {
    0% { transform: scale(0) rotate(-20deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(5deg); }
    70% { transform: scale(0.9) rotate(-3deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.result-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    text-align: center;
    margin-bottom: 0.3rem;
}

.result-player {
    text-align: center;
    color: rgba(255,255,255,0.6);
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.result-stars {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    animation: starsIn 1s ease 0.3s both;
}

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

.result-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 2rem;
}

.stat-box {
    text-align: center;
    padding: 1rem 0.5rem;
    background: rgba(255,255,255,0.06);
    border-radius: 16px;
    animation: statIn 0.5s ease both;
}

.stat-box:nth-child(1) { animation-delay: 0.4s; }
.stat-box:nth-child(2) { animation-delay: 0.55s; }
.stat-box:nth-child(3) { animation-delay: 0.7s; }

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

.stat-value {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    line-height: 1;
    margin-bottom: 0.3rem;
}

.stat-value.green { color: #00e676; }
.stat-value.red { color: #ff1744; }
.stat-value.blue { color: #00d2ff; }

.stat-label {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
    font-weight: 700;
}

.celebration-text {
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    text-align: center;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #ffd700, #ff6bcb, #00d2ff);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 2s ease infinite;
}

.result-buttons {
    display: flex;
    gap: 1rem;
    width: 100%;
    flex-wrap: wrap;
}

.result-buttons .btn {
    flex: 1;
    min-width: 140px;
}

/* ===== SCORE POPUP ===== */
.score-popup {
    position: fixed;
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    pointer-events: none;
    z-index: 300;
    animation: scorePopUp 0.8s ease forwards;
}

.score-popup.positive { color: #00e676; }
.score-popup.negative { color: #ff1744; }

@keyframes scorePopUp {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    20% { transform: translateY(-10px) scale(1.2); opacity: 1; }
    100% { transform: translateY(-60px) scale(0.8); opacity: 0; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 500px) {
    .home-title { font-size: 1.9rem; }
    .glass-card { padding: 1.8rem 1.2rem; border-radius: 20px; }
    .home-emoji-row { font-size: 2rem; }
    .drop-zone { padding: 0.6rem 0.3rem; }
    .drop-zone-emoji { font-size: 1.5rem; }
    .drop-zone-label { font-size: 0.75rem; }
    .falling-item-emoji { font-size: 1.8rem; }
    .falling-item-name { font-size: 0.65rem; }
    .result-buttons { flex-direction: column; }
    .stat-value { font-size: 1.6rem; }
}

@media (min-width: 768px) {
    .drop-zone { padding: 1rem; }
    .drop-zone-emoji { font-size: 2.2rem; }
    .falling-item-emoji { font-size: 2.5rem; }
}
