:root {
    --color-bg: #ffffff;
    --color-surface: #ffffff;
    --color-text: #14121f;
    --color-muted: #6b7280;
    --color-primary: rgb(124, 106, 247);
    --color-primary-dark: #5f4fd1;
    --color-primary-soft: #efebfe;
    --color-border: #e5e3ee;
    --color-danger: #b3261e;
    --color-danger-bg: #fbeceb;
    --color-success-bg: #efebfe;
    --color-green: #15803d;
    --color-green-soft: #e6f6ec;
    --radius: 10px;
    --radius-pill: 999px;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0f0e17;
        --color-surface: #17151f;
        --color-text: #f2f0fa;
        --color-muted: #9a94b3;
        --color-primary: rgb(151, 137, 250);
        --color-primary-dark: #7c6af7;
        --color-primary-soft: #241f38;
        --color-border: #2a2836;
        --color-danger: #ff8a80;
        --color-danger-bg: #3a2222;
        --color-success-bg: #241f38;
        --color-green: #4ade80;
        --color-green-soft: #16301f;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-mono);
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

a { color: var(--color-primary-dark); }

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.app-header .brand {
    color: var(--color-text);
    font-weight: 700;
    text-decoration: none;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}
.app-header .brand .bracket { color: var(--color-muted); }
.app-header .brand .accent { color: var(--color-primary); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.lang-link {
    color: var(--color-muted);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
}
.lang-link.active { color: var(--color-primary); }

.menu-toggle {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    touch-action: manipulation;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: none;
    outline: none;
    cursor: pointer;
    padding: 0;
}
.menu-toggle-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--color-text);
    border-radius: 1px;
}
.menu-toggle-dot {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-danger);
}

.app-nav {
    display: none;
    flex-direction: column;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.app-nav.open { display: flex; }

.app-nav a {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--color-border);
}
.app-nav a:last-child { border-bottom: none; }
.app-nav a:hover, .app-nav a:active { color: var(--color-primary); }

.badge {
    background: var(--color-danger);
    color: #fff;
    border-radius: var(--radius-pill);
    padding: 0.05rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
}

.app-main {
    max-width: 640px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: 3rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}
.flash-error { background: var(--color-danger-bg); color: var(--color-danger); }
.flash-info, .flash-success { background: var(--color-success-bg); color: var(--color-primary-dark); }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.tab-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn {
    touch-action: manipulation;
    flex: 1;
    text-align: center;
    padding: 0.6rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}
.tab-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

h1 { font-size: 1.4rem; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; letter-spacing: -0.01em; }
.text-center { text-align: center; }

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
    color: var(--color-muted);
}

input[type=text], input[type=password], input[type=number], select {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 1rem;
    background: var(--color-surface);
    color: var(--color-text);
    margin-bottom: 1rem;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.btn {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    touch-action: manipulation;
    display: inline-block;
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius);
    border: none;
    box-shadow: none;
    background: var(--color-primary);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    min-height: 48px;
}
.btn:active { background: var(--color-primary-dark); }
.btn-block { display: block; width: 100%; }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-danger { background: var(--color-danger); }
.btn-small { padding: 0.45rem 0.8rem; font-size: 0.85rem; min-height: auto; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.list li:last-child { border-bottom: none; }

.muted { color: var(--color-muted); font-size: 0.9rem; }

/* Pill chip, e.g. round status ("in progress" / "completed") */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    border-radius: var(--radius-pill);
    padding: 0.15rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
}
.chip::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.chip-active { background: var(--color-green-soft); color: var(--color-green); }

/* Stepper for score entry */
.stepper-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--color-border);
}
.stepper-row:last-child { border-bottom: none; }
.stepper-row.no-border { border-bottom: none; padding-bottom: 0.4rem; }

.hole-distance-field { padding-bottom: 0.9rem; border-bottom: 1px solid var(--color-border); }
.hole-distance-field label { margin-bottom: 0.2rem; }
.hole-distance-field input { margin-bottom: 0; }

.stepper-name { flex: 1; font-weight: 600; }

.stepper-controls {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.stepper-btn {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    touch-action: manipulation;
    width: 44px;
    height: 48px;
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    outline: none;
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    font-family: var(--font-mono);
    font-size: 1.3rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.stepper-btn:active { background: var(--color-primary); color: #fff; }

.stepper-value {
    width: 48px;
    margin-bottom: 0 !important;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    border: none;
    border-radius: 0 !important;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    -moz-appearance: textfield;
}
.stepper-value::-webkit-outer-spin-button,
.stepper-value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.hole-nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: var(--color-primary-soft);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
}

.hole-progress { flex: 1; text-align: center; }

.hole-number {
    display: block;
    color: var(--color-primary-dark);
    font-weight: 700;
    font-size: 1.3rem;
}

.hole-meta {
    display: block;
    color: var(--color-muted);
    font-size: 0.85rem;
}

.hole-back {
    touch-action: manipulation;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    text-decoration: none;
    font-size: 1.1rem;
}
.hole-back:hover { color: var(--color-primary); }
.hole-back-hidden { visibility: hidden; }

table.scorecard { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.scorecard th, table.scorecard td {
    padding: 0.4rem;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}
table.scorecard th:first-child, table.scorecard td:first-child { text-align: left; }
.scorecard-wrap { overflow-x: auto; }

.rank-1 { color: var(--color-primary-dark); font-weight: 700; }

.typeahead-results {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    margin-top: -0.75rem;
    margin-bottom: 1rem;
    overflow: hidden;
}
.typeahead-results button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.8rem;
    background: none;
    border: none;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    cursor: pointer;
    color: var(--color-text);
}
.typeahead-results button:active { background: var(--color-bg); }
