:root {

    /* Core Button Styles */
    .btn {
        padding: 0.8rem 1.5rem;
        border-radius: 8px;
        border: none;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        display: inline-block;
        text-align: center;
    }

    .btn-primary {
        background: var(--accent-color) !important;
        color: white !important;
        box-shadow: 0 4px 6px rgba(0, 137, 123, 0.3);
    }

    .btn-primary:hover {
        background: #00695c !important;
        transform: translateY(-1px);
        box-shadow: 0 6px 12px rgba(0, 137, 123, 0.4);
    }

    .btn-secondary {
        background: #6c757d;
        color: white;
    }

    .btn-secondary:hover {
        background: #5a6268;
    }

    .btn-accent {
        background: var(--brand-color);
        color: white;
        box-shadow: 0 4px 6px rgba(0, 191, 165, 0.3);
    }

    .btn-accent:hover {
        background: #c5a028;
        transform: translateY(-1px);
    }

    .btn-large {
        padding: 1.2rem 2rem;
        font-size: 1.2rem;
        width: 100%;
    }

    .btn-block {
        width: 100%;
        display: block;
    }

    .btn-small {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    --primary-color: #0c1c3e;
    --primary-dark: #1a3c6e;
    --accent-color: #008080;
    --brand-color: #d4af37;
    --danger-color: #e74c3c;
    --success-color: #2ecc71;
    --bg-modal: rgba(0, 0, 0, 0.85);
    --input-bg: #f8f9fa;
    --border-radius: 12px;
}

body {
    background-color: #0c1c3e;
    /* StAug Navy */
    background-image: radial-gradient(circle at 50% 50%, #1a3c6e 0%, #0c1c3e 100%);
    font-family: 'Inter', sans-serif;
    color: #333;
}

.app-container {
    padding: 80px 1.5rem 60px 1.5rem;
    /* Added horizontal padding */
    max-width: 800px;
    background: #ffffff;
    /* Fresh White Card */
    min-height: 100vh;
    border-radius: 20px 20px 0 0;
    /* Sheet look */
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
}

/* Fix Inputs Overflow */
input {
    max-width: 100%;
    box-sizing: border-box;
}

/* Nav */
/* Header */
header {
    background: transparent !important;
    backdrop-filter: blur(5px);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
}

header h1 {
    color: #fff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Spacer utilities */
.spacer {
    height: 1.5rem;
}

/* Dashboard Cards */
.hero-small-card {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.resume-card {
    background: #fff;
    border-left: 6px solid var(--accent-color);
    margin-bottom: 2rem;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.resume-info p {
    margin: 0;
    color: #666;
}

.btn-accent {
    background: var(--accent-color);
    color: white;
}

.history-section {
    padding: 0 1rem;
}

.history-card {
    background: white;
    padding: 1.2rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-left: 4px solid #ddd;
}

.history-card.winner-card {
    border-left-color: var(--success-color);
}

.empty-state {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 2rem;
}

/* Inputs & Cards */
.round-inputs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.player-input-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid #eee;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    border-left: 6px solid var(--primary-color);
    position: relative;
    overflow: hidden;
}

/* More Subtle Card Flare */
.player-input-card::after {
    content: '♠♥♣♦';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 6rem;
    opacity: 0.04;
    letter-spacing: -15px;
    color: var(--primary-color);
    pointer-events: none;
    font-family: serif;
}

.player-input-card.out {
    opacity: 0.6;
    background: #fafafa;
    border-left-color: var(--danger-color);
}

.player-input-card h4 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Buttons */
.quick-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

.quick-btn {
    padding: 0.8rem;
    font-size: 1rem;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    color: #555;
}

.quick-btn:hover {
    background: #f5f5f5;
}

.quick-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(12, 28, 62, 0.2);
}

input[type="number"] {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    border: 2px solid #eee;
    border-radius: 10px;
    height: 56px;
    background: #fbfbfb;
}

input[type="number"]:focus {
    border-color: var(--brand-color);
    background: #fff;
    outline: none;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-modal);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-icon {
    font-size: 2rem;
    border: none;
    background: none;
    cursor: pointer;
    line-height: 1;
}

/* Table */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
    margin-bottom: 2rem;
}

th {
    background: #1a3c6e;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

td {
    font-variant-numeric: tabular-nums;
}

.score-cell.winner {
    color: var(--success-color);
    font-weight: 800;
}

.player-out {
    background: #fff1f0;
    color: var(--danger-color);
    text-decoration: line-through;
}

/* FAB */
.fab-container {
    position: fixed;
    /* Stick to screen */
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
}

.btn-fab {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 1.2rem 2.5rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: 0 8px 25px rgba(0, 128, 128, 0.4);
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-fab:hover {
    transform: translateY(-4px) scale(1.05);
}

/* Stats Bar */
.stats-bar {
    padding: 1rem;
    background: #fff;
    border-top: 1px solid #eee;
    text-align: center;
}

.btn-block {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
}

/* Ads */
.ad-container {
    margin: 2rem auto;
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
    border: 1px dashed #ddd;
    text-align: center;
}

/* Mobile Tweaks */
@media(max-width: 600px) {
    .app-container {
        padding-top: 60px;
        /* Smaller header on mobile */
    }

    .modal-content.large {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .fab-container {
        bottom: 2rem;
        right: 50%;
        transform: translateX(50%);
        /* Center FAB on mobile */
        width: auto;
    }

    .btn-fab {
        width: max-content;
    }
}

.view.hidden {
    display: none !important;
}

.hidden {
    display: none !important;
}

/* --- Refinements v3 (User Feedback) --- */

/* Fix Resume Card Overlap */
@media(max-width: 600px) {
    .resume-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .resume-card button {
        width: 100%;
    }
}

/* Persistent Home Button (Floating) */
.btn-home-float:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Smaller Ad Unit on Mobile */
@media(max-width: 600px) {
    .ad-container {
        min-height: 250px;
        /* Prevent layout shift */
        max-height: 280px;
        overflow: hidden;
        margin: 1rem 0;
    }
}

/* Fix Home Button Blur */

/* Risk Badges */
.risk-badge {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 5px;
    font-weight: bold;
    display: inline-block;
}

.risk-warning {
    background: #fff3cd;
    color: #856404;
}

.risk-danger {
    background: #f8d7da;
    color: #721c24;
}

/* Toast Success */
.toast.success {
    background: var(--success-color);
}

/* Force Out Button */
.btn-force-out {
    background: #ffebee;
    color: var(--danger-color);
    border: 1px solid #ffcdd2;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    margin-left: 0.5rem;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
}

.btn-force-out:hover {
    background: #ffcdd2;
}

/* Home Button Fix */

/* Force Solid Home Button v3 */

/* Risk Modal List */
.risk-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1rem;
}

.risk-item {
    padding: 0.8rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.risk-item.risk-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.risk-item.risk-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* History Detail Clickable */
.history-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.history-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Read Only Scoreboard */
.scoreboard-readonly .action-bar,
.scoreboard-readonly .fab-container {
    display: none !important;
}

/* Logo Styling */
.nav-logo {
    height: 40px;
    width: 40px;
    border-radius: 50%;
    /* Rounded */
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Logo Fixes */
.nav-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    /* Ensures circle crop even if image isn't square */
    flex-shrink: 0;
}

/* Button Refinements */
.scoreboard-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Primary Add Round Button (Static, Prominent) */
.btn-add-round-static {
    background: var(--accent-color) !important;
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 1rem;
    border-radius: 12px;
    border: none;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-add-round-static:hover {
    background: #00796b;
    /* Darker teal */
    transform: translateY(-1px);
}

/* Back Button - Themed */
.btn-back {
    background: var(--accent-color) !important;
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-back:hover {
    background: #00695c;
    /* Darker Teal */
}

/* Secondary Finish Game Button (Demoted) */
.btn-finish-secondary {
    background: transparent;
    border: 1px solid #ccc;
    color: #666;
    font-size: 0.9rem;
    padding: 0.8rem;
    border-radius: 8px;
    width: 100%;
    cursor: pointer;
}

.btn-finish-secondary:hover {
    background: #eee;
    border-color: #bbb;
    color: #333;
}

/* Hide old FAB if needed, or repurpose */
.fab-container {
    display: none !important;
    /* Switch to static button */
}

/* Logo Lightbox */
.logo-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    cursor: pointer;
}

.logo-lightbox.active {
    display: flex;
}

.logo-lightbox img {
    max-width: 80%;
    max-height: 80%;
    border-radius: 50%;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s;
}

.logo-lightbox.active img {
    transform: scale(1);
}

/* Header Alignment */
header {
    background: var(--primary-dark);
    padding: 1rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 100;
}

.header-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: white;
    text-decoration: none;
    cursor: pointer;
}

.header-brand h1 {
    font-size: 1.5rem;
    margin: 0;
    color: white;
    /* Force white to match logo bg if needed, or check user request */
    font-weight: 700;
}

/* Setup Screen Refinements */
.player-name-input {
    font-size: 1.2rem !important;
    /* Larger font */
    padding: 0.8rem !important;
}

.setting-input {
    padding: 0.4rem !important;
    /* Smaller vertical space */
    font-size: 0.95rem !important;
}

.settings-group h3 {
    font-size: 1rem;
    opacity: 0.8;
}

/* Footer Link */
.footer-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: opacity 0.2s;
}

.footer-link:hover {
    opacity: 0.8;
}

/* Re-adding Home Button for Header Context */
.btn-home-float {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-home-float:hover {
    background: rgba(255, 255, 255, 0.2) !important;
}

/* Scoreboard Read-Only Enhancements */
.scoreboard-readonly .scoreboard-actions {
    display: none !important;
}

/* Scoreboard Header Spacing */
.scoreboard-header {
    margin-bottom: 1.5rem;
}

/* Back Button Styling */
.btn-back {
    background: var(--primary-color);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 137, 123, 0.3);
    transition: all 0.2s;
}

.btn-back:hover {
    background: #00796b;
    transform: translateY(-1px);
}

/* Table Improvements */
#score-table {
    border-collapse: separate;
    border-spacing: 0;
}

#score-table th,
#score-table td {
    padding: 0.8rem 0.6rem;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}

#score-table th:first-child,
#score-table td:first-child {
    border-left: 1px solid #ddd;
}

#score-table thead th {
    border-top: 1px solid #ddd;
}

#score-table th {
    background: #f8f9fa;
    font-weight: 600;
}

/* Fix Table Header Text Color */
#score-table thead th {
    color: #333 !important;
    background: #f8f9fa;
    font-weight: 700;
}

/* Center Content Container on Desktop */
.container {
    margin: 0 auto;
}

.app-container {
    margin: 0 auto;
}

/* Ensure Modal Appears Above Everything */
#risk-modal {
    z-index: 10001 !important;
}

/* Footer Navigation Links */
footer p a {
    color: #888;
    text-decoration: none;
    margin: 0 0.5rem;
    transition: color 0.2s;
}

footer p a:hover {
    color: var(--primary-color);
}