:root {
    --sand: #f4e4bc;
    --paper: #f6e7c4;
    --paper-dark: #e8d2a0;
    --desert: #e8c547;
    --sun: #f3b23a;
    --orange: #e07a2f;
    --brick: #b33c24;
    --wood: #8b5a2b;
    --wood-dark: #5c3317;
    --ink: #2b1b0e;
    --sky: #7ec8e3;
    --sky-deep: #4ea7c8;
    --success: #2f7d3a;
    --danger: #b33c24;
    --shadow: 0 10px 0 rgba(43, 27, 14, 0.18);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--ink);
    font-family: "Nunito", sans-serif;
    background-color: #7ec8e3;
    background-image: url("../images/bg.png");
    background-repeat: no-repeat;
    background-position: center top;
    background-size: cover;
    background-attachment: fixed;
}

h1, h2, h3, .sign-title, .section-title, .wanted-card h4, .victory-banner h3 {
    font-family: "Rye", serif;
    letter-spacing: 0.02em;
}

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

.desert-sky {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.deco {
    position: absolute;
    user-select: none;
    line-height: 1;
}

.deco-sun {
    top: 18px;
    right: 6%;
    font-size: 4.2rem;
    color: #f3b23a;
    animation: sun-spin 28s linear infinite;
}

.deco-cloud {
    font-size: 4.5rem;
    color: #fff6d8;
    opacity: 0.55;
}

.deco-cloud-1 {
    top: 70px;
    left: 8%;
    animation: drift 18s ease-in-out infinite;
}

.deco-cloud-2 {
    top: 110px;
    right: 18%;
    font-size: 3.2rem;
    animation: drift 22s ease-in-out infinite reverse;
}

.deco-cactus {
    bottom: 0;
    font-size: 5rem;
    color: #2f8a46;
    opacity: 0.92;
}

.deco-cactus-left { left: 8px; }
.deco-cactus-right { right: 12px; transform: scaleX(-1); }

.deco-tumbleweed {
    bottom: 18px;
    left: -80px;
    font-size: 2.4rem;
    color: #8b5a2b;
    animation: tumble 26s linear infinite;
}

.saloon-header,
.saloon-main,
.saloon-footer {
    position: relative;
}

.saloon-header {
    padding: 1.5rem 0 0.5rem;
}

.saloon-sign {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background:
        repeating-linear-gradient(
            90deg,
            #8b5a2b 0 28px,
            #7a4b22 28px 30px,
            #9a6634 30px 58px
        );
    border: 6px solid #3d2412;
    border-radius: 8px 8px 22px 22px;
    box-shadow: var(--shadow), inset 0 8px 0 rgba(255, 220, 150, 0.12);
    padding: 1.1rem 1.2rem 1.25rem;
    text-align: center;
    color: #f8e7b8;
    position: relative;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.saloon-sign:hover {
    color: #f8e7b8;
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0 rgba(43, 27, 14, 0.18), inset 0 8px 0 rgba(255, 220, 150, 0.12);
}

.saloon-sign::before,
.saloon-sign::after {
    content: "";
    position: absolute;
    top: 14px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ddd 0 35%, #666 36% 100%);
}

.saloon-sign::before { left: 18px; }
.saloon-sign::after { right: 18px; }

.sign-ornament {
    font-size: 2.4rem;
    color: #f0d36b;
    flex: 0 0 auto;
    line-height: 1;
}

.sign-eyebrow {
    margin: 0;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    color: #f3d48a;
}

.sign-title {
    margin: 0.15rem 0;
    font-size: clamp(1.7rem, 5vw, 3rem);
    color: #fff4cc;
    text-shadow: 3px 3px 0 #3d1608;
}

.sign-subtitle {
    margin: 0;
    font-family: "Special Elite", cursive;
    font-size: clamp(0.92rem, 2.4vw, 1.1rem);
    color: #ffe7a8;
}

.saloon-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.7rem;
    margin: 1.1rem 0 0.4rem;
}

.nav-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--paper);
    color: var(--ink);
    text-decoration: none;
    border: 3px solid var(--ink);
    border-radius: 999px;
    padding: 0.55rem 1rem;
    font-weight: 800;
    box-shadow: 4px 4px 0 var(--ink);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.nav-chip:hover,
.nav-chip.is-active {
    background: var(--desert);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--ink);
}

.saloon-main {
    flex: 1 0 auto;
    padding: 0.5rem 0 3rem;
}

.saloon-alert {
    border: 3px solid var(--ink);
    border-radius: 14px;
    font-weight: 700;
}

.page-intro,
.game-intro {
    margin: 0.5rem 0 1.3rem;
}

.game-intro {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.page-intro h2,
.game-intro h2 {
    margin: 0.15rem 0 0.3rem;
    font-size: clamp(1.6rem, 4vw, 2.3rem);
}

.wanted-kicker {
    margin: 0;
    font-family: "Special Elite", cursive;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--brick);
}

.hero-saloon,
.paper-card,
.wanted-card,
.victory-banner {
    background: var(--paper);
    border: 4px solid var(--ink);
    box-shadow: var(--shadow);
}

.hero-saloon,
.paper-card {
    border-radius: var(--radius);
    padding: 1.4rem;
}

.hero-saloon {
    background:
        radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.35), transparent 28%),
        var(--paper);
    margin-bottom: 1.4rem;
}

.hero-saloon h2 {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    margin-bottom: 0.7rem;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #fff3c6;
    border: 2px dashed var(--brick);
    border-radius: 999px;
    padding: 0.2rem 0.75rem 0.2rem 0.3rem;
    font-weight: 800;
    margin-bottom: 0.8rem;
}

.hero-badge .bi {
    font-size: 1.3rem;
    color: #d4a017;
}

.hero-actions,
.form-actions,
.game-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.home-grid,
.history-grid,
.wanted-grid {
    display: grid;
    gap: 1rem;
}

.home-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.history-grid {
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
}

.wanted-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 1.5rem;
}

.paper-card-icon .bi {
    font-size: 2.4rem;
    color: var(--brick);
}

.saloon-list,
.recent-games,
.history-meta {
    padding-left: 1.1rem;
    margin-bottom: 0;
}

.recent-games {
    list-style: none;
    padding: 0;
}

.recent-games a,
.history-winner {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.35);
    border: 2px solid rgba(43, 27, 14, 0.12);
    border-radius: 12px;
    padding: 0.7rem 0.8rem;
    margin-bottom: 0.55rem;
}

.recent-games span,
.history-card time,
.optional {
    color: #6b4b2a;
    font-size: 0.92rem;
}

.empty-copy,
.empty-state {
    text-align: center;
}

.empty-state {
    padding: 2rem 1.2rem;
}

.player-list-header,
.round-header,
.history-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.history-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 0.85rem;
}

.history-card-actions .btn {
    flex: 1 1 140px;
}

.player-row,
.round-row {
    display: grid;
    gap: 0.65rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.player-row {
    grid-template-columns: 42px 1fr auto;
}

.round-row {
    grid-template-columns: 1fr 120px;
}

.player-index {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    background: var(--desert);
    border: 3px solid var(--ink);
    border-radius: 50%;
    font-weight: 800;
}

.form-control,
.form-control:focus {
    border: 3px solid var(--ink);
    border-radius: 12px;
    background: #fffaf0;
    box-shadow: none;
    font-weight: 700;
}

.form-control-lg {
    min-height: 52px;
}

.badge-wood {
    background: var(--wood);
    color: #fff4cc;
    border: 2px solid var(--ink);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-weight: 800;
}

.badge-live { background: #2f7d3a; }
.badge-finished { background: var(--brick); }

.btn-saloon {
    border: 3px solid var(--ink);
    border-radius: 14px;
    font-weight: 800;
    padding: 0.65rem 1rem;
    box-shadow: 4px 4px 0 var(--ink);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-saloon:hover,
.btn-saloon:focus {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--ink);
}

.btn-saloon:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--ink);
}

.btn-saloon-primary {
    background: var(--orange);
    color: #fffaf0;
}

.btn-saloon-secondary {
    background: var(--desert);
    color: var(--ink);
}

.btn-saloon-ghost {
    background: #fff8e4;
    color: var(--ink);
}

.btn-saloon-danger {
    background: var(--brick);
    color: #fffaf0;
}

.btn-saloon-dark {
    background: var(--wood-dark);
    color: #fff4cc;
}

.btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    display: inline-grid;
    place-items: center;
}

.btn-xl {
    min-height: 58px;
    font-size: 1.1rem;
}

.btn-saloon:disabled {
    opacity: 0.55;
    box-shadow: none;
    transform: none;
}

.wanted-card {
    text-align: center;
    padding: 0.9rem 0.8rem 1.1rem;
    border-radius: 10px;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(139, 90, 43, 0.05) 0 2px,
            transparent 2px 8px
        ),
        var(--paper);
    transform: rotate(-1deg);
    animation: card-in 0.45s ease both;
}

.wanted-card:nth-child(even) { transform: rotate(1.2deg); }
.wanted-card.is-first {
    background: #fff2b0;
    transform: rotate(0) scale(1.03);
    outline: 4px solid #d4a017;
}

.wanted-card.is-last {
    background: #f3c9b2;
}

.wanted-banner {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: "Special Elite", cursive;
    text-transform: uppercase;
    color: var(--brick);
    letter-spacing: 0.08em;
    margin-bottom: 0.35rem;
}

.wanted-banner .bi {
    font-size: 1.15rem;
}

.wanted-card.is-first .wanted-banner .bi {
    color: #d4a017;
}

.wanted-card.is-last .wanted-banner .bi,
.wanted-card.is-busted .wanted-banner .bi {
    color: var(--brick);
}

.wanted-card h4 {
    margin: 0.2rem 0 0.4rem;
    font-size: 1.25rem;
    overflow-wrap: anywhere;
}

.wanted-score {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.wanted-score span {
    display: block;
    font-size: 0.85rem;
    color: #6b4b2a;
}

.wanted-position {
    margin: 0.45rem 0 0;
    font-weight: 800;
}

.round-card {
    max-width: 640px;
    margin: 0 auto 1.6rem;
}

.round-header {
    justify-content: center;
    margin-bottom: 1rem;
}

.round-header .bi {
    font-size: 2rem;
    color: var(--ink);
}

.empty-icon {
    display: block;
    font-size: 3.4rem;
    color: var(--brick);
    margin-bottom: 0.6rem;
}

.section-title .bi {
    color: #d4a017;
    margin-right: 0.25rem;
}

.round-header h3 {
    margin: 0;
}

.round-total {
    margin: 1rem 0;
    padding: 0.9rem;
    border: 3px dashed var(--ink);
    border-radius: 14px;
    text-align: center;
    background: #fff6d8;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.round-total.is-ok {
    background: #d9f5d7;
    border-color: var(--success);
    animation: pop-ok 0.35s ease;
}

.round-total.is-bad {
    background: #ffd6cc;
    border-color: var(--danger);
}

.round-total-label,
.round-total-message {
    margin: 0;
}

.round-total-label strong {
    font-size: 1.35rem;
}

.round-total-message {
    margin-top: 0.35rem;
    font-weight: 800;
}

.round-hint {
    text-align: center;
    color: #6b4b2a;
    font-weight: 700;
    margin: 0 0 1rem;
}

.form-control.is-auto {
    background: #d9f5d7;
    border-style: dashed;
}

.wanted-card.is-busted {
    outline: 3px dashed var(--brick);
}

.busted-tag {
    display: block;
    margin-top: 0.25rem;
    color: var(--brick);
    font-size: 0.82rem;
}

.victory-limit {
    margin: 0.35rem 0 0;
    font-weight: 800;
}

.section-title {
    margin: 0 0 0.9rem;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.4rem;
}

.score-table {
    margin: 0;
    min-width: 520px;
}

.score-table th,
.score-table td {
    text-align: right;
    white-space: nowrap;
    font-weight: 700;
    padding: 0.65rem 0.75rem;
}

.score-table th:first-child,
.score-table td:first-child {
    text-align: left;
}

.score-table thead th,
.score-table tfoot th,
.score-table tfoot td,
.col-total {
    background: #f0d48a;
}

.score-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.35);
}

.victory-banner {
    text-align: center;
    border-radius: var(--radius);
    padding: 1.4rem 1rem;
    margin-bottom: 1.4rem;
    background: linear-gradient(180deg, #ffe58a, #f6d36b);
}

.victory-icon {
    display: block;
    font-size: 3rem;
    color: #d4a017;
    line-height: 1;
}

.victory-banner h3 {
    margin: 0.4rem 0;
}

.finish-section {
    display: flex;
    justify-content: center;
    margin-top: 1.4rem;
}

.history-card h3 {
    margin: 0.6rem 0 0.5rem;
    overflow-wrap: anywhere;
}

.history-meta {
    list-style: none;
    padding: 0;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.history-winner {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.saloon-modal {
    background: var(--paper);
    border: 4px solid var(--ink);
    border-radius: 16px;
}

.saloon-modal .modal-header,
.saloon-modal .modal-footer {
    border-color: rgba(43, 27, 14, 0.15);
}

.saloon-footer {
    flex-shrink: 0;
    margin-top: auto;
    text-align: center;
    padding: 1.2rem 0 2rem;
    color: #3d2412;
    font-weight: 700;
    background: linear-gradient(180deg, transparent, rgba(244, 228, 188, 0.72) 35%);
}

.saloon-footer .bi {
    display: block;
    font-size: 1.8rem;
    color: var(--brick);
    margin-bottom: 0.3rem;
}

.history-winner .bi {
    font-size: 1.25rem;
    color: #d4a017;
}

@keyframes sun-spin {
    to { transform: rotate(360deg); }
}

@keyframes drift {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(18px); }
}

@keyframes tumble {
    0% { transform: translateX(0) rotate(0deg); }
    100% { transform: translateX(110vw) rotate(720deg); }
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(10px) rotate(-2deg); }
    to { opacity: 1; }
}

@keyframes pop-ok {
    0% { transform: scale(0.97); }
    60% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

@media (max-width: 767.98px) {
    body {
        background-attachment: scroll;
        background-position: center top;
    }

    .deco-cactus,
    .deco-tumbleweed,
    .sign-ornament {
        display: none;
    }

    .saloon-sign {
        padding: 1rem 0.8rem;
    }

    .nav-chip {
        flex: 1 1 140px;
        justify-content: center;
    }

    .round-row {
        grid-template-columns: 1fr;
    }

    .round-row input {
        max-width: none;
        min-height: 56px;
        font-size: 1.25rem;
    }

    .player-row {
        grid-template-columns: 36px 1fr auto;
    }

    .btn-saloon,
    .btn-xl {
        width: 100%;
    }

    .game-toolbar,
    .hero-actions,
    .form-actions {
        display: grid;
    }
}

@media (prefers-reduced-motion: reduce) {
    .deco-sun,
    .deco-cloud,
    .deco-tumbleweed,
    .wanted-card,
    .round-total.is-ok {
        animation: none;
    }
}
