/* ==========================================================================
   CRISPR Snipe - 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,
#game-over-modal.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 {
    font-family: 'Fredoka', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #090d16;
    color: #f8fafc;
    display: flex;
    flex-direction: column;
}

/* Base Page Layout (Matching Immune Rush) */
.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-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: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.hud-level-tag {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.hud-pam-tag {
    background: rgba(250, 204, 21, 0.15);
    color: #facc15;
    border: 1px solid rgba(250, 204, 21, 0.4);
}

.hud-ammo-tag {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.4);
}

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

.hud-mute-button:hover {
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.5);
    transform: scale(1.05);
}

/* Canvas Area */
.game-area-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 40%, #1e1b4b 0%, #090d16 100%);
    overflow: hidden;
    touch-action: none;
}

#gameCanvas {
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 16 / 9;
    width: auto;
    height: auto;
    display: block;
    cursor: crosshair;
    touch-action: none;
}

/* Modal System */
.modal {
    position: absolute;
    inset: 0;
    z-index: 40;
    background: rgba(10, 14, 26, 0.88);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

.modal-header {
    text-align: center;
    margin-bottom: 0.75rem;
}

.modal-title {
    font-size: 2rem;
    font-weight: 700;
    color: #38bdf8;
    text-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
    letter-spacing: 0.5px;
    line-height: 1.1;
}

.modal-subtitle {
    font-size: 0.95rem;
    font-weight: 600;
    color: #94a3b8;
    margin-top: 0.25rem;
}

.modal-body {
    width: 100%;
    max-width: 54rem;
    max-height: 60vh;
    overflow-y: auto;
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.75rem;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 4px;
}

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

.modal-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    max-width: 24rem;
}

.modal-footer-buttons {
    display: flex;
    gap: 0.75rem;
    width: 100%;
    justify-content: center;
}

/* Genetic Disease Target Selector (Option A) */
.disease-selector-container {
    width: 100%;
    background: rgba(15, 23, 42, 0.85);
    border: 1.5px solid rgba(56, 189, 248, 0.3);
    border-radius: 0.85rem;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.65rem;
}

.disease-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.45rem;
}

.disease-selector-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #38bdf8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.disease-gene-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    background: rgba(52, 211, 153, 0.2);
    color: #6ee7b7;
    border: 1px solid rgba(52, 211, 153, 0.4);
    letter-spacing: 0.4px;
}

.disease-pills-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
}

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

.disease-pill {
    padding: 0.45rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 0.6rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.disease-pill:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
    color: #ffffff;
    transform: translateY(-1px);
}

.disease-pill.active {
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.4) 0%, rgba(3, 105, 161, 0.5) 100%);
    border-color: #38bdf8;
    color: #ffffff;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.custom-target-row {
    margin-top: 0.45rem;
}

.custom-gene-input {
    width: 100%;
    padding: 0.45rem 0.75rem;
    background: rgba(15, 23, 42, 0.9);
    border: 1.5px solid rgba(56, 189, 248, 0.4);
    border-radius: 0.5rem;
    color: #f8fafc;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: border-color 0.2s ease;
}

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

.disease-mission-desc {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 0.4rem;
    line-height: 1.3;
    text-align: center;
}

.hud-target-tag {
    background: rgba(52, 211, 153, 0.15);
    color: #34d199;
    border: 1px solid rgba(52, 211, 153, 0.4);
}

/* Compact Character Intro Box */
.intro-box {
    width: 100%;
    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;
}

.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.45rem;
    width: 100%;
}

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

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

/* Character Card */
.character-card {
    position: relative;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px 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 {
    animation: wiggle 0.4s ease-in-out;
    transform: translateY(-4px) scale(1.03);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.character-card:active {
    transform: scale(0.96);
}

/* Card Categories */
.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-target { border-color: rgba(52, 211, 153, 0.4); }
.card-target:hover { border-color: #34d199; box-shadow: 0 8px 24px rgba(52, 211, 153, 0.25); }

.card-ally { border-color: rgba(250, 204, 21, 0.4); }
.card-ally:hover { border-color: #facc15; box-shadow: 0 8px 24px rgba(250, 204, 21, 0.25); }

.card-threat { border-color: rgba(248, 113, 113, 0.4); }
.card-threat:hover { border-color: #f87171; box-shadow: 0 8px 24px rgba(248, 113, 113, 0.25); }

.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-target { background: rgba(52, 211, 153, 0.2); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, 0.4); }
.badge-ally { background: rgba(250, 204, 21, 0.2); color: #fde047; border: 1px solid rgba(250, 204, 21, 0.4); }
.badge-threat { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 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;
}

/* 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%;
    padding: 0.6rem 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);
}

/* Tutorial Corner Button */
.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;
    white-space: nowrap;
}

.tutorial-corner-btn svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.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 and How-To Modals */
.fact-card, .how-to-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-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.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 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 0.4rem;
}

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

.fact-text {
    font-size: 0.95rem;
    line-height: 1.4;
    color: #cbd5e1;
    max-width: 28rem;
    margin: 0.5rem auto 1.25rem auto;
}

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

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

@media (min-width: 640px) {
    .tutorial-grid {
        grid-template-columns: repeat(3, 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.85rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.tutorial-icon-box {
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: 0.5rem;
    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.95rem;
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 0.25rem;
}

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

/* Leaderboard Sidebar & Modal */
.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;
}

@media (min-width: 1024px) {
    .leaderboard-panel {
        display: flex !important;
    }
}

.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-score {
    font-weight: 700;
    font-size: 1rem;
    color: #38bdf8;
}

.podium-open {
    border-style: dashed;
    opacity: 0.5;
}

.leaderboard-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.65rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.85rem;
}

.leaderboard-tip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(56, 189, 248, 0.1);
    border: 1px dashed rgba(56, 189, 248, 0.35);
    border-radius: 0.65rem;
    padding: 0.5rem 0.75rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: #67e8f9;
}

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

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

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

.stat-label {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 0.15rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.science-fact-box {
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 0.75rem;
    padding: 0.75rem;
    margin-top: 0.5rem;
}

/* Animations */
@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-3deg) scale(1.03); }
    75% { transform: rotate(3deg) scale(1.03); }
}

/* Floating notifications and score pops */
#score-pop-container,
#notification-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 30;
}

.score-pop {
    position: absolute;
    pointer-events: none;
    font-weight: 700;
    font-size: 1.2rem;
    color: #facc15;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
    animation: floatUp 0.8s ease-out forwards;
    z-index: 30;
}

@keyframes floatUp {
    0% { transform: translate(-50%, 0) scale(0.8); opacity: 0; }
    30% { transform: translate(-50%, -15px) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -40px) scale(1); opacity: 0; }
}

/* Footer & Brand Logo */
footer {
    flex-shrink: 0;
    padding: 1.25rem 1rem 1.5rem;
    box-sizing: border-box;
}

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

.footer-logo {
    height: 4rem;
    max-height: 4rem;
    width: auto;
    transition: transform 0.2s ease-in-out;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

.footer-logo:hover {
    transform: scale(1.06);
}

.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,
    #gameCanvas {
        max-height: 100%;
        max-width: 100%;
        aspect-ratio: 16 / 9;
        width: auto;
        height: auto;
        touch-action: none;
    }
    .modal {
        padding: 0.25rem 0.5rem;
        justify-content: space-between;
        touch-action: auto;
    }
    .modal-header {
        padding-bottom: 0.08rem;
        flex-shrink: 0;
    }
    .modal-title {
        font-size: clamp(1.1rem, 2.4vw, 1.3rem);
        line-height: 1.1;
        margin-bottom: 0.05rem;
    }
    .modal-subtitle {
        font-size: clamp(0.65rem, 1.5vw, 0.72rem);
        margin: 0;
    }
    .modal-body {
        max-height: 75vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y !important;
        padding: 0.15rem 0.35rem !important;
        margin-bottom: 0.2rem !important;
        flex: 1 1 auto;
    }
    .disease-selector-container {
        padding: 0.25rem 0.5rem;
        margin-bottom: 0.2rem;
        border-radius: 0.6rem;
    }
    .disease-selector-header {
        margin-bottom: 0.15rem;
    }
    .disease-selector-label {
        font-size: 0.7rem;
    }
    .disease-gene-badge {
        font-size: 0.65rem;
        padding: 0.08rem 0.35rem;
    }
    .disease-pills-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.25rem;
    }
    .disease-pill {
        padding: 0.2rem 0.35rem;
        font-size: 0.7rem;
        border-radius: 0.45rem;
    }
    .custom-gene-input {
        padding: 0.2rem 0.45rem;
        font-size: 0.75rem;
    }
    .disease-mission-desc {
        font-size: 0.64rem;
        margin-top: 0.15rem;
        line-height: 1.15;
    }
    .tutorial-corner-btn {
        top: 0.25rem;
        left: 0.25rem;
        right: auto !important;
        padding: 0.15rem 0.45rem;
        font-size: 0.68rem;
        gap: 0.25rem;
        white-space: nowrap;
        height: 24px;
    }
    .tutorial-corner-btn svg {
        width: 0.75rem;
        height: 0.75rem;
        flex-shrink: 0;
    }
    .intro-box {
        padding: 0.25rem 0.4rem;
        margin-bottom: 0.15rem;
        gap: 0.15rem;
        border-radius: 0.6rem;
    }
    .cards-hint {
        font-size: 0.65rem;
        margin-bottom: 0.1rem;
    }
    .cards-grid {
        display: grid !important;
        grid-template-columns: repeat(8, 1fr) !important;
        gap: 0.25rem;
        width: 100%;
    }
    @media (max-width: 580px) {
        .cards-grid {
            grid-template-columns: repeat(4, 1fr) !important;
        }
    }
    .character-card {
        padding: 0.25rem 0.15rem;
        border-radius: 0.5rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    .card-badge {
        font-size: 0.5rem;
        padding: 0.05rem 0.25rem;
        margin-bottom: 0.12rem;
        line-height: 1;
    }
    .card-portrait, .icon-container {
        width: 2.15rem;
        height: 2.15rem;
        padding: 0.15rem;
        margin-bottom: 0.12rem;
        border-radius: 0.45rem;
    }
    .card-portrait img, .icon-container img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }
    .card-name {
        font-size: 0.62rem;
        font-weight: 700;
        margin-bottom: 0;
        line-height: 1.1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .card-ability {
        display: none !important;
    }
    .modal-footer {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-items: center !important;
        padding-top: 0.2rem !important;
        gap: 0.4rem !important;
        width: 100% !important;
        max-width: 100% !important;
        flex-shrink: 0;
    }
    .player-name-input {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.82rem !important;
        height: 32px !important;
        max-width: 11rem !important;
        border-radius: 0.5rem !important;
        margin: 0 !important;
    }
    .modal-footer-buttons {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.4rem !important;
        width: auto !important;
        margin-top: 0 !important;
    }
    .btn-primary, .btn-secondary {
        padding: 0.25rem 0.85rem !important;
        font-size: 0.82rem !important;
        height: 32px !important;
        border-radius: 0.5rem !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .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;
    }
}

.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; }
