:root {
    --primary: #00D26A;
    --primary-dark: #00B85E;
    --primary-light: #33D982;
    --secondary: #FF6B35;
    --accent: #7C3AED;
    --success: #10B981;
    --success-light: #34D399;
    --error: #EF4444;
    --error-light: #F87171;
    --warning: #F59E0B;
    --bg: #F0F4F8;
    --bg-gradient: linear-gradient(135deg, #F0F4F8 0%, #E2E8F0 100%);
    --card-bg: #FFFFFF;
    --text: #1E293B;
    --text-secondary: #64748B;
    --text-light: #94A3B8;
    --border: #E2E8F0;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.1);
    --shadow-primary: 0 8px 30px rgba(0, 210, 106, 0.3);
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    height: 100%;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 430px;
    margin: 0 auto;
    background: var(--bg-gradient);
    overflow: hidden;
    position: relative;
}

.header {
    background: linear-gradient(135deg, #1E293B 0%, #334155 100%);
    color: white;
    padding: 20px 24px;
    padding-top: max(24px, env(safe-area-inset-top));
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(0, 210, 106, 0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.header-content { position: relative; z-index: 1; }
.header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-sub { font-size: 13px; opacity: 0.8; margin-top: 4px; }
.header-actions {
    position: absolute;
    right: 16px;
    top: max(20px, env(safe-area-inset-top));
    display: flex;
    gap: 8px;
    z-index: 2;
}
.header-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    padding-bottom: 120px;
}

.hero-card {
    background: linear-gradient(135deg, #1E293B 0%, #334155 100%);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    color: white;
    position: relative;
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: var(--shadow-lg);
}
.hero-card::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(0, 210, 106, 0.22) 0%, transparent 70%);
    border-radius: 50%;
}
.hero-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: relative;
    z-index: 1;
}
.hero-label { font-size: 12px; opacity: 0.7; position: relative; }
.hero-add {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    box-shadow: var(--shadow-primary);
    flex-shrink: 0;
}
.hero-add:active { transform: scale(0.94); }
.hero-value { font-family: 'JetBrains Mono', monospace; font-size: 28px; font-weight: 700; position: relative; z-index: 1; }
.hero-row { display: flex; gap: 20px; margin-top: 12px; position: relative; z-index: 1; }
.hero-mini { flex: 1; }
.hero-mini span { display: block; font-size: 11px; opacity: 0.65; }
.hero-mini b { font-family: 'JetBrains Mono', monospace; font-size: 16px; }

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}
.card-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.record-item {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.record-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--primary);
}
.record-item.finished::before { background: var(--accent); }
.record-item:active { transform: scale(0.98); }
.record-header { display: flex; justify-content: space-between; align-items: center; }
.record-title { font-size: 16px; font-weight: 700; }
.record-meta { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
}
.badge-live { background: rgba(0,210,106,0.15); color: #059669; }
.badge-done { background: rgba(124,58,237,0.12); color: #6D28D9; }
.badge-out { background: rgba(148,163,184,0.2); color: var(--text-secondary); }

.empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 48px 20px;
}
.empty-icon { font-size: 40px; margin-bottom: 8px; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; font-weight: 500; }
.form-input {
    width: 100%;
    height: 52px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0 16px;
    font-size: 16px;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(0, 210, 106, 0.1);
}
.form-input.mono { font-family: 'JetBrains Mono', monospace; font-size: 20px; text-align: center; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-weight: 700;
    border: none;
    cursor: pointer;
}
.btn-primary {
    width: 100%;
    height: 56px;
    border-radius: var(--radius-md);
    font-size: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: var(--shadow-primary);
    margin-top: 8px;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.45; box-shadow: none; }
.btn-ghost {
    width: 100%;
    height: 48px;
    border-radius: var(--radius-md);
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    margin-top: 8px;
}
.btn-danger {
    width: 100%;
    height: 48px;
    border-radius: var(--radius-md);
    font-size: 15px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    margin-top: 8px;
}

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    border: 2px solid var(--border);
    background: white;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
}
.chip.selected {
    border-color: var(--primary);
    background: rgba(0, 210, 106, 0.12);
    color: #047857;
}
.chip.muted { opacity: 0.5; }

.player-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.player-row:last-child { border-bottom: none; }
.avatar {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 700; flex-shrink: 0;
}
.player-name { font-weight: 600; flex: 1; }
.player-sub { font-size: 12px; color: var(--text-secondary); }
.icon-btn {
    width: 36px; height: 36px; border: none; border-radius: 10px;
    background: var(--bg); color: var(--text-secondary);
}

.rank-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border);
}
.rank-row:last-child { border-bottom: none; }
.rank-no {
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--bg); display: flex; align-items: center; justify-content: center;
    font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 13px;
}
.rank-row.top .rank-no { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; }
.rank-info { flex: 1; min-width: 0; }
.rank-points { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 18px; }
.rank-points.pos { color: var(--success); }
.rank-points.neg { color: var(--error); }
.muted { color: var(--text-secondary); font-size: 12px; }

.stroke-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.stroke-row .player-name { flex: 1; min-width: 0; }
.stepper {
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
}
.stepper-btn {
    width: 40px;
    height: 48px;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
    font-family: inherit;
}
.stepper-btn:first-child { border-radius: 12px 0 0 12px; border-right: none; }
.stepper-btn:last-child { border-radius: 0 12px 12px 0; border-left: none; }
.stepper .form-input {
    width: 52px;
    height: 48px;
    border-radius: 0;
    padding: 0 4px;
    font-size: 18px;
}
.roster-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: none;
    background: var(--bg);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text);
    margin-bottom: 12px;
}
.roster-panel {
    background: var(--bg);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 14px;
}
.quick-add { display: flex; gap: 8px; align-items: center; }
.quick-add .form-input { flex: 1; height: 44px; }
.quick-add-btn {
    width: auto;
    height: 44px;
    margin-top: 0;
    padding: 0 16px;
    flex-shrink: 0;
}

.round-card { padding: 14px 16px 8px; }
.round-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.round-grid {
    display: grid;
    grid-template-columns: 1fr 48px 64px;
    column-gap: 22px;
    row-gap: 8px;
    font-size: 13px;
    align-items: center;
}
.round-grid .h { color: var(--text-light); font-size: 11px; }
.round-strokes {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-secondary);
    font-weight: 600;
}
.round-pts {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
}
.round-pts.pos { color: var(--success); }
.round-pts.neg { color: var(--error); }
.round-pts.zero { color: var(--accent); }

.nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    padding: 12px 8px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.08);
    border-radius: 24px 24px 0 0;
    z-index: 100;
}
.nav.hidden { display: none; }
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 16px;
}
.nav-item.active { background: linear-gradient(135deg, rgba(0, 210, 106, 0.1) 0%, rgba(0, 210, 106, 0.05) 100%); }
.nav-item.active .nav-icon, .nav-item.active .nav-label { color: var(--primary); }
.nav-item.active .nav-label { font-weight: 600; }
.nav-icon { width: 22px; height: 22px; color: var(--text-secondary); margin-bottom: 4px; }
.nav-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; }

.fab {
    position: fixed;
    bottom: max(100px, calc(env(safe-area-inset-bottom) + 80px));
    right: calc(50% - 215px + 20px);
    width: 60px; height: 60px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white; border: none;
    box-shadow: var(--shadow-primary);
    display: flex; align-items: center; justify-content: center;
    z-index: 90;
}
@media (max-width: 430px) { .fab { right: 20px; } }
.fab.hidden { display: none; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 120px;
    transform: translateX(-50%) translateY(20px);
    background: #1E293B;
    color: white;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    z-index: 200;
    transition: all 0.25s;
    max-width: 80%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-mask {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 180;
    display: flex; align-items: flex-end; justify-content: center;
}
.modal {
    width: 100%; max-width: 430px;
    background: white;
    border-radius: 24px 24px 0 0;
    padding: 20px 20px max(24px, env(safe-area-inset-bottom));
}
.modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal p { color: var(--text-secondary); margin-bottom: 16px; }

.section-hint { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; }
.actions-row { display: flex; gap: 8px; }
.actions-row .btn-primary, .actions-row .btn-ghost { margin-top: 0; }
.actions-row .btn-ghost { flex: 1; }
.actions-row .btn-primary { flex: 1.4; }
