/* ============================================
   Cardie — Vintage Golf Club Aesthetic
   60s-70s retro · Paper texture · Serif headings
   ============================================ */

/* ---- Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@400;500;600;700&display=swap');

/* ---- Design Tokens ---- */
:root {
    /* Vintage palette */
    --green-deep: #2C4A2C;
    --green-fairway: #4A7A4A;
    --green-sage: #6B8F6B;
    --green-light: #8BAB7B;
    --green-pale: #C5D4B8;

    --cream: #F2EDE4;
    --cream-dark: #E8E0D2;
    --cream-warm: #EDE5D5;
    --paper: #FAF7F2;

    --terracotta: #C47A5A;
    --terracotta-light: #D4976E;
    --terracotta-dark: #A85A3A;

    --mustard: #C9A832;
    --mustard-light: #D4BC5A;
    --mustard-dark: #A88A20;

    --blue-lake: #4A7AB5;

    --charcoal: #2A2E28;
    --charcoal-light: #3E4A3C;
    --text: #2A2E28;
    --text-secondary: #5A6458;
    --text-tertiary: #8A9488;
    --text-on-dark: #F2EDE4;
    --text-on-dark-secondary: rgba(242, 237, 228, 0.7);

    --border: #D4CCBC;
    --border-light: #E4DED2;

    --error: #A83A2A;
    --error-surface: #F5E0DA;

    /* Score colors - vintage-muted */
    --hole-in-one: var(--mustard);
    --hole-in-one-bg: #F5EECA;
    --eagle: var(--blue-lake);
    --eagle-bg: #D8E4F0;
    --birdie: var(--green-fairway);
    --birdie-bg: #D0E0C8;
    --par-bg: transparent;
    --bogey-bg: #F0E8D0;
    --double-bogey-bg: #ECDCC4;
    --x-score-bg: #F0D4C8;
    --x-score-text: var(--terracotta-dark);

    /* Typography */
    --font-heading: 'DM Serif Display', 'Georgia', serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-3xl: clamp(2rem, 5vw + 0.5rem, 3rem);
    --text-4xl: clamp(2.5rem, 6vw + 0.5rem, 3.5rem);
    --leading-tight: 1.1;
    --leading-snug: 1.3;
    --leading-normal: 1.5;
    --leading-relaxed: 1.65;

    /* Spacing - 8px grid */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Radii - softer, vintage feel */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadows - warm, soft */
    --shadow-sm: 0 1px 3px rgba(42, 46, 40, 0.06);
    --shadow-md: 0 4px 12px rgba(42, 46, 40, 0.08);
    --shadow-lg: 0 8px 24px rgba(42, 46, 40, 0.1);

    /* Touch */
    --touch-min: 48px;

    /* Transitions */
    --duration-fast: 150ms;
    --duration-normal: 200ms;
    --duration-slow: 300ms;
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    background: var(--paper);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Paper texture overlay - applied to body */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* ---- Focus ---- */
:focus-visible {
    outline: 2px solid var(--green-fairway);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   Screens
   ============================================ */
.screen {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

.screen-content {
    padding: var(--space-5);
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
    position: relative;
    z-index: 2;
}

/* ============================================
   Screen Backgrounds — Vintage photos
   ============================================ */

/* Join / Spectate screen — aerial vintage course (08) */
#screen-join {
    position: relative;
    overflow: hidden;
}

#screen-join::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url('../Images/08.png') center center / cover no-repeat;
    z-index: 0;
}

#screen-join::after {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(
        160deg,
        rgba(250, 247, 242, 0.92) 0%,
        rgba(250, 247, 242, 0.85) 50%,
        rgba(232, 224, 210, 0.88) 100%
    );
    z-index: 1;
}

#screen-join > * {
    position: relative;
    z-index: 2;
}

/* Setup screen — colorful vintage chairs (01) */
#screen-setup {
    position: relative;
    overflow: hidden;
}

#screen-setup::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url('../Images/01.png') center center / cover no-repeat;
    z-index: 0;
}

#screen-setup::after {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(
        160deg,
        rgba(250, 247, 242, 0.92) 0%,
        rgba(250, 247, 242, 0.85) 50%,
        rgba(232, 224, 210, 0.88) 100%
    );
    z-index: 1;
}

#screen-setup > * {
    position: relative;
    z-index: 2;
}

/* Scorecard screen — cocktail illustration (03) */
#screen-scorecard {
    position: relative;
    background:
        url('../Images/03.png') center 60% / 50% no-repeat,
        var(--paper);
    background-attachment: fixed;
}

/* Subtle overlay so the illustration doesn't compete with data */
#tab-scorecard,
#tab-leaderboard {
    position: relative;
    background: rgba(250, 247, 242, 0.88);
}

/* ============================================
   Home Screen — Hero with vintage photo
   ============================================ */
.home-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--space-6) var(--space-6);
    padding-bottom: max(var(--space-8), env(safe-area-inset-bottom));
    text-align: center;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Hero background image */
.home-container::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url('../Images/04.png') center center / cover no-repeat;
    z-index: 0;
}

/* Gradient overlay for readability */
.home-container::after {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(42, 74, 44, 0.15) 0%,
        rgba(42, 74, 44, 0.3) 20%,
        rgba(42, 46, 40, 0.6) 45%,
        rgba(42, 46, 40, 0.85) 70%,
        rgba(42, 46, 40, 0.92) 100%
    );
    z-index: 1;
}

.home-container > * {
    position: relative;
    z-index: 2;
}

.home-container h1 {
    font-family: var(--font-heading);
    font-size: var(--text-4xl);
    font-weight: 400;
    color: var(--cream);
    letter-spacing: -0.01em;
    line-height: var(--leading-tight);
    margin-bottom: var(--space-1);
}

.home-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    width: 100%;
    max-width: 280px;
}

/* Entry animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

.home-container h1 {
    animation: fadeInUp 0.8s var(--ease-out) 0.2s both;
}

.landing-subtitle {
    animation: fadeInUp 0.8s var(--ease-out) 0.4s both;
}

.home-buttons .btn:nth-child(1) {
    animation: fadeInUp 0.6s var(--ease-out) 0.6s both;
}

.home-buttons .btn:nth-child(2) {
    animation: fadeInUp 0.6s var(--ease-out) 0.75s both;
}

.home-buttons .btn:nth-child(3) {
    animation: fadeInUp 0.6s var(--ease-out) 0.9s both;
}

/* ---- Home: Visitor state ---- */
.home-visitor {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 400px;
    animation: fadeInUp 0.8s var(--ease-out) 0.4s both;
}

.landing-subtitle {
    color: var(--text-on-dark-secondary);
    margin-bottom: var(--space-8);
    font-size: var(--text-md);
    font-weight: 400;
    line-height: var(--leading-relaxed);
    text-align: center;
}

/* Links row (Tinc un codi · Seguir en directe) */
.home-links-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
}

.home-links-sep {
    color: var(--text-on-dark-secondary);
    opacity: 0.4;
    font-size: var(--text-sm);
}

/* Register pitch section — right after CTAs */
.register-pitch {
    margin-top: var(--space-5);
    border-top: none;
    width: 100%;
    text-align: center;
    animation: fadeInUp 0.8s var(--ease-out) 1.4s both;
}

.register-pitch-text {
    color: var(--text-on-dark-secondary);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-4);
}

.register-pitch .btn {
    width: 100%;
    max-width: 280px;
}

.register-reassurance {
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--mustard);
    letter-spacing: 0.02em;
    font-weight: 500;
}

.register-privacy-link {
    color: var(--text-on-dark-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: 0.75;
    transition: opacity var(--duration-fast);
}

.register-privacy-link:hover {
    opacity: 1;
    color: var(--cream);
}

/* ---- Home: Dashboard state (logged in) ---- */
.home-dashboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 400px;
    margin-bottom: 15vh;
    animation: fadeInUp 0.8s var(--ease-out) 0.4s both;
}

.dashboard-greeting {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin-bottom: var(--space-8);
    color: var(--cream);
    font-size: var(--text-md);
    font-weight: 500;
}

.dash-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid rgba(242, 237, 228, 0.4);
}

.dashboard-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-top: var(--space-6);
    animation: fadeInUp 0.6s var(--ease-out) 0.8s both;
}

.dash-link {
    background: none;
    border: none;
    color: var(--cream);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    padding: var(--space-3) var(--space-3);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    transition: opacity var(--duration-fast);
    opacity: 0.8;
}

.dash-link:hover {
    opacity: 1;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.dash-link-sep {
    color: var(--text-on-dark-secondary);
    opacity: 0.4;
    font-size: var(--text-sm);
}

/* Subtle link button (used in both states) */
.btn-link-subtle {
    background: none;
    border: none;
    color: var(--text-on-dark-secondary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    padding: var(--space-3) var(--space-4);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    transition: color var(--duration-fast), opacity var(--duration-fast);
    opacity: 0.8;
}

.btn-link-subtle:hover {
    color: var(--cream);
    opacity: 1;
}

.home-dashboard .btn-link-subtle {
    margin-top: var(--space-6);
    animation: fadeInUp 0.6s var(--ease-out) 1s both;
}

/* Footer */
.home-footer {
    margin-top: var(--space-8);
    animation: fadeInUp 0.6s var(--ease-out) 1.8s both;
}

.home-footer-text {
    color: var(--text-on-dark-secondary);
    font-size: var(--text-xs);
    font-weight: 400;
    opacity: 0.55;
    letter-spacing: 0.03em;
}

/* Features — informative text lines, not clickable */
.home-visitor .landing-features {
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 1px solid rgba(250, 247, 242, 0.1);
    width: 100%;
    animation: fadeInUp 0.8s var(--ease-out) 1.4s both;
}

.landing-features {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    text-align: left;
}

.landing-feature {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background: none;
    border: none;
    padding: 0;
}

.landing-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    opacity: 0.85;
}

.landing-feature-text {
    font-size: var(--text-sm);
    color: var(--text-on-dark-secondary);
    line-height: var(--leading-normal);
    opacity: 0.85;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-min);
    padding: var(--space-3) var(--space-6);
    border: none;
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition:
        background var(--duration-normal) var(--ease-out),
        transform var(--duration-fast) var(--ease-out),
        box-shadow var(--duration-normal) var(--ease-out),
        border-color var(--duration-normal);
    -webkit-appearance: none;
    user-select: none;
    -webkit-user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

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

/* Primary - cream on dark green */
.btn-primary {
    background: var(--cream);
    color: var(--green-deep);
}

.btn-primary:hover:not(:disabled) {
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Secondary - translucent on hero */
.btn-secondary {
    background: rgba(242, 237, 228, 0.15);
    color: var(--cream);
    border: 1.5px solid rgba(242, 237, 228, 0.35);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(242, 237, 228, 0.25);
    border-color: rgba(242, 237, 228, 0.5);
}

/* Outline - translucent on hero */
.btn-outline {
    background: transparent;
    color: var(--text-on-dark-secondary);
    border: 1.5px solid rgba(242, 237, 228, 0.2);
}

.btn-outline:hover:not(:disabled) {
    color: var(--cream);
    border-color: rgba(242, 237, 228, 0.4);
}

/* Interior buttons (not on hero) */
.btn-interior-primary {
    background: var(--green-deep);
    color: var(--cream);
    border-radius: var(--radius-full);
}

.btn-interior-primary:hover:not(:disabled) {
    background: var(--charcoal-light);
}

.btn-interior-secondary {
    background: var(--cream-dark);
    color: var(--green-deep);
    border-radius: var(--radius-full);
}

.btn-small {
    min-height: 44px;
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
}

.btn-back {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    color: var(--green-fairway);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    padding: var(--space-2) 0;
    min-height: var(--touch-min);
    transition: opacity var(--duration-fast);
}

.btn-back:active { opacity: 0.5; }

/* ============================================
   Forms (interior screens)
   ============================================ */
.form-group {
    margin-bottom: var(--space-5);
    text-align: left;
}

.form-group label {
    display: block;
    font-family: var(--font-heading);
    font-weight: 400;
    font-size: var(--text-md);
    color: var(--text);
    margin-bottom: var(--space-2);
}

.form-group input,
.form-group select {
    width: 100%;
    min-height: var(--touch-min);
    padding: var(--space-3) var(--space-4);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text);
    background: var(--paper);
    -webkit-appearance: none;
    transition: border-color var(--duration-normal), box-shadow var(--duration-normal);
}

.form-group input::placeholder {
    color: var(--text-tertiary);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--green-fairway);
    box-shadow: 0 0 0 3px rgba(74, 122, 74, 0.12);
}

.error-msg {
    color: var(--error);
    font-size: var(--text-sm);
    font-weight: 500;
    margin-top: var(--space-3);
    min-height: 20px;
}

/* ============================================
   Interior screen headers
   ============================================ */
.screen-content h2 {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: 400;
    color: var(--text);
    margin-bottom: var(--space-6);
    letter-spacing: -0.01em;
}

/* ============================================
   Players List
   ============================================ */
#players-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.player-input-row {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.player-input-row input {
    flex: 1;
    min-height: var(--touch-min);
    padding: var(--space-2) var(--space-3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text);
    background: var(--paper);
    transition: border-color var(--duration-normal), box-shadow var(--duration-normal);
}

.player-input-row input::placeholder { color: var(--text-tertiary); }

.player-input-row input:focus {
    outline: none;
    border-color: var(--green-fairway);
    box-shadow: 0 0 0 3px rgba(74, 122, 74, 0.12);
}

.btn-remove-player {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast), background var(--duration-fast);
}

.btn-remove-player:hover {
    color: var(--error);
    background: var(--error-surface);
}

/* ============================================
   Scorecard Header
   ============================================ */
.scorecard-header {
    background: var(--green-deep);
    color: var(--cream);
    padding: var(--space-3) var(--space-4) 0;
    padding-top: max(var(--space-3), env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 10;
}

.scorecard-header-top {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-1);
}

.scorecard-header-top .btn-back {
    color: var(--text-on-dark-secondary);
    min-height: 40px;
    padding: var(--space-1) 0;
}

.scorecard-header-top .btn-back:active { opacity: 0.4; }

.scorecard-header-top h2 {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--cream);
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--text-xs);
    color: var(--text-on-dark-secondary);
    margin-bottom: var(--space-3);
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.game-code {
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    background: rgba(242, 237, 228, 0.1);
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast);
}

.game-code:active {
    background: rgba(242, 237, 228, 0.2);
}

/* ============================================
   Tabs
   ============================================ */
.scorecard-tabs {
    display: flex;
    align-items: center;
}

.btn-finish {
    margin-left: auto;
    padding: 8px 14px;
    min-height: 40px;
    background: var(--terracotta);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    margin-right: var(--space-2);
    transition: opacity 0.2s;
}

.btn-finish:active {
    opacity: 0.8;
}

.tab {
    flex: 1;
    min-height: var(--touch-min);
    padding: var(--space-2) var(--space-4);
    background: transparent;
    border: none;
    color: var(--text-on-dark-secondary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color var(--duration-normal), border-color var(--duration-normal);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tab.active {
    color: var(--cream);
    border-bottom-color: var(--mustard);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============================================
   Scorecard Table
   ============================================ */
.scorecard-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--paper);
}

.scorecard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
}

.scorecard-table th,
.scorecard-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.scorecard-table thead th {
    background: var(--cream-warm);
    font-weight: 600;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 2px solid var(--border);
}

.scorecard-table .hole-col {
    position: sticky;
    left: 0;
    background: var(--cream-warm);
    z-index: 1;
    font-weight: 700;
    min-width: 48px;
    font-size: var(--text-sm);
    color: var(--text);
}

.scorecard-table tbody .hole-col {
    background: var(--paper);
}

.scorecard-table .par-col {
    color: var(--text-tertiary);
    min-width: 36px;
    font-weight: 500;
}

.scorecard-table .player-col {
    min-width: 52px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    font-weight: 500;
    transition: background var(--duration-fast);
}

.scorecard-table .player-col:active {
    background: var(--cream-dark) !important;
}

/* Score cell styling - vintage muted */
.score-hole-in-one {
    background: var(--hole-in-one-bg) !important;
    color: var(--mustard-dark);
    font-weight: 700;
}

.score-eagle {
    background: var(--eagle-bg) !important;
    color: var(--eagle);
    font-weight: 700;
}

.score-birdie {
    background: var(--birdie-bg) !important;
    color: var(--birdie);
    font-weight: 700;
}

.score-par {
    background: var(--par-bg) !important;
}

.score-bogey {
    background: var(--bogey-bg) !important;
}

.score-double-bogey {
    background: var(--double-bogey-bg) !important;
}

.score-x {
    background: var(--x-score-bg) !important;
    color: var(--x-score-text);
    font-weight: 700;
}

/* Subtotal rows */
.scorecard-table .total-row td {
    font-weight: 700;
    background: var(--cream-warm);
    border-top: 2px solid var(--border);
    border-bottom: 2px solid var(--border);
}

.scorecard-table .total-row .hole-col {
    background: var(--cream-warm);
}

.scorecard-table .diff-row td {
    font-weight: 600;
    font-size: var(--text-sm);
}

.scorecard-table thead .player-name {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Diff colors */
.diff-under { color: var(--green-fairway); }
.diff-even { color: var(--text-tertiary); }
.diff-over { color: var(--terracotta-dark); }

/* ============================================
   Leaderboard
   ============================================ */
.leaderboard-list {
    padding: var(--space-3) var(--space-4);
}

.leaderboard-card {
    background: var(--paper);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    flex-wrap: wrap;
    transition: box-shadow var(--duration-normal), transform var(--duration-fast);
    border: 1px solid var(--border-light);
}

.leaderboard-card:active {
    transform: scale(0.99);
    box-shadow: none;
}

.leaderboard-pos {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: 400;
    color: var(--text-tertiary);
    min-width: 36px;
    text-align: center;
}

.leaderboard-pos.pos-1 { color: var(--mustard-dark); }
.leaderboard-pos.pos-2 { color: #8A8A8A; }
.leaderboard-pos.pos-3 { color: var(--terracotta); }

/* Leaderboard avatar */
.leaderboard-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
    flex-shrink: 0;
    border: 2px solid var(--border-light);
}

.leaderboard-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--cream);
}

.leaderboard-info {
    flex: 1;
    min-width: 0;
}

.leaderboard-name {
    font-weight: 700;
    font-size: var(--text-base);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-detail {
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    margin-top: 2px;
    font-weight: 500;
}

.leaderboard-score {
    text-align: right;
}

.leaderboard-total {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

.leaderboard-diff {
    font-size: var(--text-sm);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Expandable holes detail */
.leaderboard-holes {
    width: 100%;
    display: none;
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-light);
    margin-top: var(--space-3);
}

.leaderboard-holes.expanded {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.hole-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    border: 1px solid var(--border-light);
    font-variant-numeric: tabular-nums;
    background: var(--paper);
}

/* ============================================
   Modal — Bottom sheet
   ============================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(42, 46, 40, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.modal.active {
    display: flex;
    animation: fadeIn var(--duration-normal) var(--ease-out);
}

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

.modal-content {
    background: var(--paper);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: var(--space-6) var(--space-5);
    padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
    width: 100%;
    max-width: 420px;
    text-align: center;
    animation: slideUp var(--duration-slow) var(--ease-spring);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-content h3 {
    font-family: var(--font-heading);
    font-weight: 400;
    margin-bottom: var(--space-5);
    font-size: var(--text-xl);
}

.score-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}

.score-btn {
    min-height: 60px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 400;
    cursor: pointer;
    background: var(--paper);
    transition: transform var(--duration-fast) var(--ease-spring), border-color var(--duration-normal);
}

.score-btn:active { transform: scale(0.92); }

.score-btn.hole-in-one {
    border-color: var(--mustard);
    background: var(--hole-in-one-bg);
    color: var(--mustard-dark);
}

.score-btn.eagle {
    border-color: var(--blue-lake);
    background: var(--eagle-bg);
    color: var(--eagle);
}

.score-btn.par {
    border-color: var(--green-sage);
    background: var(--birdie-bg);
    color: var(--green-deep);
}

.score-btn.bogey {
    border-color: var(--border);
    background: var(--bogey-bg);
    color: var(--text-secondary);
}

.score-btn.double-bogey {
    border-color: var(--terracotta-light);
    background: var(--double-bogey-bg);
    color: var(--terracotta-dark);
}

.score-btn.x-score {
    border-color: var(--terracotta-dark);
    background: var(--x-score-bg);
    color: var(--x-score-text);
}

.score-btn.triple-bogey {
    border-color: var(--terracotta-light);
    background: var(--double-bogey-bg);
    color: var(--terracotta-dark);
}

.modal-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
}

.modal-actions .btn {
    flex: 1;
    border-radius: var(--radius-full);
}

.modal-actions .btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}

.modal-actions .btn-secondary {
    background: var(--cream-dark);
    color: var(--text);
    border: none;
}

/* ============================================
   Race — Horse race visualization
   ============================================ */
.race-container {
    padding: var(--space-4);
    padding-bottom: var(--space-8);
}

.race-header {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: var(--space-2);
    padding: 0 var(--space-1);
}

.race-par-legend {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-bottom: var(--space-4);
    padding: 0 var(--space-1);
}

.race-par-marker-legend {
    width: 16px;
    height: 2px;
    background: var(--terracotta);
    opacity: 0.6;
    border-top: 1px dashed var(--terracotta);
}

.race-track {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

/* Individual lane */
.race-lane {
    position: relative;
    background: var(--cream-warm);
    border-radius: var(--radius-lg);
    height: 56px;
    overflow: hidden;
    border: 1px solid var(--border-light);
    transition: height var(--duration-slow) var(--ease-out);
}

/* Top 4 lanes — amplified for impact */
.race-lane:nth-child(1) {
    height: 80px;
    border: 2px solid var(--mustard);
    box-shadow: 0 2px 12px rgba(201, 168, 50, 0.15);
}

.race-lane:nth-child(2) {
    height: 74px;
    border: 1.5px solid var(--border);
}

.race-lane:nth-child(3) {
    height: 68px;
    border: 1.5px solid var(--border);
}

.race-lane:nth-child(4) {
    height: 62px;
}

/* Bigger avatars for top lanes */
.race-lane:nth-child(1) .race-avatar { width: 52px; height: 52px; }
.race-lane:nth-child(2) .race-avatar { width: 46px; height: 46px; }
.race-lane:nth-child(3) .race-avatar { width: 42px; height: 42px; }
.race-lane:nth-child(4) .race-avatar { width: 40px; height: 40px; }

.race-lane:nth-child(1) .race-name { font-size: var(--text-base); }
.race-lane:nth-child(2) .race-name { font-size: var(--text-base); }

/* Leader crown */
.race-lane:nth-child(1)::after {
    content: '👑';
    position: absolute;
    top: 4px;
    right: 12px;
    font-size: 16px;
    z-index: 3;
    opacity: 0.8;
}

/* Grass stripes effect */
.race-lane:nth-child(odd) {
    background: var(--cream-dark);
}

/* Override bg for highlighted top lanes */
.race-lane:nth-child(1) {
    background: linear-gradient(90deg, #F5EECA 0%, var(--cream-warm) 40%);
}

/* Par reference line */
.race-par-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    border-left: 2px dashed var(--terracotta);
    opacity: 0.4;
    z-index: 1;
    transition: left 0.8s var(--ease-out);
}

/* Player runner (the "horse") */
.race-runner {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-3);
    transition: left 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 2;
}

/* Player avatar */
.race-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--cream);
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
    border: 2px solid rgba(255, 255, 255, 0.5);
}

/* Avatar with photo */
.race-avatar-photo {
    object-fit: cover;
    object-position: center 20%;
}

/* Avatar colors - cycle through vintage palette */
.race-avatar-0 { background: var(--green-deep); }
.race-avatar-1 { background: var(--terracotta); }
.race-avatar-2 { background: var(--mustard-dark); }
.race-avatar-3 { background: var(--blue-lake); }
.race-avatar-4 { background: var(--green-sage); }
.race-avatar-5 { background: var(--terracotta-dark); }
.race-avatar-6 { background: var(--charcoal); }
.race-avatar-7 { background: var(--green-fairway); }
.race-avatar-8 { background: #8B5E3C; }
.race-avatar-9 { background: #6B5B8A; }
.race-avatar-10 { background: #5A7A8A; }
.race-avatar-11 { background: #8A6B5A; }
.race-avatar-12 { background: var(--green-deep); }
.race-avatar-13 { background: var(--terracotta); }
.race-avatar-14 { background: var(--mustard-dark); }
.race-avatar-15 { background: var(--blue-lake); }

/* Runner info */
.race-info {
    display: flex;
    flex-direction: column;
    white-space: nowrap;
    min-width: 0;
}

.race-name {
    font-weight: 700;
    font-size: var(--text-sm);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.race-strokes {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* Diff badge */
.race-diff {
    font-size: var(--text-xs);
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.race-diff-under {
    background: var(--birdie-bg);
    color: var(--green-fairway);
}

.race-diff-even {
    background: var(--cream-dark);
    color: var(--text-secondary);
}

.race-diff-over {
    background: var(--x-score-bg);
    color: var(--terracotta-dark);
}

/* Bounce animation when score updates */
@keyframes runnerBounce {
    0% { transform: scale(1); }
    30% { transform: scale(1.05) translateX(3px); }
    60% { transform: scale(0.98); }
    100% { transform: scale(1); }
}

.race-runner.just-moved {
    animation: runnerBounce 0.5s var(--ease-spring);
}

/* Holes counter at bottom */
.race-holes-counter {
    text-align: center;
    margin-top: var(--space-5);
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    color: var(--text-secondary);
}

.race-holes-counter span {
    color: var(--text);
}

/* Race tab background override */
#tab-race {
    position: relative;
    background: rgba(250, 247, 242, 0.92);
    min-height: 60vh;
}

/* ============================================
   Empty state
   ============================================ */
.empty-state {
    text-align: center;
    color: var(--text-tertiary);
    padding: var(--space-16) var(--space-6);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    font-style: italic;
}

/* ============================================
   Utilities
   ============================================ */
.hidden {
    display: none !important;
}

/* Headings focusable for screen management (no visible outline) */
h1[tabindex], h2[tabindex] {
    outline: none;
}

/* Screen reader only — visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Responsive
   ============================================ */
@media (min-width: 768px) {
    .home-container h1 {
        font-size: 3rem;
    }

    .home-buttons {
        max-width: 320px;
    }

    .scorecard-table {
        font-size: var(--text-base);
    }

    .scorecard-table th,
    .scorecard-table td {
        padding: 12px 10px;
    }

    .leaderboard-list {
        max-width: 560px;
        margin: 0 auto;
    }

    /* Modal centered on tablet+ */
    .modal {
        align-items: center;
        padding: var(--space-4);
    }

    .modal-content {
        border-radius: var(--radius-xl);
        padding-bottom: var(--space-6);
    }

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

@media (min-width: 1024px) {
    .screen-content {
        max-width: 520px;
    }
}

/* ---- Mode Toggle (Stableford / Medalplay) ---- */
.mode-toggle {
    display: flex;
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
    background: var(--paper);
}

.mode-option {
    flex: 1;
    min-height: var(--touch-min);
    padding: var(--space-2) var(--space-4);
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--duration-normal), color var(--duration-normal);
    -webkit-tap-highlight-color: transparent;
}

.mode-option.active {
    background: var(--green-deep);
    color: var(--cream);
}

.mode-option:not(.active):active {
    background: var(--cream-dark);
}

/* ---- Players Roster ---- */
.players-roster {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: var(--space-3);
}

.roster-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-lg);
    border: 2px solid transparent;
    transition: all 0.2s ease;
    width: 72px;
    -webkit-tap-highlight-color: transparent;
}

.roster-player:active {
    transform: scale(0.95);
}

.roster-player.selected {
    border-color: var(--green-fairway);
    background: var(--green-pale);
}

.roster-player.selected .roster-avatar {
    box-shadow: 0 0 0 3px var(--green-fairway);
}

.roster-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    transition: box-shadow 0.2s ease;
}

.roster-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--cream);
    background: var(--green-deep);
}

.roster-name {
    font-family: var(--font-body);
    font-size: var(--text-xs);
    color: var(--text);
    text-align: center;
    font-weight: 500;
    line-height: 1.2;
}

.roster-player.selected .roster-name {
    color: var(--green-deep);
    font-weight: 700;
}

.roster-order {
    display: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--green-fairway);
    color: white;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-body);
    line-height: 20px;
    text-align: center;
    position: absolute;
    top: -4px;
    right: -4px;
}

.roster-player {
    position: relative;
}

.roster-player.selected .roster-order {
    display: block;
}

.add-custom-player {
    display: flex;
    gap: 8px;
    margin-bottom: var(--space-3);
}

.add-custom-player input {
    flex: 1;
}

.add-custom-player .btn {
    flex-shrink: 0;
    width: 44px;
    padding: 0;
    font-size: 20px;
}

.players-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 32px;
}

.selected-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--green-deep);
    color: var(--text-on-dark);
    padding: 4px 10px 4px 14px;
    border-radius: 20px;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 500;
    animation: fadeInUp 0.2s ease;
}

.selected-tag .tag-remove {
    cursor: pointer;
    opacity: 0.6;
    font-size: 16px;
    line-height: 1;
    padding: 2px;
    -webkit-tap-highlight-color: transparent;
}

.selected-tag .tag-remove:hover {
    opacity: 1;
}

/* ============================================
   Summary Screen — Post-game results
   ============================================ */
#screen-summary {
    position: relative;
    overflow: hidden;
}

#screen-summary::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url('../Images/03.png') center 60% / 50% no-repeat, var(--paper);
    z-index: 0;
}

#screen-summary::after {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(
        160deg,
        rgba(250, 247, 242, 0.94) 0%,
        rgba(250, 247, 242, 0.90) 50%,
        rgba(232, 224, 210, 0.92) 100%
    );
    z-index: 1;
}

.summary-container {
    position: relative;
    z-index: 2;
    max-width: 480px;
    margin: 0 auto;
    padding: var(--space-5);
    padding-bottom: max(var(--space-12), env(safe-area-inset-bottom));
}

/* Header */
.summary-header {
    text-align: center;
    padding: var(--space-8) 0 var(--space-6);
}

.summary-header h2 {
    font-family: var(--font-heading);
    font-size: var(--text-3xl);
    font-weight: 400;
    color: var(--green-deep);
    margin-bottom: var(--space-3);
    animation: fadeInUp 0.6s var(--ease-out) both;
}

.summary-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: 500;
    animation: fadeInUp 0.6s var(--ease-out) 0.15s both;
}

/* Podium */
.summary-podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
    padding: var(--space-4) 0;
    animation: fadeInUp 0.6s var(--ease-out) 0.3s both;
}

.podium-spot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    text-align: center;
    flex: 1;
    max-width: 120px;
}

.podium-pos {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    color: var(--text-tertiary);
    margin-bottom: var(--space-1);
}

.podium-gold .podium-pos {
    font-size: var(--text-2xl);
}

.summary-avatar {
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
    flex-shrink: 0;
    border: 3px solid var(--border-light);
    box-shadow: var(--shadow-md);
}

.summary-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-base);
    color: var(--cream);
}

/* Medal borders */
.podium-gold .summary-avatar {
    border-color: var(--mustard);
    box-shadow: 0 4px 16px rgba(201, 168, 50, 0.3);
}

.podium-silver .summary-avatar {
    border-color: #A0A0A0;
}

.podium-bronze .summary-avatar {
    border-color: var(--terracotta);
}

.podium-name {
    font-weight: 700;
    font-size: var(--text-base);
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.podium-gold .podium-name {
    font-size: var(--text-lg);
}

.podium-score {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    color: var(--text);
}

.podium-gold .podium-score {
    font-size: var(--text-xl);
}

.podium-diff {
    font-size: var(--text-sm);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.podium-gold {
    order: 2;
    transform: translateY(-8px);
}

.podium-silver {
    order: 1;
}

.podium-bronze {
    order: 3;
}

/* Rest of standings */
.summary-standings {
    margin-bottom: var(--space-6);
    animation: fadeInUp 0.6s var(--ease-out) 0.45s both;
}

/* Stats section */
.summary-stats {
    margin-bottom: var(--space-6);
    animation: fadeInUp 0.6s var(--ease-out) 0.6s both;
}

.summary-stats h3 {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 400;
    color: var(--green-deep);
    text-align: center;
    margin-bottom: var(--space-4);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-3);
}

.stat-card {
    background: var(--paper);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-emoji {
    font-size: 28px;
    margin-bottom: var(--space-2);
}

.stat-label {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.stat-value {
    font-weight: 700;
    font-size: var(--text-base);
    color: var(--text);
}

/* Action buttons */
.summary-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 280px;
    margin: 0 auto;
    padding-top: var(--space-4);
    animation: fadeInUp 0.6s var(--ease-out) 0.75s both;
}

/* Share button */
.btn-share {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-min);
    padding: var(--space-3) var(--space-6);
    border: none;
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    background: var(--mustard);
    color: var(--charcoal);
    transition: background var(--duration-normal), transform var(--duration-fast);
}

.btn-share:hover:not(:disabled) {
    background: var(--mustard-light);
}

.btn-share:active {
    transform: scale(0.97);
}

/* ============================================
   History Screen
   ============================================ */
#screen-history {
    position: relative;
    overflow: hidden;
}

#screen-history::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url('../Images/08.png') center center / cover no-repeat;
    z-index: 0;
}

#screen-history::after {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(
        160deg,
        rgba(250, 247, 242, 0.92) 0%,
        rgba(250, 247, 242, 0.85) 50%,
        rgba(232, 224, 210, 0.88) 100%
    );
    z-index: 1;
}

#screen-history > * {
    position: relative;
    z-index: 2;
}

/* History cards */
.history-card {
    background: var(--paper);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.history-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.history-card-info {
    flex: 1;
    min-width: 0;
}

.history-card-name {
    font-weight: 700;
    font-size: var(--text-base);
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-card-meta {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: 500;
    margin-top: 2px;
}

.btn-history-share {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--mustard);
    color: var(--charcoal);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--duration-fast), transform var(--duration-fast);
}

.btn-history-share:active {
    transform: scale(0.92);
    background: var(--mustard-light);
}

.history-winner {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.history-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
    flex-shrink: 0;
    border: 2px solid var(--border-light);
}

.history-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-xs);
    color: var(--cream);
    background: var(--green-deep);
}

.history-winner-name {
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--text);
}

.history-winner-score {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.history-card-players {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: 500;
}

.history-empty {
    text-align: center;
    padding: var(--space-16) var(--space-6);
    color: var(--text-tertiary);
}

.history-empty-icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
}

.history-empty p {
    font-size: var(--text-base);
    font-style: italic;
}

/* (Auth Bar legacy styles removed — replaced by visitor/dashboard pattern) */

/* ============================================
   Custom Course Configuration
   ============================================ */
.custom-course-config {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-3) 0;
}

.custom-course-config label {
    margin-bottom: 0 !important;
    font-size: var(--text-sm) !important;
    white-space: nowrap;
}

.custom-course-config select {
    width: auto;
    min-width: 120px;
}

.custom-pars-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
    margin-top: var(--space-2);
}

.custom-par-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.custom-par-item label {
    font-size: 11px !important;
    color: var(--text-tertiary) !important;
    margin-bottom: 0 !important;
    font-family: var(--font-body) !important;
    font-weight: 600 !important;
}

.custom-par-item select {
    width: 36px !important;
    min-height: 32px !important;
    padding: 2px !important;
    font-size: var(--text-xs) !important;
    text-align: center;
    border-radius: var(--radius-sm) !important;
}

.save-course-check {
    display: flex !important;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-body) !important;
    font-size: var(--text-sm) !important;
    color: var(--text-secondary) !important;
    margin-top: var(--space-3) !important;
    cursor: pointer;
}

.save-course-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--green-fairway);
}

@media (max-width: 480px) {
    .custom-pars-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* ============================================
   Claim Player Modal
   ============================================ */
.claim-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

.claim-player-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
    max-height: 300px;
    overflow-y: auto;
}

.claim-player-btn {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--paper);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: border-color var(--duration-normal), background var(--duration-fast);
    -webkit-appearance: none;
}

.claim-player-btn:hover {
    border-color: var(--green-fairway);
    background: var(--green-pale);
}

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

.claim-player-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.claim-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
    flex-shrink: 0;
    border: 2px solid var(--border-light);
}

.claim-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--cream);
    background: var(--green-deep);
}

.claim-player-name {
    flex: 1;
    text-align: left;
}

/* ============================================
   Friends Screen
   ============================================ */
#screen-friends {
    position: relative;
    overflow: hidden;
}

#screen-friends::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url('../Images/08.png') center center / cover no-repeat;
    z-index: 0;
}

#screen-friends::after {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(
        160deg,
        rgba(250, 247, 242, 0.92) 0%,
        rgba(250, 247, 242, 0.85) 50%,
        rgba(232, 224, 210, 0.88) 100%
    );
    z-index: 1;
}

#screen-friends > * {
    position: relative;
    z-index: 2;
}

/* My friend code card */
.my-code-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    background: var(--paper);
    border: 2px solid var(--mustard);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-5);
    text-align: center;
    box-shadow: 0 2px 12px rgba(201, 168, 50, 0.15);
}

.my-code-label {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.my-code-value {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    color: var(--green-deep);
    letter-spacing: 0.15em;
    cursor: pointer;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-md);
    transition: background var(--duration-fast);
}

.my-code-value:active {
    background: var(--cream-dark);
}

/* Friend search */
.friend-search {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.friend-search input {
    flex: 1;
    min-height: var(--touch-min);
    padding: var(--space-3) var(--space-4);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text);
    background: var(--paper);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.friend-search-result {
    min-height: 20px;
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.friend-search-found {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--paper);
    border: 1.5px solid var(--green-fairway);
    border-radius: var(--radius-lg);
}

.friend-found-name {
    flex: 1;
    font-weight: 700;
}

/* Friends list */
.friends-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.friend-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background: var(--paper);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow-sm);
}

.friend-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
    flex-shrink: 0;
    border: 2px solid var(--border-light);
}

.friend-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--cream);
    background: var(--green-deep);
}

.friend-info {
    flex: 1;
    min-width: 0;
}

.friend-name {
    font-weight: 700;
    font-size: var(--text-base);
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-code {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: 500;
    letter-spacing: 0.06em;
}

.btn-remove-friend {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.4rem;
    cursor: pointer;
    border-radius: 50%;
    transition: color var(--duration-fast), background var(--duration-fast);
    flex-shrink: 0;
}

.btn-remove-friend:hover {
    color: var(--error);
    background: var(--error-surface);
}

.friends-empty {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--text-tertiary);
}

.friends-empty-icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
}

.friends-empty p {
    font-size: var(--text-base);
    margin-bottom: var(--space-1);
}

.friends-empty-hint {
    font-size: var(--text-sm) !important;
    font-style: italic;
}

/* ============================================
   Summary — Add friends section
   ============================================ */
.summary-add-friends {
    margin-bottom: var(--space-6);
    animation: fadeInUp 0.6s var(--ease-out) 0.7s both;
}

.summary-add-friends h3 {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 400;
    color: var(--green-deep);
    text-align: center;
    margin-bottom: var(--space-4);
}

.add-friends-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.add-friend-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background: var(--paper);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow-sm);
}

.add-friend-name {
    flex: 1;
    font-weight: 700;
    font-size: var(--text-base);
}

.add-friend-btn.friend-added {
    background: var(--green-pale);
    color: var(--green-deep);
    border-color: var(--green-fairway);
}

/* ============================================
   Stats Screen
   ============================================ */
#screen-stats {
    position: relative;
    overflow: hidden;
}

#screen-stats::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url('../Images/01.png') center center / cover no-repeat;
    z-index: 0;
}

#screen-stats::after {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(
        160deg,
        rgba(250, 247, 242, 0.93) 0%,
        rgba(250, 247, 242, 0.88) 50%,
        rgba(232, 224, 210, 0.90) 100%
    );
    z-index: 1;
}

#screen-stats > * {
    position: relative;
    z-index: 2;
}

.stats-overview {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-6);
}

.stats-big-number {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    background: var(--green-deep);
    color: var(--cream);
    border-radius: var(--radius-xl);
    padding: var(--space-5) var(--space-8);
    box-shadow: var(--shadow-lg);
}

.stats-big-value {
    font-family: var(--font-heading);
    font-size: clamp(2.5rem, 8vw, 3.5rem);
    font-weight: 400;
    line-height: 1;
}

.stats-big-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    opacity: 0.7;
}

.stats-personal-grid {
    margin-bottom: var(--space-6);
}

.stat-detail {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-top: var(--space-1);
    font-style: italic;
}

/* Friends ranking section in stats */
.friends-ranking {
    margin-top: var(--space-6);
}

.friends-ranking h3 {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 400;
    color: var(--green-deep);
    text-align: center;
    margin-bottom: var(--space-4);
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--paper);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.ranking-table th {
    background: var(--cream-warm);
    padding: var(--space-3) var(--space-2);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    border-bottom: 2px solid var(--border);
}

.ranking-table td {
    padding: var(--space-3) var(--space-2);
    font-size: var(--text-sm);
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    font-variant-numeric: tabular-nums;
}

.ranking-table .ranking-name-cell {
    text-align: left;
    padding-left: var(--space-3);
    font-weight: 600;
}

.ranking-table .ranking-pos {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    color: var(--text-tertiary);
}

.ranking-table .ranking-pos-1 { color: var(--mustard-dark); }
.ranking-table .ranking-pos-2 { color: #8A8A8A; }
.ranking-table .ranking-pos-3 { color: var(--terracotta); }

.ranking-row-me {
    background: var(--green-pale) !important;
}

.ranking-row-me td {
    font-weight: 700;
}

.ranking-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
    vertical-align: middle;
    margin-right: var(--space-1);
    border: 1.5px solid var(--border-light);
}

.ranking-avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 11px;
    color: var(--cream);
    background: var(--green-deep);
    vertical-align: middle;
    margin-right: var(--space-1);
}

/* Head-to-head section */
.h2h-section {
    margin-top: var(--space-6);
}

.h2h-section h3 {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 400;
    color: var(--green-deep);
    text-align: center;
    margin-bottom: var(--space-4);
}

.h2h-select {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    justify-content: center;
    margin-bottom: var(--space-4);
}

.h2h-select select {
    min-height: 40px;
    padding: var(--space-2) var(--space-3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    background: var(--paper);
    color: var(--text);
}

.h2h-result {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-5);
    background: var(--paper);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-4);
}

.h2h-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    text-align: center;
    flex: 1;
}

.h2h-player-name {
    font-weight: 700;
    font-size: var(--text-sm);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.h2h-wins {
    font-family: var(--font-heading);
    font-size: var(--text-3xl);
    color: var(--green-deep);
    line-height: 1;
}

.h2h-vs {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    color: var(--text-tertiary);
}

.h2h-detail {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-align: center;
}

/* ============================================
   Photo Change Modal
   ============================================ */
.dash-avatar-editable {
    cursor: pointer;
    position: relative;
    transition: opacity var(--duration-fast), box-shadow var(--duration-fast);
}

.dash-avatar-editable:hover {
    opacity: 0.85;
    box-shadow: 0 0 0 2px var(--mustard);
}

.dash-avatar-editable:active {
    transform: scale(0.95);
}

.dash-avatar-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-xs);
    color: var(--cream);
    background: var(--green-fairway);
    border: 1.5px solid rgba(242, 237, 228, 0.4);
}

.change-photo-preview {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-5);
}

.change-photo-img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
    border: 3px solid var(--border);
    box-shadow: var(--shadow-md);
}

.change-photo-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    align-items: center;
    margin-bottom: var(--space-4);
}

.change-photo-label {
    cursor: pointer;
}

.change-photo-label input[type="file"] {
    display: none;
}

.change-photo-status {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-align: center;
    min-height: 20px;
    margin-bottom: var(--space-3);
}

/* ============================================
   Claim Modal — Self-join option
   ============================================ */
.claim-divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-3) 0;
    color: var(--text-tertiary);
    font-size: var(--text-sm);
}

.claim-divider::before,
.claim-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-light);
}

.claim-self-join-btn {
    border-style: dashed !important;
    border-color: var(--green-sage) !important;
}

.claim-self-join-btn:hover {
    border-color: var(--green-fairway) !important;
    background: var(--green-pale) !important;
}

/* ============================================
   Email Auth Modal
   ============================================ */
.register-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    width: 100%;
    max-width: 280px;
}

.email-auth-toggle {
    display: flex;
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-5);
}

.email-auth-tab {
    flex: 1;
    min-height: 40px;
    padding: var(--space-2) var(--space-3);
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--duration-normal), color var(--duration-normal);
}

.email-auth-tab.active {
    background: var(--green-deep);
    color: var(--cream);
}

.email-auth-form .form-group {
    margin-bottom: var(--space-3);
    text-align: left;
}

.email-auth-form .form-group label {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

.email-auth-form .form-group input {
    width: 100%;
    min-height: var(--touch-min);
    padding: var(--space-2) var(--space-3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text);
    background: var(--paper);
}

.email-auth-form .form-group input:focus {
    outline: none;
    border-color: var(--green-fairway);
    box-shadow: 0 0 0 3px rgba(74, 122, 74, 0.12);
}

.btn-link-forgot {
    display: inline-block;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    cursor: pointer;
    padding: var(--space-2) 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    margin-top: var(--space-2);
    transition: color var(--duration-fast);
}

.btn-link-forgot:hover {
    color: var(--text);
}
