* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body {
    width: 100vw;
    height: 100vh;
    min-height: -webkit-fill-available;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

body::selection {
    background: transparent;
}

/* During game: hide clickable elements to prevent keyboard/focus issues */
body.in-game .high-scores {
    visibility: hidden;
    pointer-events: none;
}

/* High scores table */
.high-scores {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 16px 20px;
    min-width: 140px;
    max-width: 45vw;
    z-index: 10;
}

.high-scores-title {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1.25rem;
    color: white;
    margin-bottom: 12px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.high-scores-list {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.95rem;
    color: white;
    padding-right: 20px;
    line-height: 1.6;
}

.high-scores-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.high-scores-list .score-entry {
    flex: 1;
}

.high-scores-list .score-delete {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.high-scores-list .score-delete:hover {
    background: rgba(229, 57, 53, 0.8);
}

.high-scores-list:empty::before {
    content: "אין שיאים עדיין";
    color: rgba(255, 255, 255, 0.7);
}

/* Player name section */
.player-name-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.player-name-section label {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1rem;
    color: white;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.player-name-section select {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 16px;
    padding: 12px 36px 12px 16px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.9);
    min-width: 180px;
    max-width: 90vw;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.player-name-section select:focus {
    outline: none;
    border-color: rgba(229, 57, 53, 0.8);
}

.player-name-section select.error {
    border-color: #e53935;
}

.player-name-error {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.9rem;
    color: #ffcdd2;
    margin-top: 4px;
}

.player-name-error.hidden {
    display: none;
}

.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(
            to bottom,
            rgba(255, 100, 80, 0.4) 0%,
            rgba(255, 150, 100, 0.5) 20%,
            rgba(255, 200, 120, 0.6) 40%,
            rgba(100, 150, 220, 0.7) 70%,
            rgba(30, 80, 150, 0.9) 100%
        ),
        url('https://images.unsplash.com/photo-1507525428034-b723cf961d3e?auto=format&fit=crop&w=1920&q=80') center/cover no-repeat;
    z-index: -1;
}

.start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.start-screen .play-button {
    opacity: 0;
    animation: play-button-enter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.start-screen .start-text {
    opacity: 0;
    animation: play-button-enter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

@keyframes play-button-enter {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.start-screen.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.play-button {
    width: clamp(80px, 22vw, 120px);
    height: clamp(80px, 22vw, 120px);
    border-radius: 50%;
    background: #e53935;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 6px 20px rgba(229, 57, 53, 0.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@media (hover: hover) {
    .play-button:hover {
        transform: scale(1.05);
        box-shadow: 0 8px 28px rgba(229, 57, 53, 0.6);
    }
}

.play-button:active {
    transform: scale(0.98);
}

.play-triangle {
    width: 0;
    height: 0;
    border-top: min(28px, 7vw) solid transparent;
    border-bottom: min(28px, 7vw) solid transparent;
    border-right: min(44px, 11vw) solid white;
    transform: translateX(-6px);
}

.start-text {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* Countdown screen */
.countdown-screen,
.results-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 24px;
    cursor: pointer;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.countdown-screen:not(.hidden),
.results-screen:not(.hidden) {
    animation: screen-enter 0.5s ease-out;
}

@keyframes screen-enter {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.countdown-screen.hidden,
.results-screen.hidden {
    opacity: 0;
    transform: scale(0.98);
    pointer-events: none;
}

/* Water ripple effect */
.ripples-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.ripple {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%) scale(0);
    animation: ripple-expand 0.8s ease-out forwards;
}

@keyframes ripple-expand {
    to {
        transform: translate(-50%, -50%) scale(4);
        opacity: 0;
        border-width: 1px;
    }
}

/* Flying candies and foods */
.candies-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.candy {
    position: absolute;
    left: 0;
    top: 0;
    font-size: 2rem;
    will-change: transform;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.countdown-screen .countdown-number,
.countdown-screen .clicks-during-countdown {
    position: relative;
    z-index: 2;
}

.countdown-number {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: clamp(4rem, 25vw, 8rem);
    font-weight: 700;
    color: white;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: countdown-pulse 1s ease-in-out infinite;
}

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

.clicks-during-countdown {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1.5rem;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Results screen */
.results-title {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 2.5rem;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.results-count {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 2rem;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    animation: results-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

@keyframes results-pop {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.results-hint {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Mobile & responsive */
@media (max-width: 600px) {
    .player-name-section input {
        font-size: 16px;
    }
    .high-scores {
        padding: 12px 16px;
        min-width: 120px;
        max-width: 55vw;
    }

    .high-scores-title {
        font-size: 1.1rem;
    }

    .high-scores-list {
        font-size: 0.85rem;
    }

    .start-text {
        font-size: 2rem;
    }

    .player-name-section {
        gap: 6px;
    }

    .clicks-during-countdown {
        font-size: 1.25rem;
    }

    .results-title {
        font-size: 2rem;
    }

    .results-count {
        font-size: 1.5rem;
    }

    .results-hint {
        font-size: 0.9rem;
    }

    .candy {
        font-size: 1.5rem;
    }
}

/* Version display - bottom center */
.version {
    position: fixed;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    z-index: 5;
    pointer-events: none;
}

/* Prevent pull-to-refresh during game on mobile */
@media (hover: none) and (pointer: coarse) {
    body {
        overscroll-behavior-y: contain;
    }
}
