:root {
    --felt: #135740;
    --felt-dark: #0c3b2b;
    --felt-deep: #082a1f;
    --felt-light: #1d6e52;
    --felt-line: rgba(255, 255, 255, 0.12);
    --cream: #fbf7ee;
    --ink: #1c1c1c;
    --gold: #d9a234;
    --gold-light: #f2c65c;
    --gold-dark: #9e7120;
    --red: #b3261e;
    --red-dark: #7f1a15;
    --him: #3f6dc5;
    --him-dark: #274b91;
    --her: #d036bf;
    --her-dark: #962689;
    --text-light: #eef5f1;
    --text-muted-light: #b5cdc2;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --heading-font: 'Cinzel', Georgia, serif;
}

body {
    font-family: 'Open Sans', system-ui, sans-serif;
    color: var(--text-light);
    background-color: var(--felt);
    background-image:
        radial-gradient(ellipse at top, rgba(255, 255, 255, 0.08), transparent 60%),
        radial-gradient(ellipse at bottom, rgba(0, 0, 0, 0.35), transparent 70%);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--gold-light);
}

a:hover {
    color: #fff;
}

h1, h2, h3 {
    font-family: var(--heading-font);
    letter-spacing: 0.02em;
}

.text-him {
    color: #8fb2f5;
}

.text-her {
    color: #f29be6;
}

.text-muted-light {
    color: var(--text-muted-light);
}

/* Layout */

.site-nav {
    background: var(--felt-deep);
    border-bottom: 3px solid var(--gold);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.site-nav .navbar-brand {
    font-family: var(--heading-font);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--gold-light);
}

.brand-suit {
    color: var(--cream);
}

.site-nav .nav-link {
    color: var(--text-light);
    font-weight: 600;
    border-radius: 999px;
    padding: 0.4rem 1rem !important;
}

.site-nav .nav-link:hover,
.site-nav .nav-link.active {
    color: var(--felt-deep);
    background: var(--gold);
}

.site-main {
    flex: 1;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

.site-footer {
    background: var(--felt-deep);
    color: var(--text-muted-light);
    text-align: center;
    padding: 1rem 0;
    font-size: 0.9rem;
}

.page-title {
    color: var(--gold-light);
    font-size: 1.9rem;
    margin-bottom: 1.25rem;
}

/* Flash messages - drop down over the page, never push content around */

.flash-stack {
    position: fixed;
    top: 0.75rem;
    left: 50%;
    z-index: 1090;
    width: max-content;
    max-width: calc(100% - 2rem);
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
}

.flash-toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(-150%);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.flash-toast.is-shown {
    opacity: 1;
    transform: translateY(0);
}

.flash-success {
    background: var(--cream);
    color: var(--felt-deep);
    border: 2px solid var(--gold);
}

.flash-danger {
    background: var(--red);
    color: #fff;
    border: 2px solid var(--red-dark);
}

/* Buttons */

.btn {
    border-radius: 999px;
    font-weight: 700;
    padding: 0.55rem 1.25rem;
}

.btn-gold {
    background: linear-gradient(180deg, var(--gold-light), var(--gold));
    border: 1px solid var(--gold-dark);
    color: var(--felt-deep);
}

.btn-gold:hover,
.btn-gold:focus {
    background: var(--gold);
    border-color: var(--gold-dark);
    color: var(--felt-deep);
}

.btn-red {
    background: linear-gradient(180deg, #d63a30, var(--red));
    border: 1px solid var(--red-dark);
    color: #fff;
}

.btn-red:hover,
.btn-red:focus {
    background: var(--red-dark);
    border-color: var(--red-dark);
    color: #fff;
}

.btn-felt {
    background: var(--felt-light);
    border: 1px solid var(--felt-line);
    color: #fff;
}

.btn-felt:hover,
.btn-felt:focus {
    background: var(--felt-dark);
    color: #fff;
}

.btn-deal {
    background: var(--cream);
    border: 2px dashed var(--gold-dark);
    color: var(--felt-deep);
    margin-bottom: 1rem;
}

.btn-deal:hover {
    background: #fff;
    color: var(--felt-deep);
}

.btn:disabled {
    opacity: 0.45;
}

/* Scoreboard */

.view-banner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--felt-line);
    border-radius: var(--radius);
    padding: 0.85rem 1.1rem;
    margin-bottom: 1.25rem;
}

.player-panel {
    height: 100%;
    background: var(--cream);
    color: var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem;
    border: 4px solid transparent;
    transition: border-color 0.2s ease;
}

.player-panel.is-dealing {
    border-color: var(--gold);
}

.player-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.player-name {
    font-family: var(--heading-font);
    font-weight: 700;
    font-size: 1.35rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.player-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-him .player-name {
    color: var(--him-dark);
}

.player-her .player-name {
    color: var(--her-dark);
}

.player-score {
    flex-shrink: 0;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--heading-font);
    font-size: 2.2rem;
    font-weight: 700;
    color: #fff;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2);
}

.player-him .player-score {
    background: var(--him);
}

.player-her .player-score {
    background: var(--her);
}

.dealer-badge {
    flex-shrink: 0;
    display: inline-block;
    background: var(--gold);
    color: var(--felt-deep);
    font-family: 'Open Sans', system-ui, sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
}

.score-buttons {
    display: grid;
    gap: 0.6rem;
}

.score-buttons form {
    margin: 0;
}

.score-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 0;
    border-radius: 12px;
    padding: 0.8rem 1rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(180deg, #6a2fa0, #441669);
    box-shadow: 0 3px 0 #2c0e45;
    text-align: left;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.score-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #2c0e45;
}

.score-btn.is-static {
    cursor: default;
}

.score-btn-scopa {
    font-size: 1.45rem;
    padding: 1rem;
    color: var(--felt-deep);
    background: linear-gradient(180deg, var(--gold-light), var(--gold));
    box-shadow: 0 3px 0 var(--gold-dark);
}

.score-btn-scopa:active {
    box-shadow: 0 1px 0 var(--gold-dark);
}

.score-btn-symbol {
    width: 2.2rem;
    text-align: center;
    font-size: 1.3em;
    line-height: 1;
}

.score-btn-label {
    flex: 1;
}

.score-btn-count {
    min-width: 2.4rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
}

.game-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem 1.1rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--felt-line);
    border-radius: var(--radius);
}

.game-meta {
    display: flex;
    gap: 1rem;
    align-items: baseline;
}

.game-number {
    font-family: var(--heading-font);
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--gold-light);
}

.game-hands {
    color: var(--text-muted-light);
    font-weight: 600;
}

.game-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.game-actions form {
    margin: 0;
}

.leader-banner {
    margin-top: 1rem;
    text-align: center;
    font-weight: 700;
    font-size: 1.2rem;
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    color: #fff;
}

.leader-him {
    background: var(--him);
}

.leader-her {
    background: var(--her);
}

.leader-level {
    background: var(--gold);
    color: var(--felt-deep);
}

.modal-content {
    color: var(--ink);
    border-radius: var(--radius);
}

.end-score {
    font-family: var(--heading-font);
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
}

.modal-body .text-him {
    color: var(--him-dark);
}

.modal-body .text-her {
    color: var(--her-dark);
}

/* Results, stats and rules */

.felt-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--felt-line);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.felt-card h2 {
    font-size: 1.3rem;
    color: var(--gold-light);
    margin-bottom: 0.9rem;
}

.felt-card h2 small {
    font-family: 'Open Sans', sans-serif;
    font-size: 0.85rem;
    color: var(--text-muted-light);
}

.felt-card h3 {
    font-size: 1.05rem;
    color: var(--cream);
    margin: 1.25rem 0 0.6rem;
}

.felt-card ul ul {
    margin-top: 0.3rem;
}

.stat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.stat-list > li {
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--felt-line);
}

.stat-list > li:last-child {
    border-bottom: 0;
}

.tournament {
    color: var(--gold-light);
    font-weight: 700;
}

.day-bars li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.day-name {
    width: 6.5rem;
}

.day-bar {
    flex: 1;
    height: 0.7rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
}

.day-bar span {
    display: block;
    height: 100%;
    background: var(--gold);
    border-radius: 999px;
}

.day-share {
    width: 4rem;
    text-align: right;
    font-weight: 600;
}

.result-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.result-legend span {
    border-radius: 999px;
    padding: 0.25rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.results-table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--ink);
    white-space: nowrap;
}

.results-table thead th {
    background: var(--felt-deep);
    color: var(--gold-light);
    border-color: var(--felt-line);
}

.results-table td {
    border-color: rgba(0, 0, 0, 0.08);
}

.results-table a {
    color: var(--felt-deep);
    font-weight: 700;
}

.result-her-ahead,
.results-table .result-her-ahead td {
    background: #f2c65c;
    color: var(--ink);
}

.result-her-behind,
.results-table .result-her-behind td {
    background: #f6c2f7;
    color: var(--ink);
}

.result-him-ahead,
.results-table .result-him-ahead td {
    background: #b3c7fd;
    color: var(--ink);
}

.result-him-behind,
.results-table .result-him-behind td {
    background: #d3fdb3;
    color: var(--ink);
}

.result-level,
.results-table .result-level td {
    background: #111;
    color: #fff;
}

.results-table .result-level a {
    color: var(--gold-light);
}

.chart-scroll {
    overflow-x: auto;
}

.chart-wrap {
    position: relative;
    height: 380px;
}

/* Back to top */

.back-to-top {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 1030;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--felt-deep);
    font-size: 22px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--gold-light);
    color: var(--felt-deep);
}

/* Seasonal backgrounds */

body.season-halloween {
    background-image: url('../images/seasonal/halloween_bg.webp');
    background-size: cover;
    background-position: center;
}

body.season-new-year {
    background-image: url('../images/seasonal/fireworks.webp');
    background-size: cover;
    background-position: center;
}

@media (max-width: 575.98px) {
    .site-main {
        padding-top: 1rem;
    }

    .player-name {
        font-size: 1.15rem;
    }

    .player-score {
        width: 3.8rem;
        height: 3.8rem;
        font-size: 1.8rem;
    }

    .game-bar {
        justify-content: center;
    }

    .game-actions {
        justify-content: center;
    }

    .back-to-top {
        right: 1rem;
        bottom: 1rem;
    }
}
