/* ============================================
   CSS: Grundlegende Styles und Variablen
   ============================================ */
:root {
    /* Farbpalette - harmonisch und modern */
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e3a5f;
    --grass-light: #4ade80;
    --grass-dark: #22c55e;
    --grass-border: #16a34a;
    --sand: #fcd34d;
    --water: #38bdf8;
    --ball-color: #ffffff;
    --ball-shadow: rgba(0, 0, 0, 0.3);
    --hole-color: #1f2937;
    --hole-inner: #0f172a;
    --flag-pole: #78716c;
    --flag-color: #ef4444;
    --ui-bg: rgba(255, 255, 255, 0.95);
    --ui-text: #1f2937;
    --ui-accent: #f97316;
    --ui-accent-hover: #ea580c;
    --ui-success: #22c55e;
    --ui-muted: #64748b;
    --obstacle-color: #78716c;
    --obstacle-light: #a8a29e;
    --aim-line: rgba(255, 255, 255, 0.8);
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-large: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
    --border-radius: 12px;
    --border-radius-large: 20px;
}

/* Reset und Basis */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--ui-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ============================================
   UI: Header mit Spielinfo
   ============================================ */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 600px;
    margin-bottom: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--ui-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
}

.game-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--grass-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.game-stats {
    display: flex;
    gap: 1.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--ui-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ui-text);
    line-height: 1;
}

/* ============================================
   Canvas Container und Spielfeld
   ============================================ */
.game-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 4 / 5;
    max-height: 70vh;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-large);
    cursor: crosshair;
    touch-action: none;
}

/* ============================================
   UI: Footer mit Buttons
   ============================================ */
.game-footer {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    width: 100%;
    max-width: 600px;
    justify-content: center;
}

/* Button Styles - konsistent und modern */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-soft);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.btn:active {
    transform: translateY(0);
}

.btn:focus {
    outline: 3px solid rgba(249, 115, 22, 0.5);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--ui-accent) 0%, var(--ui-accent-hover) 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--ui-accent-hover) 0%, #c2410c 100%);
}

.btn-secondary {
    background: var(--ui-bg);
    color: var(--ui-text);
}

.btn-secondary:hover {
    background: #f1f5f9;
}

/* ============================================
   Overlays - Welcome, Hole Complete, Game End
   ============================================ */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

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

.overlay-content {
    background: var(--ui-bg);
    padding: 2rem;
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-large);
    text-align: center;
    max-width: 90%;
    width: 360px;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.overlay.active .overlay-content {
    transform: scale(1);
}

.overlay-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.overlay-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ui-text);
    margin-bottom: 0.5rem;
}

.overlay-subtitle {
    font-size: 1rem;
    color: var(--ui-muted);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* Anleitung im Welcome-Overlay */
.instructions {
    text-align: left;
    background: #f8fafc;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
}

.instruction-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.instruction-item:last-child {
    margin-bottom: 0;
}

.instruction-number {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--grass-dark);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.instruction-text {
    font-size: 0.9rem;
    color: var(--ui-text);
    line-height: 1.4;
}

/* Score-Übersicht */
.score-table {
    width: 100%;
    margin-bottom: 1.5rem;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.score-row:last-child {
    border-bottom: none;
    font-weight: 700;
    color: var(--grass-dark);
}

.score-label {
    color: var(--ui-muted);
}

.score-value {
    font-weight: 700;
}

/* Par-Anzeige */
.par-display {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

.par-under {
    background: #dcfce7;
    color: #166534;
}

.par-even {
    background: #e0f2fe;
    color: #0369a1;
}

.par-over {
    background: #fef3c7;
    color: #92400e;
}

/* ============================================
   Responsive Anpassungen
   ============================================ */
@media (max-width: 480px) {
    body {
        padding: 0.5rem;
    }

    .game-header {
        padding: 0.5rem 1rem;
        margin-bottom: 0.75rem;
    }

    .game-title {
        font-size: 1rem;
    }

    .game-stats {
        gap: 1rem;
    }

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

    .game-container {
        max-height: 65vh;
    }

    .game-footer {
        margin-top: 0.75rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    .overlay-content {
        padding: 1.5rem;
    }

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

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

@keyframes celebrate {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

.celebrate {
    animation: celebrate 0.6s ease-out;
}

/* Barrierefreiheit: Fokus-Styles */
:focus-visible {
    outline: 3px solid var(--ui-accent);
    outline-offset: 2px;
}

/* Reduzierte Bewegung für Barrierefreiheit */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
