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

body {
    overflow: hidden;
    font-family: 'Fredoka', sans-serif;
    background: #1a472a;
    user-select: none;
    -webkit-user-select: none;
}

#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#scene-container canvas {
    display: block;
}

#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

#ui-overlay > * {
    pointer-events: auto;
}

/* TITLE SCREEN */
.title-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #87CEEB 0%, #98E4C1 50%, #2D8B4E 100%);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.title-text {
    font-size: clamp(48px, 10vw, 96px);
    font-weight: 700;
    color: #fff;
    text-shadow: 0 4px 0 #1a6b3a, 0 8px 20px rgba(0,0,0,0.3);
    margin-bottom: 8px;
    animation: titleBounce 2s ease infinite;
}

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

.tagline {
    font-size: clamp(16px, 3vw, 24px);
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 40px;
    font-weight: 500;
    min-height: 30px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
}

.btn {
    padding: 14px 48px;
    border: none;
    border-radius: 50px;
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(16px, 3vw, 22px);
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: 0 2px 2px rgba(0,0,0,0.2);
    box-shadow: 0 4px 0 rgba(0,0,0,0.2), 0 6px 20px rgba(0,0,0,0.15);
    min-width: 240px;
    text-align: center;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 0 rgba(0,0,0,0.2), 0 8px 25px rgba(0,0,0,0.2);
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.2), 0 3px 10px rgba(0,0,0,0.15);
}

.btn-play { background: linear-gradient(135deg, #4CAF50, #2E7D32); }
.btn-chars { background: linear-gradient(135deg, #42A5F5, #1565C0); }
.btn-courses { background: linear-gradient(135deg, #FFA726, #E65100); }
.btn-help { background: linear-gradient(135deg, #FFEE58, #F9A825); color: #5D4037; text-shadow: none; }
.btn-confirm { background: linear-gradient(135deg, #4CAF50, #2E7D32); }
.btn-back { background: linear-gradient(135deg, #78909C, #455A64); }
.btn-retry { background: linear-gradient(135deg, #FFA726, #E65100); }
.btn-next { background: linear-gradient(135deg, #42A5F5, #1565C0); }
.btn-small { padding: 10px 30px; font-size: 16px; min-width: auto; }

.footer-link {
    position: absolute;
    bottom: 16px;
    font-size: 13px;
    color: rgba(255,255,255,0.5);
    text-decoration: none;
}
.footer-link:hover { color: rgba(255,255,255,0.8); }

/* CHARACTER SELECT */
.char-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(180deg, #1a237e 0%, #283593 50%, #3949ab 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
    animation: fadeIn 0.4s ease;
}

.screen-title {
    font-size: clamp(28px, 5vw, 42px);
    font-weight: 700;
    color: #fff;
    text-shadow: 0 3px 0 rgba(0,0,0,0.3);
    margin-bottom: 20px;
}

.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    max-width: 750px;
    width: 100%;
    margin-bottom: 20px;
}

.char-card {
    background: rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 3px solid transparent;
    backdrop-filter: blur(4px);
}

.char-card:hover {
    background: rgba(255,255,255,0.18);
    transform: translateY(-3px);
}

.char-card.selected {
    border-color: #FFD700;
    background: rgba(255,215,0,0.15);
    box-shadow: 0 0 20px rgba(255,215,0,0.3);
}

.char-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.char-name {
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    text-align: center;
    margin-bottom: 8px;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.stat-label {
    color: rgba(255,255,255,0.7);
    font-size: 11px;
    width: 48px;
    flex-shrink: 0;
}

.stat-bar-bg {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.char-quip {
    color: #FFD700;
    font-size: 14px;
    text-align: center;
    margin: 10px 0;
    font-style: italic;
    min-height: 20px;
}

/* COURSE SELECT */
.course-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(180deg, #1b5e20 0%, #2e7d32 50%, #388e3c 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
    animation: fadeIn 0.4s ease;
}

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    max-width: 680px;
    width: 100%;
    margin-bottom: 20px;
}

.course-card {
    background: rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 3px solid transparent;
    position: relative;
}

.course-card:hover:not(.locked) {
    background: rgba(255,255,255,0.2);
    transform: translateY(-3px);
}

.course-card.selected {
    border-color: #FFD700;
    box-shadow: 0 0 20px rgba(255,215,0,0.3);
}

.course-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.course-emoji {
    font-size: 32px;
    margin-bottom: 6px;
}

.course-name {
    color: #fff;
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 4px;
}

.course-info {
    color: rgba(255,255,255,0.7);
    font-size: 13px;
}

.course-stars {
    color: #FFD700;
    margin-top: 4px;
}

.course-lock {
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    margin-top: 6px;
}

.course-complete {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
}

/* HOW TO PLAY */
.help-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(180deg, #F9A825 0%, #FF8F00 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px;
    overflow-y: auto;
    animation: fadeIn 0.4s ease;
}

.help-panel {
    background: rgba(255,255,255,0.2);
    border-radius: 16px;
    padding: 20px;
    max-width: 500px;
    width: 100%;
    margin-bottom: 14px;
}

.help-step {
    font-size: 18px;
    color: #fff;
    font-weight: 600;
    margin-bottom: 4px;
}

.help-desc {
    font-size: 14px;
    color: rgba(255,255,255,0.85);
}

/* GAME HUD */
.game-hud {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

.game-hud > * {
    pointer-events: auto;
}

.hud-top {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 16px;
    background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%);
}

.hud-course-info {
    color: #fff;
    font-weight: 600;
    font-size: clamp(14px, 2.5vw, 18px);
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.hud-course-sub {
    font-size: clamp(11px, 2vw, 14px);
    color: rgba(255,255,255,0.8);
    font-weight: 400;
}

.wind-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.4);
    padding: 8px 14px;
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
}

.wind-arrow {
    display: inline-block;
    font-size: 20px;
    transition: transform 0.5s ease;
}

/* MINIMAP */
.minimap {
    position: absolute;
    top: 60px;
    right: 12px;
    width: clamp(100px, 18vw, 150px);
    height: clamp(100px, 18vw, 150px);
    background: rgba(0,0,0,0.5);
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    overflow: hidden;
}

.minimap canvas {
    width: 100%;
    height: 100%;
}

/* SWING AREA */
.swing-area {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 12px 16px;
    pointer-events: auto;
}

.club-selector {
    position: absolute;
    bottom: 20px;
    left: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.club-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
    background: rgba(0,0,0,0.4);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fredoka', sans-serif;
}

.club-name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    background: rgba(0,0,0,0.4);
    padding: 4px 12px;
    border-radius: 8px;
}

.club-dist {
    color: rgba(255,255,255,0.7);
    font-size: 11px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* POWER METER */
.power-meter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.power-bar-container {
    width: 40px;
    height: clamp(120px, 25vh, 200px);
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,0.3);
    position: relative;
    overflow: hidden;
}

.power-bar-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 8px;
    transition: none;
}

.power-bar-sweet {
    position: absolute;
    left: 2px;
    right: 2px;
    border: 2px dashed rgba(255,215,0,0.7);
    border-radius: 4px;
    pointer-events: none;
}

.accuracy-bar {
    width: clamp(160px, 40vw, 260px);
    height: 30px;
    background: rgba(0,0,0,0.5);
    border-radius: 15px;
    border: 2px solid rgba(255,255,255,0.3);
    position: relative;
    overflow: hidden;
}

.accuracy-center {
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20%;
    background: rgba(255,215,0,0.3);
    border-radius: 10px;
}

.accuracy-needle {
    position: absolute;
    top: 2px;
    bottom: 2px;
    width: 4px;
    background: #fff;
    border-radius: 2px;
    box-shadow: 0 0 8px #fff;
    transition: none;
}

.swing-prompt {
    color: #fff;
    font-size: clamp(14px, 3vw, 20px);
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    text-align: center;
    animation: pulse 1s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* CHARACTER PORTRAIT */
.char-portrait {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    border: 3px solid rgba(255,255,255,0.5);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* AIM CONTROLS */
.aim-controls {
    position: absolute;
    bottom: 80px;
    right: 16px;
    display: flex;
    gap: 8px;
}

.aim-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
    background: rgba(0,0,0,0.4);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* SCORECARD */
.scorecard-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(180deg, #1b5e20 0%, #2e7d32 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.4s ease;
}

.scorecard-table {
    background: rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 20px;
    margin: 16px 0;
    width: 100%;
    max-width: 400px;
}

.scorecard-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    font-size: 16px;
}

.scorecard-row.header {
    font-weight: 700;
    border-bottom: 2px solid rgba(255,255,255,0.3);
}

.scorecard-total {
    font-weight: 700;
    font-size: 20px;
    color: #FFD700;
    border-bottom: none;
}

.performance-text {
    color: #FFD700;
    font-size: 22px;
    font-weight: 700;
    margin: 8px 0;
}

.unlock-text {
    color: #81C784;
    font-size: 18px;
    font-weight: 600;
    animation: pulse 1.5s ease infinite;
}

/* CONGRATS */
.congrats-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(180deg, #1a237e 0%, #311b92 50%, #4a148c 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.5s ease;
    text-align: center;
}

.congrats-trophy {
    font-size: 80px;
    animation: trophySpin 3s linear infinite;
}

@keyframes trophySpin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

.congrats-title {
    font-size: clamp(28px, 6vw, 48px);
    font-weight: 700;
    color: #FFD700;
    text-shadow: 0 4px 0 rgba(0,0,0,0.3), 0 0 30px rgba(255,215,0,0.4);
    margin: 16px 0 8px;
}

.congrats-sub {
    font-size: clamp(14px, 3vw, 20px);
    color: rgba(255,255,255,0.85);
    margin-bottom: 24px;
    max-width: 500px;
}

/* CLICK AREA for swing */
.click-area {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    cursor: pointer;
    pointer-events: auto;
}

/* TRAJECTORY LINE */
.traj-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    text-shadow: 0 2px 6px rgba(0,0,0,0.6);
    pointer-events: none;
}

/* Confetti canvas */
.confetti-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

/* Shot result popup */
.shot-result {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: clamp(28px, 6vw, 48px);
    font-weight: 700;
    text-shadow: 0 3px 8px rgba(0,0,0,0.5);
    pointer-events: none;
    animation: shotPop 1.5s ease forwards;
}

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

/* Distance info */
.dist-info {
    position: absolute;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    background: rgba(0,0,0,0.4);
    padding: 4px 12px;
    border-radius: 8px;
    pointer-events: none;
    text-align: center;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .char-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .course-grid {
        grid-template-columns: 1fr;
    }
}