/* ==========================================================================
   Science Lab: Protocol Rush - Standardized Game Stylesheet
   Standardized to Science Games Lab game-ui-revamp guidelines
   ========================================================================== */

/* Strict Modal and Visibility Specificity */
.hidden,
.modal.hidden,
#factModal.hidden,
#howToModal.hidden,
#mainLeaderboardModal.hidden,
#loading-modal.hidden,
#start-modal.hidden,
#gameOverModal.hidden {
    display: none !important;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Fredoka', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
}

body {
    background-color: #090d16;
    color: #f8fafc;
    display: flex;
    flex-direction: column;
}

/* Base Page Layout (Matching Standard Science Games Lab Games) */
.page-container {
    width: 100%;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0.75rem;
    box-sizing: border-box;
}

.game-wrapper {
    width: 100%;
    max-width: 64rem;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
    background: #0f172a;
    border-radius: 1rem;
    border: 1.5px solid rgba(56, 189, 248, 0.2);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

@media (min-width: 1024px) {
    .page-container {
        display: grid;
        grid-template-columns: minmax(0, 3.2fr) minmax(0, 1fr);
        width: 100%;
        max-width: 86rem;
        margin: 0 auto;
        padding: 0.75rem 1rem;
        gap: 1.25rem;
        flex: 1 1 auto;
        min-height: 0;
        box-sizing: border-box;
        align-items: stretch;
    }

    .game-wrapper {
        max-width: 100%;
        padding: 0;
    }

    .leaderboard-panel {
        display: flex !important;
    }

    #leaderboardBtn,
    #leaderboardGameOverBtn {
        display: none !important;
    }
}

/* Top HUD Bar */
.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.85rem;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1.5px solid rgba(56, 189, 248, 0.2);
    z-index: 20;
    gap: 0.5rem;
}

.hud-element {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 700;
    font-size: 0.95rem;
    color: #f8fafc;
}

.hud-score {
    color: #38bdf8;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.hud-combo {
    color: #facc15;
    font-size: 0.95rem;
}

.hud-timer {
    color: #f43f5e;
    font-size: 1rem;
}

.hud-left-group, .hud-right-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.hud-center-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.hud-tag {
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
}

.hud-shift-tag {
    color: #93c5fd;
    border-color: rgba(147, 197, 253, 0.3);
}

.hud-target-tag {
    color: #fde047;
    border-color: rgba(253, 224, 71, 0.35);
    background: rgba(253, 224, 71, 0.1);
}

.hud-stars-tag {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.3);
}

.hud-mute-button {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.5rem;
    padding: 0.35rem 0.55rem;
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.2s ease;
}

.hud-mute-button:hover {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.4);
}

/* Game Area Viewport and Canvas */
.game-area-wrapper {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #060b13;
    overflow: hidden;
}

#gameCanvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
    image-rendering: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}


/* Modals System (Matching Immune Rush) */
.modal {
    position: absolute;
    inset: 0;
    z-index: 50;
    background-color: rgba(10, 10, 12, 0.94);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border-radius: 0.75rem;
    box-sizing: border-box;
}

#startContent {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    width: 100%;
}

.modal-header {
    flex-shrink: 0;
    padding-bottom: 0.5rem;
    text-align: center;
}

.modal-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.75rem;
    letter-spacing: 1px;
    font-weight: 700;
    color: white;
    margin-bottom: 0.2rem;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.modal-subtitle {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    color: #facc15;
    font-weight: 600;
}

.modal-body {
    flex-grow: 1;
    overflow-y: auto;
    width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-footer {
    flex-shrink: 0;
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
}

.modal-footer-buttons {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 28rem;
    margin: 0 auto;
}

/* Buttons */
.btn-primary, .btn-secondary {
    font-family: 'Fredoka', sans-serif;
    color: white;
    font-weight: 700;
    padding: 0.65rem 1.4rem;
    border-radius: 0.65rem;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    border: 1px solid #38bdf8;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 18px rgba(56, 189, 248, 0.4);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #cbd5e1;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    color: #ffffff;
}

.player-name-input {
    width: 100%;
    max-width: 18rem;
    padding: 0.55rem 0.85rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1.5px solid rgba(56, 189, 248, 0.4);
    border-radius: 0.65rem;
    color: #f8fafc;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.player-name-input:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.player-name-input.shake-input {
    animation: input-shake 0.4s ease-in-out;
    border-color: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

@keyframes input-shake {
    10%, 90% { transform: translateX(-4px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

/* Character Intro Cards */
.intro-box {
    width: 100%;
    max-width: 58rem;
    margin: 0 auto 0.75rem auto;
    padding: 0.75rem;
    background-color: rgba(24, 24, 27, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-sizing: border-box;
}

.cards-hint {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    color: #94a3b8;
    letter-spacing: 0.3px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    width: 100%;
}

@media (min-width: 640px) {
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 860px) {
    .cards-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.character-card {
    position: relative;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.85rem;
    padding: 0.65rem 0.5rem 0.6rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.character-card:hover {
    transform: translateY(-4px) scale(1.03);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.card-hero { border-color: rgba(34, 211, 238, 0.4); }
.card-hero:hover { border-color: #22d3ee; box-shadow: 0 8px 24px rgba(34, 211, 238, 0.25); }
.card-ally { border-color: rgba(56, 189, 248, 0.35); }
.card-ally:hover { border-color: #38bdf8; box-shadow: 0 8px 24px rgba(56, 189, 248, 0.2); }

.card-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
    line-height: 1.2;
}

.badge-hero { background: rgba(34, 211, 238, 0.2); color: #67e8f9; border: 1px solid rgba(34, 211, 238, 0.4); }
.badge-ally { background: rgba(56, 189, 248, 0.2); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.4); }

.card-portrait, .icon-container {
    width: 3.5rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 0.65rem;
    padding: 0.3rem;
    margin-bottom: 0.35rem;
    transition: transform 0.2s ease;
}

.character-card:hover .card-portrait,
.character-card:hover .icon-container {
    transform: scale(1.08);
}

.card-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.card-name {
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.2rem;
}

.card-ability {
    font-size: 0.72rem;
    color: #d4d4d8;
    line-height: 1.25;
    font-weight: 500;
}

.mission-brief-box {
    text-align: center;
    max-width: 42rem;
    margin: 0.4rem auto;
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.4;
}

/* Modals & How to Play */
.fact-card, .how-to-card, .game-over-card {
    position: relative;
    width: 100%;
    max-width: 44rem;
    max-height: 90vh;
    margin: auto;
    overflow-y: auto;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.98) 0%, rgba(10, 15, 30, 0.98) 100%);
    border: 2px solid rgba(56, 189, 248, 0.45);
    border-radius: 1.25rem;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(56, 189, 248, 0.2);
    text-align: center;
}

.fact-card { max-width: 28rem; }
.game-over-card { max-width: 32rem; }

.tutorial-corner-btn {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(56, 189, 248, 0.4);
    border-radius: 9999px;
    padding: 0.4rem 0.85rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: #a5f3fc;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: all 0.2s ease;
}

.tutorial-corner-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.8);
    transform: translateY(-2px) scale(1.03);
}

.fact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.fact-close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.fact-close-btn:hover { color: #f87171; }

.how-to-header-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.4);
    text-transform: uppercase;
}

.fact-title, .how-to-title, .game-over-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 0.35rem;
}

.how-to-subtitle {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 1.25rem;
}

.tutorial-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
    .tutorial-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 860px) {
    .tutorial-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.tutorial-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.85rem;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.tutorial-icon-box {
    width: 3.25rem;
    height: 3.25rem;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tutorial-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.tutorial-step-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 0.25rem;
}

.tutorial-step-desc {
    font-size: 0.72rem;
    color: #cbd5e1;
    line-height: 1.3;
}

.fact-portrait { margin: 0.5rem auto 1rem auto; }
.fact-text {
    font-size: 0.95rem;
    line-height: 1.4;
    color: #cbd5e1;
    margin-bottom: 1.25rem;
}

.fact-btn { min-width: 130px; margin: 0 auto; }

/* Score Summary Grid (Game Over) */
.score-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.summary-stat-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.65rem;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.72rem;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 600;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    margin-top: 0.15rem;
}

.final-score-text {
    font-size: 1.35rem;
    font-weight: 700;
    color: #facc15;
    margin: 0.35rem 0;
}

.leaderboard-rank-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 0.5rem;
}

.science-fact-box {
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 0.75rem;
    padding: 0.75rem;
    max-width: 26rem;
    margin: 0 auto;
}

/* Leaderboard Sidebar & Modal (Standardized) */
.leaderboard-panel {
    display: none;
    width: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 1rem;
    border: 1.5px solid rgba(56, 189, 248, 0.25);
    padding: 1rem;
    flex-direction: column;
    min-height: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

.leaderboard-panel-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #facc15;
    margin: 0 0 0.75rem 0;
    text-align: center;
    letter-spacing: 0.5px;
}

.leaderboard-box {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
    flex-grow: 1;
}

.leaderboard-podium-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.4rem;
    border-radius: 0.65rem;
    background: rgba(255, 255, 255, 0.04);
    transition: transform 0.15s ease-out;
}

.leaderboard-podium-card:hover {
    transform: translateX(2px);
}

.podium-rank-1 {
    background: linear-gradient(90deg, rgba(250, 204, 21, 0.2) 0%, rgba(15, 23, 42, 0.7) 100%);
    border: 1.5px solid rgba(250, 204, 21, 0.6);
    box-shadow: 0 4px 15px rgba(250, 204, 21, 0.2);
}

.podium-rank-2 {
    background: linear-gradient(90deg, rgba(203, 213, 225, 0.16) 0%, rgba(15, 23, 42, 0.7) 100%);
    border: 1.5px solid rgba(203, 213, 225, 0.5);
    box-shadow: 0 3px 12px rgba(203, 213, 225, 0.15);
}

.podium-rank-3 {
    background: linear-gradient(90deg, rgba(217, 119, 6, 0.16) 0%, rgba(15, 23, 42, 0.7) 100%);
    border: 1.5px solid rgba(217, 119, 6, 0.5);
    box-shadow: 0 3px 12px rgba(217, 119, 6, 0.15);
}

.podium-player-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.podium-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.podium-badge.rank-1 {
    background: linear-gradient(135deg, #facc15 0%, #ca8a04 100%);
    color: #0f172a;
    box-shadow: 0 0 10px rgba(250, 204, 21, 0.6);
}

.podium-badge.rank-2 {
    background: linear-gradient(135deg, #f1f5f9 0%, #94a3b8 100%);
    color: #0f172a;
    box-shadow: 0 0 10px rgba(203, 213, 225, 0.5);
}

.podium-badge.rank-3 {
    background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(217, 119, 6, 0.5);
}

.podium-player-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.podium-player-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.podium-rank-tag {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #94a3b8;
}

.podium-score {
    font-weight: 700;
    font-size: 1.05rem;
    flex-shrink: 0;
    padding-left: 0.5rem;
}

.score-glow-1 { color: #fde047; text-shadow: 0 0 8px rgba(250, 204, 21, 0.5); }
.score-glow-2 { color: #e2e8f0; text-shadow: 0 0 8px rgba(226, 232, 240, 0.4); }
.score-glow-3 { color: #f59e0b; text-shadow: 0 0 8px rgba(245, 158, 11, 0.4); }

.leaderboard-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.75rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.leaderboard-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.leaderboard-row-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.leaderboard-row-rank {
    font-size: 0.8rem;
    font-weight: 700;
    color: #64748b;
    width: 20px;
    text-align: center;
}

.leaderboard-row-name {
    font-size: 0.85rem;
    color: #cbd5e1;
    font-weight: 600;
}

.leaderboard-row-score {
    font-size: 0.9rem;
    font-weight: 700;
    color: #38bdf8;
}

.leaderboard-empty {
    text-align: center;
    padding: 1.5rem 0.5rem;
    color: #64748b;
}

.leaderboard-empty-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #cbd5e1;
    margin: 0.5rem 0 0.2rem 0;
}

.leaderboard-subtext {
    font-size: 0.75rem;
    color: #64748b;
}

.leaderboard-tip {
    margin-top: 0.75rem;
    padding: 0.55rem 0.75rem;
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.75rem;
    color: #93c5fd;
    line-height: 1.3;
}

.leaderboard-tip-icon {
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
}

/* Floating Feedback & Score Popups */
#score-pop-container, #notification-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 40;
    overflow: hidden;
}

.score-pop {
    position: absolute;
    font-size: 1.3rem;
    font-weight: 700;
    color: #facc15;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    animation: floatUpFade 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.notification-toast {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    border: 1.5px solid #38bdf8;
    border-radius: 9999px;
    padding: 0.4rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: #f8fafc;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    animation: toastPop 1.8s forwards;
}

@keyframes floatUpFade {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-35px) scale(1.15); }
}

@keyframes toastPop {
    0% { opacity: 0; transform: translate(-50%, -10px); }
    15% { opacity: 1; transform: translate(-50%, 0); }
    80% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -10px); }
}

/* Global Footer (Matching Immune Rush) */
footer {
    flex-shrink: 0;
    padding: 1rem;
    padding-top: 0;
    box-sizing: border-box;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.footer-logo, .h-16 {
    height: 4rem;
    max-height: 4rem;
    width: auto;
    opacity: 0.95;
    transition: opacity 0.2s, transform 0.2s;
    display: block;
}

.footer-logo:hover, .h-16:hover {
    opacity: 1;
    transform: scale(1.04);
}

/* Custom Scrollbar */
.modal-body::-webkit-scrollbar, .leaderboard-box::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track, .leaderboard-box::-webkit-scrollbar-track {
    background: #0f172a;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb, .leaderboard-box::-webkit-scrollbar-thumb {
    background-color: #38bdf8;
    border-radius: 4px;
}

/* =========================================================
   DEVICE WORKSTATION MINI-GAME OVERLAYS
   ========================================================= */
#workstation-modal {
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 0.75rem;
}

.workstation-card {
    position: relative;
    width: 95%;
    max-width: 820px;
    height: min(470px, 92vh);
    max-height: 92vh;
    background: rgba(15, 23, 42, 0.96);
    border: 1.5px solid rgba(56, 189, 248, 0.35);
    border-radius: 1.25rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(56, 189, 248, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #f8fafc;
    animation: modalScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.workstation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 1.25rem;
    background: rgba(30, 41, 59, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.ws-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ws-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    background: rgba(56, 189, 248, 0.18);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.4);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.ws-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
}

.ws-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ws-assay-tag {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 0.5rem;
    background: rgba(250, 204, 21, 0.12);
    border: 1px solid rgba(250, 204, 21, 0.3);
    color: #fde047;
}

.ws-close-btn {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.4);
    color: #fda4af;
    padding: 0.3rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ws-close-btn:hover {
    background: rgba(244, 63, 94, 0.3);
    color: #ffffff;
    border-color: #f43f5e;
    transform: scale(1.04);
}

.workstation-body {
    flex: 1;
    padding: 0.75rem 1.25rem;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 0;
}

/* --- Centrifuge Workstation --- */
.ws-centrifuge-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 1.25rem;
    height: 100%;
    align-items: center;
}

.rotor-chamber {
    position: relative;
    width: 240px;
    height: 240px;
    background: radial-gradient(circle at center, #1e293b 0%, #0b1329 70%, #030712 100%);
    border: 3px solid rgba(56, 189, 248, 0.35);
    border-radius: 50%;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.9), 0 0 25px rgba(56, 189, 248, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.rotor-plate {
    position: relative;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    background: radial-gradient(circle at center, #334155 0%, #1e293b 60%, #0f172a 100%);
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    transition: transform 0.1s linear;
}

.rotor-plate.spinning-fast {
    animation: rotorSpin 0.12s linear infinite;
}

@keyframes rotorSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.rotor-hub {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #0f172a;
    border: 2px solid #64748b;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: #94a3b8;
    font-weight: 700;
}

.rotor-well-slot {
    position: absolute;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #09101d;
    border: 2px dashed rgba(255, 255, 255, 0.25);
    transform: translate(-50%, -50%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.rotor-well-slot:hover {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.2);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
    transform: translate(-50%, -50%) scale(1.12);
}

.rotor-well-number {
    font-size: 0.72rem;
    font-weight: 700;
    color: rgba(148, 163, 184, 0.7);
}

.rotor-tube-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 800;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.rotor-tube-icon.sample-tube {
    border: 2px solid #ffffff;
}

.rotor-tube-icon.water-tube {
    background: #0284c7;
    border: 2px solid #38bdf8;
}

/* Centrifuge Right Panel */
.centrifuge-controls {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    height: 100%;
    justify-content: center;
}

.tachometer-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 0.65rem;
    padding: 0.45rem 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tachometer-val {
    font-size: 1.35rem;
    font-weight: 800;
    color: #34d399;
    font-family: monospace;
    letter-spacing: 0.05em;
}

.tube-tray-container {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.65rem;
    padding: 0.5rem 0.75rem;
}

.tube-tray-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
}

.tube-tray-rack {
    display: flex;
    gap: 0.65rem;
}

.tray-tube-slot {
    flex: 1;
    min-height: 48px;
    background: rgba(30, 41, 59, 0.8);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.5rem;
    padding: 0.35rem 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tray-tube-slot:hover {
    border-color: #38bdf8;
    background: rgba(30, 41, 59, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.25);
}

.tray-tube-slot.selected {
    border-color: #facc15;
    background: rgba(250, 204, 21, 0.12);
    box-shadow: 0 0 12px rgba(250, 204, 21, 0.3);
}

.tray-tube-slot.empty {
    opacity: 0.4;
    cursor: not-allowed;
    border-style: dashed;
}

.tube-indicator-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tube-slot-info {
    display: flex;
    flex-direction: column;
}

.tube-slot-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #f8fafc;
}

.tube-slot-desc {
    font-size: 0.65rem;
    color: #94a3b8;
}

.ws-status-banner {
    padding: 0.45rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: #a5f3fc;
    line-height: 1.35;
}

.ws-status-banner.alert {
    background: rgba(244, 63, 94, 0.18);
    border-color: #f43f5e;
    color: #fecdd3;
    animation: alertPulse 0.5s ease infinite alternate;
}

.ws-status-banner.success {
    background: rgba(34, 197, 94, 0.18);
    border-color: #22c55e;
    color: #bbf7d0;
}

@keyframes alertPulse {
    from { opacity: 0.85; }
    to { opacity: 1; }
}

.vibrate-heavy {
    animation: heavyShake 0.1s linear infinite;
}

@keyframes heavyShake {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-5px, 4px) rotate(-1.5deg); }
    50% { transform: translate(5px, -3px) rotate(1.5deg); }
    75% { transform: translate(-4px, -4px) rotate(-1deg); }
    100% { transform: translate(4px, 3px) rotate(1deg); }
}

.ws-action-btn {
    padding: 0.65rem 1.25rem;
    font-size: 0.92rem;
    font-weight: 700;
    border-radius: 0.65rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.ws-action-btn.btn-run {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.ws-action-btn.btn-run:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
}

.ws-action-btn.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #475569;
    color: #94a3b8;
    box-shadow: none;
}

/* --- Pipette Workstation --- */
.ws-pipette-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.25rem;
    height: 100%;
    align-items: center;
}

.pipette-visual-bench {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 0.85rem;
    height: 100%;
    box-sizing: border-box;
}

.pipette-sprite-large {
    width: 90px;
    height: 90px;
    object-fit: contain;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5));
    transition: transform 0.2s ease;
}

.pipette-visual-bench:hover .pipette-sprite-large {
    transform: scale(1.05);
}

.pipette-interactive-controls {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    justify-content: center;
    height: 100%;
}

.pipette-volume-counter {
    background: #0f172a;
    border: 1.5px solid #c084fc;
    border-radius: 0.5rem;
    padding: 0.45rem 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pipette-vol-digits {
    font-size: 1.35rem;
    font-weight: 800;
    color: #c084fc;
    font-family: monospace;
}
.pipette-bench-title {
    margin-top: 0.75rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: #c084fc;
    text-align: center;
}

.pipette-bench-desc {
    font-size: 0.8rem;
    color: #94a3b8;
    text-align: center;
    margin-top: 0.25rem;
}

.pipette-tip-fluid-box {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.8);
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pipette-tip-fluid-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
}

.pipette-tip-fluid-val {
    font-size: 0.85rem;
    font-weight: 700;
    color: #cbd5e1;
}

.pipette-vol-label {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 700;
}

.timing-meter-container {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.75rem;
    padding: 1rem;
}

.timing-meter-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.timing-meter-bar-track {
    position: relative;
    width: 100%;
    height: 22px;
    background: #0f172a;
    border-radius: 11px;
    border: 1.5px solid #475569;
    overflow: hidden;
}

.timing-meter-zone-left {
    position: absolute;
    left: 0;
    width: 35%;
    height: 100%;
    background: rgba(245, 158, 11, 0.15);
}

.timing-meter-zone-sweet {
    position: absolute;
    left: 35%;
    width: 30%;
    height: 100%;
    background: rgba(34, 197, 94, 0.65);
    border-left: 2px solid #4ade80;
    border-right: 2px solid #4ade80;
}

.timing-meter-zone-right {
    position: absolute;
    left: 65%;
    width: 35%;
    height: 100%;
    background: rgba(244, 63, 94, 0.2);
}

.timing-meter-indicator {
    position: absolute;
    left: 50%;
    top: 0;
    width: 8px;
    height: 100%;
    background: #facc15;
    border-radius: 3px;
    transform: translateX(-50%);
    box-shadow: 0 0 8px #facc15;
}

.timing-meter-labels {
    position: relative;
    height: 1.2rem;
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 600;
    margin-top: 0.4rem;
    display: flex;
    justify-content: space-between;
}

.timing-sweet-label {
    color: #4ade80;
    font-weight: 700;
    white-space: nowrap;
}

/* --- Incubator Workstation --- */
.ws-incubator-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.25rem;
    height: 100%;
    align-items: center;
}

.incubator-chamber-visual {
    position: relative;
    width: 100%;
    height: 220px;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    border: 3px solid #fbbf24;
    border-radius: 0.75rem;
    box-shadow: inset 0 0 25px rgba(251, 191, 36, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    box-sizing: border-box;
    transition: box-shadow 0.2s ease;
}

.incubator-chamber-visual:hover {
    box-shadow: inset 0 0 30px rgba(251, 191, 36, 0.35), 0 0 20px rgba(251, 191, 36, 0.2);
}

.incubator-temp-glow {
    font-size: 2.3rem;
    font-weight: 800;
    font-family: monospace;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}

.incubator-controls-panel {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.incubator-btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.incubator-temp-bar-bg {
    position: relative;
    width: 100%;
    height: 18px;
    background: #0f172a;
    border-radius: 9px;
    border: 1.5px solid #475569;
    overflow: hidden;
}

.incubator-temp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8 0%, #4ade80 75%, #f43f5e 100%);
    transition: width 0.15s ease-out;
}

.incubator-reaction-fill {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8 0%, #10b981 100%);
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
    transition: width 0.1s linear;
}
.incubator-chamber-sprite {
    width: 115px;
    height: 115px;
    object-fit: contain;
    margin-bottom: 0.35rem;
    transition: transform 0.2s ease;
}

.incubator-meter-box {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.75rem;
    padding: 0.65rem 0.85rem;
}

.incubator-meter-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 0.35rem;
}

.incubator-sweet-window {
    position: absolute;
    left: 66.6%;
    width: 10.4%;
    height: 100%;
    background: rgba(34, 197, 94, 0.45);
    border-left: 1.5px solid #4ade80;
    border-right: 1.5px solid #4ade80;
    z-index: 1;
}

.incubator-meter-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: #64748b;
    font-weight: 600;
    margin-top: 0.25rem;
}

.incubator-reaction-track {
    width: 100%;
    height: 14px;
    background: #0f172a;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid #334155;
}

.incubator-heat-btn {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.incubator-cool-btn {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
}

.incubator-auto-btn {
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
}

/* --- Microscope Workstation --- */
.ws-microscope-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.25rem;
    height: 100%;
    align-items: center;
}

.microscope-eyepiece {
    position: relative;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: #020617;
    border: 4px solid #f472b6;
    box-shadow: 0 0 25px rgba(244, 114, 182, 0.25), inset 0 0 35px rgba(0, 0, 0, 0.95);
    overflow: hidden;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.specimen-canvas {
    width: 100%;
    height: 100%;
    transition: filter 0.08s ease;
}

.eyepiece-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: 
        radial-gradient(circle, transparent 35px, rgba(244, 114, 182, 0.15) 36px, transparent 37px),
        linear-gradient(to right, transparent 49.5%, rgba(255, 255, 255, 0.2) 50%, transparent 50.5%),
        linear-gradient(to bottom, transparent 49.5%, rgba(255, 255, 255, 0.2) 50%, transparent 50.5%);
}

.focus-knob-container {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    justify-content: center;
}

.focus-slider {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    background: #1e293b;
    outline: none;
    cursor: pointer;
    accent-color: #f472b6;
    transition: filter 0.2s ease;
}

.focus-slider:hover {
    filter: brightness(1.2);
}
.microscope-slider-box {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 1rem;
}

.microscope-slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

/* --- Sample Rack Intake Workstation --- */
.ws-rack-layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    height: 100%;
}

.rack-requisition-header {
    background: rgba(15, 23, 42, 0.95);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    border: 2px solid #38bdf8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.rack-req-eyebrow {
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
}

.rack-req-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #38bdf8;
    margin-top: 0.15rem;
}

.rack-req-sub {
    font-size: 0.8rem;
    color: #cbd5e1;
    margin-top: 0.2rem;
}

.rack-req-badge {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.4);
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 800;
    white-space: nowrap;
}

.rack-tubes-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    align-items: stretch;
}

.rack-tube-slot {
    background: radial-gradient(circle at center top, rgba(30, 41, 59, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.85rem;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.rack-tube-slot:hover {
    transform: translateY(-8px);
    border-color: #38bdf8;
    box-shadow: 0 10px 24px rgba(56, 189, 248, 0.25);
}

.rack-tube-img {
    width: 65px;
    height: 110px;
    object-fit: contain;
    transition: transform 0.2s ease;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}

.rack-tube-slot:hover .rack-tube-img {
    transform: scale(1.08);
}

.rack-tube-slot.shake-slot {
    animation: input-shake 0.4s ease-in-out;
    border-color: #ef4444 !important;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.5) !important;
}

.rack-tube-well {
    width: 48px;
    height: 12px;
    border-radius: 50%;
    background: #090d16;
    border: 1.5px solid #334155;
    margin-top: -6px;
    margin-bottom: 0.4rem;
}

.rack-tube-specimen {
    font-size: 0.8rem;
    font-weight: 800;
    color: #f8fafc;
    text-align: center;
    margin-bottom: 0.25rem;
}

.rack-tube-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    text-align: center;
    margin-bottom: 0.5rem;
}

.rack-take-btn {
    width: 100%;
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 800;
    border-radius: 0.5rem;
    text-align: center;
    border: 1px solid rgba(56, 189, 248, 0.35);
    background: rgba(15, 23, 42, 0.85);
    color: #38bdf8;
    cursor: pointer;
    pointer-events: none;
    transition: all 0.15s ease;
}

.rack-take-btn:hover:not(:disabled) {
    background: #38bdf8;
    color: #0f172a;
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.rack-take-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: #475569;
    color: #64748b;
}

.order-steps-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0.35rem 0;
}

.order-step-chip {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 0.35rem;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
}

@media (max-width: 680px) {
    .workstation-card {
        height: min(520px, 94vh);
        max-height: 94vh;
    }
    .ws-centrifuge-layout,
    .ws-pipette-layout,
    .ws-incubator-layout,
    .ws-microscope-layout {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .rotor-chamber {
        width: 170px;
        height: 170px;
    }
    .rotor-plate {
        width: 140px;
        height: 140px;
    }
    .pipette-visual-bench {
        display: none;
    }
    .incubator-chamber-visual {
        height: 120px;
    }
    .microscope-eyepiece {
        width: 140px;
        height: 140px;
    }
}

.hud-mute-button {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    transition: transform 0.15s ease, background-color 0.2s, border-color 0.2s;
}

.hud-mute-button:hover {
    transform: scale(1.06);
    background: rgba(39, 39, 42, 0.95);
    border-color: #a1a1aa;
}

.hud-mute-button:active {
    transform: scale(0.95);
}

.hud-mute-button svg {
    width: 1.25rem;
    height: 1.25rem;
    display: block;
}

#rotate-warning {
    display: none;
    position: fixed;
    inset: 0;
    background-color: #18181b;
    color: #f4f4f5;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 200;
    padding: 1.5rem;
    font-family: 'Fredoka', sans-serif;
}

.rotate-icon {
    width: 4.5rem;
    height: 4.5rem;
    margin-bottom: 1.25rem;
    color: #38bdf8;
    animation: rotate-pulse 2s infinite ease-in-out;
}

@keyframes rotate-pulse {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(90deg) scale(1.08); }
}

@media screen and (max-width: 1023px) and (orientation: portrait) {
    .page-container, footer {
        display: none !important;
    }
    #rotate-warning {
        display: flex !important;
    }
}

@media screen and (max-height: 540px) and (orientation: landscape) {
    footer {
        display: none !important;
    }
    .page-container {
        padding: 0.25rem 0.5rem;
    }
    .game-wrapper {
        max-width: 100%;
        height: 100%;
    }
    .leaderboard-panel {
        display: none !important;
    }
    .hud {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 0.25rem !important;
        gap: 0.35rem !important;
    }
    .hud-element {
        font-size: 0.78rem;
        padding: 0.2rem 0.5rem;
        border-radius: 0.5rem;
    }
    .hud-label {
        display: none !important;
    }
    .integrity-container {
        min-width: 70px;
        max-width: 180px;
        flex-grow: 1;
    }
    .integrity-bar {
        height: 0.95rem;
        border-radius: 0.35rem;
    }
    .hud-mute-button {
        display: flex !important;
        padding: 0.2rem 0.4rem;
    }
    .canvas-container,
    .game-area-wrapper,
    #game-container {
        min-height: 0;
        flex: 1 1 auto;
    }
    canvas {
        max-height: 100%;
        max-width: 100%;
    }
    .modal {
        padding: 0.35rem 0.6rem;
    }
    .modal-header {
        padding-bottom: 0.15rem;
    }
    .modal-title {
        font-size: 1.3rem;
        line-height: 1.1;
    }
    .modal-subtitle {
        font-size: 0.7rem;
        margin: 0;
    }
    .tutorial-corner-btn {
        top: 0.35rem;
        left: 0.35rem;
        right: auto !important;
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }
    .intro-box {
        padding: 0.3rem 0.4rem;
        margin-bottom: 0.25rem;
    }
    .cards-hint {
        font-size: 0.65rem;
        margin-bottom: 0.15rem;
    }
    .cards-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 0.25rem;
    }
    .character-card {
        padding: 0.25rem 0.2rem;
        border-radius: 0.5rem;
    }
    .card-badge {
        font-size: 0.5rem;
        padding: 0.05rem 0.25rem;
        margin-bottom: 0.15rem;
    }
    .card-portrait, .icon-container {
        width: 2rem;
        height: 2rem;
        padding: 0.15rem;
        margin-bottom: 0.15rem;
    }
    .card-name {
        font-size: 0.65rem;
        margin-bottom: 0.05rem;
    }
    .card-ability {
        font-size: 0.56rem;
        line-height: 1.1;
    }
    .modal-footer {
        padding-top: 0.25rem;
    }
    .player-name-input {
        padding: 0.3rem 0.6rem;
        font-size: 0.85rem;
        max-width: 16rem;
        border-radius: 0.5rem;
    }
    .modal-footer-buttons {
        margin-top: 0.25rem;
        gap: 0.5rem;
    }
    .btn-primary, .btn-secondary {
        padding: 0.35rem 1rem;
        font-size: 0.88rem;
        border-radius: 0.5rem;
    }
    .game-over-title {
        font-size: 1.3rem;
    }
    .game-over-fact-card {
        padding: 0.35rem 0.6rem;
        max-width: 22rem;
        margin: 0.2rem auto;
    }
    .game-over-fact-portrait {
        width: 2.75rem;
        height: 2.75rem;
        margin-bottom: 0.2rem;
    }
    .game-over-fact-title {
        font-size: 0.95rem;
        margin-bottom: 0.15rem;
    }
    .game-over-fact-text {
        font-size: 0.72rem;
        line-height: 1.25;
    }
    #mainLeaderboardModal .modal-body,
    .how-to-card,
    .fact-card {
        max-height: 85vh;
        overflow-y: auto;
    }
    .tutorial-cards {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.35rem;
    }
    .tutorial-card {
        padding: 0.4rem;
    }
    .tutorial-step-img {
        width: 2rem;
        height: 2rem;
    }
    #workstation-modal {
        padding: 0.15rem 0.4rem !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .workstation-card {
        width: 100% !important;
        max-width: 880px !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0.65rem !important;
        border-width: 1.5px !important;
    }
    .workstation-header {
        padding: 0.2rem 0.55rem !important;
    }
    .ws-title {
        font-size: 0.82rem !important;
    }
    .ws-badge {
        font-size: 0.58rem !important;
        padding: 0.08rem 0.35rem !important;
    }
    .ws-assay-tag {
        font-size: 0.62rem !important;
        padding: 0.08rem 0.35rem !important;
    }
    .ws-close-btn {
        font-size: 0.65rem !important;
        padding: 0.12rem 0.4rem !important;
    }
    .workstation-body {
        padding: 0.25rem 0.55rem !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .ws-status-banner {
        padding: 0.18rem 0.45rem !important;
        font-size: 0.68rem !important;
        line-height: 1.25 !important;
        border-radius: 0.4rem !important;
    }
    .ws-action-btn {
        padding: 0.32rem 0.75rem !important;
        font-size: 0.75rem !important;
        border-radius: 0.45rem !important;
        min-height: unset !important;
    }

    /* Centrifuge compact landscape */
    .ws-centrifuge-layout {
        grid-template-columns: 190px 1fr !important;
        gap: 0.6rem !important;
        height: 100% !important;
    }
    .rotor-chamber {
        width: 190px !important;
        height: 190px !important;
    }
    .centrifuge-controls {
        gap: 0.25rem !important;
        justify-content: center !important;
    }
    .tachometer-card {
        padding: 0.2rem 0.55rem !important;
    }
    .tachometer-val {
        font-size: 1.05rem !important;
    }
    .tube-tray-container {
        padding: 0.22rem 0.45rem !important;
    }
    .tube-tray-title {
        font-size: 0.62rem !important;
        margin-bottom: 0.15rem !important;
    }
    .tube-tray-rack {
        gap: 0.35rem !important;
    }
    .tray-tube-slot {
        min-height: 28px !important;
        padding: 0.18rem 0.35rem !important;
        gap: 0.35rem !important;
        border-radius: 0.35rem !important;
    }
    .tube-indicator-dot {
        width: 12px !important;
        height: 12px !important;
    }
    .tube-slot-label {
        font-size: 0.65rem !important;
    }
    .tube-slot-desc {
        font-size: 0.55rem !important;
    }

    /* Pipette compact landscape */
    .ws-pipette-layout {
        grid-template-columns: 135px 1fr !important;
        gap: 0.6rem !important;
        height: 100% !important;
    }
    .pipette-visual-bench {
        display: flex !important;
        padding: 0.35rem !important;
        justify-content: center !important;
    }
    .pipette-sprite-large {
        width: 44px !important;
        height: 44px !important;
    }
    .pipette-bench-title {
        font-size: 0.72rem !important;
        margin-top: 0.15rem !important;
        line-height: 1.1 !important;
    }
    .pipette-bench-desc {
        font-size: 0.58rem !important;
        margin-top: 0.1rem !important;
        line-height: 1.15 !important;
    }
    .pipette-tip-fluid-box {
        margin-top: 0.25rem !important;
        padding: 0.15rem 0.4rem !important;
        gap: 0.35rem !important;
    }
    .pipette-tip-fluid-label {
        font-size: 0.62rem !important;
    }
    .pipette-tip-fluid-val {
        font-size: 0.65rem !important;
    }
    .pipette-interactive-controls {
        gap: 0.25rem !important;
        justify-content: center !important;
    }
    .pipette-volume-counter {
        padding: 0.2rem 0.5rem !important;
    }
    .pipette-vol-label {
        font-size: 0.62rem !important;
    }
    .pipette-vol-digits {
        font-size: 0.95rem !important;
    }
    .timing-meter-container {
        padding: 0.25rem 0.5rem !important;
        border-radius: 0.5rem !important;
    }
    .timing-meter-header {
        font-size: 0.62rem !important;
        margin-bottom: 0.15rem !important;
    }
    .timing-meter-bar-track {
        height: 16px !important;
        border-radius: 8px !important;
    }
    .timing-meter-labels {
        height: 0.95rem !important;
        font-size: 0.58rem !important;
        margin-top: 0.12rem !important;
    }

    /* Incubator compact landscape */
    .ws-incubator-layout {
        grid-template-columns: 145px 1fr !important;
        gap: 0.6rem !important;
        height: 100% !important;
    }
    .incubator-chamber-visual {
        height: 155px !important;
        padding: 0.35rem !important;
    }
    .incubator-chamber-sprite {
        width: 55px !important;
        height: 55px !important;
        margin-bottom: 0.15rem !important;
    }
    .incubator-temp-glow {
        font-size: 1.35rem !important;
        margin-bottom: 0.1rem !important;
    }
    .incubator-controls-panel {
        gap: 0.22rem !important;
        justify-content: center !important;
    }
    .incubator-meter-box {
        padding: 0.18rem 0.45rem !important;
        border-radius: 0.45rem !important;
    }
    .incubator-meter-header {
        font-size: 0.62rem !important;
        margin-bottom: 0.12rem !important;
    }
    .incubator-temp-bar-bg {
        height: 10px !important;
        border-radius: 5px !important;
    }
    .incubator-meter-labels {
        font-size: 0.55rem !important;
        margin-top: 0.1rem !important;
    }
    .incubator-reaction-track {
        height: 9px !important;
        border-radius: 4px !important;
    }
    .incubator-btn-row {
        gap: 0.3rem !important;
    }
    .incubator-heat-btn, .incubator-cool-btn {
        padding: 0.22rem 0.45rem !important;
        font-size: 0.7rem !important;
        border-radius: 0.4rem !important;
    }
    .incubator-auto-btn {
        padding: 0.28rem 0.65rem !important;
        font-size: 0.72rem !important;
        border-radius: 0.4rem !important;
    }

    /* Microscope compact landscape */
    .ws-microscope-layout {
        grid-template-columns: 155px 1fr !important;
        gap: 0.6rem !important;
        height: 100% !important;
    }
    .microscope-eyepiece {
        width: 155px !important;
        height: 155px !important;
    }
    .specimen-canvas {
        width: 100% !important;
        height: 100% !important;
    }
    .focus-knob-container {
        gap: 0.28rem !important;
        justify-content: center !important;
    }
    .microscope-slider-box {
        padding: 0.25rem 0.5rem !important;
        border-radius: 0.45rem !important;
    }
    .microscope-slider-header {
        font-size: 0.65rem !important;
        margin-bottom: 0.18rem !important;
    }
    .focus-slider {
        height: 8px !important;
    }

    /* Sample Rack Intake compact landscape */
    .ws-rack-layout {
        gap: 0.25rem !important;
        height: auto !important;
    }
    .rack-requisition-header {
        padding: 0.2rem 0.45rem !important;
        border-width: 1.5px !important;
        gap: 0.35rem !important;
    }
    .rack-req-eyebrow {
        font-size: 0.55rem !important;
    }
    .rack-req-title {
        font-size: 0.75rem !important;
        margin-top: 0.03rem !important;
    }
    .rack-req-sub {
        font-size: 0.62rem !important;
        margin-top: 0.03rem !important;
    }
    .rack-req-badge {
        font-size: 0.62rem !important;
        padding: 0.15rem 0.4rem !important;
    }
    .rack-tubes-grid {
        gap: 0.25rem !important;
    }
    .rack-tube-slot {
        padding: 0.2rem 0.18rem !important;
        border-radius: 0.45rem !important;
        border-width: 1.5px !important;
    }
    .rack-tube-specimen {
        font-size: 0.62rem !important;
        margin-bottom: 0.05rem !important;
        line-height: 1.1 !important;
    }
    .rack-tube-img {
        width: 26px !important;
        height: 44px !important;
    }
    .rack-tube-well {
        width: 22px !important;
        height: 5px !important;
        margin-top: -2px !important;
        margin-bottom: 0.1rem !important;
    }
    .rack-tube-name {
        font-size: 0.58rem !important;
        margin-bottom: 0.15rem !important;
        line-height: 1.1 !important;
    }
    .rack-take-btn {
        padding: 0.18rem 0.25rem !important;
        font-size: 0.62rem !important;
        border-radius: 0.3rem !important;
    }
}

.science-corner-btn {
    position: absolute;
    top: 1rem;
    left: auto;
    right: 1rem;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #f4f4f5;
    background: rgba(5, 150, 105, 0.35);
    border: 1.5px solid #34d399;
    border-radius: 9999px;
    padding: 0.35rem 1rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}
.science-corner-btn:hover {
    background: #059669;
    color: #ffffff;
    box-shadow: 0 0 15px rgba(52, 211, 153, 0.6);
    transform: translateY(-1px);
}
#scienceInfoModal {
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    box-sizing: border-box;
}
#scienceInfoModal.hidden {
    display: none !important;
}
.science-info-card {
    position: relative;
    background: #18181b;
    border: 2px solid #34d399;
    border-radius: 1.25rem;
    padding: 1.5rem;
    max-width: 48rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65);
    margin: auto;
}
.science-info-body {
    text-align: left;
    color: #d4d4d8;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    line-height: 1.55;
    width: 100%;
}
.science-info-body h3 {
    color: #6ee7b7;
    font-size: 0.95rem;
    font-weight: 700;
    margin: 1rem 0 0.4rem 0;
}
.science-info-body p { margin: 0.5rem 0; }
.science-info-body ul {
    margin: 0.3rem 0 0.6rem 1.1rem;
    list-style: disc;
}
.science-info-body li { margin: 0.2rem 0; }
.science-info-body a {
    color: #38bdf8;
    text-decoration: underline;
}
.science-info-body a:hover { color: #7dd3fc; }
.science-grade { font-size: 0.8rem; color: #a1a1aa; }
@media (max-width: 1024px) {
    .science-corner-btn {
        top: 0.35rem;
        right: 0.35rem;
        left: auto !important;
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }
}

.footer-legal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    margin-top: 0.4rem;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.7rem;
}
.footer-legal a, .footer-legal-btn {
    color: #71717a;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}
.footer-legal a:hover, .footer-legal-btn:hover { color: #34d399; }
