/* ==========================================================================
           01. GLOBAL VARIABLES & DESIGN TOKENS
           ========================================================================== */
:root {
    --win95-bg: #c0c0c0;
    --win95-dark: #808080;
    --win95-darker: #404040;
    --win95-white: #ffffff;
    --win95-black: #000000;
    --win95-teal: #008080;
    --win95-blue: #000080;
    --win95-green: #008000;

    --raised: inset -1px -1px 0 #404040, inset 1px 1px 0 #ffffff, inset -2px -2px 0 #808080, inset 2px 2px 0 #dfdfdf;
    --sunken: inset 1px 1px 0 #404040, inset -1px -1px 0 #ffffff, inset 2px 2px 0 #808080, inset -2px -2px 0 #dfdfdf;
    --button-raised: inset -1px -1px 0 #000000, inset 1px 1px 0 #ffffff, inset -2px -2px 0 #808080, inset 2px 2px 0 #dfdfdf;
    --button-pressed: inset 1px 1px 0 #000000, inset -1px -1px 0 #ffffff, inset 2px 2px 0 #808080, inset -2px -2px 0 #dfdfdf;

    /* Adaptive Board Sizing */
    --board-width: 800px;
    --card-w: calc((var(--board-width) - 60px) / 7);
    --card-h: calc(var(--card-w) * 1.45);
    --card-overlap: calc(var(--card-h) * 0.22);
    --pile-gap: 10px;

    --fs-corner: 24px;
    --fs-center: 54px;
}

/* ── LAPTOP HEIGHT SCALING FIX (For 1366x768 screens) ── */
@media (max-width: 1400px),
(max-height: 850px) {
    :root {
        --board-width: 650px;
        --fs-corner: 20px;
        --fs-center: 46px;
    }
}

/* Extra small height fallback */
@media (max-height: 650px) {
    :root {
        --board-width: 500px;
        --fs-corner: 16px;
        --fs-center: 36px;
    }
}

@media (max-width: 1024px) {
    :root {
        --board-width: calc(100vw - 40px);
    }
}

@media (max-width: 768px) {
    :root {
        --board-width: calc(100vw - 20px);
        --pile-gap: 2px;
        --card-w: calc((var(--board-width) - (var(--pile-gap) * 8)) / 7);
        --card-h: calc(var(--card-w) * 1.45);
        --card-overlap: calc(var(--card-h) * 0.22);
        --fs-corner: calc(var(--card-w) * 0.35);
        --fs-center: calc(var(--card-w) * 0.65);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

body {
    background-color: var(--win95-teal);
    font-family: 'MS Sans Serif', 'Microsoft Sans Serif', Arial, sans-serif;
    font-size: 11px;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ── MOBILE TOP AD BANNER ── */
.mobile-top-ad-wrapper {
    display: none;
    width: 100%;
    padding: 8px 0 0 0;
    flex-shrink: 0;
}

#desktop {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 32px;
    padding: 16px 24px 16px 100px;
    flex: 1;
    min-height: calc(100vh - 36px - 28px);
    position: relative;
    margin: 0 auto;
    width: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

@media (max-width: 1024px) {
    #desktop {
        flex-direction: column;
        padding: 16px 16px 16px 88px;
    }

    #ad-window {
        width: 100%;
        height: auto;
        align-self: auto;
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    #desktop {
        padding: 8px;
    }

    .mobile-top-ad-wrapper {
        display: flex;
        justify-content: center;
    }
}

.desk-icon {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    width: 72px;
    padding: 4px;
    cursor: pointer;
    z-index: 10;
}

.desk-icon .icon-img {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
}

.desk-icon .icon-label {
    font-size: 11px;
    color: white;
    text-shadow: 1px 1px 2px #000;
    text-align: center;
    line-height: 1.2;
    padding: 0 2px;
}

.desk-icon.selected .icon-img {
    filter: brightness(0.55) sepia(1) hue-rotate(190deg) saturate(4);
    outline: 1px dotted rgba(255, 255, 255, 0.8);
}

.desk-icon.selected .icon-label {
    background: var(--win95-blue) !important;
}

.win95-window {
    position: relative;
    background: var(--win95-bg);
    box-shadow: var(--raised);
    border: 2px solid var(--win95-darker);
    display: flex;
    flex-direction: column;
}

.win95-window.minimized,
.win95-window.closed {
    display: none !important;
}

#game-window {
    flex: 1;
    max-width: 960px;
    width: 100%;
    min-width: 300px;
    align-self: stretch;
}

#ad-window {
    width: 320px;
    flex-shrink: 0;
    align-self: stretch;
    margin-left: auto;
}

.win-titlebar {
    background: linear-gradient(to right, #000080, #1084d0);
    padding: 3px 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    flex-shrink: 0;
}

.win-titlebar-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

.win-titlebar-icon {
    width: 16px;
    height: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    flex-shrink: 0;
}

.win-titlebar-icon span {
    display: block;
}

.win-titlebar-icon span:nth-child(1) {
    background: #ff6666;
}

.win-titlebar-icon span:nth-child(2) {
    background: #66ff66;
}

.win-titlebar-icon span:nth-child(3) {
    background: #6666ff;
}

.win-titlebar-icon span:nth-child(4) {
    background: #ffff66;
}

.win-title {
    color: white;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.3px;
}

.win-controls {
    display: flex;
    gap: 2px;
}

.win-ctrl-btn {
    width: 16px;
    height: 14px;
    background: var(--win95-bg);
    box-shadow: var(--button-raised);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 9px;
    font-weight: bold;
    color: var(--win95-black);
    font-family: inherit;
    padding: 0;
    line-height: 1;
}

.win-ctrl-btn:active {
    box-shadow: var(--button-pressed);
}

.win-menubar {
    background: var(--win95-bg);
    border-bottom: 1px solid var(--win95-dark);
    padding: 2px 0;
    display: flex;
    flex-shrink: 0;
    position: relative;
    z-index: 1000;
}

.win-menu-trigger {
    padding: 2px 8px;
    font-size: 11px;
    color: var(--win95-black);
    cursor: pointer;
    white-space: nowrap;
}

.win-menu-trigger:hover,
.win-menu-trigger.open {
    background: var(--win95-blue);
    color: white;
}

.win-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    background: var(--win95-bg);
    box-shadow: var(--raised);
    border: 1px solid var(--win95-darker);
    z-index: 10000;
    min-width: 180px;
}

.win-dropdown.show {
    display: block;
}

.win-dd-item {
    padding: 4px 24px 4px 16px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
}

.win-dd-item:hover {
    background: var(--win95-blue);
    color: white;
}

.win-dd-sep {
    border-top: 1px solid var(--win95-dark);
    border-bottom: 1px solid white;
    margin: 2px 0;
}

#game-controls-bar {
    background: var(--win95-bg);
    border-bottom: 1px solid var(--win95-dark);
    padding: 3px 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.ctrl-label {
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-score-label {
    display: none;
}

.win95-select {
    background: white;
    border: none;
    box-shadow: var(--sunken);
    padding: 2px 18px 2px 4px;
    font-family: inherit;
    font-size: 11px;
    color: var(--win95-black);
    height: 22px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-color: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23000'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
}

.win95-btn {
    background: var(--win95-bg);
    box-shadow: var(--button-raised);
    border: none;
    padding: 3px 10px;
    font-family: inherit;
    font-size: 11px;
    color: var(--win95-black);
    cursor: pointer;
    height: 23px;
    min-width: 55px;
    white-space: nowrap;
}

.win95-btn:hover {
    background: #d0d0d0;
}

.win95-btn:active {
    box-shadow: var(--button-pressed);
    padding: 4px 9px 2px 11px;
}

.win-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#game-content {
    background: var(--win95-green);
    padding: 8px;
    margin: 4px;
    box-shadow: var(--sunken);
    border: 2px solid var(--win95-darker);
    flex: 1;
    overflow: hidden;
    position: relative;
    transition: opacity 0.3s ease;
}

.ad-container {
    background-color: #dfdfdf;
    box-shadow: var(--sunken);
    border: 1px solid #808080;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin: 4px auto;
    text-align: center;
    color: var(--win95-dark);
    font-size: 10px;
    flex-shrink: 0;
}

.win-statusbar {
    background: var(--win95-bg);
    border-top: 1px solid var(--win95-dark);
    padding: 2px 6px;
    display: flex;
    gap: 4px;
    font-size: 10px;
    flex-shrink: 0;
    color: var(--win95-black);
    margin-top: auto;
}

.sbar-pane {
    box-shadow: var(--sunken);
    padding: 1px 6px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sbar-pane.narrow {
    flex: 0 0 auto;
    min-width: 80px;
}

#game-board {
    width: var(--board-width);
    max-width: 100%;
    margin: 0 auto;
    padding: 0 var(--pile-gap);
    position: relative;
}

.deck-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: clamp(8px, 2vw, 18px);
    height: var(--card-h);
}

.stock-waste,
.foundations {
    display: flex;
    gap: var(--pile-gap);
}

.tableau-row {
    display: flex;
    gap: var(--pile-gap);
    width: 100%;
}

.pile {
    width: var(--card-w);
    min-height: var(--card-h);
    border: 2px solid rgba(0, 0, 0, 0.4);
    border-radius: 2px;
    position: relative;
    background: rgba(0, 100, 0, 0.3);
    box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.pile.drop-target {
    outline: 2px solid #ffff00;
    outline-offset: -2px;
}

.card {
    width: var(--card-w);
    height: var(--card-h);
    background: #fff;
    border-radius: 2px;
    box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #fff, 2px 2px 4px rgba(0, 0, 0, 0.45);
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border: 1px solid #808080;
    cursor: grab;
    will-change: transform;
    touch-action: none;
}

.card:active {
    cursor: grabbing;
}

.card.back {
    background-color: #000080;
    background-image: repeating-linear-gradient(45deg, #000080 0, #000080 4px, #0000aa 4px, #0000aa 8px);
    border: 2px solid #c0c0c0;
    cursor: pointer;
}

.card.back::after {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 1px;
}

.card.selected-card {
    outline: 3px solid #ffff00;
    outline-offset: -2px;
    box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #fff, 0 0 0 3px #ffff00, 2px 2px 4px rgba(0, 0, 0, 0.45);
    z-index: 50;
}

.corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 0.85;
    font-weight: bold;
    font-size: var(--fs-corner);
    font-family: Arial, sans-serif;
}

.corner.top-left {
    top: 4%;
    left: 6%;
}

.corner.bottom-right {
    bottom: 4%;
    right: 6%;
    transform: rotate(180deg);
}

.center-suit {
    font-size: var(--fs-center);
    line-height: 1;
    pointer-events: none;
}

.red {
    color: #cc0000;
}

.black {
    color: #000000;
}

#drag-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
}

.is-dragging {
    opacity: 0 !important;
}

#taskbar {
    background: var(--win95-bg);
    box-shadow: inset 0px 1px 0px #ffffff;
    border-top: 1px solid #dfdfdf;
    height: 28px;
    width: 100%;
    display: flex;
    z-index: 1000;
    flex-shrink: 0;
}

#taskbar-inner {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 2px 4px;
}

#start-btn {
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--win95-bg);
    box-shadow: var(--button-raised);
    border: none;
    padding: 0 4px 0 2px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    color: var(--win95-black);
    font-weight: bold;
}

#start-btn:active,
#start-btn.active {
    box-shadow: var(--button-pressed);
    padding: 1px 3px -1px 3px;
}

#start-btn .win-icon {
    width: 14px;
    height: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    flex-shrink: 0;
}

#start-btn .win-icon span {
    display: block;
}

#start-btn .win-icon span:nth-child(1) {
    background: #ff0000;
}

#start-btn .win-icon span:nth-child(2) {
    background: #00aa00;
}

#start-btn .win-icon span:nth-child(3) {
    background: #0000ff;
}

#start-btn .win-icon span:nth-child(4) {
    background: #ffff00;
}

.tb-sep {
    width: 2px;
    height: 20px;
    border-left: 1px solid var(--win95-dark);
    border-right: 1px solid var(--win95-white);
    margin: 0 4px;
}

#taskbar-windows {
    display: flex;
    flex: 1;
    gap: 4px;
    margin-left: 4px;
    align-items: center;
}

.tb-win-btn {
    height: 22px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--win95-bg);
    box-shadow: var(--button-raised);
    border: none;
    padding: 0 8px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    color: var(--win95-black);
    min-width: 120px;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    font-weight: bold;
}

.tb-win-btn:active {
    box-shadow: var(--button-pressed);
}

.tb-win-btn.active {
    box-shadow: var(--button-pressed);
    background: repeating-linear-gradient(45deg, #c0c0c0, #c0c0c0 2px, #d0d0d0 2px, #d0d0d0 4px);
}

#tb-clock-area {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 2px;
}

#tb-sound-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    outline: none;
    font-size: 14px;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#tb-sound-btn:active {
    transform: translateY(1px);
}

#tb-clock {
    height: 22px;
    display: flex;
    align-items: center;
    box-shadow: var(--sunken);
    padding: 0 8px;
    font-size: 11px;
    white-space: nowrap;
}

#start-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 4px;
    background: var(--win95-bg);
    box-shadow: var(--raised);
    border: 2px solid var(--win95-darker);
    z-index: 600;
    min-width: 200px;
    padding: 2px;
}

#start-menu.open {
    display: block;
}

.sm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 11px;
    cursor: pointer;
}

.sm-item:hover {
    background: var(--win95-blue);
    color: white;
}

.sm-sep {
    border-top: 1px solid var(--win95-dark);
    border-bottom: 1px solid white;
    margin: 2px 0;
}

.sm-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

#desktop-spacer {
    height: 64px;
    width: 100%;
}

#win95-footer {
    background: var(--win95-bg);
    box-shadow: var(--raised);
    border: 2px solid var(--win95-darker);
    margin: 0 auto 32px auto;
    max-width: 1280px;
    width: 95%;
    padding: 16px;
    font-size: 11px;
    color: var(--win95-black);
}

#win95-footer h2 {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 6px;
}

#win95-footer p {
    margin-bottom: 12px;
    line-height: 1.5;
}

#win95-footer .footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    border-top: 1px solid var(--win95-dark);
    padding-top: 8px;
    margin-top: 4px;
}

#win95-footer a {
    color: var(--win95-blue);
    text-decoration: underline;
    font-size: 11px;
}

#win95-footer .copyright {
    margin-left: auto;
    color: var(--win95-darker);
}

/* ── DIALOGS ── */
#win95-dialog,
#stats-dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
}

#win95-dialog {
    z-index: 99999;
}

#stats-dialog {
    z-index: 99998;
}

#win95-dialog.show,
#stats-dialog.show,
#calendar-dialog.show,
#leaderboard-dialog.show,
#initials-dialog.show {
    display: flex !important;
}

.dlg-box {
    background: var(--win95-bg);
    box-shadow: var(--raised);
    border: 2px solid var(--win95-darker);
    min-width: 260px;
    max-width: 380px;
}

.dlg-titlebar {
    background: linear-gradient(to right, #000080, #1084d0);
    padding: 3px 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.dlg-title {
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.dlg-body {
    padding: 14px 14px 6px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    color: var(--win95-black);
}

.dlg-icon {
    font-size: 26px;
    flex-shrink: 0;
}

.dlg-text {
    font-size: 11px;
    line-height: 1.6;
    white-space: pre-line;
    color: var(--win95-black);
}

.dlg-btns {
    padding: 4px 14px 10px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.dlg-btn {
    background: var(--win95-bg);
    box-shadow: var(--button-raised);
    border: none;
    padding: 4px 18px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    min-width: 70px;
}

.dlg-btn:active {
    box-shadow: var(--button-pressed);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dotted var(--win95-dark);
    padding-bottom: 4px;
    width: 100%;
    font-size: 12px;
}

.stat-row span:last-child {
    font-weight: bold;
}

/* ── PHASE 1 COSMETICS ── */
body.theme-clouds {
    background-color: #3a6ea5;
    background-image: radial-gradient(circle at 50% 50%, #ffffff 0%, #87ceeb 40%, #008080 100%);
    background-size: cover;
}

/* Wallpaper Patterns */
body.bg-default {
    background-color: var(--win95-teal) !important;
    background-image: none !important;
}
body.bg-thatch {
    background-color: #000000 !important;
    background-image: 
        repeating-linear-gradient(45deg, #181818, #181818 2px, transparent 2px, transparent 10px),
        repeating-linear-gradient(-45deg, #181818, #181818 2px, transparent 2px, transparent 10px) !important;
    background-size: 16px 16px !important;
}
body.bg-houndstooth {
    background-color: #ffffff !important;
    background-image: 
        linear-gradient(45deg, #000000 25%, transparent 25%, transparent 75%, #000000 75%), 
        linear-gradient(45deg, #000000 25%, transparent 25%, transparent 75%, #000000 75%) !important;
    background-size: 8px 8px !important;
    background-position: 0 0, 4px 4px !important;
}
body.bg-blue-gradient {
    background: linear-gradient(to bottom, #000080, #1084d0) !important;
}


.crt-scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 2px, 3px 100%;
    z-index: 999999;
    pointer-events: none;
    display: none;
}

.crt-scanline-overlay.active {
    display: block;
}

.card.back.red {
    background-color: #800000;
    background-image: repeating-linear-gradient(45deg, #800000 0, #800000 4px, #aa0000 4px, #aa0000 8px);
}

#appearance-dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    z-index: 99998;
}

#appearance-dialog.show {
    display: flex;
}

/* ── PHASE 2 CALENDAR ── */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: #808080;
    padding: 2px;
    border: 2px solid var(--win95-darker);
    box-shadow: var(--sunken);
}

.cal-header {
    text-align: center;
    font-weight: bold;
    font-size: 10px;
    padding: 2px 0;
    background: var(--win95-bg);
    border: 1px solid #dfdfdf;
    border-bottom-color: #808080;
    border-right-color: #808080;
}

.cal-day {
    background: var(--win95-white);
    height: 32px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 2px 4px;
    font-size: 11px;
    cursor: pointer;
    position: relative;
    border: 1px solid transparent;
}

.cal-day:hover {
    outline: 1px dotted #000;
    outline-offset: -1px;
}

.cal-day.empty {
    background: transparent;
    cursor: default;
}

.cal-day.selected {
    background: var(--win95-blue);
    color: white;
}

.cal-day.today {
    font-weight: bold;
    text-decoration: underline;
}

.cal-star {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 14px;
    line-height: 1;
    color: gold;
    text-shadow: 1px 1px 1px #000;
}

/* ── PHASE 3 LEADERBOARD ── */
.leaderboard-table-container {
    background: white;
    border: 2px solid;
    border-top-color: #808080;
    border-left-color: #808080;
    border-bottom-color: #dfdfdf;
    border-right-color: #dfdfdf;
    height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.leaderboard-table th {
    background: var(--win95-bg);
    border-right: 1px solid #808080;
    border-bottom: 1px solid #808080;
    border-top: 1px solid #fff;
    border-left: 1px solid #fff;
    padding: 2px 4px;
    text-align: left;
    font-weight: normal;
    position: sticky;
    top: 0;
}

.leaderboard-table td {
    padding: 2px 4px;
    border-right: 1px dotted #ccc;
    border-bottom: 1px solid transparent;
}

.leaderboard-table tr:hover td {
    background: var(--win95-blue);
    color: white;
    cursor: default;
}

.win95-input {
    background: white;
    border: 2px solid;
    border-top-color: #808080;
    border-left-color: #808080;
    border-bottom-color: #dfdfdf;
    border-right-color: #dfdfdf;
    padding: 2px 4px;
    font-family: inherit;
    font-size: 11px;
    outline: none;
}

.win95-input:focus {
    outline: 1px dotted #000;
    outline-offset: -1px;
}

/* ── PHASE 4 STATS TABS ── */
.tab-btn {
    background: var(--win95-bg);
    border: 2px solid;
    border-top-color: #dfdfdf;
    border-left-color: #dfdfdf;
    border-bottom-color: #808080;
    border-right-color: #808080;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    position: relative;
    top: 0;
    outline: none;
    border-bottom: none;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: -2px;
    z-index: 1;
}

.tab-btn.active {
    background: white;
    border-top-color: #fff;
    border-left-color: #fff;
    z-index: 4;
    padding-top: 6px;
    padding-bottom: 6px;
    top: -2px;
    font-weight: bold;
    border-bottom: 2px solid white;
}

.tab-btn:focus {
    outline: 1px dotted #000;
    outline-offset: -3px;
}

@media (max-width: 768px) {
    .desk-icon {
        display: none !important;
    }

    #desktop:has(#game-window.minimized) .desk-icon,
    #desktop:has(#game-window.closed) .desk-icon {
        display: inline-flex !important;
        position: relative !important;
        top: auto !important;
        left: auto !important;
        float: left !important;
        margin: 12px 8px !important;
    }

    .win-controls {
        display: flex !important;
        align-items: center;
        gap: 4px;
    }

    .win-ctrl-btn {
        width: 22px !important;
        height: 20px !important;
        font-size: 13px !important;
    }

    .mobile-score-label {
        display: inline !important;
        margin-right: 8px;
    }

    #game-window {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: none !important;
        border: none;
        box-shadow: none;
        position: relative;
    }

    .desktop-ad-win {
        display: none !important;
    }

    .desktop-horizontal-ad {
        display: none !important;
    }

    #opponent-status-window {
        top: auto !important;
        bottom: 50px !important;
        right: 10px !important;
        width: 190px !important;
    }
}

/* ==========================================================================
   TOOLBAR (Unified Navigation)
   ========================================================================== */
.win95-toolbar {
    background: var(--win95-bg);
    box-shadow: var(--raised);
    border-bottom: 2px solid var(--win95-darker);
    display: flex;
    align-items: stretch;
    padding: 2px 4px;
    gap: 2px;
    flex-shrink: 0;
    z-index: 2000;
    position: relative;
}

.toolbar-item {
    display: flex;
    align-items: center;
    padding: 4px 10px;
    color: var(--win95-black);
    text-decoration: none;
    font-size: 11px;
    border: 1px solid transparent;
    cursor: pointer;
    position: relative;
}

.toolbar-item:hover {
    box-shadow: var(--button-raised);
    background-color: #d0d0d0;
}

.toolbar-item:active,
.toolbar-item.active {
    box-shadow: var(--button-pressed);
    background-color: #c0c0c0;
}

.toolbar-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--win95-bg);
    box-shadow: var(--raised);
    border: 2px solid var(--win95-darker);
    z-index: 3000;
    min-width: 160px;
}

.toolbar-item.active .toolbar-dropdown-menu {
    display: block;
}

.toolbar-dd-item {
    display: block;
    padding: 6px 16px;
    color: var(--win95-black);
    text-decoration: none;
    font-size: 11px;
    white-space: nowrap;
}

.toolbar-dd-item:hover {
    background: var(--win95-blue);
    color: var(--win95-white);
}

.toolbar-dd-sep {
    border-top: 1px solid var(--win95-dark);
    border-bottom: 1px solid var(--win95-white);
    margin: 2px 4px;
}

@media (max-width: 768px) {
    .win95-toolbar {
        flex-wrap: wrap;
    }

    .toolbar-item {
        padding: 6px 8px;
        flex: 1 1 auto;
        justify-content: center;
    }
}

/* Optimized Webkit Scrollbar */
::-webkit-scrollbar {
    width: 16px;
    height: 16px;
    background-color: #dfdfdf;
    background-image: repeating-linear-gradient(45deg, #c0c0c0, #c0c0c0 1px, #e0e0e0 1px, #e0e0e0 2px);
}
::-webkit-scrollbar-thumb {
    background-color: var(--win95-bg);
    border: 2px solid;
    border-top-color: #fff;
    border-left-color: #fff;
    border-right-color: #808080;
    border-bottom-color: #808080;
    box-shadow: inset 1px 1px 0px #fff, inset -1px -1px 0px #808080;
}
::-webkit-scrollbar-button {
    display: block;
    background-color: var(--win95-bg);
    box-shadow: var(--button-raised);
}