:root {
    --bg: #ffffff;
    --panel: #f4f4f4;
    --text: #000000;
    --accent: var(--theme-accent, #538d4e);
    /* Green */
    --accent-hover: #43703e;
    --purple: #9D4EDD;
    --disabled: #3a3a3c;
    --gold: #FFD700;
    --charge: #0077ED;
    /* Blue for Charge */
    --boss-hp: #e21b3c;
    /* Red for Boss */
    --merger-blue: #0077ED;
    /* Blue for Merger */
    --selection-border: #0044cc;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    transform: none !important;
    filter: none !important;
    perspective: none !important;
    will-change: auto !important;
}

body.charging-active,
body.charging-active * {
    cursor: none !important;
}

/* HEADER */
header {
    padding: 15px;
    background-color: var(--panel);
    border-bottom: 2px solid #ccc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.back-link {
    color: #888;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: bold;
}

h1 {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem;
    text-transform: uppercase;
}

/* NEWS TICKER */
.beagle-ticker-wrap {
    width: 100%;
    background-color: var(--panel, #eee);
    color: var(--text, #444);
    font-family: 'Georgia', 'Times New Roman', Times, serif;
    font-size: 16px;
    font-weight: bold;
    padding: 8px 0;
    white-space: nowrap;
    border-bottom: 2px solid #ccc;
    display: none;
    align-items: center;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 8;
}

.beagle-ticker-content {
    display: flex;
    align-items: center;
    animation: beagle-scroll 60s linear infinite;
    padding-left: 100%;
}

.ticker-item {
    margin-right: 150px;
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 100%;
}

.ticker-item::after {
    content: "♦";
    position: absolute;
    right: -75px;
    color: var(--accent);
    font-size: 14px;
    top: 50%;
    transform: translateY(-50%);
}

.ticker-item.golden-news {
    color: var(--gold);
    cursor: pointer;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.ticker-item.golden-news::before {
    content: "🚨 ";
}

.ticker-item.golden-news:hover {
    text-decoration: underline;
    color: #000;
}

.beagle-ticker-wrap:hover .beagle-ticker-content {
    animation-play-state: paused;
}

@keyframes beagle-scroll {
    0% {
        transform: translate3d(0, 0, 0);
    }

    100% {
        transform: translate3d(-100%, 0, 0);
    }
}

/* GAME LAYOUT */
#game-container {
    display: flex;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

#click-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: radial-gradient(circle at center, var(--panel, #f4f4f4) 0%, var(--bg, #ffffff) 80%);
    transition: background 0.5s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#click-zone.flow-active {
    background: radial-gradient(circle at center, #4a3b00 0%, var(--bg) 70%);
    box-shadow: inset 0 0 50px var(--gold);
}

#click-zone.boss-active {
    background: radial-gradient(circle at center, #330000 0%, #1a0000 70%);
    box-shadow: inset 0 0 50px red;
}

#click-zone.merger-active {
    background: radial-gradient(circle at center, #001a33 0%, #000d1a 70%);
    box-shadow: inset 0 0 50px var(--merger-blue);
}

#flow-timer {
    position: absolute;
    top: 60px;
    background: var(--gold);
    color: black;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 900;
    font-family: 'Poppins', sans-serif;
    text-transform: uppercase;
    display: none;
    z-index: 100;
    box-shadow: 0 0 20px var(--gold);
    animation: pulse 1s infinite;
}

/* ORBITING WRITERS - CSS ANIMATION SYSTEM */
#writer-orbit-container {
    position: absolute;
    top: 58%;
    left: 50%;
    width: 0;
    height: 0;
    z-index: 6;
    pointer-events: none;
}

.orbit-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    animation: spinRing linear infinite;
}

#ring-1 {
    animation-duration: 20s;
}

#ring-2 {
    animation-duration: 30s;
    animation-direction: reverse;
}

#ring-3 {
    animation-duration: 45s;
}

@keyframes spinRing {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.writer-wrapper {
    position: absolute;
    width: 30px;
    height: 30px;
    margin-left: -15px;
    margin-top: -15px;
}

.writer-inner {
    font-size: 24px;
    display: block;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.8);
    animation: tapBeagle 2s infinite linear;
}

@keyframes tapBeagle {
    0% {
        transform: translateY(0);
    }

    2.5% {
        transform: translateY(15px);
    }

    5% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(0);
    }
}

.writer-wrapper .teach-overlay {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
    font-size: 10px;
    background: rgba(0, 0, 0, 0.8);
    padding: 2px 4px;
    border-radius: 4px;
    color: #fff;
    white-space: nowrap;
    z-index: 10;
}

/* UI ELEMENTS - TV SCREEN STYLE */
#microgame-ui {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85vw;
    max-width: 800px;
    height: 70vh;
    max-height: 600px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    background: #050505;
    /* Deep black screen */
    border: 15px solid #2a2a2b;
    /* TV Bezel */
    border-radius: 25px;
    padding: 40px;
    box-shadow:
        0 0 0 4px #111,
        /* Outer rim */
        0 30px 60px rgba(0, 0, 0, 0.9),
        /* Heavy Drop Shadow */
        inset 0 0 80px rgba(0, 0, 0, 0.8);
    /* Inner Screen Depth */
}

/* Screen Glare */
/* Screen Glare - REMOVED to prevent click blocking */
#microgame-ui::after {
    display: none;
}

#game-title-display {
    font-family: 'Poppins', sans-serif;
    font-size: 2.5rem;
    color: #fff;
    text-transform: uppercase;
    margin-bottom: 20px;
    text-shadow: 0 0 15px var(--accent);
    text-align: center;
    letter-spacing: 2px;
    z-index: 2;
}

#game-timer-display {
    font-family: 'Roboto Mono', monospace;
    font-size: 3.5rem;
    color: #ff4444;
    text-shadow: 0 0 20px red;
    margin-bottom: 40px;
    z-index: 2;
}

#challenge-bar-container {
    width: 90%;
    height: 40px;
    background: #222;
    border: 4px solid #444;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

#challenge-bar-fill {
    width: 100%;
    height: 100%;
    background-color: var(--boss-hp);
    transition: width 0.1s linear;
}

/* BOSS IN TV STYLES */
#microgame-boss-wrapper {
    width: 180px;
    height: 180px;
    margin-bottom: 20px;
    position: relative;
    z-index: 5;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
}

#microgame-boss-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.5));
    transition: transform 0.05s;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: transparent;
}

#microgame-boss-img:active {
    transform: scale(0.95);
}

#microgame-boss-img.charging {
    animation: shake 0.1s infinite;
    filter: drop-shadow(0 0 15px var(--charge));
}

#microgame-boss-img.impact-shake {
    animation: shake 0.3s ease-out;
}

#microgame-boss-img.impact-shake-light {
    animation: shake-light 0.2s ease-out;
}

/* TYPING TEST UI */
#typing-container {
    width: 95%;
    margin-top: 10px;
    padding: 20px;
    border-radius: 10px;
    display: none;
    background: rgba(30, 30, 30, 0.6);
    border: 2px solid #555;
    box-sizing: border-box;
    z-index: 2;
}

#typing-target {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.3rem;
    color: #aaa;
    margin-bottom: 20px;
    line-height: 1.6;
    text-align: left;
    word-break: break-word;
}

.char-correct {
    color: #538d4e;
    text-shadow: 0 0 8px #538d4e;
}

.char-wrong {
    color: #e21b3c;
    text-decoration: underline;
    background: rgba(226, 27, 60, 0.2);
}

.char-current {
    border-bottom: 2px solid white;
    animation: blink 1s infinite;
}

@keyframes blink {
    50% {
        border-color: transparent;
    }
}

#typing-input {
    width: 100%;
    max-width: 100%;
    padding: 20px;
    font-family: 'Roboto Mono', monospace;
    font-size: 1.4rem;
    background: #111;
    border: 2px solid #555;
    color: white;
    border-radius: 8px;
    outline: none;
    box-sizing: border-box;
}

#typing-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(83, 141, 78, 0.3);
}


#charge-cursor {
    position: fixed;
    width: 40px;
    height: 40px;
    pointer-events: none;
    display: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
}

#charge-cursor svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.ring-bg {
    fill: rgba(0, 0, 0, 0.5);
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 6;
}

.ring-prog {
    fill: none;
    stroke: var(--charge);
    stroke-width: 6;
    stroke-dasharray: 251;
    stroke-dashoffset: 251;
    stroke-linecap: round;
}

#charge-val {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: white;
    font-size: 0.7rem;
    text-shadow: 0 0 3px black;
    white-space: nowrap;
}

#level-display {
    font-family: 'Poppins', sans-serif;
    text-transform: uppercase;
    font-size: 0.9rem;
    background: var(--panel, #333);
    color: var(--text, #fff);
    padding: 5px 15px;
    border-radius: 15px;
    margin-bottom: 10px;
    letter-spacing: 1px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid #555;
    transition: all 0.3s ease;
}

.golden-treat {
    position: absolute;
    font-size: 4rem;
    cursor: pointer;
    z-index: 150;
    filter: drop-shadow(0 0 15px var(--gold));
    animation: floatUpTreat 6s linear forwards;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

@keyframes floatUpTreat {
    0% {
        bottom: -100px;
        transform: rotate(0deg);
    }

    100% {
        bottom: 120%;
        transform: rotate(360deg);
    }
}

#score-display {
    font-family: 'Poppins', sans-serif;
    font-size: 3.5rem;
    margin-bottom: 5px;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

#bps-display {
    color: #888;
    font-size: 1rem;
    margin-bottom: 20px;
    font-weight: bold;
    pointer-events: none;
}

/* MOBILE DPAD */
.dpad-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-top: 15px;
    padding-bottom: 20px;
    width: 100%;
}

.dpad-row {
    display: flex;
    flex-direction: row;
    /* FORCE ROW */
    gap: 10px;
    justify-content: center;
    width: 100%;
}

.dpad-btn {
    width: 60px;
    height: 60px;
    min-width: 60px;
    /* Prevent shrink */
    min-height: 60px;
    background: var(--panel, #333);
    border: 2px solid var(--cell-border, #555);
    border-radius: 10px;
    color: var(--text, white);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.dpad-btn:active {
    background: #555;
    border-color: #888;
    transform: scale(0.95);
}

.dpad-spacer {
    width: 60px;
    height: 60px;
    min-width: 60px;
    display: inline-block;
}

/* Ensure canvas doesn't break layout */
#u-canvas {
    max-width: 90vw;
    max-height: 50vh;
    /* Limit height to fit on mobile screens */
    width: auto;
    height: auto;
    object-fit: contain;
}

#the-beagle {
    width: 280px;
    height: 280px;
    cursor: pointer;
    transition: transform 0.05s;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-user-drag: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    z-index: 5;
    position: relative;
}

#the-beagle:active {
    transform: scale(0.95);
}

#the-beagle.charging {
    animation: shake 0.1s infinite;
    filter: drop-shadow(0 0 20px var(--charge));
}

#the-beagle.impact-shake {
    animation: shake 0.3s ease-out;
}

#the-beagle.impact-shake-light {
    animation: shake-light 0.2s ease-out;
}

#the-beagle img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    -webkit-user-drag: none;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

@keyframes shake-light {
    0% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(2px, -1px);
    }

    100% {
        transform: translate(0, 0);
    }
}

/* SHOP */
#shop-zone {
    width: 350px;
    background-color: var(--panel);
    border-left: 2px solid #ccc;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.shop-tabs {
    display: flex;
    background-color: var(--panel, #e0e0e0);
    border-bottom: 2px solid var(--cell-border, #ccc);
    position: sticky;
    top: 0;
    z-index: 6;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    background: none;
    border: none;
    color: var(--text, #666);
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    text-transform: uppercase;
    position: relative;
    opacity: 0.7;
}

.tab-btn:hover {
    background-color: var(--sidebar-bg, #d0d0d0);
    opacity: 1;
}

.tab-btn.active {
    color: var(--text, #000);
    border-bottom: 3px solid var(--accent);
    background-color: var(--bg, #f8f8f8);
    opacity: 1;
}

.tab-badge {
    background-color: var(--accent);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
    vertical-align: middle;
    display: none;
}

.item-badge {
    background-color: var(--accent);
    color: white;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: bold;
    display: none;
}

.upgrade-item {
    padding: 15px;
    border-bottom: 1px solid var(--cell-border, #eee);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.upgrade-item:hover {
    background-color: var(--sidebar-bg, #ffffff);
}

.upgrade-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.upgrade-info {
    display: flex;
    flex-direction: column;
}

.upgrade-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.up-name {
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 4px;
}

.up-cost {
    color: var(--accent);
    font-weight: bold;
    font-size: 0.9rem;
}

.up-count {
    font-size: 1.5rem;
    font-weight: bold;
    color: #888;
    min-width: 30px;
    text-align: center;
}

/* EXAM STYLES */
.upgrade-item.exam-ready {
    background: radial-gradient(circle at center, #2a2a00 0%, #1a1a1b 100%);
    border: 1px solid var(--gold);
    box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.1);
    animation: pulse-gold 2s infinite;
}

.upgrade-item.exam-ready .up-name {
    color: var(--gold);
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.upgrade-item.exam-ready:hover {
    background-color: #332b00;
    filter: brightness(1.2);
}

@keyframes pulse-gold {
    0% {
        border-color: #bfa800;
    }

    50% {
        border-color: var(--gold);
    }

    100% {
        border-color: #bfa800;
    }
}

.floating-text {
    position: absolute;
    color: white;
    font-weight: bold;
    font-size: 1.5rem;
    pointer-events: none;
    animation: floatUp 0.8s ease-out forwards;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.2);
    }
}

@media (max-width: 768px) {
    #game-container {
        flex-direction: column;
    }

    #click-zone {
        flex: 1;
        min-height: 50vh;
    }

    #shop-zone {
        width: 100%;
        flex: 1;
        border-left: none;
        border-top: 2px solid #333;
    }

    #the-beagle {
        width: 200px;
        height: 200px;
    }

    #score-display {
        font-size: 2.5rem;
    }
}

#data-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    z-index: 5;
}

.data-btn {
    font-size: 0.7rem;
    color: #555;
    background: none;
    border: 1px solid #333;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
}

.data-btn:hover {
    background: #222;
    color: #888;
}

/* --- NFT STOCK WIDGET --- */
#stock-widget {
    position: fixed;
    bottom: 20px;
    right: 360px;
    /* Moved left to avoid shop overlap */
    width: 320px;
    background: rgba(10, 15, 10, 0.95);
    border: 2px solid #00ff00;
    border-radius: 12px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    color: #00ff00;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.2);
    z-index: 1000;
    display: none;
    /* Hidden by default */
}

.stock-header {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 1.2em;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
}

#stock-chart {
    background: #050505;
    border: 1px solid #335533;
    width: 100%;
    height: 120px;
    margin-bottom: 10px;
}

.stock-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stock-info {
    text-align: center;
    font-size: 0.9em;
    color: #ccffcc;
}

.stock-actions-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

#stock-action,
#stock-amount {
    flex: 1;
    background: #002200;
    color: #00ff00;
    border: 1px solid #005500;
    padding: 8px;
    font-family: inherit;
    font-size: 0.9em;
    border-radius: 4px;
    cursor: pointer;
}

#stock-action:hover,
#stock-amount:hover {
    border-color: #00aa00;
}

#stock-go {
    flex: 0 0 50px;
    background: #00aa00;
    color: #000;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    padding: 8px 0;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

#stock-go:hover {
    background: #00ff00;
    box-shadow: 0 0 10px #00ff00;
}

#stock-go:active {
    transform: scale(0.95);
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 768px) {
    #stock-widget {
        position: fixed;
        /* Keep fixed to sit above content or use a dedicated tab view */
        bottom: 80px;
        /* Above bottom nav */
        right: 50%;
        transform: translateX(50%);
        width: 90%;
        max-width: 400px;
    }
}

/* TRIVIA MODAL */
#trivia-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 300;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

#trivia-box {
    background: #1a1a1b;
    border: 2px solid var(--accent);
    padding: 20px;
    border-radius: 10px;
    max-width: 500px;
    width: 100%;
    text-align: center;
}

#trivia-q {
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: bold;
}

.trivia-opt {
    background: #333;
    padding: 12px;
    margin: 8px 0;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid #444;
}

.trivia-opt:hover {
    background: #444;
}

#trivia-progress {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

/* CUSTOM NOTIFICATION MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    /* CRITICAL: Must be higher than microgame UI (9999) */
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal-box {
    background: var(--panel);
    border: 2px solid var(--accent);
    padding: 25px;
    border-radius: 15px;
    width: 85%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
    transform: scale(0.9);
    animation: modalPop 0.2s forwards;
}

@keyframes modalPop {
    to {
        transform: scale(1);
    }
}

.modal-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.4rem;
    color: var(--gold);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-text {
    font-family: 'Roboto Mono', monospace;
    color: var(--text);
    margin-bottom: 25px;
    line-height: 1.5;
    font-size: 0.95rem;
    white-space: pre-wrap;
}

.modal-btn-row {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-btn {
    padding: 12px 25px;
    border-radius: 8px;
    border: none;
    font-weight: 900;
    cursor: pointer;
    text-transform: uppercase;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    transition: transform 0.1s, filter 0.2s;
}

.modal-btn:active {
    transform: scale(0.95);
}

.btn-confirm {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 10px rgba(83, 141, 78, 0.3);
}

.btn-confirm:hover {
    filter: brightness(1.1);
}

.btn-cancel {
    background: #333;
    color: #aaa;
    border: 1px solid #444;
}

.btn-cancel:hover {
    background: #444;
    color: white;
}

.modal-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid #444;
    color: var(--text);
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-family: 'Roboto Mono';
    font-size: 0.9rem;
    box-sizing: border-box;
    resize: vertical;
    min-height: 80px;
}

.modal-input:focus {
    outline: none;
    border-color: var(--gold);
}

/* MICROGAME INTRO OVERLAY */
#intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 500;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    pointer-events: none;
}

#intro-title {
    font-family: 'Poppins', sans-serif;
    font-size: 3.5rem;
    color: var(--gold);
    text-transform: uppercase;
    margin-bottom: 20px;
    text-shadow: 0 0 20px var(--gold);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#intro-instruct {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.5rem;
    color: #fff;
    max-width: 80%;
    background: #333;
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid #555;
    animation: slideUp 0.5s ease-out 0.2s backwards;
}

@keyframes popIn {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* FIX: Microgame UI Layout - Fixed Overlay */
#microgame-ui {
    display: none;
    /* Toggled by JS */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.9);
    /* Darker background for focus */
    z-index: 5000;
    /* High z-index to sit above everything */
    z-index: 5000;
    /* High z-index to sit above everything */
    overflow: hidden;
    transform: none !important;
    /* RESET ANY PRIOR TRANSFORMS */
    padding: 0 !important;
    border: none !important;
    max-width: none !important;
    max-height: none !important;
}

#game-title-display {
    font-family: 'Poppins', sans-serif;
    font-size: 2rem;
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold);
    margin-bottom: 10px;
    text-align: center;
    max-width: 90%;
    word-wrap: break-word;
}

/* FIX: Desktop adjustment for D-Pad */
@media (min-width: 769px) {
    .dpad-container {
        align-items: flex-start;
        /* Move to left */
        padding-left: 20px;
        /* Little offset */
        width: auto;
        /* Don't stretch full width if not needed */
    }

    /* Keep centering for buttons within the container, but container itself is left-aligned */
}

/* FLOATING TEXT / EFFECTS */
.floating-text {
    position: fixed;
    font-family: 'Poppins', sans-serif;
    font-weight: bold;
    font-size: 1.5rem;
    color: white;
    text-shadow: 0 0 5px black;
    pointer-events: none;
    z-index: 100000;
    animation: floatUp 0.8s ease-out forwards;
    transform: translate(-50%, -50%);
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(1.2);
    }
}

/* --- ZEAGLE ATTACKS & SECURITY --- */

#enemy-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to game usually */
    z-index: 50;
    /* Above game, below UI */
    overflow: hidden;
}

.zeagle-enemy {
    position: absolute;
    width: 60px;
    height: 60px;
    background-image: url('https://games.eastmeckbeagle.com/assets/zeagle.jpg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 50%;
    box-shadow: 0 0 10px red;
    pointer-events: auto;
    /* Catch clicks */
    cursor: grab;
    transition: transform 0.1s;
    z-index: 55;
    background-color: white;
    /* Fallback bg color if image is missing */
}

.zeagle-enemy:active {
    cursor: grabbing;
    transform: scale(1.1);
}

/* Animation for the Zeagle enemy being flicked away */
.zeagle-enemy.flicked {
    transition: none !important;
    /* Disconnect from physics loop for animation */
    pointer-events: none;
    opacity: 0;
    transform: scale(0.5);
}

.security-guard {
    position: absolute;
    width: 50px;
    height: 50px;
    background-color: #333;
    border: 2px solid var(--gold);
    border-radius: 5px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 0 10px var(--gold);
    transition: all 0.5s ease-out;
    z-index: 54;
}

.security-guard::after {
    content: "🛡️";
}

/* TARGET PRACTICE MICROGAME TARGETS */
.target-practice-target {
    position: fixed;
    /* fixed so it escapes any parent stacking context */
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, #ff0000 40%, #ffffff 41%, #ffffff 60%, #ff0000 61%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    animation: popInTarget 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 99999;
    /* above microgame UI and all overlays */
}

@keyframes popInTarget {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- DECISION / WILD CARD MODAL --- */
.decision-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.decision-card {
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
    border: 2px solid #4a4a8a;
    border-radius: 20px;
    padding: 35px 40px;
    max-width: 560px;
    width: 92vw;
    box-shadow:
        0 0 0 1px rgba(100, 100, 200, 0.3),
        0 20px 60px rgba(0, 0, 0, 0.9),
        inset 0 0 40px rgba(50, 50, 150, 0.15);
    animation: decisionSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}

@keyframes decisionSlideIn {
    from {
        transform: scale(0.7) translateY(-30px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.decision-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: pulse 2s infinite;
}

.decision-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(150, 150, 255, 0.6);
}

.decision-flavor {
    font-size: 0.95rem;
    color: #aab;
    margin-bottom: 28px;
    line-height: 1.5;
    font-style: italic;
}

.decision-choices {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.decision-choice-btn {
    flex: 1;
    min-width: 180px;
    max-width: 240px;
    padding: 20px 16px;
    border: 2px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-family: 'Poppins', sans-serif;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.decision-btn-a {
    background: linear-gradient(135deg, #1a2a1a, #0d1f0d);
    border-color: #2a6a2a;
    color: #8dff8d;
}

.decision-btn-a:hover,
.decision-btn-a:active {
    transform: scale(1.04) translateY(-3px);
    border-color: #4eff4e;
    box-shadow: 0 0 25px rgba(78, 255, 78, 0.3);
}

.decision-btn-b {
    background: linear-gradient(135deg, #2a1a1a, #1f0d0d);
    border-color: #6a2a2a;
    color: #ff8d8d;
}

.decision-btn-b:hover,
.decision-btn-b:active {
    transform: scale(1.04) translateY(-3px);
    border-color: #ff4e4e;
    box-shadow: 0 0 25px rgba(255, 78, 78, 0.3);
}

.choice-letter {
    display: block;
    font-size: 2rem;
    font-weight: 900;
    line-height: 1;
}

.choice-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
}

.decision-warning {
    margin-top: 22px;
    font-size: 0.78rem;
    color: #666;
    letter-spacing: 0.5px;
}

/* =============================================================
   PRESTIGE SYSTEM STYLES
   ============================================================= */

/* Prestige Badge — shows diploma count below level display */
#prestige-display {
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
    letter-spacing: 1px;
    margin-bottom: 8px;
    padding: 4px 14px;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.25);
    border-radius: 12px;
    animation: prestige-shimmer 3s ease-in-out infinite;
    z-index: 2;
    pointer-events: none;
}

@keyframes prestige-shimmer {

    0%,
    100% {
        text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
        border-color: rgba(255, 215, 0, 0.2);
    }

    50% {
        text-shadow: 0 0 16px rgba(255, 215, 0, 0.7), 0 0 30px rgba(255, 215, 0, 0.3);
        border-color: rgba(255, 215, 0, 0.5);
    }
}

/* Lifetime Stats Panel — fixed bottom-left corner */
#lifetime-stats-panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 0;
    background: var(--panel);
    border: 2px solid #ccc;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    width: 250px;
    z-index: 1000;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
}

#lifetime-stats-panel .widget-body {
    padding: 0 14px 10px;
}

.stats-title {
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem;
    font-weight: 900;
    color: #ffd700;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.3);
    margin: 0;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.75rem;
    color: var(--text);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.stats-row:last-child {
    border-bottom: none;
}

.stats-row span:first-child {
    color: #666;
}

.stats-row span:last-child {
    font-weight: 700;
    color: var(--text);
}

/* === WIDGET MINIMIZE BUTTON (shared by NFT + Stats) === */
.widget-minimize-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ccc;
    font-size: 1rem;
    font-weight: bold;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: all 0.2s;
    flex-shrink: 0;
}

.widget-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* NFT widget minimize button — green tinted */
#stock-widget .widget-minimize-btn {
    border-color: rgba(0, 255, 0, 0.3);
    color: #00ff00;
}

#stock-widget .widget-minimize-btn:hover {
    background: rgba(0, 255, 0, 0.15);
}

/* Stats widget minimize button — gold tinted */
#lifetime-stats-panel .widget-minimize-btn {
    border-color: rgba(255, 215, 0, 0.3);
    color: #ffd700;
}

#lifetime-stats-panel .widget-minimize-btn:hover {
    background: rgba(255, 215, 0, 0.15);
}

/* === COLLAPSED STATE === */
/* When .widget-minimized, hide the body content */
.widget-minimized .widget-body {
    display: none !important;
}

/* Shrink NFT widget when minimized */
#stock-widget.widget-minimized {
    width: auto;
    min-width: 180px;
}

/* Shrink stats panel when minimized */
#lifetime-stats-panel.widget-minimized {
    width: auto;
    min-width: 180px;
}

/* Mobile — stats panel adjustments */
@media (max-width: 768px) {
    #lifetime-stats-panel {
        bottom: 10px;
        left: 10px;
        width: 200px;
    }
}

/* Graduate Shop Item — gold gradient glow to stand out */
#upg-22 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.06) 0%, rgba(40, 35, 10, 0.4) 100%);
    border: 1px solid rgba(255, 215, 0, 0.3) !important;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3) !important;
    animation: prestige-shimmer 3s ease-in-out infinite;
}

#upg-22 .up-name {
    color: #ffd700;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
}

#upg-22:hover {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.12) 0%, rgba(50, 45, 15, 0.6) 100%) !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.15);
}

/* =============================================================
   BEAGLE HQ WIDGET
   ============================================================= */

/* HQ Widget Container — positioned bottom-right, above stock widget */
.hq-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    max-height: 70vh;
    overflow-y: auto;
    background: rgba(20, 15, 30, 0.95);
    border: 1px solid rgba(138, 100, 220, 0.4);
    border-radius: 14px;
    box-shadow:
        0 0 0 1px rgba(138, 100, 220, 0.15),
        0 8px 30px rgba(0, 0, 0, 0.6),
        inset 0 0 20px rgba(100, 60, 200, 0.05);
    z-index: 900;
    font-family: 'Poppins', sans-serif;
    color: #fff;
}

/* HQ Header Bar */
.hq-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(100, 60, 200, 0.2), rgba(50, 30, 100, 0.3));
    border-bottom: 1px solid rgba(138, 100, 220, 0.3);
    border-radius: 14px 14px 0 0;
    gap: 8px;
}

.hq-title {
    font-weight: 900;
    font-size: 1rem;
    color: #c9a0ff;
    text-shadow: 0 0 10px rgba(180, 130, 255, 0.4);
    letter-spacing: 1px;
}

.hq-mult {
    font-size: 0.75rem;
    font-weight: 700;
    color: #9D4EDD;
    background: rgba(157, 78, 221, 0.12);
    padding: 2px 8px;
    border-radius: 8px;
    border: 1px solid rgba(157, 78, 221, 0.3);
}

/* HQ Widget minimize button — purple tinted */
.hq-widget .widget-minimize-btn {
    border-color: rgba(157, 78, 221, 0.4);
    color: #c9a0ff;
}

.hq-widget .widget-minimize-btn:hover {
    background: rgba(157, 78, 221, 0.2);
}

/* Collapsed state */
.hq-widget.widget-minimized {
    width: auto;
    min-width: 180px;
}

/* Buff Summary Tags */
.hq-buff-summary {
    padding: 8px 14px;
    font-size: 0.7rem;
    color: #bbb;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.hq-buff-summary strong {
    color: #c9a0ff;
    margin-right: 4px;
    font-size: 0.72rem;
}

.hq-buff-tag {
    background: rgba(157, 78, 221, 0.12);
    border: 1px solid rgba(157, 78, 221, 0.25);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.65rem;
    color: #ddd;
    white-space: nowrap;
}

/* =============================================================
   HQ LAYOUT EDITOR MODAL
   ============================================================= */
.hq-editor-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 5, 20, 0.9);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.hq-editor-content {
    background: rgba(20, 15, 30, 0.95);
    border: 1px solid rgba(138, 100, 220, 0.5);
    border-radius: 16px;
    width: 90vw;
    height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), inset 0 0 30px rgba(100, 60, 200, 0.1);
    overflow: hidden;
}

.hq-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: linear-gradient(90deg, rgba(80, 40, 160, 0.3), rgba(40, 20, 80, 0.4));
    border-bottom: 1px solid rgba(138, 100, 220, 0.3);
}

.hq-editor-header h2 {
    margin: 0;
    color: #c9a0ff;
    font-size: 1.5rem;
    text-shadow: 0 0 10px rgba(180, 130, 255, 0.4);
}

.hq-close-btn {
    background: transparent;
    border: none;
    color: #c9a0ff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s, transform 0.2s;
}

.hq-close-btn:hover {
    color: #fff;
    transform: scale(1.1);
}

.hq-editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* LEFT PANEL - GRID */
.hq-grid-area {
    flex: 2;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-linear-gradient(45deg, rgba(30, 20, 50, 0.4), rgba(30, 20, 50, 0.4) 10px, rgba(40, 30, 60, 0.4) 10px, rgba(40, 30, 60, 0.4) 20px);
    overflow: auto;
}

.hq-grid-container {
    display: grid;
    gap: 4px;
    background: rgba(138, 100, 220, 0.2);
    padding: 6px;
    border-radius: 8px;
    border: 2px solid rgba(138, 100, 220, 0.5);
    box-shadow: 0 0 20px rgba(138, 100, 220, 0.2);
    position: relative;
}

.hq-grid-cell {
    width: 60px;
    height: 60px;
    background: rgba(20, 15, 30, 0.8);
    border: 1px dashed rgba(138, 100, 220, 0.3);
    border-radius: 4px;
    transition: background 0.2s;
}

.hq-grid-cell.drag-over {
    background: rgba(138, 100, 220, 0.4);
    border: 1px solid #c9a0ff;
}

.hq-grid-cell.drag-invalid {
    background: rgba(200, 50, 50, 0.4);
    border: 1px solid #ff5555;
}

.hq-placed-item {
    background: linear-gradient(135deg, rgba(80, 40, 160, 0.9), rgba(40, 20, 80, 0.9));
    border: 2px solid #a67cff;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 10;
    position: absolute;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s;
    user-select: none;
}

.hq-placed-item:active {
    cursor: grabbing;
    transform: scale(0.95);
    z-index: 20;
}

.hq-placed-icon {
    font-size: 2.5rem;
    pointer-events: none;
}

.hq-placed-name {
    font-size: 0.6rem;
    color: #fff;
    pointer-events: none;
    text-align: center;
    padding: 0 2px;
}

/* RIGHT PANEL - SHOP */
.hq-shop-panel {
    flex: 1;
    min-width: 300px;
    max-width: 350px;
    background: rgba(25, 20, 40, 0.9);
    border-left: 1px solid rgba(138, 100, 220, 0.3);
    display: flex;
    flex-direction: column;
}

.hq-shop-panel h3 {
    margin: 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    color: #c9a0ff;
    text-align: center;
    border-bottom: 1px solid rgba(138, 100, 220, 0.2);
}

.hq-shop-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hq-shop-item {
    background: rgba(40, 30, 60, 0.8);
    border: 1px solid rgba(138, 100, 220, 0.4);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
}

.hq-shop-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(138, 100, 220, 0.3);
    background: rgba(50, 40, 70, 0.9);
}

.hq-shop-item:active {
    cursor: grabbing;
}

.hq-shop-item.locked,
.hq-shop-item.too-expensive {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(0.8);
}

.hq-item-icon {
    font-size: 2.2rem;
    background: rgba(0, 0, 0, 0.3);
    width: 60px;
    height: 60px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hq-item-details {
    flex: 1;
}

.hq-item-name {
    font-weight: bold;
    color: #fff;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.hq-item-buff {
    color: #a67cff;
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.hq-item-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #aaa;
}

.hq-trash-zone {
    padding: 20px;
    text-align: center;
    background: rgba(200, 50, 50, 0.1);
    border-top: 2px dashed rgba(200, 50, 50, 0.4);
    color: #ff8888;
    transition: background 0.2s, color 0.2s;
    display: none;
}

.hq-trash-zone.active-trash {
    display: block;
}

.hq-trash-zone.drag-over {
    background: rgba(200, 50, 50, 0.3);
    color: #ffbbbb;
}

.hq-trash-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

/* =============================================================
   GRID CLEANUP MICROGAME
   ============================================================= */

.cleanup-ui-container {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    background: transparent;
    backdrop-filter: blur(5px);
}

.cleanup-header {
    text-align: center;
    margin-bottom: 20px;
}

.cleanup-title {
    font-size: 2.5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 10px rgba(138, 100, 220, 0.8);
    margin-bottom: 5px;
}

.cleanup-timer {
    font-size: 1.5rem;
    color: #ffaaaa;
    font-family: monospace;
}

.cleanup-workspace {
    display: flex;
    gap: 30px;
    align-items: center;
    max-width: 95vw;
    margin: 0 auto;
}

/* Tool Bar */
.cleanup-tools {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(30, 30, 40, 0.8);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #555;
}

.cleanup-tool {
    width: 70px;
    height: 70px;
    background: #2a2a35;
    border: 2px solid #444;
    border-radius: 8px;
    font-size: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
}

.cleanup-tool span.tool-label {
    font-size: 0.6rem;
    margin-top: 4px;
    text-transform: uppercase;
}

.cleanup-tool:hover {
    background: #3a3a45;
    transform: scale(1.05);
}

.cleanup-tool.active {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.2);
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
}

/* The Grid */
.cleanup-grid-wrapper {
    background: rgba(20, 20, 25, 0.9);
    padding: 10px;
    border-radius: 8px;
    border: 2px dashed #666;
}

.cleanup-grid {
    display: grid;
    gap: 2px;
    background: #444;
    border: 2px solid #333;
}

.cleanup-cell {
    width: 60px;
    height: 60px;
    background: #2a2a35;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Grid Items (Messes) */
.cleanup-item {
    font-size: 2rem;
    user-select: none;
    line-height: 1;
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.cleanup-item.type-dirt {
    filter: drop-shadow(0 0 2px #000) sepia(0.8) hue-rotate(330deg);
}

.cleanup-item.type-water {
    filter: drop-shadow(0 0 2px #000) saturate(1.5);
}

/* Bins */
.cleanup-bins {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cleanup-bin {
    width: 120px;
    height: 120px;
    background: rgba(40, 40, 50, 0.8);
    border: 3px dashed #666;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #aaa;
    transition: all 0.2s;
}

.cleanup-bin.drag-over {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.cleanup-bin.drag-over-garbage {
    border-color: #ff6b6b;
    color: #ff6b6b;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
}

.cleanup-bin.drag-over-recycle {
    border-color: #4dabf7;
    color: #4dabf7;
    box-shadow: 0 0 20px rgba(77, 171, 247, 0.3);
}

.bin-icon {
    font-size: 3rem;
    margin-bottom: 5px;
}

/* Contextual Cursors */
.cursor-grabber .cleanup-item.draggable {
    cursor: grab;
}

.cursor-grabber .cleanup-item.draggable:active {
    cursor: grabbing;
}

.cursor-grabber .cleanup-item:not(.draggable) {
    cursor: not-allowed;
}

.cursor-scrubber .cleanup-grid {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><text y="20" font-size="20">🧽</text></svg>') 16 16, auto;
}

.cursor-mop .cleanup-grid {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><text y="20" font-size="20">🧹</text></svg>') 0 32, auto;
}

/* Mobile responsive HQ widget */
@media (max-width: 768px) {
    .hq-widget {
        position: fixed;
        bottom: 80px;
        right: 50%;
        transform: translateX(50%);
        width: 90%;
        max-width: 360px;
    }

    .hq-furniture-grid {
        grid-template-columns: 1fr 1fr;
        gap: 4px;
        padding: 4px 8px 10px;
    }

    .hq-furn-icon {
        font-size: 1.3rem;
    }

    .trash-item {
        font-size: 2.8rem;
    }
}

/* DRAGGABLE WIDGET HEADERS */
.stock-header,
.hq-header,
.stats-header {
    cursor: grab;
}

.stock-header:active,
.hq-header:active,
.stats-header:active {
    cursor: grabbing;
}

/* NOTIFICATION TOAST */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid var(--accent);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 15px;
    font-family: 'Poppins', sans-serif;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon {
    font-size: 24px;
}

.toast-content {
    display: flex;
    flex-direction: column;
}

.toast-title {
    font-size: 0.8rem;
    color: var(--gold);
    text-transform: uppercase;
    font-weight: bold;
}

.toast-desc {
    font-size: 1rem;
    font-weight: normal;
}

/* ACHIEVEMENTS UI */
.achievement-item {
    display: flex;
    align-items: center;
    background: #1a1a1b;
    border: 2px solid #333;
    padding: 10px 15px;
    border-radius: 8px;
    gap: 15px;
}

.achievement-item.unlocked {
    border-color: var(--accent);
    background: rgba(83, 141, 78, 0.1);
}

.achievement-icon {
    font-size: 30px;
    opacity: 0.3;
}

.achievement-item.unlocked .achievement-icon {
    opacity: 1;
}

.achievement-meta {
    display: flex;
    flex-direction: column;
}

.achievement-name {
    font-weight: bold;
    color: #fff;
    font-size: 1.1rem;
    opacity: 0.5;
}

.achievement-item.unlocked .achievement-name {
    opacity: 1;
    color: var(--gold);
}

.achievement-desc {
    font-size: 0.85rem;
    color: #aaa;
}

/* ESSAY MODAL */
#essay-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

@media (max-width: 600px) {
    #toast-container {
        top: 20px;
        bottom: auto;
        right: 50%;
        transform: translateX(50%);
        align-items: center;
    }

    .toast {
        transform: translateY(-120%);
    }

    .toast.show {
        transform: translateY(0);
    }
}

/* =============================================================
   BADGE DISPLAY CASE
   ============================================================= */
.badge-display-case {
    margin-top: 15px;
    padding: 12px;
    background: linear-gradient(135deg, #1f142b 0%, #11091a 100%);
    border-radius: 6px;
    border: 3px solid #b89947;
    box-shadow: inset 0px 5px 15px rgba(0, 0, 0, 0.8), 0 4px 10px rgba(0, 0, 0, 0.5);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.badge-display-case::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;utf8,<svg width="40" height="40" xmlns="http://www.w3.org/2000/svg"><circle cx="20" cy="20" r="1" fill="rgba(255,255,255,0.05)"/></svg>');
    opacity: 0.5;
    pointer-events: none;
}

.badge-case-title {
    font-size: 0.75rem;
    color: #ffd700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    border-bottom: 1px solid rgba(184, 153, 71, 0.3);
    padding-bottom: 4px;
}

.badge-case-list {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.badge-case-list span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.1) 0%, rgba(0, 0, 0, 0.4) 100%);
    border-radius: 50%;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.1), 0 2px 5px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(184, 153, 71, 0.4);
}