:root {
    --gf-gold: hsl(44, 94%, 56%);
    --gf-gold-light: hsl(46, 96%, 72%);
    --gf-gold-glow: hsla(44, 94%, 55%, 0.34);
    --gf-cyan: hsl(186, 88%, 52%);
    --gf-cyan-glow: hsla(186, 88%, 52%, 0.3);
    --gf-coral: hsl(8, 86%, 60%);
    --gf-turf: hsl(142, 46%, 34%);
    --gf-turf-light: hsl(138, 42%, 44%);
    --gf-bg-deep: hsl(196, 52%, 5%);
    --gf-bg-surface: hsl(196, 40%, 10%);
    --gf-text-primary: hsl(180, 24%, 95%);
    --gf-text-secondary: hsl(190, 16%, 70%);
    --gf-glass: rgba(6, 24, 30, 0.74);
    --gf-glass-border: rgba(120, 220, 220, 0.2);
    --gf-z-modal: 1000;
}

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

.hidden {
    display: none !important;
}

/* Site shell owns body background/layout; keep only game-specific resets */
body {
    font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
    color: var(--gf-text-primary);
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.gf-shell {
    position: relative;
    width: 100%;
    max-width: 940px;
    margin: 20px auto 36px;
    padding: 16px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(160deg, hsl(196, 40%, 13%), hsl(200, 48%, 7%));
    border: 1px solid rgba(120, 220, 220, 0.22);
    border-radius: 24px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55), 0 0 70px var(--gf-gold-glow);
    overflow: hidden;
}

/* ─── Topbar + HUD chips ─── */
.gf-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.gf-back-btn {
    display: inline-block;
    padding: 8px 14px;
    background: var(--gf-glass);
    border: 1px solid var(--gf-glass-border);
    border-radius: 10px;
    color: var(--gf-text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.gf-back-btn:hover {
    background: rgba(120, 220, 220, 0.14);
    border-color: rgba(120, 220, 220, 0.45);
}

.gf-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.gf-brand-logo {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    filter: drop-shadow(0 0 10px var(--gf-gold-glow));
}

.gf-brand-name {
    font-family: var(--font-heading, 'Montserrat', sans-serif);
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--gf-gold);
    text-shadow: 0 0 16px var(--gf-gold-glow);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gf-hud {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.gf-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 70px;
    padding: 6px 12px;
    background: var(--gf-glass);
    border: 1px solid var(--gf-glass-border);
    border-radius: 12px;
}

.gf-chip-best {
    border-color: rgba(251, 191, 36, 0.42);
}

.gf-chip-label {
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--gf-gold);
}

.gf-chip-value {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1;
    color: var(--gf-text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ─── Stage ─── */
.gf-stage {
    position: relative;
    width: 100%;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(120, 220, 220, 0.24);
    box-shadow: 0 0 50px rgba(60, 200, 210, 0.14), 0 24px 50px rgba(0, 0, 0, 0.5);
    background: var(--gf-bg-deep);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 800 / 520;
    touch-action: none;
    cursor: crosshair;
}

#gameCanvas:focus-visible {
    outline: 3px solid var(--gf-gold);
    outline-offset: -3px;
}

/* ─── Hole-out flash + act cards + toast ─── */
.gf-out {
    position: absolute;
    top: 34%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 44px;
    background: rgba(4, 18, 22, 0.88);
    border: 2px solid var(--gf-gold);
    border-radius: 18px;
    z-index: 22;
    pointer-events: none;
    box-shadow: 0 0 34px var(--gf-gold-glow);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: gfOutIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gf-out-label {
    font-size: clamp(1.1rem, 4.4vw, 1.8rem);
    font-weight: 900;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gf-gold-light);
    white-space: nowrap;
}

.gf-out-points {
    font-size: clamp(1.4rem, 5vw, 2.2rem);
    font-weight: 900;
    color: var(--gf-cyan);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 18px var(--gf-cyan-glow);
}

@keyframes gfOutIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.7);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.gf-act-banner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(3, 16, 20, 0.86);
    text-align: center;
    z-index: 30;
    pointer-events: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: gfActFade 2.5s forwards;
}

.gf-act-kicker {
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--gf-gold);
}

.gf-act-title {
    font-size: clamp(1.6rem, 6vw, 2.9rem);
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: linear-gradient(120deg, var(--gf-gold-light), var(--gf-cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gf-act-sub {
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gf-text-secondary);
}

@keyframes gfActFade {
    0% {
        opacity: 0;
        transform: scale(1.05);
    }

    14% {
        opacity: 1;
        transform: scale(1);
    }

    82% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(0.98);
    }
}

.gf-toast {
    position: absolute;
    left: 50%;
    bottom: 12%;
    transform: translateX(-50%);
    padding: 9px 20px;
    background: rgba(4, 18, 22, 0.94);
    border: 1px solid rgba(90, 200, 255, 0.5);
    border-radius: 999px;
    color: #9ad9ff;
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    z-index: 26;
    pointer-events: none;
    box-shadow: 0 0 26px rgba(90, 200, 255, 0.28);
    animation: gfToastIn 0.3s ease;
}

@keyframes gfToastIn {
    from {
        opacity: 0;
        transform: translate(-50%, 10px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* ─── Bottom bar ─── */
.gf-bottombar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.gf-hint {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gf-text-secondary);
}

.gf-club-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 13px;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.34);
    border-radius: 999px;
    font-size: 0.8rem;
}

.gf-club-label {
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gf-gold);
}

.gf-club-chip strong {
    font-weight: 800;
    color: var(--gf-text-primary);
}

.gf-act-label {
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gf-gold);
    padding: 5px 12px;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.32);
    border-radius: 999px;
}

/* ─── Overlays ─── */
.gf-overlay {
    position: fixed;
    /* The site header is fixed at z-index 3000: keep cards below it. */
    inset: max(var(--app-header-h, 72px), 56px) 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(3, 16, 20, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow-y: auto;
    z-index: var(--gf-z-modal);
    padding: 8px 16px max(8px, var(--safe-area-inset-bottom));
    cursor: default;
}

.gf-card {
    margin: auto;
    background: linear-gradient(150deg, rgba(10, 34, 40, 0.97), rgba(3, 16, 20, 0.99));
    border: 1px solid rgba(120, 220, 220, 0.26);
    border-radius: 22px;
    padding: 30px 30px;
    max-width: min(520px, 92vw);
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 0 70px rgba(60, 200, 210, 0.16);
    animation: gfCardIn 0.35s cubic-bezier(0.34, 1.5, 0.64, 1);
}

.gf-card:focus {
    outline: none;
}

@keyframes gfCardIn {
    from {
        opacity: 0;
        transform: scale(0.88) translateY(18px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.gf-card-logo {
    width: 88px;
    height: 88px;
    margin-bottom: 6px;
    filter: drop-shadow(0 0 18px var(--gf-gold-glow));
}

.gf-card h2 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 900;
    letter-spacing: -0.5px;
    background: linear-gradient(120deg, #fff, var(--gf-gold));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.gf-kicker {
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--gf-gold);
    margin-bottom: 8px;
}

.gf-kicker-story {
    color: var(--gf-cyan);
}

.gf-card > p,
.gf-story p,
.gf-hole-blurb {
    color: var(--gf-text-secondary);
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 14px;
    text-align: left;
}

.gf-card > p,
.gf-trophy-line {
    text-align: center;
}

.gf-trophy-line {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--gf-gold);
    text-shadow: 0 0 18px var(--gf-gold-glow);
    margin-bottom: 12px;
}

.gf-story {
    margin-bottom: 14px;
}

.gf-howto {
    background: rgba(120, 220, 220, 0.06);
    border: 1px solid rgba(120, 220, 220, 0.16);
    border-radius: 14px;
    padding: 14px 16px;
    text-align: left;
    margin-bottom: 16px;
}

.gf-howto summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--gf-cyan);
    cursor: pointer;
    list-style: none;
}

.gf-howto summary::-webkit-details-marker {
    display: none;
}

.gf-howto summary::after {
    content: "+";
    font-size: 1rem;
    line-height: 1;
    color: var(--gf-gold);
}

.gf-howto[open] summary {
    margin-bottom: 10px;
}

.gf-howto[open] summary::after {
    content: "\2212";
}

.gf-howto ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.gf-howto li {
    position: relative;
    padding-left: 16px;
    font-size: 0.84rem;
    line-height: 1.45;
    color: var(--gf-text-secondary);
}

.gf-howto li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gf-gold);
}

.gf-input-group {
    text-align: left;
    margin-bottom: 16px;
}

.gf-input-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--gf-text-secondary);
    margin-bottom: 6px;
}

.gf-input-group input {
    width: 100%;
    padding: 11px 14px;
    background: rgba(120, 220, 220, 0.08);
    border: 1px solid var(--gf-glass-border);
    border-radius: 10px;
    color: var(--gf-text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.gf-input-group input:focus {
    border-color: var(--gf-gold);
}

.gf-input-group input:focus-visible {
    outline: 2px solid var(--gf-gold);
    outline-offset: 2px;
}

.gf-hole-meta {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.gf-meta-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    padding: 7px 14px;
    background: var(--gf-glass);
    border: 1px solid var(--gf-glass-border);
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gf-gold);
}

.gf-meta-chip strong {
    font-size: 0.95rem;
    letter-spacing: 0;
    color: var(--gf-text-primary);
    font-variant-numeric: tabular-nums;
}

.gf-card-hole {
    max-width: min(460px, 94vw);
}

.gf-card-victory {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gf-card-victory .gf-card-body {
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
}

.gf-card-victory .gf-stats {
    margin-bottom: 4px;
}

.gf-card-actions {
    flex: 0 0 auto;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid rgba(120, 220, 220, 0.14);
}

.gf-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(120, 220, 220, 0.07);
    border: 1px solid rgba(120, 220, 220, 0.16);
    border-radius: 14px;
    padding: 12px 16px;
    margin-bottom: 18px;
    font-size: 0.92rem;
    color: var(--gf-text-secondary);
    font-variant-numeric: tabular-nums;
    text-align: left;
}

.gf-stats strong {
    color: var(--gf-gold);
    font-weight: 800;
}

/* ─── Buttons ─── */
.gf-btn-primary,
.gf-btn-secondary {
    display: block;
    width: 100%;
    padding: 13px 22px;
    border-radius: 14px;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    margin-top: 8px;
}

.gf-btn-primary {
    background: linear-gradient(135deg, var(--gf-gold), hsl(32, 95%, 52%));
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #15100a;
    box-shadow: 0 6px 24px var(--gf-gold-glow);
}

.gf-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px var(--gf-gold-glow);
}

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

.gf-btn-secondary {
    background: transparent;
    border: 1px solid var(--gf-glass-border);
    color: var(--gf-text-secondary);
}

.gf-btn-secondary:hover {
    border-color: var(--gf-cyan);
    color: var(--gf-text-primary);
}

:where(a, button, input, [tabindex]):focus-visible {
    outline: 3px solid var(--gf-cyan);
    outline-offset: 3px;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    /* _base.css resets body padding to an undefined --body-pad here, which
       would drop the shell behind the fixed .app-header. */
    body {
        padding-top: max(var(--app-header-h, 72px), 56px, var(--safe-area-inset-top));
        padding-left: max(0px, var(--safe-area-inset-left));
        padding-right: max(0px, var(--safe-area-inset-right));
        padding-bottom: max(0px, var(--safe-area-inset-bottom));
    }

    .gf-shell {
        max-width: 100%;
        margin: 8px auto 24px;
        padding: 12px 10px 14px;
        gap: 10px;
        border-radius: 18px;
    }

    .gf-topbar {
        gap: 8px;
    }

    .gf-back-btn {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    .gf-brand-logo {
        width: 28px;
        height: 28px;
    }

    .gf-brand-name {
        font-size: 0.92rem;
    }

    .gf-hud {
        gap: 5px;
        width: 100%;
        justify-content: space-between;
    }

    .gf-chip {
        min-width: 0;
        flex: 1;
        padding: 5px 4px;
        border-radius: 10px;
    }

    .gf-chip-label {
        font-size: 0.54rem;
        letter-spacing: 0.7px;
    }

    .gf-chip-value {
        font-size: 0.9rem;
    }

    .gf-stage {
        border-radius: 14px;
    }

    .gf-out {
        padding: 10px 24px;
    }

    .gf-toast {
        font-size: 0.7rem;
        padding: 7px 14px;
        max-width: 92%;
        white-space: normal;
        text-align: center;
    }

    .gf-hint {
        font-size: 0.72rem;
        width: 100%;
    }

    .gf-bottombar {
        gap: 6px;
    }

    .gf-club-chip,
    .gf-act-label {
        font-size: 0.7rem;
        padding: 4px 10px;
    }

    .gf-card {
        padding: 24px 18px;
        max-width: 96vw;
    }

    .gf-card h2 {
        font-size: 1.45rem;
    }

    .gf-card > p,
    .gf-story p,
    .gf-hole-blurb {
        font-size: 0.88rem;
    }
}

@media (max-width: 420px) {
    .gf-chip-label {
        font-size: 0.5rem;
        letter-spacing: 0.3px;
    }

    .gf-chip-value {
        font-size: 0.84rem;
    }

    .gf-card {
        padding: 20px 14px;
    }

    .gf-btn-primary,
    .gf-btn-secondary {
        font-size: 0.9rem;
        padding: 12px 16px;
    }

    .gf-brand-name {
        font-size: 0.84rem;
    }
}

/* The floating badge can cover the main action inside the dialogs. */
body:has(.gf-overlay:not(.hidden)) .achievements-button {
    visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .gf-out,
    .gf-act-banner,
    .gf-toast,
    .gf-card {
        animation: none;
    }

    .gf-btn-primary:hover {
        transform: none;
    }
}
