html {
    max-width: 100vw;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    touch-action: manipulation;
    margin: 0;
    padding: 4px 8px;
    box-sizing: border-box;
    transition: padding 0.2s ease-in-out;
}

body.fullscreen-mode {
    padding: 0;
    align-items: flex-start;
}

.window-container {
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    width: 98vw;
    max-width: 1650px;
    display: flex;
    flex-direction: column;
    min-height: auto;
    height: auto;
    transition: max-width 0.2s ease-in-out, height 0.2s ease-in-out, border-radius 0.2s ease-in-out;
}

body.fullscreen-mode .window-container {
    max-width: 100vw;
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
}

.title-bar {
    background-color: #4a90e2;
    color: #ffffff;
    padding: 4px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    font-weight: bold;
    font-size: 0.9rem;
}

.title-bar-buttons button {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1rem;
    margin-left: 6px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.title-bar-buttons button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.content-area {
    padding: 6px 12px;
    flex-grow: 1;
    overflow-y: auto;
}

.players-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    margin-bottom: 6px;
}

.player-score-card {
    background-color: #f8f9fa;
    border-radius: 6px;
    padding: 6px 10px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: 1px solid #e0e0e0;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.player-score-card.active-player {
    border-color: #4a90e2;
    border-width: 2px;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.25);
}

.score-display {
    font-size: 1.8rem;
    font-weight: bold;
    color: #333;
    min-width: 70px;
    text-align: center;
    line-height: 1.1;
}

.fires-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    font-size: 0.8rem;
    color: #555;
    max-width: 100%;
}

.fire-item {
    padding: 2px 5px;
    border-radius: 3px;
    background-color: #ffcccc;
    border: 1px solid #ff9999;
    font-weight: bold;
}

.fire-item.extinguished {
    background-color: #ccffcc;
    border: 1px solid #99ff99;
    text-decoration: line-through;
    color: #008000;
}

.burndown-targets-list {
    font-size: 0.75rem;
    color: #777;
    margin-top: 2px;
    text-align: left;
    width: 100%;
    padding-left: 4px;
    box-sizing: border-box;
}

.burndown-targets-list p {
    margin-bottom: 1px;
}

.input-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
}

/* User-Resizable Dartboard Container */
#dartboard-container {
    position: relative;
    width: min(560px, 52vh);
    height: min(560px, 52vh);
    min-width: 240px;
    min-height: 240px;
    max-width: 100%;
    margin: 0 auto;
    resize: both;
    overflow: hidden;
    padding-bottom: 4px;
}

#dartboardCanvas, #heatmap-canvas {
    display: block;
    width: 100%;
    height: 100%;
    border: 2px solid #333;
    border-radius: 50%;
    background-color: #eee;
    touch-action: manipulation;
}

body.fullscreen-mode #dartboard-container {
    width: 75vh;
    height: 75vh;
    max-width: none;
}

/* Single Unified Row for Darts Beside Turn Action Buttons */
.turn-controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 12px;
    width: 100%;
    margin-top: 4px;
}

.dart-display-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.dart-input {
    background-color: #e0e0e0;
    padding: 5px 8px;
    border-radius: 6px;
    font-weight: bold;
    color: #444;
    width: 72px;
    text-align: center;
    font-size: 0.9rem;
    border: 1px solid #ccc;
    -moz-appearance: textfield;
}

.dart-input::-webkit-outer-spin-button,
.dart-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.dart-input:focus {
    outline: 2px solid #4a90e2;
    background-color: #fff;
}

.dart-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.dart-buttons button {
    background-color: #6c757d;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dart-buttons button:hover {
    background-color: #5a6268;
}

.dart-buttons button:active {
    background-color: #495057;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.dart-buttons .btn-zero {
    background-color: #f0ad4e;
}

.dart-buttons .btn-zero:hover {
    background-color: #ec971f;
}

.dart-buttons .btn-zero:active {
    background-color: #d58512;
}

/* --- 3-Tier Pub Game Controls Deck --- */
.game-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    margin-top: 6px;
    width: 100%;
}

/* Tier 1: Marquee Banner - Clean Pub Theme (Blue on Blue) */
.tier-1-marquee {
    border: 1px solid #bfdbfe;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

#open-game-lounge-btn {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 50%, #3b82f6 100%) !important;
    color: #ffffff !important;
    border: 1px solid rgba(147, 197, 253, 0.8) !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28) !important;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
}

#open-game-lounge-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 50%, #60a5fa 100%) !important;
    border-color: #bfdbfe !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.38) !important;
    transform: translateY(-1px);
}

.game-lounge-btn-prefix {
    color: #bfdbfe;
}

/* Tier 2: Loaded Mode & Recent Favorites Shelf - Clean Pub Theme */
.tier-2-shelf {
    background-color: #f8fafc;
    border: 1px solid #bfdbfe;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.06);
}

.tier-2-loaded-badge {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    border: 1px solid #3b82f6;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(30, 64, 175, 0.2);
}

.tier-2-loaded-prefix {
    color: #bfdbfe;
}

.tier-2-recent-label {
    color: #1d4ed8;
}

.tier-2-recent-subtext {
    color: #64748b;
}

.game-lounge-pill {
    background-color: #ffffff !important;
    border: 1px solid #93c5fd !important;
    color: #1e40af !important;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08) !important;
}

.game-lounge-pill:hover {
    background-color: #eff6ff !important;
    border-color: #2563eb !important;
    color: #1d4ed8 !important;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.16) !important;
    transform: translateY(-1px);
}

.tier-3-lineup {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* --- THEME: FIRE MODE OVERRIDES --- */
body.theme-fire .tier-1-marquee {
    border: 1px solid rgba(249, 115, 22, 0.45);
    background: linear-gradient(135deg, #18181b 0%, #27272a 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

body.theme-fire #open-game-lounge-btn {
    background: linear-gradient(135deg, #c2410c 0%, #ea580c 50%, #f97316 100%) !important;
    border: 1px solid rgba(254, 215, 170, 0.6) !important;
    color: #ffffff !important;
    box-shadow: 0 3px 12px rgba(234, 88, 12, 0.45) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

body.theme-fire #open-game-lounge-btn:hover {
    background: linear-gradient(135deg, #ea580c 0%, #f97316 50%, #fb923c 100%) !important;
    border-color: #fed7aa !important;
    box-shadow: 0 4px 16px rgba(249, 115, 22, 0.6) !important;
}

body.theme-fire .game-lounge-btn-prefix {
    color: #fed7aa;
}

body.theme-fire .tier-2-shelf {
    background-color: #18181b;
    border: 1px solid #3f3f46;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

body.theme-fire .tier-2-loaded-badge {
    background: linear-gradient(135deg, #7c2d12 0%, #9a3412 100%);
    border: 1px solid #ea580c;
    color: #ffedd5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

body.theme-fire .tier-2-loaded-prefix {
    color: #fdba74;
}

body.theme-fire .tier-2-recent-label {
    color: #fb923c;
}

body.theme-fire .tier-2-recent-subtext {
    color: #a1a1aa;
}

body.theme-fire .game-lounge-pill {
    background-color: #27272a !important;
    border: 1px solid #52525b !important;
    color: #fed7aa !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

body.theme-fire .game-lounge-pill:hover {
    background-color: #7c2d12 !important;
    border-color: #f97316 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(249, 115, 22, 0.35) !important;
}

body.theme-fire .tier-3-lineup {
    background-color: #1e293b;
    border-color: #334155;
}

body.theme-fire #tier-3-helper-microcopy {
    color: #94a3b8;
}

body.theme-fire #show-player-name-modal-btn {
    background: linear-gradient(135deg, #ea580c, #c2410c) !important;
    box-shadow: 0 2px 8px rgba(234, 88, 12, 0.4) !important;
}

/* --- THEME: GOLD BAR MODE OVERRIDES --- */
body.theme-gold .tier-1-marquee {
    border: 1px solid rgba(212, 175, 55, 0.45);
    background: linear-gradient(135deg, #1c1917 0%, #292524 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

body.theme-gold #open-game-lounge-btn {
    background: linear-gradient(135deg, #b45309 0%, #d4af37 50%, #f59e0b 100%) !important;
    border: 1px solid rgba(254, 240, 138, 0.8) !important;
    color: #451a03 !important;
    font-weight: 900 !important;
    box-shadow: 0 3px 12px rgba(212, 175, 55, 0.45) !important;
    text-shadow: 0 1px 1px rgba(254, 240, 138, 0.5);
}

body.theme-gold #open-game-lounge-btn:hover {
    background: linear-gradient(135deg, #d4af37 0%, #f59e0b 50%, #fbbf24 100%) !important;
    border-color: #fef9c3 !important;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.6) !important;
}

body.theme-gold .game-lounge-btn-prefix {
    color: #78350f;
}

body.theme-gold .tier-2-shelf {
    background-color: #1c1917;
    border: 1px solid #44403c;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

body.theme-gold .tier-2-loaded-badge {
    background: linear-gradient(135deg, #451a03 0%, #78350f 100%);
    border: 1px solid #d4af37;
    color: #fef08a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

body.theme-gold .tier-2-loaded-prefix {
    color: #fef08a;
}

body.theme-gold .tier-2-recent-label {
    color: #d4af37;
}

body.theme-gold .tier-2-recent-subtext {
    color: #a8a29e;
}

body.theme-gold .game-lounge-pill {
    background-color: #292524 !important;
    border: 1px solid #78716c !important;
    color: #fef08a !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

body.theme-gold .game-lounge-pill:hover {
    background: linear-gradient(135deg, #d4af37, #f59e0b) !important;
    border-color: #fef08a !important;
    color: #451a03 !important;
    box-shadow: 0 2px 6px rgba(212, 175, 55, 0.35) !important;
}

body.theme-gold .tier-3-lineup {
    background-color: #1c1917;
    border-color: #44403c;
}

body.theme-gold #tier-3-helper-microcopy {
    color: #d6d3d1;
}

body.theme-gold #show-player-name-modal-btn {
    background: linear-gradient(135deg, #d4af37, #b45309) !important;
    color: #451a03 !important;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.4) !important;
}

#show-player-name-modal-btn {
    background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3) !important;
}

#show-player-name-modal-btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af) !important;
    transform: translateY(-1px);
}

#shuffle-and-start-btn {
    background: linear-gradient(135deg, #f97316, #ea580c) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(234, 88, 12, 0.35) !important;
}

#shuffle-and-start-btn:hover {
    background: linear-gradient(135deg, #fb923c, #f97316) !important;
    transform: translateY(-1px);
}

.game-controls button:not(.game-lounge-pill):not(#open-game-lounge-btn):not(#show-player-name-modal-btn):not(#shuffle-and-start-btn), .game-controls select {
    background-color: #28a745;
    color: white;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

.game-controls select {
    background-color: #007bff;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 28px;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23ffffff" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 15px;
}

.message-box {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    border-radius: 6px;
    padding: 8px;
    margin-top: 6px;
    text-align: center;
    font-weight: 500;
    font-size: 0.85rem;
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.message-box.error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.message-box.success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.player-name-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.player-name-modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 440px;
    animation: fadeIn 0.3s ease-out;
}

.player-slot {
    margin-bottom: 0.6rem;
}

.player-profile-select, .new-player-name-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.new-player-name-input {
    margin-top: 0.3rem;
}

.hidden {
    display: none;
}

.history-item {
    background-color: #f0f0f0;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.history-item.winner {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}

.history-item p {
    margin: 0;
    font-size: 0.8rem;
    color: #333;
}

.history-item .winner-name {
    font-weight: bold;
    color: #155724;
}

.history-item .game-date {
    font-size: 0.7rem;
    color: #666;
    margin-top: 2px;
}

.history-item ul {
    list-style: none;
    padding: 0;
    margin-top: 4px;
}

.history-item ul li {
    font-size: 0.75rem;
    color: #555;
    margin-bottom: 2px;
}

.player-stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 6px;
    max-height: 340px;
    overflow-y: auto;
    padding-right: 2px;
}

.player-stat-card {
    background-color: #e6f7ff;
    border: 1px solid #b3e0ff;
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.player-stat-card h4 {
    font-size: 0.95rem;
    font-weight: bold;
    color: #0056b3;
    margin-bottom: 4px;
    text-align: center;
}

.player-stat-card p {
    font-size: 0.75rem;
    color: #333;
    margin-bottom: 3px;
    text-align: center;
}

.view-stats-btn {
    background-color: #007bff;
    color: white;
    padding: 4px 8px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
    margin-top: 4px;
    align-self: center;
    font-size: 0.75rem;
}

.view-stats-btn:hover {
    background-color: #0056b3;
}

.stats-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.stats-modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeIn 0.3s ease-out;
    position: relative;
}

.stats-modal-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    font-weight: bold;
    color: #888;
    cursor: pointer;
}

.stats-modal-close-btn:hover {
    color: #333;
}

#stats-modal-details ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

#stats-modal-details ul li {
    background-color: #f8f9fa;
    padding: 6px;
    border-radius: 5px;
    font-size: 0.85rem;
}

.burndown-details-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.burndown-details-list {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
}

.burndown-details-list h5 {
    font-weight: bold;
    margin-bottom: 6px;
    color: #333;
}

.burndown-details-list ul {
    list-style-type: none;
    padding: 0;
}

.burndown-details-list li {
    margin-bottom: 3px;
}

.multiplayer-section {
    background-color: #e9ecef;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ced4da;
}

.multiplayer-section h4 {
    font-size: 0.95rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 6px;
}

.game-id-display {
    background-color: #fff;
    padding: 5px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 1rem;
    font-weight: bold;
    text-align: center;
    color: #495057;
    margin-bottom: 6px;
    cursor: pointer;
}

.join-game-container {
    display: flex;
    gap: 6px;
}

#join-game-id-input {
    flex-grow: 1;
    padding: 5px 8px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 0.9rem;
}

#join-game-btn {
    background-color: #17a2b8;
    color: white;
    padding: 5px 12px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
}

#join-game-btn:hover {
    background-color: #138496;
}

body.fullscreen-mode .main-grid {
    display: flex;
    flex-direction: column;
}

/* --- Mobile Portrait Viewport Optimization (Strictly Scoped + Coarse Pointer Fallback) --- */
@media (max-width: 767px) and (orientation: portrait), (pointer: coarse) and (orientation: portrait) {
    body {
        padding: 0;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .window-container {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        box-shadow: none;
        overflow-x: hidden;
    }

    .title-bar {
        border-radius: 0;
        padding: max(4px, env(safe-area-inset-top)) 8px 4px 8px;
        flex-wrap: wrap;
        gap: 4px;
    }

    .content-area {
        padding: 4px 6px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    /* 1. Pinned Top Player Scorecards */
    .players-container {
        position: sticky;
        top: 0;
        z-index: 30;
        background-color: #ffffff;
        grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
        gap: 4px;
        padding: 4px 0;
        margin-bottom: 4px;
        border-bottom: 1px solid #e5e7eb;
    }

    .player-score-card {
        padding: 4px 6px;
        gap: 2px;
    }

    .player-score-card h2 {
        font-size: 0.9rem;
        line-height: 1.1;
    }

    .score-display {
        font-size: 1.35rem;
        min-width: 50px;
    }

    .burndown-targets-list {
        font-size: 0.68rem;
        max-height: 44px;
        overflow-y: auto;
    }

    .fires-display {
        gap: 2px;
        font-size: 0.7rem;
    }

    .fire-item {
        padding: 1px 4px;
    }

    /* 2. Centered 1:1 Circular Dartboard (Prevents Portrait Oval Stretch & Horizontal Overflow) */
    .input-section {
        padding: 6px 4px;
        gap: 4px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    #dartboard-container,
    body.fullscreen-mode #dartboard-container {
        width: min(100%, 88vw, 44vh);
        height: auto;
        min-width: 200px;
        min-height: 200px;
        max-width: calc(100vw - 24px);
        max-height: calc(100vw - 24px);
        aspect-ratio: 1 / 1;
        resize: none;
        margin: 2px auto;
        padding-bottom: 0;
    }

    .tier-2-recent-subtext {
        display: none !important;
    }

    #game-lounge-recent-pills {
        flex-wrap: wrap;
        max-width: 100%;
    }

    /* 3. Pinned Bottom One-Thumb Throw Controls */
    .turn-controls-row {
        position: sticky;
        bottom: 0;
        z-index: 30;
        background-color: rgba(255, 255, 255, 0.97);
        border-top: 1px solid #e5e7eb;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        margin-top: 2px;
        gap: 6px;
        width: 100%;
        box-sizing: border-box;
    }

    .dart-display-container {
        width: 100%;
        justify-content: center;
        gap: 6px;
    }

    .dart-input {
        flex: 1;
        min-width: 0;
        max-width: 96px;
        padding: 6px;
        font-size: 0.9rem;
    }

    .dart-buttons {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .dart-buttons button {
        width: 100%;
        min-height: 36px;
        padding: 6px 8px;
        font-size: 0.8rem;
    }
}

/* --- Optional "Fire Theme" (Toggled via Title Bar 🔥/☀️ Button) --- */
body.theme-fire {
    background-color: #0f172a;
    color: #f8fafc;
}

body.theme-fire .window-container {
    background-color: #1e293b;
    border: 1px solid #334155;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

body.theme-fire .title-bar {
    background: linear-gradient(90deg, #0f172a 0%, #1e293b 60%, #7c2d12 100%);
    border-bottom: 2px solid #f97316;
}

body.theme-fire .player-score-card {
    background-color: #0f172a;
    border-color: #334155;
}

body.theme-fire .player-score-card h2 {
    color: #e2e8f0;
}

body.theme-fire .player-score-card.active-player {
    border-color: #f97316;
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.35), 0 0 12px rgba(249, 115, 22, 0.25);
}

body.theme-fire .score-display {
    color: #f8fafc;
}

body.theme-fire .burndown-targets-list {
    color: #94a3b8;
}

body.theme-fire .input-section,
body.theme-fire .content-area .bg-white {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0;
}

body.theme-fire .content-area h3,
body.theme-fire .content-area .text-gray-800,
body.theme-fire .content-area .text-gray-700,
body.theme-fire .content-area .text-gray-900 {
    color: #f1f5f9 !important;
}

body.theme-fire #current-player-display {
    color: #fb923c !important;
}

body.theme-fire #dartboardCanvas {
    background-color: #1e293b;
    border-color: #f97316;
    background-color: #eee;
    box-shadow: 0 0 16px rgba(249, 115, 22, 0.25);
}

body.theme-fire .game-controls label {
    color: #e2e8f0 !important;
}

body.theme-fire .dart-input {
    background-color: #1e293b;
    border-color: #475569;
    color: #f8fafc;
}

body.theme-fire .dart-input:focus {
    outline-color: #f97316;
    background-color: #0f172a;
}

body.theme-fire .multiplayer-section {
    background-color: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

body.theme-fire #join-game-id-input {
    background-color: #1e293b;
    border-color: #475569;
    color: #f8fafc;
}

body.theme-fire .player-stat-card {
    background-color: #1e293b;
    border-color: #334155;
}

body.theme-fire .player-stat-card h4 {
    color: #fb923c;
}

body.theme-fire .player-stat-card p {
    color: #cbd5e1;
}

body.theme-fire .view-stats-btn {
    background-color: #ea580c;
}

body.theme-fire .view-stats-btn:hover {
    background-color: #c2410c;
}

body.theme-fire .history-item {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.theme-fire .history-item p,
body.theme-fire .history-item li {
    color: #cbd5e1 !important;
}

@media (max-width: 767px) and (orientation: portrait), (pointer: coarse) and (orientation: portrait) {
    body.theme-fire .players-container,
    body.theme-fire .turn-controls-row {
        background-color: #1e293b;
        border-color: #334155;
    }
}


/* --- Help & Rules Modal Styles --- */
.help-rule-card.help-rule-active {
    border-color: #3b82f6 !important;
    background-color: #eff6ff !important;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35);
}

body.theme-fire .stats-modal-content {
    background-color: #1e293b;
    color: #f1f5f9;
    border: 1px solid #334155;
}

body.theme-fire .stats-modal-content h3,
body.theme-fire .stats-modal-content h4 {
    color: #f8fafc !important;
}

body.theme-fire .help-rule-card,
body.theme-fire .help-tips-card {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #cbd5e1 !important;
}

body.theme-fire .help-rule-card.help-rule-active {
    border-color: #f97316 !important;
    background-color: #172554 !important;
    box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.45);
}

body.theme-fire .help-active-badge {
    background-color: #ea580c !important;
}


/* --- Optional "Gold Bar" Easter-Egg Theme (VIP Gold & 5-Year Gold Pass) --- */
body.theme-gold {
    background-color: #1c1917;
    color: #fef3c7;
}

body.theme-gold .window-container {
    background-color: #292524;
    border: 1px solid #b45309;
    box-shadow: 0 12px 30px rgba(245, 158, 11, 0.22);
}

body.theme-gold .title-bar {
    background: linear-gradient(90deg, #451a03 0%, #78350f 35%, #b45309 70%, #d97706 100%);
    border-bottom: 2px solid #fbbf24;
}

body.theme-gold .player-score-card {
    background-color: #1c1917;
    border-color: #78350f;
}

body.theme-gold .player-score-card h2 {
    color: #fde68a;
}

body.theme-gold .player-score-card.active-player {
    border-color: #fbbf24;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.45), 0 0 14px rgba(245, 158, 11, 0.35);
}

body.theme-gold .score-display {
    color: #fef3c7;
}

body.theme-gold .burndown-targets-list {
    color: #fcd34d;
}

body.theme-gold .input-section,
body.theme-gold .content-area .bg-white {
    background-color: #1c1917 !important;
    border-color: #78350f !important;
    color: #fef3c7;
}

body.theme-gold .content-area h3,
body.theme-gold .content-area .text-gray-800,
body.theme-gold .content-area .text-gray-700,
body.theme-gold .content-area .text-gray-900 {
    color: #fde68a !important;
}

body.theme-gold #current-player-display {
    color: #fbbf24 !important;
}

body.theme-gold #dartboardCanvas {
    background-color: #eee;
    border-color: #fbbf24;
    box-shadow: 0 0 18px rgba(251, 191, 36, 0.35);
}

body.theme-gold .game-controls label {
    color: #fde68a !important;
}

body.theme-gold .dart-input {
    background-color: #292524;
    border-color: #b45309;
    color: #fef3c7;
}

body.theme-gold .dart-input:focus {
    outline-color: #fbbf24;
    background-color: #1c1917;
}

body.theme-gold .multiplayer-section {
    background-color: #1c1917;
    border-color: #78350f;
    color: #fde68a;
}

body.theme-gold #join-game-id-input {
    background-color: #292524;
    border-color: #b45309;
    color: #fef3c7;
}

body.theme-gold .player-stat-card {
    background-color: #292524;
    border-color: #78350f;
}

body.theme-gold .player-stat-card h4 {
    color: #fbbf24;
}

body.theme-gold .player-stat-card p {
    color: #fde68a;
}

body.theme-gold .view-stats-btn {
    background-color: #d97706;
}

body.theme-gold .view-stats-btn:hover {
    background-color: #b45309;
}

body.theme-gold .history-item {
    background-color: #292524 !important;
    border-color: #78350f !important;
}

body.theme-gold .history-item p,
body.theme-gold .history-item li {
    color: #fde68a !important;
}

body.theme-gold .stats-modal-content {
    background-color: #292524;
    color: #fef3c7;
    border: 1px solid #b45309;
}

body.theme-gold .stats-modal-content h3,
body.theme-gold .stats-modal-content h4 {
    color: #fde68a !important;
}

body.theme-gold .help-rule-card,
body.theme-gold .help-tips-card {
    background-color: #1c1917 !important;
    border-color: #78350f !important;
    color: #fde68a !important;
}

body.theme-gold .help-rule-card.help-rule-active {
    border-color: #fbbf24 !important;
    background-color: #451a03 !important;
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.5);
}

body.theme-gold .help-active-badge {
    background-color: #d97706 !important;
}

@media (max-width: 767px) and (orientation: portrait), (pointer: coarse) and (orientation: portrait) {
    body.theme-gold .players-container,
    body.theme-gold .turn-controls-row {
        background-color: #292524;
        border-color: #78350f;
    }
}

/* --- Tier Badges in Title Bar --- */
.tier-badge-btn {
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 9999px;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: 1px solid transparent;
}

.tier-badge-btn:hover {
    transform: translateY(-1px);
}

.tier-badge-vip-gold {
    background: linear-gradient(135deg, #fde68a 0%, #f59e0b 50%, #b45309 100%);
    color: #451a03;
    border-color: #fef3c7;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.55);
}

.tier-badge-pro {
    background: linear-gradient(135deg, #38bdf8 0%, #2563eb 100%);
    color: #ffffff;
    border-color: #93c5fd;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.45);
}

.tier-badge-free {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.45);
}


/* --- Stats Modal Dark / Gold Theme Table & List Overrides --- */
body.theme-fire #stats-modal-details ul li,
body.theme-fire .burndown-details-list {
    background-color: #0f172a;
    color: #e2e8f0;
    border: 1px solid #334155;
}

body.theme-fire .burndown-details-list h5 {
    color: #f8fafc;
}

body.theme-fire #section-breakdown-tbody {
    background-color: #0f172a;
    color: #e2e8f0;
}

body.theme-fire #section-breakdown-tbody tr:hover {
    background-color: #1e293b;
}

body.theme-gold #stats-modal-details ul li,
body.theme-gold .burndown-details-list {
    background-color: #1c1917;
    color: #fde68a;
    border: 1px solid #78350f;
}

body.theme-gold .burndown-details-list h5 {
    color: #fbbf24;
}

body.theme-gold #section-breakdown-tbody {
    background-color: #1c1917;
    color: #fde68a;
}

body.theme-gold #section-breakdown-tbody tr:hover {
    background-color: #292524;
}


/* --- Sticky Close Button for Scrollable Modals (#stats-modal & #help-modal) --- */
.stats-modal-close-btn {
    position: sticky !important;
    top: 0px !important;
    float: right;
    z-index: 40;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background-color: rgba(241, 245, 249, 0.95) !important;
    border: 1px solid #cbd5e1 !important;
    color: #334155 !important;
    font-size: 1.35rem;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    margin-left: 8px;
}

.stats-modal-close-btn:hover {
    background-color: #ef4444 !important;
    border-color: #dc2626 !important;
    color: #ffffff !important;
}

body.theme-fire .stats-modal-close-btn {
    background-color: rgba(15, 23, 42, 0.95) !important;
    border-color: #475569 !important;
    color: #f8fafc !important;
}

body.theme-gold .stats-modal-close-btn {
    background-color: rgba(28, 25, 23, 0.95) !important;
    border-color: #b45309 !important;
    color: #fde68a !important;
}
