/* Banned player overlay */
.ban-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.ban-overlay-box {
    background: rgba(60, 0, 0, 0.9);
    border: 1px solid rgba(255, 80, 80, 0.8);
    border-radius: 12px;
    padding: 20px 24px;
    max-width: 560px;
    width: calc(100% - 40px);
    color: #fff;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.ban-overlay-title {
    font-size: 20px;
    font-weight: 700;
    color: #ff4444;
    margin-bottom: 10px;
}
.ban-overlay-message {
    font-size: 16px;
    color: #eee;
}
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: #222;
    color: white;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

/* ban overlay removed */

.version-info {
    position: fixed;
    bottom: 10px;
    right: 10px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-family: Arial, sans-serif;
    z-index: 1000;
    pointer-events: none;
}

.game-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
}

#boosts-banner {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin: 4px 0 6px 0;
}

#boosts-banner.hidden { display: none; }

.boost-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 4px 8px;
    font-size: 12px;
    color: #e6f1ff;
}

.boost-badge .name { font-weight: 600; color: #4aa3ff; }
.boost-badge .time { font-family: monospace; opacity: 0.9; }

#counter {
    font-size: 42px;
    margin-bottom: 30px;
    color: #FFD700;
}

#scrap-image {
    width: 120px;
    height: 200px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 10px;
    touch-action: manipulation;
    user-select: none;
}

#scrap-image:hover {
    transform: scale(1.03);
}

#scrap-image:active {
    transform: scale(0.98);
}

#cooldown-container {
    width: 300px;
    height: 30px;
    background-color: #444;
    margin-top: 30px;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

#cooldown-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #FF8C00, #FFD700);
    transition: width 0.05s linear;
}

#cooldown-timer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    font-weight: bold;
    color: white;
}

#upgrade-container {
    position: static;
}

#upgrade-btn {
    width: 100px;
    height: 100px;
    cursor: pointer;
    transition: transform 0.2s;
}

#upgrade-btn:hover {
    transform: scale(1.1);
}

#upgrade-btn:active {
    transform: scale(0.95);
}

#upgrade-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    max-width: 500px;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    border: 2px solid #FFD700;
    border-radius: 15px;
    padding: 20px;
    z-index: 100;
    display: none;
}

#upgrade-window.active {
    display: block;
}

.upgrade-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
}

.upgrade-item {
    background-color: rgba(30, 30, 30, 0.8);
    border: 1px solid #444;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upgrade-item:hover {
    border-color: #FFD700;
    transform: scale(1.03);
}

.upgrade-item.locked {
    opacity: 0.6;
    cursor: not-allowed;
}

.upgrade-title {
    font-size: 16px;
    color: #FFD700;
    margin-bottom: 8px;
}

.upgrade-level {
    font-size: 14px;
    color: #AAA;
}

.upgrade-note {
    font-size: 12px;
    color: #888;
    margin-top: -4px;
    margin-bottom: 6px;
}

.upgrade-cost {
    font-size: 14px;
    color: #4CAF50;
    margin-top: 8px;
}

#close-upgrades {
    position: absolute;
    top: 10px;
    right: 15px;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

#close-upgrades:hover {
    color: #FF5555;
}

.upgrade-item.hidden {
    display: none;
}


.sub-upgrade { margin-top: 10px; padding-top: 8px; border-top: 1px dashed #555; }
.sub-title { font-size: 14px; color: #ccc; margin-bottom: 4px; }
.sub-level { font-size: 13px; color: #aaa; }
.sub-cost { font-size: 13px; color: #4CAF50; margin: 6px 0; }
.sub-btn { font-size: 13px; padding: 6px 10px; border-radius: 6px; border: 1px solid #666; background: #333; color: #eee; cursor: pointer; }
.sub-btn:hover { background: #3a3a3a; }
.sub-upgrade.hidden { display: none; }

#book-container {
    position: static;
    margin-right: auto;
}

#book-container.show {
    opacity: 1;
    transform: translateY(0);
}

#book-btn {
    width: 70px;
    height: 70px;
    cursor: pointer;
    transition: transform 0.2s;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}


#upgrade-container {
    position: static; 
    transform: none;
}

#upgrade-btn {
    width: 70px;
    height: 70px;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}


#book-btn:hover, #upgrade-btn:hover {
    transform: scale(1.1);
}

#book-btn:active, #upgrade-btn:active {
    transform: scale(0.95);
}

#bottom-buttons {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    align-items: center;
    z-index: 50;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 50px;
    backdrop-filter: blur(5px);
    border: 1px solid #444;
    touch-action: manipulation;
}

#brick-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 4px 12px;
    font-size: 18px;
    color: #e67e22;
    font-weight: bold;
}

#tiles-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 4px 12px;
    font-size: 18px;
    color: #9b59b6;
    font-weight: bold;
}

#scrapyard-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    max-width: 700px;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    border: 2px solid #FFD700;
    border-radius: 15px;
    padding: 20px;
    z-index: 100;
    display: none;
}

#scrapyard-window.active {
    display: block;
}

.scrapyard-content {
    text-align: center;
    display: grid;
    grid-template-columns: 1fr 2px 1fr 2px 1fr;
    gap: 30px;
    align-items: stretch;
}

.scrapyard-left, #brickyard-section, #tilesyard-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 400px;
    height: 430px;
    padding: 20px 0;
    flex: 1;
}


.scrapyard-left { grid-column: 1; }
#brickyard-separator { grid-column: 2; }
#brickyard-section { grid-column: 3; }
#tilesyard-separator { grid-column: 4; }
#tilesyard-section { grid-column: 5; }

.scrapyard-description, .brickyard-description, .tilesyard-description {
    margin: 15px 0;
    color: #95a5a6;
    font-size: 14px;
    line-height: 1.35;
    min-height: 44px;
}


#brickyard-section small,
#tilesyard-section small,
.scrapyard-description small {
    color: #9aa0a6;
    font-style: italic;
    font-size: 12px;
}

#scrapyard-image {
    width: 122px;
    height: 122px;
    margin: 30px auto 20px auto;
    border-radius: 10px;
    transition: all 0.3s;
    cursor: pointer;
}

#scrapyard-image:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

#scrapyard-image:active {
    transform: scale(0.98);
}

#brickyard-image {
    width: 122px;
    height: 122px;
    margin: 30px auto 20px auto;
    border-radius: 10px;
    transition: all 0.3s;
    cursor: pointer;
}


#tilesyard-image {
    width: 122px;
    height: 122px;
    margin: 30px auto 20px auto;
    border-radius: 10px;
    transition: all 0.3s;
    cursor: pointer;
}

#tilesyard-image:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

#tilesyard-image:active {
    transform: scale(0.98);
}

#brickyard-image:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

#brickyard-image:active {
    transform: scale(0.98);
}

#scrapyard-image.purchased {
    filter: brightness(1) saturate(1);
}

#scrapyard-cost, #brickyard-cost {
    font-size: 18px;
    color: #FFD700;
    margin: 15px 0;
    font-weight: bold;
}
#scrapyard-cost, #brickyard-cost, #tilesyard-status {
    margin-top: auto;
    min-height: 22px;
}


#buy-scrapyard,
#buy-brick {
    margin-top: 10px;
}

#brickyard-cost {
    color: #e67e22;
}

#buy-scrapyard {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
}

#buy-scrapyard:hover {
    background-color: #45a049;
    transform: scale(1.05);
}

#buy-scrapyard:disabled {
    background-color: #555;
    cursor: not-allowed;
}

#buy-brick {
    background-color: #e67e22;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
}

#buy-brick:hover {
    background-color: #d35400;
    transform: scale(1.05);
}

#buy-brick:disabled {
    background-color: #555;
    cursor: not-allowed;
}

#brickyard-separator {
    background: linear-gradient(180deg, transparent, #34495e, transparent);
    opacity: 0.7;
    width: 2px;
    margin: 0 10px;
    align-self: stretch;
    height: auto;
}


#tilesyard-separator {
    background: linear-gradient(180deg, transparent, #6c5ce7, transparent);
    opacity: 0.7;
    width: 2px;
    margin: 0 10px;
    align-self: stretch;
    height: auto;
}

#brickyard-section h3 {
    color: #e67e22;
    margin-bottom: 10px;
}


.scrapyard-left h3,
#brickyard-section h3,
#tilesyard-section h3 {
    min-height: 24px;
}


#tilesyard-section h3 {
    color: #9b59b6;
    margin-bottom: 10px;
}

#tilesyard-status {
    margin-top: 10px;
    color: #9b59b6;
    font-weight: bold;
}

#tiles-upgrade-level {
    margin-top: 8px;
    color: #caa9ff;
    font-size: 14px;
}

#tiles-level-label {
    margin-top: 4px;
    color: #caa9ff;
    font-size: 14px;
}

#tiles-upgrade-btn {
    background-color: #9b59b6;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    margin-top: 10px;
}

#tiles-upgrade-btn:hover { background-color: #8e44ad; transform: scale(1.05); }
#tiles-upgrade-btn:disabled { background-color: #555; cursor: not-allowed; transform: none; }




@media (max-width: 720px) {
    .scrapyard-content {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    #brickyard-separator,
    #tilesyard-separator {
        display: none;
    }
}

#brickyard-section small {
    color: #95a5a6;
    font-style: italic;
}

#close-scrapyard {
    position: absolute;
    top: 10px;
    right: 15px;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

#close-scrapyard:hover {
    color: #FF5555;
}

#star-container {
    position: static;
    margin-left: auto;
}

#star-btn {
    width: 70px;
    height: 70px;
    cursor: pointer;
    transition: transform 0.2s;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
    display: none;
}

#star-btn:hover {
    transform: scale(1.1);
}

#star-btn:active {
    transform: scale(0.95);
}


#rebirth-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 400px;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border: 2px solid #FF5555;
    border-radius: 15px;
    padding: 20px;
    z-index: 100;
    display: none;
    box-shadow: 0 0 20px rgba(255, 85, 85, 0.3);
}

#rebirth-window.active {
    display: block;
}

.rebirth-content {
    text-align: center;
}

.rebirth-description {
    margin: 15px 0;
    color: #AAA;
    line-height: 1.5;
}

#rebirth-count {
    font-size: 24px;
    color: #FFD700;
    margin: 15px 0;
    font-weight: bold;
}

#confirm-rebirth {
    background: linear-gradient(135deg, #FF5555, #CC0000);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s;
    margin-top: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#confirm-rebirth:hover {
    background: linear-gradient(135deg, #FF3333, #AA0000);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

#confirm-rebirth:active {
    transform: translateY(0);
}


#funnyjoke-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 520px;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    border: 2px solid #888;
    border-radius: 14px;
    padding: 20px;
    z-index: 200;
    display: none;
    box-shadow: 0 0 20px rgba(0,0,0,0.4);
}

#funnyjoke-window.active { display: block; }

.funnyjoke-content { text-align: center; }
.funnyjoke-message { color: #DDD; white-space: pre-line; margin: 12px 0 16px; line-height: 1.5; }
#funnyjoke-close {
    background: linear-gradient(135deg, #666, #444);
    color: white; border: none; padding: 10px 20px; border-radius: 8px;
    cursor: pointer; font-size: 15px; font-weight: bold; transition: all 0.2s;
}
#funnyjoke-close:hover { transform: translateY(-1px); }
#funnyjoke-close:active { transform: translateY(0); }
#close-funnyjoke { position: absolute; top: 10px; right: 15px; color: #aaa; cursor: pointer; font-size: 20px; }
#close-funnyjoke:hover { color: white; }

#confirm-rebirth:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}

/* unified close buttons will style all #close-* elements */

/* Item Shop Modal */
#itemshop-window { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.55); backdrop-filter: blur(2px); z-index: 6000; }
#itemshop-window.active { display: flex; }
.itemshop-content { position: relative; background: var(--panel, rgba(0,0,0,0.7)); border: 1px solid var(--border, #444); border-radius: 14px; padding: 18px; width: min(920px, 94vw); max-height: 82vh; color: var(--text); box-shadow: 0 18px 42px rgba(0,0,0,0.55); display: flex; flex-direction: column; }
.itemshop-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 6px 12px; border-bottom: 1px solid color-mix(in oklab, var(--border) 80%, #5a778e 20%); padding-bottom: 8px; }
.itemshop-header h3 { margin: 0; font-size: 22px; letter-spacing: .3px; }
.itemshop-timer { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }
.itemshop-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; padding: 6px; overflow-y: auto; }
.itemshop-card { position: relative; border: 1px solid color-mix(in oklab, var(--border) 80%, #4a6b86 20%); background: linear-gradient(180deg, rgba(12,18,24,0.55), rgba(10,16,22,0.42)); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: inset 0 1px 2px rgba(0,0,0,0.25); transition: transform .15s ease, box-shadow .15s ease, border-color .2s ease; align-items: center; text-align: center; }
.itemshop-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.35); border-color: color-mix(in oklab, var(--border) 60%, #7aa8cf 40%); }
.itemshop-card > * { align-self: center; }
.itemshop-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; text-align: center; width: 100%; }
.itemshop-rarity { display: inline-block; font-size: 12px; opacity: 0.95; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.06); width: fit-content; border: 1px solid color-mix(in oklab, var(--border) 70%, currentColor 30%); margin-inline: auto; }
.itemshop-price { color: var(--accent-2, #4CAF50); font-weight: 700; font-size: 14px; }
.itemshop-stock { font-size: 12px; color: var(--muted); }
.itemshop-price, .itemshop-stock { width: 100%; text-align: center; }
.itemshop-buy { margin-top: 4px; padding: 9px 12px; border-radius: 10px; border: 1px solid color-mix(in oklab, var(--border) 50%, var(--accent-2) 50%); background: var(--accent-2, #4CAF50); color: #fff; cursor: pointer; font-weight: 700; transition: transform .12s ease, filter .12s ease; }
.itemshop-buy:hover { filter: brightness(1.06); transform: translateY(-1px); }
.itemshop-buy:active { transform: translateY(0); }
.itemshop-buy:disabled { background: #555; border-color: #555; cursor: not-allowed; filter: none; transform: none; }
/* Remove older close button styles in favor of unified rule below */

/* Rarity colors (fallback if no theme mapping) */
.rarity-Common { color: #bfbfbf; }
.rarity-Uncommon { color: #4CAF50; }
.rarity-Rare { color: #4aa3ff; }
.rarity-Mythic { color: #ff66d9; }
.rarity-Legendary { color: #FFD700; }

/* removed per-window hover styling */

.hidden {
    display: none !important;
}

/* Use for elements that should be unavailable visually but still usable by scripts (e.g., file inputs) */
.visually-hidden {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

#greenupgrade-btn {
    width: 60px;
    height: 55px;
    cursor: pointer;
    transition: transform 0.2s;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}
#greenupgrade-btn:hover { transform: scale(1.1); }
#greenupgrade-btn:active { transform: scale(0.95); }


#blueupgrade-btn {
    width: 60px;
    height: 70px;
    cursor: pointer;
    transition: transform 0.2s;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}
#blueupgrade-btn:hover {
    transform: scale(1.1);
}
#blueupgrade-btn:active {
    transform: scale(0.95);
}

#greenupgrade-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    max-width: 500px;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    border: 2px solid #FFD700;
    border-radius: 15px;
    padding: 20px;
    z-index: 100;
    display: none;
}

#greenupgrade-window.active {
    display: block;
}

.greenupgrade-content {
    text-align: center;
}


#greenupgrade-window .greenupgrade-grid {
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-width: thin;
}
#greenupgrade-window .greenupgrade-grid::-webkit-scrollbar { width: 8px; }
#greenupgrade-window .greenupgrade-grid::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius:4px; }
#greenupgrade-window .greenupgrade-grid::-webkit-scrollbar-thumb { background:#555; border-radius:4px; }
#greenupgrade-window .greenupgrade-grid::-webkit-scrollbar-thumb:hover { background:#777; }

.greenupgrade-description {
    margin: 15px 0;
    color: #AAA;
    font-size: 1.1em;
    margin-bottom: 24px;
}

.greenupgrade-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
}

.greenupgrade-item {
    background-color: transparent;
    border: 1px solid #444;
    border-radius: 12px;
    padding: 16px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    min-width: 120px;
    min-height: 160px;
}

.greenupgrade-item img {
    width: 46px;
    height: 58px;
    border-radius: 5px;
    margin-bottom: 8px;
}

.greenupgrade-item:hover {
    border-color: #27ae60;
    transform: scale(1.03);
}

.greenupgrade-item.equipped {
    border-color: #FFD700;
    box-shadow: 0 0 10px rgba(255,215,0,0.4);
    position: relative;
}
.greenupgrade-item.equipped::after {
    content: 'EQUIPPED';
    position: absolute;
    top: -10px;
    right: -10px;
    background: linear-gradient(90deg,#f1c40f,#e67e22);
    color: #000;
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

#close-greenupgrade {
    position: absolute;
    top: 10px;
    right: 15px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

.greenupgrade-button {
    margin: 12px 0 8px 0;
    padding: 8px 24px;
    font-size: 14px;
    font-weight: bold;
    color: white;
    background-color: #27ae60;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.greenupgrade-button:hover {
    background-color: #219a52;
    transform: scale(1.05);
}


#blueupgrade-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    max-width: 520px;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    border: 2px solid #2196F3;
    border-radius: 15px;
    padding: 20px;
    z-index: 120;
    display: none;
}

#blueupgrade-window.active {
    display: block;
}

.blueupgrade-content {
    text-align: center;
}

.blueupgrade-description {
    margin: 15px 0;
    color: #AAA;
    font-size: 1.1em;
    margin-bottom: 24px;
}

#blueupgrade-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px 32px;
    justify-items: center;
    align-items: stretch;
    position: relative;
}

#blue-earnings-upgrade {
    grid-column: 1 / span 2;
    justify-self: center;
}


.blueupgrade-item .blueupgrade-title { min-height: 20px; }
.blueupgrade-item .blueupgrade-level { min-height: 18px; }
.blueupgrade-item .blueupgrade-effect { min-height: 34px; display:flex; align-items:center; }
.blueupgrade-item .blueupgrade-cost { min-height: 18px; }

@media (max-width: 520px) {
    #blueupgrade-grid { grid-template-columns: 1fr; }
    #blue-earnings-upgrade { grid-column: 1; }
}

.blueupgrade-item {
    background-color: transparent;
    border: 1px solid #444;
    border-radius: 12px;
    padding: 16px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    min-width: 120px;
    min-height: 160px;
}

.blueupgrade-item img {
    width: 46px;
    height: 58px;
    border-radius: 5px;
    margin-bottom: 8px;
}

.blueupgrade-item:hover {
    border-color: #2196F3;
    transform: scale(1.03);
}

#close-blueupgrade {
    position: absolute;
    top: 10px;
    right: 15px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

#close-blueupgrade:hover {
    color: #2196F3;
}

.blueupgrade-button {
    margin: 12px 0 8px 0;
    padding: 8px 24px;
    font-size: 14px;
    font-weight: bold;
    color: white;
    background-color: #2196F3;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.blueupgrade-button:hover {
    background-color: #1b7ccc;
    transform: scale(1.05);
}

.greenupgrade-button:disabled {
    background-color: #bbb;
    cursor: not-allowed;
}

.greenupgrade-text {
    margin-top: 5px;
    font-size: 1.1em;
    color: #27ae60;
    text-align: center;
    font-weight: bold;
}

#mysterybook-container {
    position: static;
    margin-left: auto;
}

#tree-container {
    position: static;
}

#tree-btn {
    width: 70px;
    height: 70px;
    cursor: pointer;
    transition: transform 0.2s;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}

#tree-btn:hover {
    transform: scale(1.1);
}

#tree-btn:active {
    transform: scale(0.95);
}

#mysterybook-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    max-width: 500px;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    border: 2px solid #FFD700;
    border-radius: 15px;
    padding: 20px;
    z-index: 100;
    display: none;
}

#mysterybook-window.active {
    display: block;
}

.mysterybook-content {
    text-align: center;
}

.mysterybook-description {
    margin: 15px 0;
    color: #AAA;
    font-size: 1.1em;
    margin-bottom: 24px;
}

.mysterybook-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-width: thin;
}
.mysterybook-grid::-webkit-scrollbar { width: 8px; }
.mysterybook-grid::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius:4px; }
.mysterybook-grid::-webkit-scrollbar-thumb { background:#555; border-radius:4px; }
.mysterybook-grid::-webkit-scrollbar-thumb:hover { background:#777; }

.mysterybook-item {
    background-color: transparent;
    border: 1px solid #444;
    border-radius: 12px;
    padding: 16px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    min-width: 100px;
    min-height: 140px;
}

.mysterybook-item img {
    width: 46px;
    height: 58px;
    border-radius: 5px;
    margin-bottom: 8px;
}

.mysterybook-item:hover {
    border-color: #FFD700;
    transform: scale(1.03);
}

.mysterybook-text {
    margin-top: 5px;
    font-size: 12px;
    color: #FFD700;
    text-align: center;
}

#mysterybook-btn {
    width: 70px;
    height: 70px;
    cursor: pointer;
    transition: transform 0.2s;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}

#mysterybook-btn:hover {
    transform: scale(1.1);
}

#mysterybook-btn:active {
    transform: scale(0.95);
}

#master-token-display {
    margin-top: 20px;
    text-align: center;
}

#master-token-count {
    font-size: 18px;
    color: #FFD700;
    font-weight: bold;
}

.mysterybook-button {
    margin-top: 5px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    background-color: #4CAF50;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.mysterybook-button:hover {
    background-color: #45a049;
    transform: scale(1.05);
}

.mysterybook-button:disabled {
    background-color: #555;
    cursor: not-allowed;
}

.mysterybook-level {
    font-size: 11px;
    color: #AAA;
    text-align: center;
    margin-top: 3px;
}

.mysterybook-cost {
    font-size: 11px;
    color: #FFD700;
    text-align: center;
    margin-top: 3px;
}

#tree-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    max-width: 500px;
    height: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    border: 2px solid #FFD700;
    border-radius: 15px;
    padding: 20px;
    z-index: 100;
    display: none;
}

#tree-window.active {
    display: block;
}

.tree-content {
    text-align: center;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.tree-description {
    margin: 15px 0;
    color: #AAA;
}

.tree-grid {
    position: relative;
    width: 420px;
    height: 860px;
    margin: 10px auto 0;
}


.tree-slot {
    position: absolute;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}



#slot-0 { left: 160px; top: 0px; }
#slot-1 { left: 20px;  top: 140px; }
#slot-2 { left: 160px; top: 280px; }
#slot-3 { left: 300px; top: 140px; }
#slot-4 { left: 300px; top: 280px; }
#slot-5 { left: 160px; top: 420px; }
#slot-6 { left: 20px;  top: 560px; }
#slot-8 { left: 300px; top: 560px; }
#slot-7 { left: 160px; top: 700px; }

.tree-item:nth-child(1) { grid-column: 1/3; justify-self: center; }
.tree-item:nth-child(2) { grid-column: 1; }
.tree-item:nth-child(3) { grid-column: 2; }
.tree-item:nth-child(4) { grid-column: 1; }
.tree-item:nth-child(5) { grid-column: 2; }
.tree-item:nth-child(6) { grid-column: 1/3; justify-self: center; }

.tree-connections {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.tree-item {
    width: 90px;
    height: 90px;
    background-color: #4a90e2;
    border: 3px solid #333;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.tree-item.locked {
    background-color: #666;
    opacity: 0.5;
    cursor: not-allowed;
}

.tree-item.purchased {
    background-color: #4CAF50;
    border-color: #45a049;
}

.tree-item.available {
    background-color: #4a90e2;
    border-color: #333;
}

.tree-item:hover:not(.locked) {
    border-color: #FFD700;
    transform: scale(1.1);
}

.tree-item.available:hover {
    background-color: #5ba3f5;
}

.tree-item.purchased:hover {
    background-color: #66d46a;
}

.tree-item img {
    width: 56px;
    height: 56px;
    border-radius: 5px;
    object-fit: contain;
}

.tree-text {
    font-size: 11px;
    color: #FFD700;
    text-align: center;
    margin-bottom: 5px;
}

.tree-button {
    margin-top: 5px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    background-color: #4CAF50;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.tree-button:hover {
    background-color: #45a049;
    transform: scale(1.05);
}

.tree-button:disabled {
    background-color: #555;
    cursor: not-allowed;
}

.tree-cost {
    font-size: 10px;
    color: #FFD700;
    text-align: center;
    margin-top: 3px;
}

#close-tree {
    position: absolute;
    top: 10px;
    right: 15px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

#close-tree:hover {
    color: #4CAF50;
}

#tree-info-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    max-width: 400px;
    height: auto;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border: 2px solid #4CAF50;
    border-radius: 15px;
    padding: 20px;
    z-index: 150;
    display: none;
}

#tree-info-window.active {
    display: block;
}

.tree-info-content {
    text-align: center;
}

.tree-info-description {
    margin: 15px 0;
    color: #AAA;
    line-height: 1.5;
}

.tree-info-requirement {
    font-size: 16px;
    color: #FFD700;
    margin: 15px 0;
    font-weight: bold;
}

.tree-info-status {
    font-size: 14px;
    color: #4CAF50;
    margin: 10px 0;
}

.tree-info-button {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
    margin: 15px 0;
}

.tree-info-button:hover {
    background: linear-gradient(135deg, #45a049, #3d8b40);
    transform: translateY(-2px);
}

.tree-info-button:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}


.tree-info-button:disabled[data-state="bought"] {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    opacity: 0.8;
}

.tree-info-button:disabled[data-state="bought"]:before {
    content: "✓ ";
    font-weight: bold;
}

.tree-info-tokens {
    font-size: 12px;
    color: #FFD700;
    margin-top: 10px;
}

#close-tree-info {
    position: absolute;
    top: 10px;
    right: 15px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

#close-tree-info:hover {
    color: #4CAF50;
}


#storm-cloud {
    position:fixed;
    top:-60px;
    left:0;
    width:100%;
    height:200px;
    background:url('assets/storm.png') repeat-x top center;
    background-size:contain;
    pointer-events:none;
    opacity:0;
    transition:opacity .5s ease;
    z-index:4000;
}
#storm-cloud.active { opacity:1; }
#storm-timer.storm-owned { display:block !important; }



.mysterybook-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: auto;
    gap: 24px 32px;
    max-width: 560px;
    margin: 0 auto 40px;
    justify-items: stretch;
    align-items: stretch;
}

.mysterybook-item {
    width: 100% !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 180px;
    box-sizing: border-box;
}


.mysterybook-item:nth-child(n) {
    transform: none !important;
    left: 0 !important;
    right: 0 !important;
}


.mysterybook-item img { margin-bottom: 10px !important; }
.mysterybook-button { margin-top: 4px !important; }
.mysterybook-level, .mysterybook-cost { margin-top: 2px !important; }


.mysterybook-grid > .mysterybook-item { flex: 0 0 auto; }
.mysterybook-button { min-width: 84px; }
.mysterybook-item { min-width: unset !important; }


@media (max-width: 520px) {
    .mysterybook-grid { gap: 16px 16px; }
}


@media (max-width: 900px) {
    #upgrade-window,
    #scrapyard-window,
    #rebirth-window,
    #greenupgrade-window,
    #mysterybook-window,
    #blueupgrade-window,
    #tree-window,
    #tree-info-window {
        max-height: 80vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .upgrade-grid,
    .scrapyard-content,
    .rebirth-content,
    .greenupgrade-content,
    .mysterybook-content,
    #blueupgrade-grid,
    .tree-content,
    .tree-info-content {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        max-height: 100%;
        padding-right: 6px;
    }

    
    .upgrade-grid,
    .scrapyard-content,
    .rebirth-content,
    .greenupgrade-content,
    .mysterybook-content,
    #blueupgrade-grid,
    .tree-content,
    .tree-info-content {
        scrollbar-color: #555 #202020;
    }

    .upgrade-grid::-webkit-scrollbar,
    .scrapyard-content::-webkit-scrollbar,
    .rebirth-content::-webkit-scrollbar,
    .greenupgrade-content::-webkit-scrollbar,
    .mysterybook-content::-webkit-scrollbar,
    #blueupgrade-grid::-webkit-scrollbar,
    .tree-content::-webkit-scrollbar,
    .tree-info-content::-webkit-scrollbar { width: 6px; }
    .upgrade-grid::-webkit-scrollbar-track,
    .scrapyard-content::-webkit-scrollbar-track,
    .rebirth-content::-webkit-scrollbar-track,
    .greenupgrade-content::-webkit-scrollbar-track,
    .mysterybook-content::-webkit-scrollbar-track,
    #blueupgrade-grid::-webkit-scrollbar-track,
    .tree-content::-webkit-scrollbar-track,
    .tree-info-content::-webkit-scrollbar-track { background: rgba(0,0,0,0.25); }
    .upgrade-grid::-webkit-scrollbar-thumb,
    .scrapyard-content::-webkit-scrollbar-thumb,
    .rebirth-content::-webkit-scrollbar-thumb,
    .greenupgrade-content::-webkit-scrollbar-thumb,
    .mysterybook-content::-webkit-scrollbar-thumb,
    #blueupgrade-grid::-webkit-scrollbar-thumb,
    .tree-content::-webkit-scrollbar-thumb,
    .tree-info-content::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }
    .upgrade-grid::-webkit-scrollbar-thumb:hover,
    .scrapyard-content::-webkit-scrollbar-thumb:hover,
    .rebirth-content::-webkit-scrollbar-thumb:hover,
    .greenupgrade-content::-webkit-scrollbar-thumb:hover,
    .mysterybook-content::-webkit-scrollbar-thumb:hover,
    #blueupgrade-grid::-webkit-scrollbar-thumb:hover,
    .tree-content::-webkit-scrollbar-thumb:hover,
    .tree-info-content::-webkit-scrollbar-thumb:hover { background: #777; }
}


@media (max-height: 600px) {
    #mysterybook-window .mysterybook-content,
    #greenupgrade-window .greenupgrade-content,
    #blueupgrade-window .greenupgrade-content {
        max-height: 70vh;
    }
}

#settings-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 75%;
    max-width: 900px;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    border: 2px solid #888;
    border-radius: 14px;
    padding: 20px 20px 60px 20px;
    z-index: 140;
    display: none;
}
#settings-window.active { display: block; }

.settings-content { position: relative; text-align: center; }
.settings-content h3 { margin: 0 0 12px 0; }

.settings-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid #444;
    border-radius: 10px;
    margin-bottom: 16px;
}
.settings-stats .stat { font-size: 15px; color: #ddd; }
.settings-stats .label { color: #FFD700; margin-right: 6px; }

.settings-actions { display: flex; gap: 12px; justify-content: center; }
.settings-actions button {
    background: #4CAF50;
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: transform .2s, background .2s;
}
.settings-actions button:hover { transform: scale(1.05); background: #45a049; }
.settings-actions button:active { transform: scale(0.96); }

#settings-palette {
    position: absolute;
    left: 12px;
    bottom: -10px;
    width: 56px;
    height: 56px;
    opacity: 0.95;
    pointer-events: auto;
    cursor: pointer;
}

#settings-theme-label {
    position: absolute;
    left: 80px;
    bottom: -14px;
    font-size: 14px;
    color: var(--text);
    opacity: 0.9;
    user-select: none;
}

#close-settings {
    position: absolute;
    top: 10px;
    right: 15px;
    color: white;
    font-size: 24px;
    cursor: pointer;
}
#close-settings:hover { color: #FF5555; }

@media (max-width: 720px) {
    #settings-window { width: 90%; }
    .settings-stats { grid-template-columns: repeat(2, 1fr); }
}

.tree-content::-webkit-scrollbar {
    width: 8px;
}

.tree-content::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
}

.tree-content::-webkit-scrollbar-thumb {
    background: #4a90e2;
    border-radius: 4px;
}

.tree-content::-webkit-scrollbar-thumb:hover {
    background: #5ba3f5;
}

#settings-container {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: auto;
    height: auto;
}


#settings-btn {
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
    filter: drop-shadow(0 0 4px rgba(0,0,0,0.4));
}

/* Unified hover/active animation for UI icon buttons */
#settings-btn,
#earth-btn,
#leaderboard-btn,
#itemshop-btn,
#inventory-btn,
#book-btn,
#mysterybook-btn,
#tree-btn,
#greenupgrade-btn,
#blueupgrade-btn,
#upgrade-btn,
#star-btn {
    transition: transform .2s ease, filter .2s ease;
}
#settings-btn:hover,
#earth-btn:hover,
#leaderboard-btn:hover,
#itemshop-btn:hover,
#inventory-btn:hover,
#book-btn:hover,
#mysterybook-btn:hover,
#tree-btn:hover,
#greenupgrade-btn:hover,
#blueupgrade-btn:hover,
#upgrade-btn:hover,
#star-btn:hover {
    transform: scale(1.08);
    filter: brightness(1.05);
}
#settings-btn:active,
#earth-btn:active,
#leaderboard-btn:active,
#itemshop-btn:active,
#inventory-btn:active,
#book-btn:active,
#mysterybook-btn:active,
#tree-btn:active,
#greenupgrade-btn:active,
#blueupgrade-btn:active,
#upgrade-btn:active,
#star-btn:active {
    transform: scale(0.95);
}

#earth-btn {
    width: 50px;
    height: 60px;
    margin-top: 0;
    cursor: pointer;
    display: block;
    filter: drop-shadow(0 0 4px rgba(0,0,0,0.35));
    transition: transform 0.2s ease, filter 0.2s ease;
}
/* overrides replaced by unified rules above */

.chat-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 6000;
}
.chat-username-content {
    background: #222;
    padding: 24px 28px;
    border-radius: 10px;
    width: 320px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.5);
}
.chat-username-content h3 { margin-top: 0; margin-bottom: 16px; }
#chat-username-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #555;
    background: #111;
    color: #eee;
    border-radius: 6px;
    margin-bottom: 14px;
}
.chat-username-actions { display: flex; gap: 10px; justify-content: flex-end; }
.chat-username-actions button {
    background: #444;
    border: 1px solid #666;
    color: #eee;
    padding: 8px 14px;
    cursor: pointer;
    border-radius: 6px;
}
.chat-username-actions button:hover { background: #555; }

#chat-panel {
    position: fixed;
    top: 70px;
    right: 12px;
    width: 330px;
    max-height: 520px;
    background: rgba(20,20,20,0.92);
    border: 1px solid #333;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    z-index: 5500;
    backdrop-filter: blur(4px);
}
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #2c2c2c;
    border-bottom: 1px solid #3a3a3a;
    border-radius: 10px 10px 0 0;
    font-weight: bold;
}
.chat-header-buttons button {
    background: #444;
    color: #eee;
    border: 1px solid #555;
    cursor: pointer;
    padding: 2px 8px;
    margin-left: 6px;
    border-radius: 4px;
}
.chat-header-buttons button:hover { background:#555; }
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.35;
    scrollbar-width: thin;
}
#chat-messages::-webkit-scrollbar { width: 8px; }
#chat-messages::-webkit-scrollbar-track { background: #161616; }
#chat-messages::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
#chat-messages::-webkit-scrollbar-thumb:hover { background: #555; }
.chat-line { margin-bottom: 6px; word-wrap: break-word; }
.chat-line .user { color: #4aa3ff; margin-right: 4px; }
.chat-line .time { color:#777; font-size:11px; margin-left:4px; }
.chat-line.system { color:#b8860b; font-style: italic; }
.chat-input-row {
    display: flex;
    gap: 6px;
    padding: 10px 10px 12px 10px;
    border-top: 1px solid #333;
}
#chat-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #444;
    background: #111;
    color: #eee;
    border-radius: 6px;
}
#chat-send {
    background: #4aa3ff;
    border: none;
    color: white;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.falling-master-token {
    position: fixed;
    top: -80px;
    width: 80px;
    height: 80px;
    pointer-events: auto;
    cursor: pointer;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulseMaster 1.2s ease-in-out infinite;
    filter: drop-shadow(0 0 6px rgba(255,215,0,0.75));
}
@keyframes pulseMaster {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.18); }
}

/* ===== Global Chat (icon + window) ===== */
#chat-send:hover { background:#5bb2ff; }
#chat-send:disabled { opacity: 0.5; cursor: default; }
#chat-container { position: static; z-index: 1200; display: flex; flex-direction: column; align-items: center; gap: 10px; width: 50px; }
/* ensure icons in the side stack are centered */
#chat-container img { display: block; margin: 0 auto; touch-action: manipulation; }
#earth-btn { width: 50px; height: 60px; cursor: pointer; filter: drop-shadow(0 0 4px rgba(0,0,0,0.35)); transition: transform .2s ease, filter .2s ease; }
#earth-btn:hover { transform: scale(1.08) rotate(-6deg); }
#earth-btn:active { transform: scale(0.94); }
/* Leaderboard icon next to chat */
#leaderboard-btn { width: 40px; height: 40px; cursor: pointer; filter: drop-shadow(0 0 4px rgba(0,0,0,0.35)); transition: transform .2s ease, filter .2s ease; margin: 2px 0; }
#leaderboard-btn:hover { transform: scale(1.08); }
#leaderboard-btn:active { transform: scale(0.94); }
#chat-window { position: fixed; top: 90px; right: 20px; width: min(440px, 94vw); height: 560px; background: color-mix(in oklab, var(--panel) 85%, #1a2530 15%); border: 1px solid color-mix(in oklab, var(--border) 70%, #4a6b86 30%); border-radius: 14px; box-shadow: 0 16px 36px rgba(0,0,0,0.55); z-index: 4500; display: none; backdrop-filter: blur(6px); }
#chat-window.active { display: block; }
#chat-window.muted { filter: blur(1px) saturate(0.7); }
#chat-window .chat-muted-overlay { position:absolute; inset:0; display:none; align-items:center; justify-content:center; backdrop-filter: blur(4px) brightness(0.8); z-index:5; }
#chat-window.muted .chat-muted-overlay { display:flex; }
#chat-window .chat-muted-overlay .mute-box { background: rgba(0,0,0,0.6); border:1px solid rgba(255,255,255,0.15); border-radius:12px; padding:18px 22px; color:#fff; text-align:center; box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
#chat-window .chat-muted-overlay .mute-title { font-size:18px; font-weight:800; letter-spacing:0.3px; margin-bottom:6px; }
#chat-window .chat-muted-overlay .mute-sub { font-size:14px; opacity:0.9; }
#close-chat { position: absolute; top: 10px; right: 14px; color: var(--muted); cursor: pointer; font-size: 20px; }
#close-chat:hover { color: var(--text); }
.chat-content { display: flex; flex-direction: column; height: 100%; padding: 12px 12px 22px; }

/* Leaderboard window */
.leaderboard-content { display: flex; flex-direction: column; height: 100%; padding: 24px 16px 30px; position: relative; gap: 14px; box-sizing: border-box; }
.leaderboard-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; padding-right: 64px; }
.leaderboard-tabs { display: flex; gap: 8px; }
.leaderboard-tabs .lb-tab { padding: 6px 10px; border: 1px solid var(--border); background: #2a2a2a; color: var(--text); border-radius: 8px; cursor: pointer; }
.leaderboard-tabs .lb-tab.active { background: #3a3a3a; color: var(--accent); border-color: var(--accent); }
.leaderboard-body { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--border); border-radius: 12px; padding: 12px 12px 14px; background: rgba(0,0,0,0.25); margin: 16px 12px 24px; }
.leaderboard-body { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--border); border-radius: 12px; padding: 14px 14px 16px; background: rgba(0,0,0,0.25); margin: 16px 18px 12px; }
.leaderboard-row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; padding: 8px; border-bottom: 1px dashed var(--border); }
.leaderboard-row:nth-child(odd) { background: rgba(255,255,255,0.03); }
.leaderboard-rank { font-weight: 700; color: var(--accent); text-align: right; }
.leaderboard-name { color: var(--text); }
.leaderboard-value { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.leaderboard-note { margin-top: 8px; color: var(--muted); font-size: 12px; }

/* Centered, tidy leaderboard window */
#leaderboard-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(540px, 94vw);
    height: min(540px, 78vh);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 16px 36px rgba(0,0,0,0.55);
    z-index: 4400;
    display: none;
    backdrop-filter: blur(6px);
    overflow: hidden; /* clip inner shadows/edges so nothing sticks out */
    box-sizing: border-box;
}
#leaderboard-window.active { display: block; }
/* Unified close button style for all windows - plain white X, no hover/animation */
.close-btn,
[id^="close-"] {
    position: absolute;
    top: 10px;
    right: 12px;
    cursor: pointer;
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    user-select: none;
    background: transparent;
    border: none;
    width: auto;
    height: auto;
    z-index: 1;
}

@media (max-width: 520px) {
    #leaderboard-window {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: calc(100vw - 20px);
    height: min(580px, 82vh);
    }
}

/* Mobile-friendly sizing */
@media (max-width: 520px) {
  #counter { font-size: 32px; }
  #scrap-image { width: 100px; height: 160px; }
  #cooldown-container { width: 92vw; max-width: 340px; }
  #bottom-buttons { gap: 10px; padding: 8px 14px; }
}

/* Reduce accidental selection and zoom on interactive elements */
button, .inventory-actions button, img { user-select: none; -webkit-user-drag: none; }
button, .inventory-actions button, #scrap-image, #earth-btn, #leaderboard-btn, #itemshop-btn, #inventory-btn { touch-action: manipulation; }
#chat-messages { padding-bottom: 16px; }
.chat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; cursor: move; user-select: none; }
.chat-header h3 { margin: 0; font-size: 18px; color: color-mix(in oklab, var(--text) 92%, #cfe8ff 8%); letter-spacing: .3px; }
.chat-actions { display: flex; align-items: center; gap: 8px; cursor: default; }
#chat-status { font-size: 12px; color: #d7fbe8; padding: 3px 9px; border: 1px solid #1f6b43; border-radius: 999px; background: #0e2b1d; }
#chat-minimize { display: none !important; }
#chat-messages { flex: 1; overflow-y: auto; border: 1px solid color-mix(in oklab, var(--border) 70%, #5a778e 30%); border-radius: 10px; padding: 10px; background: linear-gradient(180deg, rgba(12,18,24,0.55), rgba(10,16,22,0.4)); box-shadow: inset 0 1px 3px rgba(0,0,0,0.35); }
.chat-msg { margin: 6px 0; line-height: 1.35; word-wrap: break-word; color: #e9f2fb; padding: 0; border-radius: 0; background: transparent; border: none; }
.chat-msg .from { color: #ffdf88; margin-right: 6px; font-weight: 700; }
.chat-msg .time { color: #b9c6d3; font-size: 11px; margin-left: 6px; }
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; margin-bottom: 8px; }
#chat-input { flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid color-mix(in oklab, var(--border) 70%, #4a6b86 30%); background: #0e141a; color: var(--text); box-shadow: inset 0 1px 2px rgba(0,0,0,0.25); outline: none; }
#chat-input:focus { border-color: #365f7b; box-shadow: 0 0 0 3px rgba(76, 194, 255, .15); }
#chat-send { padding: 10px 16px; border-radius: 10px; border: 1px solid #174e2c; background: linear-gradient(180deg, #1a8f4a, #156e3a); color: #fff; cursor: pointer; font-weight: 700; }
#chat-send:hover { filter: brightness(1.05); }
#chat-send:active { transform: translateY(1px); }
#chat-send:disabled { opacity: 0.6; cursor: not-allowed; }
@media (max-width: 520px) { #chat-container { right: 60px; } #chat-window { right: 10px; left: 10px; width: auto; height: 60vh; } }
#chat-name-window { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.55); z-index: 6000; }
#chat-name-window:not(.hidden) { display: flex; }
.chat-name-content {
    width: min(440px, 92vw);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 16px 36px rgba(0,0,0,.55);
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-auto-rows: auto;
    gap: 10px;
}
.chat-name-content h3 { margin: 0 0 8px; color: color-mix(in oklab, var(--text) 92%, #cfe8ff 8%); grid-column: 1 / -1; }
.chat-name-content p { grid-column: 1 / -1; margin: 6px 0 0; }
.chat-name-content input { grid-column: 1; width: 100%; padding: 10px 12px; border: 1px solid color-mix(in oklab, var(--border) 70%, #4a6b86 30%); border-radius: 10px; background: #0e141a; color: var(--text); margin: 0; outline: none; align-self: center; }
.chat-name-content input:focus { border-color: #365f7b; box-shadow: 0 0 0 3px rgba(76, 194, 255, .15); }
.chat-name-actions { grid-column: 2; align-self: center; margin: 0; }
#chat-name-save { background: var(--accent-2); color: #fff; border: 1px solid color-mix(in oklab, var(--border) 50%, var(--accent-2) 50%); padding: 10px 14px; border-radius: 10px; cursor: pointer; }
#chat-name-save:hover { filter: brightness(1.05); }
.chat-name-actions { display: flex; justify-content: flex-end; gap: 10px; }
.chat-name-actions .primary { background: #0d497d; color: #fff; border: 1px solid #0b3a63; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
#close-chat-name { position: absolute; top: 10px; right: 12px; cursor: pointer; font-size: 18px; color: var(--muted); }

/* ===== ItemShop Icon ===== */
#itemshop-btn { width: 40px; height: 50px; cursor: pointer; filter: drop-shadow(0 0 3px rgba(0,0,0,0.35)); display: block; margin-top: 6px; }
/* overrides replaced by unified rules above */
#inventory-btn { width: 50px; height: 65px; cursor: pointer; filter: drop-shadow(0 0 3px rgba(0,0,0,0.35)); display: block; margin-top: 6px; }
/* overrides replaced by unified rules above */

/* Inventory Modal */
#inventory-window { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 4500; }
#inventory-window.active { display: flex; }
.inventory-content { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; width: min(760px, 92vw); height: min(520px, 80vh); display: flex; flex-direction: column; gap: 12px; }
.inventory-header { display: flex; align-items: center; justify-content: space-between; }
.inventory-capacity { color: var(--muted); font-size: 14px; }
.inventory-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 6px; overflow-y: auto; }
.inventory-card { position: relative; border: 1px solid var(--border); background: rgba(0,0,0,0.35); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; min-height: 120px; text-align: center; }
.inventory-card.empty { opacity: 0.4; border-style: dashed; }
.inventory-name { font-weight: 600; color: var(--text); font-size: 14px; text-align: center; }
.inventory-rarity { display: inline-block; font-size: 12px; opacity: 0.95; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.06); width: fit-content; border: 1px solid color-mix(in oklab, var(--border) 70%, currentColor 30%); margin-inline: auto; }
.inventory-price { color: var(--accent-2, #4CAF50); font-weight: 700; font-size: 13px; width: 100%; text-align: center; }
.inventory-actions { display: flex; gap: 8px; }
.inventory-actions button { font-size: 12px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: #333; color: #eee; cursor: pointer; }
.inventory-actions button:hover { filter: brightness(1.05); }
.hint-badge { position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; background: url('assets/hint.png') center/contain no-repeat; opacity: 0.9; cursor: pointer; }

/* Inventory actions: place reload button next to close X */
#reload-inventory { right: 38px !important; top: 10px !important; transform: translateY(2px); }

/* Item hint modal */
#itemhint-window { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 4600; }
#itemhint-window.active { display: flex; }
.itemhint-content { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; width: min(520px, 92vw); max-height: 70vh; overflow: auto; }
.itemhint-text { color: var(--text); white-space: pre-line; }