/* ============================================================
   RESET & BASE
============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', sans-serif;
    background: linear-gradient(135deg, #1a472a 0%, #2d5016 50%, #1a472a 100%);
    min-height: 100vh;
    color: #f0e6d2;
}

/* ============================================================
   TOP NAV
============================================================ */
#topNav {
    display: flex;
    visibility: hidden;
    opacity: 0;
    position: sticky;
    top: 0;
    z-index: 500;
    background: linear-gradient(135deg, #4a3218 0%, #2d1f0e 100%);
    border-bottom: 2px solid #d4af37;
    padding: 0 15px;
    align-items: center;
    gap: 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
#topNav.visible { visibility: visible; opacity: 1; }

.nav-brand {
    display: flex;
    align-items: center;
    padding: 12px 15px 12px 0;
    flex-shrink: 0;
}
.nav-brand-en {
    font-size: 1.2em;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    white-space: nowrap;
}

/* Your Run card header with optional JP mode label */
.your-run-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 15px;
}
.your-run-header h2 { margin-bottom: 0; }
.jp-card-label {
    display: none;
    font-size: 1.4em;
    color: #ffd700;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.6);
    white-space: nowrap;
}
.jp-card-label.visible { display: block; }

.nav-tabs {
    display: flex;
    gap: 2px;
    flex: 1;
}

.nav-tab {
    padding: 14px 18px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    color: #b8860b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}
.nav-tab:hover { color: #ffd700; }
.nav-tab.active {
    color: #ffd700;
    border-bottom-color: #ffd700;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

/* JP Toggle */
.jp-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
.jp-label {
    font-size: 11px;
    font-weight: bold;
    color: #b8860b;
    text-transform: uppercase;
}
.jp-label.active { color: #ffd700; }

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    cursor: pointer;
}
.toggle-switch input { display: none; }
.toggle-track {
    width: 100%;
    height: 100%;
    background: #333;
    border-radius: 12px;
    border: 2px solid #654321;
    transition: background 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: #cc2200; border-color: #ff4400; }
.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #b8860b;
    border-radius: 50%;
    transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.toggle-switch input:checked ~ .toggle-thumb { left: 23px; background: #ff6633; }

.btn-logout {
    padding: 7px 14px;
    background: linear-gradient(135deg, #dc143c 0%, #8b0000 100%);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
}
.btn-logout:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,0.4); }

/* ============================================================
   AUTH MODAL
============================================================ */
#authModal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}
#authModal.active { display: flex; }

.auth-box {
    background: linear-gradient(135deg, #3a2a1a 0%, #1a1008 100%);
    border: 3px solid #d4af37;
    border-radius: 12px;
    padding: 35px 40px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

.auth-header {
    text-align: center;
    margin-bottom: 25px;
}
.auth-header h2 {
    font-size: 2em;
    color: #ffd700;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.8);
    margin-bottom: 5px;
}
.auth-header p { color: #b8860b; font-size: 0.95em; }

.auth-section { display: none; }
.auth-section.active { display: block; }

.auth-form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 15px;
}
.auth-form-group label { color: #d4af37; font-weight: bold; font-size: 0.9em; }
.auth-form-group input {
    padding: 11px 13px;
    border: 2px solid #654321;
    border-radius: 6px;
    background: rgba(245,222,179,0.9);
    color: #2d2d2d;
    font-size: 14px;
    font-weight: bold;
    width: 100%;
    transition: border-color 0.2s;
}
.auth-form-group input:focus { outline: none; border-color: #d4af37; }
.auth-form-group small { color: #d4af37; font-size: 0.8em; margin-top: 3px; }

.btn-auth-primary {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #228b22 0%, #006400 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    margin-top: 5px;
}
.btn-auth-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.4); }

.auth-link-row {
    text-align: center;
    margin-top: 15px;
    color: #b8860b;
    font-size: 0.9em;
}
.auth-link-row a { color: #ffd700; text-decoration: none; }
.auth-link-row a:hover { text-decoration: underline; }

.auth-msg {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-weight: bold;
    font-size: 0.9em;
    display: none;
}
.auth-msg.success { background: rgba(34,139,34,0.3); border: 2px solid #228b22; color: #90ee90; display: block; }
.auth-msg.error { background: rgba(139,0,0,0.3); border: 2px solid #8b0000; color: #ffcccb; display: block; }

#appMain {
    display: block;
    /* Reserve space for the sticky nav to prevent CLS when it becomes visible */
    min-height: 100vh;
}
.page-view { display: none; padding: 15px; }
.page-view.active { display: block; }

.page-container { max-width: 1400px; margin: 0 auto; }

/* ============================================================
   RUNS PAGE
============================================================ */
.runs-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 15px;
    margin-bottom: 20px;
}
.runs-column { display: flex; flex-direction: column; gap: 15px; }

/* Active players — full width stacked cards */
#activePlayers {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.active-player {
    background: rgba(0,0,0,0.3);
    border: 2px solid #654321;
    border-radius: 10px;
    overflow: hidden;
}

/* Player header bar — dark brown */
.active-player-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #1a3d1a 0%, #0d2010 100%);
    border-bottom: 2px solid #228b22;
    flex-wrap: wrap;
}
.active-player-name {
    color: #ffd700;
    font-weight: bold;
    font-size: 1.2em;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    flex: 1;
}
.active-player-elapsed {
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
    color: #00ff00;
    text-shadow: 0 0 8px rgba(0,255,0,0.5);
    margin-left: auto;
}

/* ── DESKTOP: horizontal table ── */
.ap-table-wrap {
    width: 100%;
    overflow-x: auto;
}
.active-splits-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;          /* size each column to its content */
}
.active-splits-table thead {
    background: linear-gradient(135deg, #1a3d1a 0%, #0d2010 100%);
}
.rr-player .active-splits-table thead {
    background: linear-gradient(135deg, #4a3218 0%, #2d1f0e 100%);
}
.ap-boss-th {
    padding: 8px 8px 6px;
    text-align: center;
    font-size: 0.7em;
    font-weight: bold;
    text-transform: uppercase;
    border-bottom: 2px solid rgba(139,115,85,0.4);
    vertical-align: bottom;
    color: #f0e6d2;
    white-space: nowrap;         /* one line per name, table scrolls if needed */
}
.ap-boss-label { line-height: 1.2; }

.ap-time-td {
    padding: 8px 8px 10px;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 0.78em;
    font-weight: bold;
    color: #555;
    white-space: nowrap;
}

/* Column state colours */
.ap-col-done.ap-boss-th    { color: #90ee90; }
.ap-col-done.ap-time-td    { color: #90ee90; background: rgba(34,139,34,0.1); }
.ap-col-current.ap-boss-th { color: #ff8c00; animation: col-pulse 2s ease-in-out infinite; }
.ap-col-current.ap-time-td { color: #ff8c00; background: rgba(255,140,0,0.15); animation: col-pulse 2s ease-in-out infinite; font-style: italic; font-family: inherit; }
.ap-col-pending.ap-boss-th { opacity: 0.4; }
.ap-col-pending.ap-time-td { opacity: 0.3; }

@keyframes col-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.55; }
}

.active-player-total {
    padding: 8px 14px;
    background: rgba(0,0,0,0.25);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85em;
    color: #b8860b;
    border-top: 1px solid #654321;
}
.active-player-total strong {
    font-family: 'Courier New', monospace;
    color: #ffd700;
    font-size: 1em;
}

/* ── MOBILE: stacked rows ── */
.ap-stacked { display: none; }

@media (max-width: 900px) {
    .ap-table-wrap { display: none; }
    .ap-stacked    { display: block; }
}
.ap-stacked-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 14px;
    border-bottom: 1px solid rgba(139,115,85,0.2);
    font-size: 0.9em;
}
.ap-stacked-row:last-child { border-bottom: none; }
.ap-stacked-boss {
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.85em;
    color: #f0e6d2;
}
.ap-stacked-time {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #555;
}
.ap-stacked-row.ap-col-done    .ap-stacked-boss { color: #90ee90; }
.ap-stacked-row.ap-col-done    .ap-stacked-time { color: #90ee90; }
.ap-stacked-row.ap-col-current .ap-stacked-boss { color: #ff8c00; }
.ap-stacked-row.ap-col-current .ap-stacked-time { color: #ff8c00; font-style: italic; }
.ap-stacked-row.ap-col-pending { opacity: 0.35; }
.card {
    background: rgba(139,115,85,0.3);
    border: 2px solid #8b7355;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.card.scrollable { overflow-y: auto; flex: 1; }
.card h2 {
    color: #ffd700;
    margin-bottom: 15px;
    font-size: 1.4em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.6);
}

.page-header {
    text-align: center;
    padding: 14px 15px;
    background: linear-gradient(135deg, #8b7355 0%, #654321 100%);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    margin-bottom: 15px;
    border: 2px solid #d4af37;
}
.page-header h1 {
    font-size: 1.8em;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}
.page-header .subtitle {
    color: #b8860b;
    font-size: 0.95em;
    margin-top: 4px;
    font-style: italic;
}

.timer-display {
    text-align: center;
    padding: 18px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    margin: 10px 0;
    border: 2px solid #2d5016;
}
.timer-text {
    font-size: 3em;
    font-weight: bold;
    color: #00ff00;
    text-shadow: 0 0 20px rgba(0,255,0,0.7);
    font-family: 'Courier New', monospace;
}

.controls { display: flex; flex-direction: column; gap: 8px; }

select, input[type="email"], input[type="text"], input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 2px solid #654321;
    border-radius: 6px;
    background: rgba(245,222,179,0.9);
    color: #2d2d2d;
    font-size: 14px;
    font-weight: bold;
}

/* Auto-filled email field gets a green border to signal it was pre-populated */
#emailInput.autofilled {
    border-color: #228b22;
    background: rgba(200,235,200,0.9);
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.4); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-start { background: linear-gradient(135deg, #228b22 0%, #006400 100%); color: white; }
.btn-quit  { background: linear-gradient(135deg, #dc143c 0%, #8b0000 100%); color: white; }
.btn-boss  { background: linear-gradient(135deg, #8b0000 0%, #660000 100%); color: white; width: 100%; margin-bottom: 8px; font-size: 15px; padding: 15px; }
.btn-boss:hover:not(:disabled) { background: linear-gradient(135deg, #b30000 0%, #8b0000 100%); }
.btn-undo  { background: linear-gradient(135deg, #ff8c00 0%, #ff4500 100%); color: white; }
.btn-admin { background: linear-gradient(135deg, #4169e1 0%, #0000cd 100%); color: white; padding: 8px 15px; font-size: 12px; }
.btn-delete { background: linear-gradient(135deg, #dc143c 0%, #8b0000 100%); color: white; padding: 6px 12px; font-size: 12px; }
.btn-edit   { background: linear-gradient(135deg, #ff8c00 0%, #ff6347 100%); color: white; padding: 6px 12px; font-size: 12px; }

.boss-grid { display: flex; flex-direction: column; gap: 8px; }





.section-divider { border-bottom: 2px solid #8b7355; margin: 15px 0; padding-bottom: 5px; color: #d4af37; font-weight: bold; }

.msg-bar { padding: 10px; border-radius: 6px; margin-bottom: 10px; font-weight: bold; font-size: 0.9em; }
.msg-bar.success { background: rgba(34,139,34,0.3); border: 2px solid #228b22; color: #90ee90; }
.msg-bar.error   { background: rgba(139,0,0,0.3);  border: 2px solid #8b0000; color: #ffcccb; }

.year-badge { background: #654321; padding: 2px 8px; border-radius: 8px; font-size: 0.8em; border: 1px solid #8b7355; margin-left: 5px; }
.year-badge-mini { background: #b85e00; } /* #ff8c00 → darker orange, white contrast ~5.1:1 */
.year-badge-full { background: #1a3a9e; } /* #4169e1 → darker blue, white contrast ~5.4:1 */

/* Admin / run list utility classes */
.text-empty { text-align: center; color: #888; }
.locked-icon { color: #888; font-size: 0.85em; font-style: italic; }
.run-type-label { font-weight: bold; }
.run-status { font-weight: bold; }
.run-status-completed  { color: #90ee90; }
.run-status-inprogress { color: #ff8c00; }
.run-status-dnf        { color: #ff6b6b; }

/* Recent results card hidden by default via CSS, not inline style */
#recentResultsCard { display: none; }
#recentResultsCard.visible { display: block; }

/* Admin */
.admin-section { margin-top: 20px; display: none; padding-bottom: 40px; }
.admin-section.visible { display: block; }
.admin-panel   { background: rgba(65,105,225,0.2); border: 2px solid #4169e1; padding: 0; overflow: hidden; }

.admin-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(65,105,225,0.25);
    border: none;
    color: #87ceeb;
    font-size: 1.3em;
    font-weight: bold;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
    border-radius: 0;
}
.admin-toggle:hover { background: rgba(65,105,225,0.4); }
.admin-toggle-arrow {
    font-size: 0.75em;
    transition: transform 0.25s;
    color: #4169e1;
}
.admin-toggle[aria-expanded="true"] .admin-toggle-arrow { transform: rotate(180deg); }

.admin-body { display: none; padding: 20px; }
.admin-body.open { display: block; }

.admin-tabs    { display: flex; gap: 10px; margin-bottom: 15px; }
.admin-tab     { padding: 10px 20px; background: rgba(101,67,33,0.5); border: 2px solid #8b7355; border-radius: 6px; cursor: pointer; font-weight: bold; color: #d4af37; transition: all 0.2s; }
.admin-tab.active { background: rgba(65,105,225,0.4); border-color: #4169e1; color: #87ceeb; }
.admin-tab:hover  { transform: translateY(-2px); }
.admin-content    { display: none; }
.admin-content.active { display: block; }
.admin-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { color: #d4af37; font-weight: bold; font-size: 0.9em; }
.user-list-item, .run-list-item {
    background: rgba(101,67,33,0.4); padding: 12px; border-radius: 6px; margin-bottom: 8px;
    display: flex; justify-content: space-between; align-items: center; border-left: 3px solid #ffd700;
}
.user-info, .run-info { flex: 1; }
.user-name, .run-user  { color: #ffd700; font-weight: bold; }
.user-email, .run-details { color: #d4af37; font-size: 0.9em; margin-top: 4px; }
.user-role { display: inline-block; background: #654321; padding: 2px 8px; border-radius: 4px; font-size: 0.8em; margin-top: 4px; }
.admin-badge { background: #4169e1; color: white; }
.user-actions, .run-actions { display: flex; gap: 8px; }

/* ============================================================
   MODALS (run-page confirmations)
============================================================ */
.modal {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.8); z-index: 1000;
    justify-content: center; align-items: center;
}
.modal.active { display: flex; }
.modal-content {
    background: linear-gradient(135deg, #8b7355 0%, #654321 100%);
    padding: 30px; border-radius: 10px; border: 2px solid #d4af37;
    max-width: 500px; width: 90%;
}
.modal-header { color: #ffd700; font-size: 1.5em; margin-bottom: 20px; font-weight: bold; }
.modal-body   { color: #f0e6d2; font-size: 1.1em; margin-bottom: 20px; line-height: 1.6; }
.modal-buttons { display: flex; gap: 10px; margin-top: 20px; }
.modal-buttons .btn { flex: 1; }

/* ============================================================
   ACTIVE PLAYERS — place badge, behind/leading labels
============================================================ */
.ap-place {
    font-size: 1.4em;
    min-width: 32px;
    text-align: center;
}
.ap-header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    margin-left: auto;
}
.ap-leading {
    font-size: 0.75em;
    font-weight: bold;
    color: #ffd700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ap-behind {
    font-size: 0.75em;
    font-weight: bold;
    color: #ff6b6b;
    font-family: 'Courier New', monospace;
}
/* Completed run cards get a subtle green tint */
/* Completed run cards — dark brown to distinguish from active */
.rr-player { border-color: #8b7355; }
.rr-player .active-player-header { background: linear-gradient(135deg, #4a3218 0%, #2d1f0e 100%); border-bottom-color: #8b7355; }

.no-data { text-align: center; padding: 30px; color: #888; font-size: 1em; font-style: italic; }
.loading { text-align: center; padding: 30px; color: #b8860b; font-size: 1em; }

/* ============================================================
   RECORDS PAGE
============================================================ */
.rec-section {
    background: rgba(139,115,85,0.3); border: 2px solid #8b7355; border-radius: 10px;
    padding: 25px; box-shadow: 0 4px 16px rgba(0,0,0,0.3); margin-bottom: 25px; overflow-x: auto;
}
.rec-section-title {
    font-size: 1.8em; color: #ffd700; text-shadow: 2px 2px 4px rgba(0,0,0,0.6);
    margin-bottom: 20px; text-align: center; text-transform: uppercase;
    border-bottom: 2px solid #d4af37; padding-bottom: 12px;
}
.category-header {
    background: linear-gradient(135deg, #2d5016 0%, #1a472a 100%);
    color: #ffd700; padding: 13px; font-size: 1.2em; font-weight: bold;
    text-align: center; border-radius: 8px; margin: 20px 0 10px 0;
    border: 2px solid #654321; text-transform: uppercase; letter-spacing: 1px;
}
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px 0; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; margin-bottom: 15px; background: rgba(0,0,0,0.3); border-radius: 8px; table-layout: auto; }
thead { background: linear-gradient(135deg, #654321 0%, #4a3218 100%); }
th { padding: 9px 6px; text-align: center; color: #ffd700; font-weight: bold; text-transform: uppercase; font-size: 0.7em; border-bottom: 2px solid #8b7355; line-height: 1.3; word-wrap: break-word; vertical-align: middle; }
td { padding: 9px 6px; border-bottom: 1px solid rgba(139,115,85,0.3); color: #f0e6d2; font-size: 0.8em; line-height: 1.4; text-align: center; vertical-align: middle; }
td:first-child { text-align: left; font-weight: bold; }
th:first-child { text-align: left; }
tbody tr { transition: background 0.3s; }
tbody tr:nth-child(even) { background: rgba(0,0,0,0.15); }
tbody tr:hover { background: rgba(255,215,0,0.1); }
.wide-table td:first-child { position: sticky; left: 0; background: rgba(101,67,33,0.98); z-index: 10; box-shadow: 2px 0 5px rgba(0,0,0,0.2); }
.wide-table th:first-child { position: sticky; left: 0; background: rgba(74,50,24,0.98); z-index: 11; box-shadow: 2px 0 5px rgba(0,0,0,0.3); }
.wide-table tbody tr:nth-child(even) td:first-child { background: rgba(90,60,30,0.98); }
.wide-table tbody tr:hover td:first-child { background: rgba(101,67,33,1); }
.best-time { background: rgba(255,215,0,0.2); font-weight: bold; }
.dnf { color: #ff6b6b; font-style: italic; }
.rank-1-cell { color: #ffd700; font-weight: bold; }
.rank-2-cell { color: #c0c0c0; font-weight: bold; }
.rank-3-cell { color: #cd7f32; font-weight: bold; }
.time-cell { font-family: 'Courier New', monospace; font-weight: bold; color: #90ee90; }
.date-cell { color: #b8860b; font-size: 0.9em; }
.best-possible-cell { background: rgba(212,175,55,0.15); color: #ffd700 !important; font-weight: bold; font-style: italic; }

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 1200px) {
    .runs-layout { grid-template-columns: 1fr; }
    .card.scrollable { height: auto; max-height: 400px; }
    .timer-text { font-size: 2em; }
}
@media (max-width: 768px) {
    .page-view { padding: 8px; }
    .page-header h1 { font-size: 1.3em; }
    .nav-tab { padding: 12px 10px; font-size: 11px; }
    .jp-label { display: none; }
    .leader-card { flex-direction: column; gap: 10px; padding: 10px; }
    .leader-stats { width: 100%; text-align: left; }
    .race-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    th { font-size: 0.6em; padding: 7px 3px; }
    td { font-size: 0.7em; padding: 7px 3px; }
    .rec-section { padding: 12px; }
    /* Records: smaller text on mobile so tables fit */
    .rec-section-title { font-size: 1.2em; }
    .category-header { font-size: 0.95em; padding: 9px; }
    .date-cell { font-size: 0.75em; }
    .date-cell { font-size: 0.65em; white-space: nowrap; }

    /* Boss card: hide non-active buttons, show only next boss */
    .card.scrollable { height: auto; max-height: none; }
    .btn-boss.mobile-hidden { display: none; }
    .btn-boss { padding: 12px; font-size: 14px; margin-bottom: 0; }

    /* Compact active player cards so 2 fit on screen */
    .active-player { border-radius: 8px; }
    .active-player-header { padding: 8px 12px; gap: 6px; }
    .active-player-name { font-size: 1em; }
    .active-player-elapsed { font-size: 0.9em; }
    .ap-place { font-size: 1.1em; min-width: 24px; }
    .ap-leading, .ap-behind { font-size: 0.7em; }
    .active-player-total { padding: 5px 12px; font-size: 0.78em; }
    .year-badge { font-size: 0.7em; padding: 1px 5px; }

    /* Active players card: don't fix height, scroll naturally */
    #activePlayers { gap: 8px; }
}

/* ============================================================
   UTILITY CLASSES (replaces remaining inline styles)
============================================================ */
.auth-hint-text {
    color: #f0e6d2;
    margin-bottom: 16px;
    text-align: center;
    font-size: 0.95em;
}
.btn-undo-full {
    width: 100%;
    margin-top: 5px;
}
.no-runs-placeholder {
    text-align: center;
    color: #888;
    padding: 20px;
}
.admin-add-heading {
    color: #87ceeb;
    margin-bottom: 10px;
}
.filter-row {
    margin-bottom: 15px;
}
.filter-label {
    color: #d4af37;
    font-weight: bold;
    display: block;
    margin-bottom: 10px;
}
.filter-selects {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.filter-select { width: auto; }
.dnf-highlight { color: #ff6b6b; }
.resume-warning { color: #ff8c00; font-size: 0.9em; }
.live-indicator {
    position: fixed;
    bottom: 15px;
    right: 15px;
    background: rgba(139, 115, 85, 0.9);
    padding: 8px 14px;
    border-radius: 20px;
    border: 2px solid #654321;
    font-size: 0.8em;
    color: #d4af37;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Records page additions */
.wins-cell {
    font-weight: bold;
    color: #ffd700;
}
.rec-stats-mini-header {
    margin-top: 30px;
}
.rec-mini-year-header {
    margin-top: 40px;
}
.rec-year-heading {
    color: #ffd700;
    margin: 20px 0 10px 0;
    font-size: 1.2em;
}

/* ============================================================
   PLAYER PROFILE MODAL
============================================================ */

/* ============================================================
   PLAYER PROFILE MODAL
============================================================ */
.player-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.88);
    z-index: 3000;
    justify-content: center;
    align-items: flex-start;
    padding: 20px 12px;
    overflow-y: auto;
    box-sizing: border-box;
}
.player-modal-overlay.active { display: flex; }

.player-modal-box {
    background: linear-gradient(160deg, #1e3010 0%, #0d1a08 100%);
    border: 2px solid #d4af37;
    border-radius: 14px;
    width: 100%;
    max-width: 860px;
    max-height: calc(100vh - 40px);
    padding: 28px 28px 36px;
    position: relative;
    box-shadow: 0 24px 80px rgba(0,0,0,0.8);
    animation: modal-in 0.2s ease-out;
    box-sizing: border-box;
    min-width: 0;
    overflow-y: auto;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.player-modal-close {
    position: absolute;
    top: 14px; right: 16px;
    background: none;
    border: none;
    color: #8b7355;
    font-size: 1.4em;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s;
}
.player-modal-close:hover { color: #ffd700; }
/* Modal header layout (name/subtitle set via JS IDs) */
.player-modal-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 2px solid #2d5016;
    padding-right: 36px; /* room for close button */
}
.player-modal-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #654321 0%, #2d1f0e 100%);
    border: 3px solid #d4af37;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 1.8em;
    line-height: 1;
}
.player-modal-name {
    font-size: 1.8em;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.8);
    margin-bottom: 4px;
}
.player-modal-subtitle { color: #b8860b; font-size: 0.9em; }


/* Header */
.pm-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 2px solid #2d5016;
}
.pm-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #654321 0%, #2d1f0e 100%);
    border: 3px solid #d4af37;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8em;
    flex-shrink: 0;
}
.pm-title h2 {
    font-size: 1.8em;
    color: #ffd700;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.8);
    margin-bottom: 4px;
}
.pm-title p { color: #b8860b; font-size: 0.9em; }

/* Stat cards row */
.pm-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 28px;
}
.pm-stat {
    background: rgba(0,0,0,0.35);
    border: 1px solid #2d5016;
    border-radius: 10px;
    padding: 12px 8px;
    text-align: center;
    min-width: 0;
}
.pm-stat-value {
    font-size: 1.3em;
    font-weight: bold;
    color: #ffd700;
    font-family: 'Courier New', monospace;
    display: block;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pm-stat-label {
    font-size: 0.68em;
    color: #8b7355;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Section headings */
.pm-section {
    margin-bottom: 26px;
}
.pm-section-title {
    font-size: 1em;
    font-weight: bold;
    color: #d4af37;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #2d5016;
}

/* Yearly progression */
.pm-year-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pm-year-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.25);
    border-radius: 8px;
    padding: 10px 12px;
    border-left: 4px solid #2d5016;
    min-width: 0;
}
.pm-year-row.is-pb { border-left-color: #ffd700; background: rgba(255,215,0,0.06); }
.pm-pb-tag {
    font-size: 0.65em;
    font-weight: bold;
    color: #ffd700;
    background: rgba(255,215,0,0.15);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #d4af37;
    white-space: nowrap;
    flex-shrink: 0;
}
.pm-year-badge {
    background: #2d5016;
    color: #ffd700;
    font-weight: bold;
    font-size: 0.85em;
    padding: 2px 8px;
    border-radius: 5px;
    min-width: 44px;
    text-align: center;
    flex-shrink: 0;
}
.pm-year-type {
    font-size: 0.75em;
    color: #8b7355;
    min-width: 36px;
    flex-shrink: 0;
}
.pm-year-time {
    font-family: 'Courier New', monospace;
    font-size: 1.05em;
    font-weight: bold;
    color: #90ee90;
    flex-shrink: 0;
}
.pm-year-place {
    font-size: 0.85em;
    flex-shrink: 0;
}
.pm-year-dnf { color: #ff6b6b; font-style: italic; font-size: 0.9em; }

/* Bar track for progression */
.pm-bar-wrap {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
    min-width: 30px;
}
.pm-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #228b22, #90ee90);
    transition: width 0.4s ease;
}

/* Boss PB grid */
.pm-boss-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}
.pm-boss-card {
    background: rgba(0,0,0,0.3);
    border: 1px solid #2d5016;
    border-radius: 8px;
    padding: 10px 12px;
}
.pm-boss-name {
    font-size: 0.72em;
    color: #8b7355;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.pm-boss-time {
    font-family: 'Courier New', monospace;
    font-size: 1em;
    font-weight: bold;
    color: #90ee90;
}
.pm-boss-year {
    font-size: 0.7em;
    color: #654321;
    margin-top: 2px;
}

/* Top-3 finishes */
.pm-top3-list { display: flex; flex-direction: column; gap: 6px; }
.pm-top3-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    background: rgba(0,0,0,0.25);
    border-radius: 7px;
    font-size: 0.88em;
}
.pm-top3-place { font-size: 1.3em; min-width: 30px; }
.pm-top3-year { color: #d4af37; font-weight: bold; min-width: 36px; }
.pm-top3-type { color: #8b7355; font-size: 0.85em; min-width: 36px; }
.pm-top3-time { font-family: 'Courier New', monospace; color: #90ee90; font-weight: bold; }
.pm-top3-vs { flex: 1; text-align: right; color: #654321; font-size: 0.8em; }

/* Clickable player names in tables */
.player-name-link {
    cursor: pointer;
    color: inherit;
}
.player-name-link:hover { color: #ffd700; text-decoration: underline; }

.boss-name-link {
    cursor: pointer;
    color: inherit;
}
.boss-name-link:hover { color: #ffd700; text-decoration: underline; }
    cursor: pointer;
    color: #ffd700;
    text-decoration: none;
    border-bottom: 1px dashed #654321;
    transition: color 0.15s, border-color 0.15s;
}
.player-name-link:hover {
    color: #fff;
    border-bottom-color: #ffd700;
}

@media (max-width: 768px) {
    .player-modal-overlay { padding: 10px 8px; }
    .player-modal-box { padding: 16px 14px 24px; }
    .player-modal-header { gap: 10px; }
    .player-modal-avatar { width: 44px; height: 44px; font-size: 1.3em; }
    .player-modal-name { font-size: 1.3em; }
    .pm-stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .pm-stat-value { font-size: 1.1em; }
    .pm-stat { padding: 10px 6px; }
    .pm-year-time { font-size: 0.9em; }
    .pm-year-badge { min-width: 36px; font-size: 0.78em; padding: 2px 5px; }
    .pm-section-title { font-size: 0.9em; }
    .pm-boss-grid { grid-template-columns: repeat(2, 1fr); }
    .pm-top3-row { gap: 8px; flex-wrap: wrap; }
    .pm-stats-row { grid-template-columns: repeat(3, 1fr); }
    .pm-boss-grid { grid-template-columns: repeat(2, 1fr); }
}
