/* ==========================================================================
   GLOBAL STYLES
   ========================================================================== */
body { 
    margin: 0; 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    display: flex; 
    height: 100vh; 
    background: #2c3e50; 
    color: #333; 
    overflow: hidden; 
}

/* ==========================================================================
   BUTTONS & INPUTS
   ========================================================================== */
.btn {
    padding: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: background 0.2s, opacity 0.2s;
    color: white;
}
.btn:hover:not(:disabled) { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-small { padding: 5px 10px; font-size: 12px; }

.hidden { display: none !important; }
.btn-large { padding: 15px; font-size: 18px; }
.btn-full-width { width: 100%; }
.btn-margin-top { margin-top: 10px; }

/* Colors */
.btn-orange { background: #e67e22; }
.btn-purple { background: #8e44ad; }
.btn-yellow { background: #f39c12; }
.btn-red    { background: #c0392b; }
.btn-gray   { background: #7f8c8d; }
.btn-blue   { background: #3498db; }
.btn-green  { background: #27ae60; }

.text-blue   { color: #3498db; }
.text-green  { color: #2ecc71; }
.text-orange { color: #f39c12; }
.text-red    { color: #e74c3c; }

/* ==========================================================================
   SIDEBAR LAYOUT
   ========================================================================== */
.sidebar { 
    width: 250px; 
    min-width: 250px; 
    flex-shrink: 0; 
    background: #34495e; 
    color: #ecf0f1; 
    padding: 20px; 
    box-sizing: border-box; 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
    overflow-y: auto; 
    height: 100vh; 
}
.sidebar-header h2 { margin: 0 0 5px 0; font-size: 24px; color: #3498db; }
.seed-text { font-size: 12px; color: #95a5a6; display: flex; align-items: center; }

/* Heartbeat Monitor */
.heartbeat-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(192, 57, 43, 0.1);
    border: 1px solid #c0392b;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 10px;
    font-weight: bold;
    color: #e74c3c;
    letter-spacing: 1px;
}
.heartbeat-dot {
    width: 8px;
    height: 8px;
    background: #e74c3c;
    border-radius: 50%;
    box-shadow: 0 0 5px #e74c3c;
    animation: pulse 1.5s infinite;
}
.heartbeat-text {
    animation: flicker 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.stat-box { 
    background: #2c3e50; 
    padding: 10px; 
    border-radius: 6px; 
    font-size: 32px; 
    font-weight: bold; 
    color: #f1c40f; 
    text-align: center; 
}
.stats-row { display: flex; justify-content: space-between; }

/* Inventory */
.inventory-bay {
    background: #2c3e50; 
    border-radius: 6px; 
    padding: 10px; 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    min-height: 120px;
}
.inventory-title { font-size: 12px; color: #bdc3c7; margin-bottom: 5px; text-transform: uppercase; }
.inventory-bar {
    display: flex; 
    flex-grow: 1; 
    background: #34495e; 
    border-radius: 4px; 
    align-items: flex-start; 
    justify-content: center; 
    align-content: flex-start; 
    padding: 10px; 
    gap: 8px; 
    flex-wrap: wrap; 
    overflow-y: auto;
}
.inventory-empty { font-size: 12px; color: #aaa; font-style: italic; align-self: center; }

.sidebar-controls { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.control-row { display: flex; gap: 5px; }
.jump-select { flex-grow: 1; padding: 10px; border: none; border-radius: 4px; font-weight: bold; font-size: 14px; }

/* ==========================================================================
   GAME BOARD AREA
   ========================================================================== */
.game-area { 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column;
    justify-content: center; 
    align-items: center; 
    background: #ecf0f1; 
    position: relative; 
    overflow-x: auto;
    overflow-y: auto;
    scrollbar-gutter: stable both-edges;
    overflow-anchor: none;
    /* Stable roof headroom for notices. This prevents an in-board fallback
       without a message-triggered layout shift. */
    padding-top: 72px;
    box-sizing: border-box;
}
.game-message-rail {
    position: absolute;
    z-index: 120;
    left: 8px;
    top: 8px;
    width: min(360px, calc(100vw - 32px));
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 2px solid #3498db;
    border-radius: 7px;
    background: rgba(247, 251, 252, .97);
    color: #243746;
    box-shadow: 0 3px 12px rgba(0,0,0,.18);
    font-size: 14px;
    line-height: 1.3;
    pointer-events: none;
    margin: 0;
}
.game-message-rail[hidden] { display: none; }
.game-message-rail button { margin-left: auto; flex: 0 0 auto; border: 0; background: transparent; color: #53616d; font-size: 20px; line-height: 1; cursor: pointer; pointer-events: auto; }
#world { 
    position: relative; 
    background: #bdc3c7; 
    border: 4px solid #7f8c8d; 
    border-radius: 8px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.3); 
    display: grid; 
    --floor-height: 60px;
    --shaft-width: 120px;
    --label-width: 50px;
    --lobby-width: 360px; 
    min-width: max-content;
}

.zoning-controls { margin-top: 12px; padding: 10px; border: 1px solid #9aa7b2; border-radius: 6px; background: #f3f6f8; }
.zoning-controls h3 { margin: 0 0 5px; font-size: 15px; }
.zoning-controls label { display: block; margin: 5px 0; font-size: 12px; }
.zoning-controls input, .zoning-controls select { width: 100%; box-sizing: border-box; }
.workshop-help { margin: 5px 0; color: #53616d; font-size: 11px; }

/* Grid Elements */
.floor { 
    display: flex; 
    border-bottom: 2px solid #95a5a6; 
    box-sizing: border-box; 
    position: relative;
    height: var(--floor-height);
}
.label { 
    width: var(--label-width); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    background: #7f8c8d; 
    color: white; 
    font-weight: bold; 
    border-right: 2px solid #34495e; 
    box-sizing: border-box; 
}
.lobby { 
    width: var(--lobby-width); 
    display: flex; 
    flex-direction: row-reverse;
    align-items: center; 
    justify-content: flex-start; /* row-reverse: physical right edge, beside the lift */
    overflow: hidden;
    padding: 5px; 
    gap: 5px; 
    border-right: 2px solid #7f8c8d; 
    position: relative; 
    box-sizing: border-box; 
}
.shaft { 
    width: var(--shaft-width); 
    border-right: 2px dashed #95a5a6; 
    background: #d0d6d9; 
    cursor: crosshair; 
    box-sizing: border-box; 
}
.capsule-bank .shaft {
    position: relative;
    border-right: 4px solid #34495e;
    background: linear-gradient(90deg, rgba(236, 240, 241, 0.84), rgba(189, 195, 199, 0.5), rgba(236, 240, 241, 0.84));
}
.zoning-active .shaft.zone-served { background: #d0d6d9; box-shadow: none; opacity: 1; }
.zoning-active .shaft.zone-unserved { background: #b8c1c6; box-shadow: none; opacity: 1; }
.zoning-active.capsule-bank .shaft.zone-served { background: #d0d6d9; }
.zoning-active.capsule-bank .shaft.zone-unserved { background: #b8c1c6; }
.capsule-bank .shaft::after {
    display: none;
}

.counterweight-pair-visual { position: absolute; top: 0; z-index: 2; pointer-events: none; }
.counterweight-cable-frame { position: absolute; top: 10px; right: 25%; bottom: 10px; left: 25%; border: 4px solid #607487; border-radius: 18px; box-sizing: border-box; opacity: .85; }
.counterweight-pulley { position: absolute; width: 22px; height: 22px; border: 3px solid #34495e; border-radius: 50%; background: #bdc3c7; box-sizing: border-box; transform: translate(-50%, -50%); z-index: 1; }
.counterweight-pulley.top-left { top: 10px; left: 25%; }
.counterweight-pulley.top-right { top: 10px; left: 75%; }
.counterweight-pulley.bottom-left { bottom: 10px; left: 25%; transform: translate(-50%, 50%); }
.counterweight-pulley.bottom-right { right: 25%; bottom: 10px; transform: translate(50%, 50%); }
.counterweight-car::before { display: none; }
.counterweight-car { outline: 2px solid rgba(52, 152, 219, .45); outline-offset: 2px; }

/* Permanent in-game Automation Dock. */
.automation-dock-host { display: flex; flex: 0 0 var(--lobby-width); width: var(--lobby-width); overflow: visible; padding: 1px 3px; }
.automation-control-row > .label { flex: 0 0 var(--label-width); }
.automation-control-row > .lobby { flex: 0 0 var(--lobby-width); }
.automation-dock { width: 100%; box-sizing: border-box; display: flex; align-items: center; gap: 4px; font-size: 10px; line-height: 1.1; }
.automation-carousel { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1 1 auto; }
.automation-carousel-viewport { min-width: 120px; flex: 0 1 260px; }
.automation-carousel-card { width: 100%; overflow: hidden; text-overflow: ellipsis; }
.automation-carousel-arrow { flex: 0 0 36px; width: 36px; height: 26px; padding: 0; border: 1px solid #95a5a6; border-radius: 4px; background: #fff; color: #34495e; font-size: 22px; line-height: 22px; cursor: pointer; }
.automation-carousel-indicator { min-width: 25px; color: #53616d; text-align: center; font-size: 9px; }
.automation-dock-pinned { display: none; }
.automation-policy-btn { border: 1px solid #95a5a6; background: #fff; border-radius: 4px; padding: 3px 5px; white-space: nowrap; font-size: 10px; cursor: pointer; }
.automation-policy-btn.selected, .automation-status.selected { background: #3498db; color: #fff; border-color: #21618c; }
.automation-carousel-card.automation-policy-preview { opacity: .78; }
.automation-dock-actions { display: flex; gap: 2px; align-items: center; flex: 0 0 auto; }
.automation-dock-actions .btn { padding: 3px 5px; font-size: 10px; }
.automation-dock-actions .btn-green:disabled { opacity: .38; filter: grayscale(1); box-shadow: none; cursor: not-allowed; }
.automation-dock.automation-ready .btn-green:not(:disabled) { box-shadow: 0 0 7px rgba(46, 204, 113, .95); animation: automationApplyGlow 1s ease-in-out infinite alternate; }
.automation-dock.automation-armed .automation-carousel-card.selected { background: #3498db; color: #fff; border-color: #21618c; box-shadow: 0 0 6px rgba(52, 152, 219, .75); }
.automation-dock.automation-policy-hint .automation-carousel-card { animation: automationPolicyHint .75s ease-in-out infinite alternate; outline: 2px solid #f1c40f; outline-offset: -2px; }
.automation-status-row { display: contents; }
.automation-status { flex: 0 0 var(--shaft-width); width: var(--shaft-width); height: 36px; box-sizing: border-box; border: 0; border-right: 2px solid #ddd; background: transparent; color: #34495e; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.automation-status.automation-target-hint { animation: automationTargetHint 0.75s ease-in-out infinite alternate; outline: 2px solid #f1c40f; outline-offset: -3px; }
.tutorial-step-target { position: relative; z-index: 3; animation: automationTargetHint .75s ease-in-out infinite alternate; outline: 3px solid #f1c40f; outline-offset: -3px; }
.tutorial-step-target::after { content: attr(data-tutorial-step); position: absolute; top: -12px; right: -8px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #f1c40f; color: #1f2d3d; border: 2px solid #fff; font: 800 12px/1 Arial, sans-serif; box-shadow: 0 1px 4px rgba(0,0,0,.35); pointer-events: none; }
@keyframes automationTargetHint { from { background: #fff; } to { background: #f9e79f; } }
@keyframes automationApplyGlow { from { box-shadow: 0 0 4px rgba(46, 204, 113, .55); } to { box-shadow: 0 0 10px rgba(46, 204, 113, 1); } }
@keyframes automationPolicyHint { from { background: #fff; } to { background: #f9e79f; } }
.automation-library-overlay { position: fixed; inset: 0; z-index: 1200; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: flex-start; padding: 12px; box-sizing: border-box; }
.automation-library { width: min(420px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto; background: #fff; border: 2px solid #34495e; border-radius: 8px; padding: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.automation-library-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.automation-library-search { width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 6px; }
.automation-library-list { display: grid; gap: 5px; }
.automation-library-group { border: 1px solid #ccd4da; border-radius: 5px; overflow: hidden; }
.automation-library-group-toggle { width: 100%; display: flex; justify-content: space-between; padding: 7px 8px; border: 0; background: #e8ecf1; color: #34495e; font-weight: 700; text-align: left; cursor: pointer; }
.automation-library-items { display: grid; gap: 1px; background: #ccd4da; }
.automation-library-item { display: flex; align-items: center; justify-content: space-between; text-align: left; gap: 8px; padding: 6px 7px; background: #f8fafb; }
.automation-library-select { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; align-items: flex-start; border: 0; background: transparent; text-align: left; cursor: pointer; }
.automation-library-select span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.automation-library-select small { color: #53616d; }
.automation-library-pin { flex: 0 0 auto; color: #53616d; font-size: 10px; white-space: nowrap; cursor: pointer; }
.automation-library-empty { padding: 8px; color: #53616d; font-size: 11px; background: #f8fafb; }
@media (max-width: 700px) { .automation-dock-host { width: var(--lobby-width); } .automation-policy-btn { font-size: 9px; } .automation-dock-actions .btn { padding-left: 3px; padding-right: 3px; } }

/* Entities */
.lift { 
    position: absolute; 
    width: var(--lift-width, 110px); 
    background: #ecf0f1; 
    border: 3px solid #000; 
    border-radius: 6px; 
    left: var(--lift-left, 415px);
    display: flex; 
    flex-wrap: wrap; 
    align-items: center; 
    justify-content: center; 
    z-index: 10; 
    box-shadow: 0 4px 8px rgba(0,0,0,0.2); 
    gap: 2px; 
    bottom: calc(var(--lift-pos, 0px) + var(--lift-bottom-offset, 40px));
    height: var(--lift-height, 50px);
    transition: bottom var(--lift-anim-speed, 0.016s) linear;
    box-sizing: border-box;
}
.lift.capsule-car {
    border-radius: 14px;
    border-width: 2px;
    background: #e7f8ff;
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.45), inset 0 0 4px rgba(52, 152, 219, 0.35);
    padding: 2px;
}
.lift.capsule-car::before {
    display: none;
}
.capsule-bank .lift::before {
    display: none;
}
.lift::before { 
    content: ''; 
    position: absolute; 
    top: -1000px; 
    bottom: 100%; 
    left: 50%;
    transform: translateX(-50%);
    width: 4px; 
    background: #7f8c8d; 
    z-index: -1; 
}
.guest { 
    width: 20px; 
    height: 20px; 
    border-radius: 50%; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    font-size: 10px; 
    font-weight: bold; 
    color: white; 
    transition: transform 0.3s, background-color 0.3s; 
    flex-shrink: 0;
}
.queue-overflow {
    flex: 0 0 auto;
    padding: 2px 5px;
    border-radius: 8px;
    background: #34495e;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
}

/* Status Colors & Guest Modifiers */
.happy { background: #2ecc71; }
.checkout-ground { color: #f8f9fa; border: 1px solid rgba(255,255,255,0.8); text-shadow: 0 1px 2px rgba(0,0,0,0.55); }
.checkout-ground { color: #111 !important; text-shadow: none; }
.annoyed { background: #f1c40f; color: #333; }
.critical { background: #e74c3c; animation: pulse 1s infinite; }
.rage { background: #000; animation: shake 0.5s infinite; }
.vip { border: 2px solid #f1c40f; box-shadow: 0 0 10px #f1c40f; }
.swol { 
    width: 30px; 
    border-radius: 4px; 
    font-size: 11px;
}

.room-service {
    width: 42px !important;
    min-width: 42px !important;
    height: 20px !important;
    box-sizing: border-box;
    border-radius: 10px !important; /* Half height for perfect pill ends */
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 5px !important;
    font-size: 14px;
    background: #ecf0f1;
    color: #2c3e50;
    border: 1px solid #7f8c8d;
    white-space: nowrap;
    overflow: hidden;
    flex-shrink: 0 !important;
}
.partying { animation: bounce 0.5s infinite alternate; }

.floor.rooftop-party {
    background: linear-gradient(135deg, #3b1766 0%, #b83280 35%, #f39c12 68%, #2ecc71 100%);
    box-shadow: inset 0 0 18px rgba(255, 241, 118, 0.75), inset 0 -12px 24px rgba(52, 152, 219, 0.35);
    animation: rooftopPulse 1.2s infinite alternate;
}
.lift-effect-overlay {
    position: absolute;
    bottom: calc(var(--lift-pos, 0px) + var(--lift-bottom-offset, 40px));
    height: 28px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
    overflow: visible;
}
.floor.rooftop-party::after {
    content: '✦  ✧  ✦';
    position: absolute;
    left: 8px;
    top: 4px;
    color: #fff176;
    letter-spacing: 4px;
    font-size: 11px;
    animation: discoLights 0.7s steps(2, end) infinite;
    pointer-events: none;
}
.floor.rooftop-party::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(110deg, rgba(255, 255, 255, 0.22) 0 8px, transparent 8px 28px);
    background-size: 220% 100%;
    mix-blend-mode: screen;
    background-position: 0 0;
    animation: discoSweep 1.4s linear infinite;
    pointer-events: none;
}
#world.rooftop-party-board::before {
    display: none;
}

/* Lift Status */
.jammed { border-color: #e74c3c; box-shadow: 0 0 15px rgba(231, 76, 60, 0.8); }
.jammed-alert { display: inline-block; color: #f1c40f; font-weight: 900; text-shadow: 0 0 8px #f1c40f; animation: flashJam 0.4s infinite alternate; }
.lift.capacity-full { border-color: #8e44ad !important; border-width: 3px; box-shadow: 0 0 12px rgba(142, 68, 173, 0.85); }
.automation-controls-locked { opacity: .45; filter: grayscale(1); }
.automation-controls-locked .automation-status { cursor: not-allowed; }
#world.final-life-warning { animation: finalLifeWarning .65s ease-in-out infinite alternate; }
@keyframes finalLifeWarning { from { border-color: #8e2020; box-shadow: 0 0 0 rgba(231, 76, 60, 0); } to { border-color: #e74c3c; box-shadow: 0 0 22px rgba(231, 76, 60, .95); } }

.stinky { background: #d7e0c3; border-color: #82b541; }
.stinky::after {
    content: '💨';
    position: absolute;
    top: -15px;
    right: -10px;
    font-size: 24px;
    z-index: 20;
    pointer-events: none;
    animation: float 2s infinite ease-in-out;
}

/* Phase 2.5: Expansion Power-ups */
/* Double-Decker internal layout */
.lift-deck {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 50%;
    width: 100%;
    box-sizing: border-box;
}
.lift-deck.top {
    border-bottom: none;
}
.lift-deck.bottom {
    border-top: none;
}

.lift.double-decker {
    border-width: 4px;
}
.lift.open-plan {
    border-color: #3498db;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.8);
    animation: openPlanPulse 1.5s infinite alternate;
}

@keyframes openPlanPulse {
    from { border-color: #3498db; box-shadow: 0 0 5px rgba(52, 152, 219, 0.4); }
    to { border-color: #5dade2; box-shadow: 0 0 20px rgba(52, 152, 219, 0.9); }
}

/* Doors States */
.lift.doors-opening { background: #cfd8dc; }
.lift.boarding { background: #ffffff; border-color: #2ecc71; border-width: 3px; }
.lift.doors-closing { background: #cfd8dc; }
.lift.transit { opacity: 0.95; }

/* ==========================================================================
   STANDARD MODALS (Welcome, Review, Leaderboard)
   ========================================================================== */
.overlay { 
    position: absolute; 
    top: 0; left: 0; right: 0; bottom: 0; 
    background: rgba(0,0,0,0.8); 
    display: none; 
    justify-content: center; 
    align-items: center; 
    z-index: 10000; 
}
#manifestOverlay {
    z-index: 11000;
}
.modal-content {
    background: white; 
    padding: 30px; 
    border-radius: 8px; 
    width: 440px; 
    text-align: center; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.5); 
    max-height: 90vh;
    overflow-y: auto;
}
.modal-content h2 { 
    margin-top: 0; 
    color: #2c3e50; 
    border-bottom: 2px solid #ecf0f1; 
    padding-bottom: 10px; 
}
.round-briefing-modal { width: 594px; height: calc(100vh - 24px); max-width: calc(100vw - 32px); max-height: calc(100vh - 24px); box-sizing: border-box; overflow: hidden; display: flex; flex-direction: column; text-align: left; }
.round-briefing-modal #briefingDetails { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.round-briefing-modal #shopContainer { flex: 1 1 261px; min-height: 0; display: flex; flex-direction: column; }
.round-briefing-modal h2 { margin-bottom: 10px; }
.round-rank, .promotion-heading { margin: 0; color: #6b7c85; font-size: 12px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; }
.modal-instructions { line-height: 1.45; color: #2c3e50; margin: 12px 0; }
.briefing-card { margin: 12px 0; padding: 11px 14px; border: 1px solid #c9d5da; border-left: 4px solid #3498db; border-radius: 6px; background: #f7fbfc; }
.briefing-card h3, .briefing-challenges h3 { margin: 0 0 5px; font-size: 12px; color: #52636b; letter-spacing: .8px; text-transform: uppercase; }
.briefing-card p { margin: 0; line-height: 1.35; }
.briefing-objective { border-left-color: #27ae60; }
.briefing-challenges { margin: 12px 0; }
.challenge-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.challenge-chip { padding: 4px 8px; border-radius: 999px; background: #e8f0f4; border: 1px solid #b8c9d0; color: #2c3e50; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.challenge-chip-icon, .briefing-intro-icon { font-weight: normal; }
.briefing-intro-term { white-space: nowrap; }
.briefing-intro-term strong { font-weight: 800; }
.promotion-banner { text-align: center; padding: 20px 18px 10px; }
.promotion-heading { color: #b8860b; font-size: 14px; }
.promotion-copy { margin: 10px auto 14px; max-width: 470px; color: #2c3e50; font-size: 16px; line-height: 1.3; }
.round-briefing-modal.promotion-pending #briefingDetails { display: none; }
.round-briefing-modal.briefing-compact,
.round-briefing-modal.promotion-pending {
    height: auto;
    min-height: 0;
    max-height: calc(100vh - 48px);
}
.round-briefing-modal.promotion-pending {
    width: 468px;
}
.round-briefing-modal.promotion-pending .promotion-banner {
    flex: 0 0 auto;
    padding: 12px 18px 0;
}

.modal-form-row {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 15px 0;
}
.modal-form-label {
    width: 75px;
    text-align: right;
    font-weight: bold;
    color: #2c3e50;
    font-size: 14px;
    margin-right: 10px;
}
.modal-form-input-group {
    width: 220px; 
    display: flex;
    gap: 8px;
}
.player-name-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}
.game-id-input {
    width: 100%;
    min-width: 0; 
    padding: 8px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}
.share-btn {
    white-space: nowrap; 
    flex-shrink: 0;
}
.briefing-footer { position: static; margin-top: 10px; flex: 0 0 auto; }
#startRoundBtn { margin-top: 0; flex: 0 0 auto; }

.round-countdown {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 8500;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border: 3px solid #f1c40f;
    border-radius: 999px;
    background: rgba(44, 62, 80, 0.94);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
}
.round-countdown strong { color: #f1c40f; font-size: 2rem; line-height: 1; }
.round-countdown-skip { position: absolute; top: 6px; right: 6px; border: 0; border-radius: 50%; width: 20px; height: 20px; padding: 0; background: rgba(44,62,80,.72); color: #fff; font-size: .9rem; line-height: 1; font-weight: 900; cursor: pointer; }
.round-countdown-skip:hover, .round-countdown-skip:focus-visible { background: #f7dc6f; outline: 3px solid #fff; }
.audio-mute-row { flex-basis: 100%; justify-content: center; }
.compact-modal { max-width: 420px; text-align: center; }
.modal-help { color: #d5dbdb; font-size: 0.9rem; }

.capacity-float {
    position: absolute;
    z-index: 200;
    width: var(--shaft-width, 110px);
    padding: 4px 0;
    border-radius: 14px;
    background: #3498db;
    color: white;
    text-align: center;
    font-size: 13px;
    font-weight: 800;
    pointer-events: none;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
    animation: capacity-pop 0.35s ease-out;
}

.automation-teaching-cue {
    border: 3px solid #f1c40f !important;
    background: #fff7c7;
    color: #2c3e50;
    animation: friendly-control-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes capacity-pop {
    from { opacity: 0; transform: translateY(12px) scale(0.85); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes friendly-control-pulse {
    from { box-shadow: 0 0 0 0 rgba(241, 196, 15, 0.35); transform: scale(1); }
    to { box-shadow: 0 0 0 8px rgba(241, 196, 15, 0); transform: scale(1.04); }
}

/* Leaderboard Specific */
.leaderboard-list { list-style: none; padding: 0; margin: 20px 0; max-height: 250px; overflow-y: auto; text-align: left; }
.leaderboard-list li { padding: 10px; border-bottom: 1px solid #ecf0f1; display: flex; justify-content: space-between; color: #2c3e50; font-weight: bold; font-size: 16px; align-items: center; }
.leaderboard-list li:last-child { border-bottom: none; }
.leaderboard-list li:nth-child(odd) { background-color: #fdfdfd; }
.leaderboard-list li:nth-child(even) { background-color: #ecf0f1; }
.floor-row:nth-child(odd) { background: #e5e7eb; }
.floor-row:nth-child(even) { background: #f1f3f5; }
.audio-controls { display:flex; gap:10px; align-items:center; justify-content:center; flex-wrap:wrap; margin:8px 0; font-size:12px; color:#566; }
.audio-controls label { display:flex; gap:4px; align-items:center; }
.audio-credits { margin-top:8px; font-size:11px; color:#667; text-align:left; }
.audio-credits p { margin:5px 0; }
.audio-attribution-list { margin:5px 0 5px 18px; padding:0; }
.audio-attribution-list li { margin:4px 0; line-height:1.35; }
.audio-attribution-list a { color:#1e6ea7; }
.audio-attribution-scroller { overflow:hidden; white-space:nowrap; font-size:10px; color:#889; margin:4px 0 8px; }
.audio-attribution-scroller span { display:inline-block; animation: audioCreditsScroll 22s linear infinite; }
.melbourne-heart { color: #ff4f9a; }
.audio-credits > div[id] { max-height: 120px; overflow-y: auto; padding-right: 4px; }
.feedback-privacy-note { margin: 8px 0 0; color: #667; font-size: 11px; line-height: 1.35; text-align: center; }
@keyframes audioCreditsScroll { from { transform:translateX(100%); } to { transform:translateX(-100%); } }

/* Round Review Layout Framework */
.review-outcome-message {
    margin: -4px 0 18px;
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1.45;
    text-align: center;
}

.review-stats-row {
    display: flex; 
    justify-content: space-around; 
    margin: 20px 0; 
    gap: 15px; 
    align-items: stretch; 
}
.review-stat { 
    text-align: center; 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
    box-sizing: border-box;
}
.review-stat-val { 
    font-size: 28px; 
    font-weight: bold; 
    line-height: 1.2; 
    display: block; 
}
.review-stat-value-container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Aligns primary metrics to the top baseline */
    flex-grow: 1;
    margin-bottom: 12px;
}
.review-stat-breakdown {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    margin-top: 6px;
    font-weight: 500;
}
.review-stat-casualty {
    font-size: 11px;
    margin-top: 8px;
    font-weight: bold;
}
.review-stat-metric {
    font-size: 12px;
    margin-top: 10px;
    color: #2c3e50;
}
.review-stat-label {
    font-size: 12px;
    color: #7f8c8d;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.review-list { list-style: none; padding: 0; margin-bottom: 20px; font-size: 14px; text-align: left; }
.review-list li { padding: 6px 10px; border-bottom: 1px solid #f4f6f7; color: #2c3e50; font-weight: 500; }


/* Perfected Debug Menu Layout */
.debug-controls { 
    text-align: left; 
    max-height: 350px; 
    overflow-y: auto; 
    margin-bottom: 20px; 
    border: 1px solid #bdc3c7; 
    border-radius: 4px; 
}
.debug-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 10px 15px; 
    border-bottom: 1px solid #ecf0f1; 
}
.debug-row:last-child { border-bottom: none; }
.debug-row:nth-child(odd) { background-color: #fdfdfd; }
.debug-row:nth-child(even) { background-color: #f4f6f7; }
.debug-row > span { font-weight: bold; color: #2c3e50; font-size: 14px; }
.debug-seed-controls { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.debug-seed-controls input { width: 110px; box-sizing: border-box; }
.spinner-ctrl { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
}
.spinner-ctrl button { 
    width: 28px; 
    height: 28px; 
    border: none; 
    background: #3498db; 
    color: white; 
    border-radius: 4px; 
    font-weight: bold; 
    cursor: pointer; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    padding: 0;
}
.spinner-ctrl button:hover { background: #2980b9; }
.spinner-ctrl div { 
    min-width: 50px; 
    text-align: center; 
    font-family: monospace; 
    font-weight: bold; 
    color: #e67e22; 
    font-size: 14px;
}

/* ==========================================================================
   WORKSHOP MODAL OVERRIDES
   ========================================================================== */
#workshopOverlay .modal-content, .workshop-modal {
    width: 95vw !important;
    max-width: 1200px !important;
    height: 85vh !important;
    display: flex;
    flex-direction: column;
    text-align: left !important;
    padding: 20px;
}

.workshop-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 10px;
}
.workshop-controls h2 {
    margin: 0; 
    padding: 0;
    border-bottom: none;
}

.workshop-layout {
    display: flex;
    gap: 20px;
    flex-grow: 1;
    align-items: stretch;
}

.workshop-sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.workshop-input-group { display: flex; gap: 8px; }
.workshop-select { flex-grow: 1; }
.workshop-input, .workshop-textarea, .workshop-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}
.workshop-textarea { height: 60px; resize: none; font-family: inherit; }
.build-version { margin: 12px 0 0; color: #5d6d7e; font-size: 11px; text-align: center; }

.workshop-actions {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}
.workshop-actions .btn {
    flex: 1; 
    padding: 5px 8px;
    font-size: 12px;
}

.workshop-meta {
    font-size: 12px;
    color: #7f8c8d;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #ecf0f1;
}
.workshop-meta-val { font-weight: bold; color: #2c3e50; }
.meta-margin { margin-top: 4px; }

.compiled-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1; 
    gap: 5px;
}
.compiled-label { font-size: 12px; font-weight: bold; color: #2c3e50; }
.compiled-textarea {
    flex-grow: 1;
    width: 100%;
    min-height: 100px;
    resize: none;
    font-family: monospace;
    font-size: 12px;
    background: #000;
    color: #fff;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    padding: 8px;
    box-sizing: border-box;
}

.blockly-area {
    flex-grow: 1;
    position: relative; 
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    overflow: hidden;
}
#blocklyDiv {
    position: absolute; 
    top: 0; left: 0; right: 0; bottom: 0;
}

/* ==========================================================================
   UI OVERLAY COMPONENTS (Shop, Cart, Toast)
   ========================================================================== */
.game-toast {
    position: fixed; top: 92px; left: 50%; transform: translateX(-50%);
    background: #2c3e50; color: #fff; padding: 12px 24px; border-radius: 8px;
    font-weight: bold; z-index: 10000; transition: opacity 0.4s ease-in-out;
    pointer-events: none; box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border: 2px solid #34495e; opacity: 0;
}
.game-toast.show { opacity: 1; }

.inv-btn {
    font-size: 18px; width: 36px; height: 36px; box-sizing: border-box;
    border-radius: 50%; cursor: pointer; display: flex; justify-content: center;
    align-items: center; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: all 0.2s ease-in-out;
}
.inv-btn:hover { transform: scale(1.1); }
.inv-btn-t1 { background: #fdf6e3; border: 2px solid #cd7f32; }
.inv-btn-t2 { background: #d9e2ec; border: 3px solid #667788; }
.inv-btn-t3 { background: #ffe38a; border: 3px solid #b8860b; }
.inv-btn.active { border: 2px solid #3498db; background: #e0f7fa; }
.inv-btn-t1.active { box-shadow: 0 0 10px #3498db, 0 0 5px #cd7f32 inset; }
.inv-btn-t2.active { box-shadow: 0 0 10px #3498db, 0 0 5px #bdc3c7 inset; }
.inv-btn-t3.active { box-shadow: 0 0 10px #3498db, 0 0 5px #f1c40f inset; }

.shop-header { margin: 0 0 5px 0; border-bottom: 1px solid #ccc; padding-bottom: 5px; font-size: 16px; }
.shop-container { display: flex; flex-direction: column; height: auto; min-height: 0; gap: 10px; margin-bottom: 10px; flex: 1 1 0; }
.shop-scroll-region { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 5px; }
.shop-layout { display: grid; grid-template-columns: minmax(0, 3.25fr) minmax(104px, .9fr); gap: 8px; align-items: start; }
.shop-items-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-content: flex-start; padding: 5px 5px 5px 0; }
.round-briefing-modal .shop-items-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); justify-content: stretch; }
.shop-btn { padding: 8px; border-radius: 6px; cursor: pointer; width: 115px; text-align: center; display: flex; flex-direction: column; align-items: center; transition: transform 0.1s, opacity 0.2s, box-shadow 0.2s; position: relative; flex-shrink: 0; }
.round-briefing-modal .shop-btn { width: auto; min-width: 0; }
.shop-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
.shop-btn:disabled { opacity: 0.4; cursor: not-allowed; background: #f5f5f5 !important; border-color: #ddd !important; }
.shop-btn-t1 { background: #fdf6e3; border: 2px solid #cd7f32; }
.shop-btn-t2 { background: #f8f9fa; border: 2px solid #bdc3c7; }
.shop-btn-t3 { background: #fffbf0; border: 2px solid #f1c40f; }
.shop-btn-tier { position: absolute; top: 0; left: 0; width: 100%; font-size: 9px; font-weight: bold; border-radius: 4px 4px 0 0; padding: 2px 0; }
.shop-btn-t1 .shop-btn-tier { background: #cd7f32; color: #fff; }
.shop-btn-t2 .shop-btn-tier { background: #bdc3c7; color: #333; }
.shop-btn-t3 .shop-btn-tier { background: #f1c40f; color: #fff; }
.shop-btn-icon { font-size: 32px; margin-bottom: 2px; margin-top: 12px; display: flex; justify-content: center; align-items: center; }
.shop-btn-cost { color: #333; font-size: 12px; }
.shop-btn-desc { font-size: 11px; color: #666; margin-top: 5px; line-height: 1.2; }
.shop-btn-scope { margin-top: 5px; font-size: 10px; font-weight: 700; color: #425566; text-transform: uppercase; letter-spacing: .03em; }

.cart-container { min-width: 104px; background: #f8f9fa; border: 1px dashed #f39c12; border-radius: 6px; padding: 8px; box-sizing: border-box; text-align: left; display: flex; flex-direction: column; min-height: 261px; }
.cart-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; flex-shrink: 0; font-size: 14px; }
.cart-header span:first-child { font-weight: bold; color: #2c3e50; }
.cart-total { color: #7f8c8d; display: block; font-size: 12px; line-height: 1.15; white-space: nowrap; }
.cart-items-grid { display: grid; grid-template-columns: repeat(2, 38px); gap: 6px; padding-right: 2px; align-content: start; justify-content: start; }
.cart-item { position: relative; border-radius: 5px; padding: 5px; font-size: 20px; cursor: pointer; display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.1); min-height: 36px; box-sizing: border-box; transition: opacity 0.2s, transform 0.15s; }
.cart-empty { color: #7f8c8d; font-size: 12px; padding: 8px 2px; }
.cart-item:hover { opacity: 0.7; }
.cart-item:focus-visible { outline: 3px solid #3498db; outline-offset: 2px; }
.cart-item-t1 { background: #fdf6e3; border: 2px solid #cd7f32; }
.cart-item-t2 { background: #f8f9fa; border: 2px solid #bdc3c7; }
.cart-item-t3 { background: #fffbf0; border: 2px solid #f1c40f; }
.cart-item > .quantity-badge { position: absolute; top: -6px; right: -6px; }

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes shake { 0% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } 100% { transform: translateX(0); } }
@keyframes bounce { 0% { transform: translateY(0); } 100% { transform: translateY(-5px); } }
@keyframes rooftopPulse { 0% { filter: saturate(1); } 100% { filter: saturate(1.45) brightness(1.12); } }
@keyframes discoLights { 0% { opacity: 0.35; color: #fff176; } 50% { opacity: 1; color: #7df9ff; } 100% { opacity: 0.55; color: #ff9ff3; } }
@keyframes boardDiscoSweep { from { background-position: 0 0; } to { background-position: 100% 0; } }
@keyframes discoSweep { from { background-position: 0 0; } to { background-position: 100% 0; } }

@media (prefers-reduced-motion: reduce) {
    .floor.rooftop-party,
    .floor.rooftop-party::before,
    .floor.rooftop-party::after,
    #world.rooftop-party-board::before { animation: none; }
}
.quantity-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; box-sizing: border-box; border-radius: 50%; background: #111; color: #fff; font-size: 11px; line-height: 1; font-weight: 800; }
.inv-btn { position: relative; }
.inv-btn > .quantity-badge { position: absolute; top: -5px; right: -5px; }
.shell-modal { max-width: 480px; }
.shell-hook { font-size: 18px; line-height: 1.45; color: #34495e; margin: 24px 0; }
.shell-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.shell-modal a { color: #2879b8; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

@keyframes flyOut {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translate(-300px, 200px) rotate(-720deg) scale(0); opacity: 0; }
}

@keyframes flashJam {
    0% { transform: scale(1); filter: drop-shadow(0 0 2px red); }
    100% { transform: scale(1.2); filter: drop-shadow(0 0 8px yellow); }
}

.flying-out {
    position: absolute !important;
    z-index: 9999 !important;
    animation: flyOut 3s cubic-bezier(0.25, 0.1, 0.25, 1) forwards !important;
    pointer-events: none;
    font-size: 24px;
    text-shadow: 0 2px 5px rgba(0,0,0,0.5);
}
