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

body {
    font-family: 'Fredoka', cursive, sans-serif;
    background-color: #09131f;
    color: #f8fafc;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    flex-direction: column;
}

/* Modal Specificity and Visibility Rule */
.hidden,
.modal.hidden,
#start-modal.hidden,
#loading-modal.hidden,
#game-over-modal.hidden,
#factModal.hidden,
#howToModal.hidden,
#mainLeaderboardModal.hidden,
#soundOffIcon.hidden,
#soundOnIcon.hidden {
    display: none !important;
}

.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 Column */
.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;
}

/* HUD Styling - Inline with Leaderboard */
.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
    flex-shrink: 0;
}

.toxin-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 140px;
    max-width: 440px;
    margin: 0 0.5rem;
}

.hud-toxin-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    padding: 0 0.25rem;
}

.hud-label {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fca5a5;
    letter-spacing: 0.5px;
}

.hud-phase-tag {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: #38bdf8;
    background: rgba(14, 116, 144, 0.25);
    border: 1px solid rgba(56, 189, 248, 0.4);
    padding: 0.1rem 0.55rem;
    border-radius: 9999px;
}

.hud-combo-tag {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: #facc15;
}

.toxin-bar {
    width: 100%;
    height: 1.15rem;
    background-color: rgba(0, 0, 0, 0.6);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 9999px;
    padding: 2px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    overflow: hidden;
}

.toxin-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #22c55e 0%, #eab308 50%, #ef4444 100%);
    border-radius: 9999px;
    transition: width 0.3s ease-out;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.hud-element {
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    padding: 0.45rem 0.85rem;
    border-radius: 0.75rem;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    letter-spacing: 0.5px;
    white-space: nowrap;
    font-size: 0.95rem;
    color: #f8fafc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.hud-score {
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.4);
    min-width: 120px;
}

.hud-timer {
    color: #facc15;
    border-color: rgba(250, 204, 21, 0.4);
    min-width: 100px;
    text-align: right;
}

.hud-combo-tag.combo-pulse {
    animation: combo-pulse-animation 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes combo-pulse-animation {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.18); filter: brightness(1.3); }
}

.hud-mute-button {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem;
    border-color: rgba(56, 189, 248, 0.4);
    color: #38bdf8;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.hud-mute-button:hover {
    transform: scale(1.08);
    background: rgba(56, 189, 248, 0.2);
}

/* Game Area Wrapper */
.game-area-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    flex-grow: 1;
    min-height: 0;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    overflow: hidden;
    background-color: #042036;
    border: 2px solid rgba(56, 189, 248, 0.35);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(4, 32, 54, 0.8);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.game-area-wrapper.toxin-warning {
    border-color: #ef4444;
    animation: pulse-border-crisis 1s infinite;
}

.game-area-wrapper.screen-shake {
    animation: screen-shake-animation 0.25s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes pulse-border-crisis {
    0%, 100% { box-shadow: 0 0 15px rgba(239, 68, 68, 0.5), inset 0 0 30px rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 35px rgba(239, 68, 68, 0.8), inset 0 0 50px rgba(239, 68, 68, 0.5); }
}

@keyframes screen-shake-animation {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(3px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    cursor: crosshair;
    background: linear-gradient(180deg, #38bdf8 0%, #0284c7 25%, #0369a1 55%, #082f49 85%, #02121e 100%);
}

#water-depth-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 10%, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
    pointer-events: none;
    z-index: 1;
}

#eagle-eye-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 40;
    box-shadow: inset 0 0 80px rgba(6, 182, 212, 0.6);
    animation: eagle-eye-pulse 1.5s infinite alternate;
}

@keyframes eagle-eye-pulse {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Osprey Cursor and Flyby */
.osprey-cursor {
    position: absolute;
    width: 104px;
    height: 74px;
    background-image: url('img/osprey.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    z-index: 99;
    will-change: transform;
    display: none;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.45));
    transition: transform 0.05s ease-out;
}

#osprey-flyby-container {
    position: absolute;
    top: 6%;
    left: 0;
    width: 100%;
    height: 130px;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}

.osprey-flyby {
    position: absolute;
    width: 180px;
    height: 128px;
    background-image: url('img/osprey.png');
    background-size: contain;
    background-repeat: no-repeat;
    animation: flyby-animation 2.2s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.55));
}

@keyframes flyby-animation {
    from { transform: translate(-200px, 10px) scale(0.95); }
    50% { transform: translate(50vw, -20px) scale(1.25); }
    to { transform: translate(calc(100vw + 200px), 10px) scale(0.95); }
}

/* Game Items and Sprites */
.game-item {
    position: absolute;
    bottom: -80px;
    will-change: transform;
    z-index: 15;
    cursor: pointer;
    user-select: none;
    animation-name: fish-jump;
    animation-timing-function: cubic-bezier(0.25, 1, 0.5, 1);
    animation-fill-mode: forwards;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sprite {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.2s ease, filter 0.2s ease;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.sprite.minnow {
    width: 56px;
    height: 36px;
    background-image: url('img/minnow.png');
}

.sprite.perch {
    width: 72px;
    height: 54px;
    background-image: url('img/perch.png');
}

.sprite.perch.toxic {
    background-image: url('img/toxic_perch.png');
    animation: pulse-toxic 0.6s infinite alternate;
}

.sprite.toxin {
    width: 36px;
    height: 50px;
    background-image: url('img/toxin.png');
    animation: pulse-toxic 0.8s infinite alternate;
}

.sprite.cleanerShrimp {
    width: 52px;
    height: 50px;
    background-image: url('img/cleaner_shrimp.png');
    animation: pulse-powerup 1.2s infinite ease-in-out;
}

.sprite.goldenFish {
    width: 68px;
    height: 50px;
    background-image: url('img/golden_fish.png');
    animation: pulse-powerup 0.6s infinite ease-in-out;
}

.sprite.bloatedFish {
    width: 72px;
    height: 55px;
    background-image: url('img/bloated_fish.png');
    animation: pulse-toxic 1s infinite alternate;
}

@keyframes fish-jump {
    0% {
        transform: translateY(0) rotate(0deg) scale(0.85);
    }
    45% {
        transform: translateY(-240px) rotate(15deg) scale(1.05);
    }
    100% {
        transform: translateY(30px) rotate(35deg) scale(0.85);
    }
}

@keyframes pulse-toxic {
    0% { filter: drop-shadow(0 0 5px rgba(239, 68, 68, 0.4)) brightness(1); }
    100% { filter: drop-shadow(0 0 16px rgba(239, 68, 68, 0.9)) brightness(1.25); transform: scale(1.06); }
}

@keyframes pulse-powerup {
    0% { filter: drop-shadow(0 0 5px rgba(250, 204, 21, 0.4)) brightness(1); }
    100% { filter: drop-shadow(0 0 16px rgba(250, 204, 21, 0.9)) brightness(1.25); transform: scale(1.06); }
}

/* Splash and Visual Effects */
.splash-effect {
    position: absolute;
    width: 52px;
    height: 52px;
    border: 3px solid rgba(56, 189, 248, 0.8);
    background-color: rgba(56, 189, 248, 0.25);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    z-index: 25;
    animation: splash-animation 0.4s ease-out forwards;
}

@keyframes splash-animation {
    from { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
    to { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

.toxin-jump-visual {
    position: absolute;
    width: 18px;
    height: 18px;
    background: radial-gradient(circle, #f87171 20%, #dc2626 80%);
    border-radius: 50%;
    border: 1.5px solid #ef4444;
    box-shadow: 0 0 10px #ef4444;
    z-index: 45;
    pointer-events: none;
}

/* Floating Scores and Notifications */
.score-pop {
    position: absolute;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    pointer-events: none;
    z-index: 101;
    animation: score-pop-animation 0.9s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.score-positive {
    color: #fde047;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), 0 0 12px rgba(250, 204, 21, 0.7);
}

.score-negative {
    color: #f87171;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), 0 0 12px rgba(239, 68, 68, 0.7);
}

.score-toxin {
    color: #f87171;
    font-size: 1.5rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8), 0 0 18px rgba(239, 68, 68, 0.9);
}

.score-combo {
    color: #38bdf8;
    font-size: 1.4rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8), 0 0 16px rgba(56, 189, 248, 0.8);
}

@keyframes score-pop-animation {
    0% { transform: translate(-50%, 0) scale(0.8); opacity: 0; }
    20% { transform: translate(-50%, -15px) scale(1.15); opacity: 1; }
    100% { transform: translate(-50%, -60px) scale(1); opacity: 0; }
}

#notification-container {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    pointer-events: none;
    z-index: 100;
}

.notification-item {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
    animation: notif-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 1;
    transition: opacity 0.4s ease-out;
}

.notification-item.fade-out {
    opacity: 0;
}

@keyframes notif-in {
    from { opacity: 0; transform: translateY(15px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* In-Game Modals (Absolute inside #game-area-wrapper) */
.modal {
    position: absolute;
    inset: 0;
    z-index: 30;
    background: rgba(9, 19, 31, 0.92);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
    border-radius: 0.85rem;
}

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

.modal-body {
    flex-grow: 1;
    overflow-y: auto;
    width: 100%;
    min-height: 0;
}

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

.modal-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #f8fafc;
    margin-bottom: 0.2rem;
    text-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.modal-subtitle {
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #38bdf8;
    margin-bottom: 0.35rem;
}

.game-over-title {
    font-size: 1.85rem;
}

.failure-title {
    color: #f87171;
}

.final-score-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: #facc15;
    margin-bottom: 0.25rem;
}

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

/* Dialog Overlay Modals (Fixed) */
#howToModal,
#factModal,
#mainLeaderboardModal {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(9, 19, 31, 0.88);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

/* Character Intro Box and Grid */
.intro-box {
    width: 100%;
    max-width: 58rem;
    margin: 0 auto 0.5rem auto;
    padding: 0.75rem;
    background-color: rgba(15, 23, 42, 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-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.3px;
}

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

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

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

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

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

/* Compact Character Trading Card */
.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;
    user-select: none;
    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-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-hero .card-portrait {
    width: 3.6rem;
    height: 3.6rem;
    background: rgba(34, 211, 238, 0.15);
    border: 1px solid rgba(34, 211, 238, 0.35);
}

.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-threat { border-color: rgba(248, 113, 113, 0.35); }
.card-threat:hover { border-color: #f87171; box-shadow: 0 8px 24px rgba(248, 113, 113, 0.2); }

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

.card-caution { border-color: rgba(251, 146, 60, 0.35); }
.card-caution:hover { border-color: #fb923c; box-shadow: 0 8px 24px rgba(251, 146, 60, 0.2); }

.card-badge {
    font-family: 'Fredoka', sans-serif;
    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); }
.badge-threat { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4); }
.badge-bonus { background: rgba(250, 204, 21, 0.2); color: #fde047; border: 1px solid rgba(250, 204, 21, 0.4); }
.badge-caution { background: rgba(249, 115, 22, 0.2); color: #fdba74; border: 1px solid rgba(249, 115, 22, 0.4); }

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

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

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

.card-name {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.2rem;
}

.card-ability {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.72rem;
    color: #cbd5e1;
    line-height: 1.25;
    font-weight: 500;
}

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

/* Inputs and Buttons */
.player-name-input {
    background-color: rgba(15, 23, 42, 0.75);
    color: white;
    width: 100%;
    max-width: 26rem;
    text-align: center;
    padding: 0.65rem 1rem;
    border-radius: 0.75rem;
    border: 1.5px solid rgba(56, 189, 248, 0.35);
    margin-bottom: 0.75rem;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.player-name-input.shake-input {
    animation: input-shake 0.4s;
}

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

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

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

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

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

.btn-secondary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 18px rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.15);
}

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

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

/* How to Play Corner Button */
.tutorial-corner-btn {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    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.35rem 0.75rem;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
    color: #a5f3fc;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: all 0.2s ease;
}

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

/* How to Play and Science Fact Modal Cards */
.how-to-card, .fact-card {
    position: relative;
    width: 100%;
    max-width: 46rem;
    max-height: 90vh;
    margin: auto;
    overflow-y: auto;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.96) 0%, rgba(8, 47, 73, 0.98) 100%);
    border: 2px solid rgba(56, 189, 248, 0.45);
    border-radius: 1.25rem;
    padding: 1.5rem 1.75rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(56, 189, 248, 0.2);
    text-align: center;
    box-sizing: border-box;
}

.fact-card {
    max-width: 26rem;
    padding: 1.5rem;
}

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

.how-to-header-badge {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.75rem;
    border-radius: 9999px;
    background: rgba(56, 189, 248, 0.2);
    color: #7dd3fc;
    border: 1px solid rgba(56, 189, 248, 0.4);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.fact-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    transition: color 0.2s ease, background 0.2s ease;
}

.fact-close-btn:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.1);
}

.how-to-title, .fact-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: #f8fafc;
    margin: 0 0 0.25rem 0;
}

.how-to-subtitle {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.95rem;
    color: #94a3b8;
    margin: 0 0 1.25rem 0;
}

.fact-portrait {
    width: 5.5rem;
    height: 5.5rem;
    margin: 0.5rem auto 0.75rem auto;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 1rem;
    padding: 0.5rem;
}

.fact-text {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.95rem;
    color: #cbd5e1;
    line-height: 1.4;
    margin-bottom: 1.25rem;
}

.fact-btn {
    width: 100%;
}

.tutorial-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

@media (min-width: 640px) {
    .tutorial-grid {
        grid-template-columns: repeat(2, 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;
    gap: 0.35rem;
}

.tutorial-icon-box {
    width: 3.5rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 0.75rem;
    padding: 0.35rem;
}

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

.tutorial-step-title {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: #38bdf8;
}

.tutorial-step-desc {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.3;
}

/* Biomagnification Pyramid in Game Over */
.food-pyramid {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 0.35rem;
    width: 100%;
}

.pyramid-level {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.35rem 0.55rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    margin-bottom: -1px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0.35rem;
    box-sizing: border-box;
}

.pyramid-level.osprey {
    background: rgba(147, 51, 234, 0.3);
    border-color: rgba(168, 85, 247, 0.5);
    width: 60%;
}

.pyramid-level.perch {
    background: rgba(3, 105, 161, 0.35);
    border-color: rgba(56, 189, 248, 0.45);
    width: 75%;
}

.pyramid-level.minnow {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(52, 211, 153, 0.45);
    width: 90%;
}

.pyramid-level.toxin {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(248, 113, 113, 0.45);
    width: 100%;
}

.pyramid-dose {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.science-fact-box {
    background: rgba(6, 182, 212, 0.1);
    border: 1px dashed rgba(6, 182, 212, 0.4);
    border-radius: 0.75rem;
    padding: 0.55rem 0.75rem;
    margin-top: 0.35rem;
}

/* Leaderboard Sidebar & Mobile Modal */
.leaderboard-panel {
    display: none;
}

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

#desktopLeaderboardList {
    overflow-y: auto;
    flex-grow: 1;
    min-height: 0;
    background: transparent;
    border: none;
    padding: 0;
    max-width: 100%;
}

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

.leaderboard-player {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

/* Podium Cards */
.leaderboard-podium-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.35rem;
    border-radius: 0.75rem;
    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.8) 100%);
    border: 1.5px solid rgba(250, 204, 21, 0.6);
    box-shadow: 0 4px 15px rgba(250, 204, 21, 0.15);
}

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

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

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

.podium-badge.rank-1 {
    background: linear-gradient(135deg, #facc15 0%, #ca8a04 100%);
    color: #1e092b;
    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;
    gap: 0.1rem;
    min-width: 0;
}

.podium-player-info .player-name {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 0.92rem;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.podium-rank-tag {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #94a3b8;
    text-transform: uppercase;
}

.podium-score {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: #facc15;
    white-space: nowrap;
    margin-left: 0.5rem;
}

/* Open Podium Slots */
.podium-open {
    border-style: dashed;
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.02);
    opacity: 0.6;
}

.podium-open .podium-badge {
    background: rgba(255, 255, 255, 0.08);
    color: #64748b;
}

.podium-open .player-name {
    color: #64748b;
    font-style: italic;
}

/* Standard Leaderboard Rows (Rank 4 to 10) */
.leaderboard-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-family: 'Fredoka', sans-serif;
    font-size: 0.82rem;
    transition: background 0.15s ease;
}

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

.leaderboard-row .rank-num {
    font-weight: 700;
    color: #94a3b8;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.leaderboard-row .player-name {
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-row .player-score {
    font-weight: 700;
    color: #38bdf8;
    margin-left: 0.5rem;
    white-space: nowrap;
}

.leaderboard-tip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(6, 182, 212, 0.1);
    border: 1px dashed rgba(6, 182, 212, 0.35);
    border-radius: 0.65rem;
    padding: 0.5rem 0.75rem;
    margin-top: 0.75rem;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.78rem;
    color: #67e8f9;
}

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

/* Rotate Warning */
/* Responsive Breakpoints */
@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;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    .leaderboard-panel {
        display: flex !important;
        flex-direction: column;
        background: rgba(15, 23, 42, 0.85);
        backdrop-filter: blur(8px);
        border-radius: 0.85rem;
        padding: 1rem;
        border: 2px solid rgba(56, 189, 248, 0.35);
        min-height: 0;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }
    .leaderboard-panel-title {
        font-family: 'Fredoka', sans-serif;
        font-size: 1.35rem;
        font-weight: 700;
        color: #facc15;
        margin: 0 0 0.75rem 0;
        text-align: center;
        letter-spacing: 0.5px;
    }
    #leaderboardBtn,
    #leaderboardGameOverBtn {
        display: none !important;
    }
}

/* Custom Scrollbars */
.modal-body::-webkit-scrollbar,
.how-to-card::-webkit-scrollbar,
#desktopLeaderboardList::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track,
.how-to-card::-webkit-scrollbar-track,
#desktopLeaderboardList::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb,
.how-to-card::-webkit-scrollbar-thumb,
#desktopLeaderboardList::-webkit-scrollbar-thumb {
    background-color: rgba(56, 189, 248, 0.4);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover,
.how-to-card::-webkit-scrollbar-thumb:hover,
#desktopLeaderboardList::-webkit-scrollbar-thumb:hover {
    background-color: rgba(56, 189, 248, 0.7);
}

/* Footer Styling (Outside page-container 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 {
    height: 4rem; /* h-16 = 64px matching Immune Rush */
    max-height: 4rem;
    width: auto;
    transition: transform 0.2s ease-in-out;
}

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

.footer-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #94a3b8;
    transition: color 0.2s;
}

.footer-link:hover {
    color: #f8fafc;
}

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

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