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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0a0a1a;
}

.game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.4);
}

.title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #FFD93D;
}

.stats {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.stat-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

#strokes {
    color: #FFD93D;
}

#par {
    color: #4CAF50;
}

.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: radial-gradient(ellipse at center, #0d1b2a 0%, #0a0a1a 100%);
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.controls-block {
    padding: 0.75rem 1rem 3.5rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
}

.controls-row {
    display: flex;
    justify-content: center;
}

.restart-btn {
    margin-top: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: none;
}

.restart-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

.state-playing .restart-btn {
    display: inline-block;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.overlay-content {
    text-align: center;
    padding: 2rem;
    max-width: 400px;
}

.overlay-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #FFD93D;
    margin: 0 0 1rem;
}

.overlay-text {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 1.5rem;
    line-height: 1.5;
}

.overlay-score {
    font-size: 1.5rem;
    font-weight: 700;
    color: #4CAF50;
    margin: 0 0 0.5rem;
}

.overlay-best {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 0 0 1rem;
}

/* Score result colors */
.overlay-score.under-par { color: #4CAF50; }
.overlay-score.on-par { color: #FFD93D; }
.overlay-score.over-par { color: #FF6B6B; }

/* Level Select Grid */
.level-select {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin: 1rem 0;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

.level-btn {
    width: 48px;
    height: 48px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.level-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #FFD93D;
}

.level-btn.current {
    border-color: #FFD93D;
    background: rgba(255, 217, 61, 0.2);
}

.level-btn.completed {
    border-color: #4CAF50;
}

.level-btn .score {
    font-size: 0.5rem;
    color: rgba(255, 255, 255, 0.6);
}

.level-btn .score.good {
    color: #4CAF50;
}

.share-container {
    margin: 1rem 0;
}

.start-btn {
    background: #FFD93D;
    color: #0a0a1a;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(255, 217, 61, 0.4);
}

.start-btn:active {
    transform: scale(0.98);
}

.home-link {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    transition: background 0.2s ease, color 0.2s ease;
    z-index: 200;
}

.home-link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.8);
}

/* State-based visibility */
.state-playing .controls-block {
    opacity: 0.3;
}

.state-idle .level-select {
    display: grid;
}

.state-playing .overlay {
    opacity: 0;
    pointer-events: none;
}

/* Hole complete celebration */
.overlay-title.hole-complete {
    animation: celebrate 0.5s ease;
}

@keyframes celebrate {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); color: #4CAF50; }
}

/* Responsive */
@media (max-width: 600px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .title {
        font-size: 1.25rem;
    }

    .stats {
        gap: 0.75rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

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

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

    .overlay-text {
        font-size: 1rem;
    }

    .controls-block {
        padding: 0.5rem 1rem 3rem;
    }

    .level-select {
        max-width: 240px;
    }

    .level-btn {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }
}

@media (max-height: 600px) {
    .header {
        padding: 0.5rem 1rem;
    }

    .overlay-content {
        padding: 1rem;
    }

    .overlay-title {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
    }
}
