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

body {
    font-family: 'Fredoka', system-ui, -apple-system, sans-serif;
    background-color: #14110f;
    color: #f4f4f5;
    display: flex;
    flex-direction: column;
}

.page-container {
    width: 100%;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0.75rem 1rem;
    box-sizing: border-box;
}

.leaderboard-panel {
    display: none;
}

.game-wrapper {
    width: 100%;
    max-width: 64rem;
    margin: 0 auto;
    box-sizing: border-box;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

footer {
    flex-shrink: 0;
    padding: 1rem;
    padding-top: 0;
    box-sizing: border-box;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.footer-logo,
.footer-content img {
    height: 4rem;
    max-height: 4rem;
    width: auto;
    object-fit: contain;
    transition: transform 0.2s ease-in-out;
}

.footer-logo:hover,
.footer-content a:hover img {
    transform: scale(1.08);
}

.canvas-container {
    position: relative;
    width: 100%;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    touch-action: none;
}

canvas {
    background-color: #1a1512;
    border-radius: 0.75rem;
    cursor: crosshair;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    transition: box-shadow 0.3s ease-in-out;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 16 / 9;
    touch-action: none;
}

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

.hud-element {
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    background: rgba(28, 22, 18, 0.88);
    backdrop-filter: blur(6px);
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    border: 2px solid #574336;
    letter-spacing: 0.5px;
    transition: color 0.3s, border-color 0.3s, transform 0.2s;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.hud-cargo {
    font-size: 0.95rem;
    color: #f5f5f4;
}

.integrity-container {
    flex-grow: 1;
    text-align: center;
    min-width: 100px;
}

.hud-label {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    letter-spacing: 0.5px;
    color: #e7e5e4;
}

.integrity-bar {
    width: 100%;
    height: 1.35rem;
    background-color: rgba(0, 0, 0, 0.6);
    border: 2px solid #574336;
    border-radius: 0.5rem;
    padding: 2px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.integrity-fill {
    height: 100%;
    width: 100%;
    background-color: #22c55e;
    border-radius: 0.25rem;
    transition: width 0.3s ease-in-out, background-color 0.3s ease-in-out;
}

.mission-prompt {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 17, 15, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #e0f2fe;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.35rem 0.9rem;
    border-radius: 9999px;
    pointer-events: none;
    z-index: 25;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transition: opacity 0.3s;
}

#waveWarning {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    text-align: center;
    font-size: 2.2rem;
    font-weight: 700;
    color: #f97316;
    font-family: 'Fredoka', sans-serif;
    letter-spacing: 1px;
    text-shadow: 0 0 10px #fb923c, 0 0 25px #ea580c;
    pointer-events: none;
    z-index: 100;
    animation: wave-pulse 1s infinite;
}

@keyframes wave-pulse {
    0%, 100% { transform: translateY(-50%) scale(1); opacity: 1; }
    50% { transform: translateY(-50%) scale(1.08); opacity: 0.85; }
}

#comboMeter {
    position: absolute;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.2rem;
    font-weight: 700;
    color: #facc15;
    font-family: 'Fredoka', sans-serif;
    letter-spacing: 0.5px;
    text-shadow: 0 0 8px #fef08a, 0 0 18px #ca8a04;
    pointer-events: none;
    z-index: 100;
    transition: opacity 0.3s, transform 0.2s;
}

.score-pop {
    position: absolute;
    font-size: 1.35rem;
    font-weight: 700;
    pointer-events: none;
    font-family: 'Fredoka', sans-serif;
    z-index: 101;
    animation: score-pop-animation 1s ease-out forwards;
}

.score-positive { color: #fde047; text-shadow: 0 0 5px #f59e0b; }
.score-negative { color: #f87171; text-shadow: 0 0 5px #ef4444; }

@keyframes score-pop-animation {
    0% { transform: translate(-50%, 0); opacity: 1; }
    100% { transform: translate(-50%, -50px); opacity: 0; }
}

.in-game-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 0.5rem;
    z-index: 30;
}

.control-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(28, 22, 18, 0.85);
    border: 2px solid #574336;
    border-radius: 0.65rem;
    padding: 0.35rem 0.75rem;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s, background-color 0.15s, border-color 0.15s;
    user-select: none;
}

.control-action-btn:hover {
    transform: translateY(-2px);
    border-color: #22c55e;
}

.control-action-btn:active {
    transform: scale(0.95);
}

.control-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.control-badge {
    font-size: 0.68rem;
    font-weight: 600;
}

.modal {
    position: absolute;
    inset: 0;
    background-color: rgba(18, 14, 12, 0.94);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border-radius: 0.75rem;
    z-index: 40;
}

#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.25rem;
    font-weight: 700;
    color: #facc15;
    margin: 0;
    letter-spacing: 0.5px;
}

.modal-subtitle {
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #a8a29e;
    margin: 0.2rem 0 0 0;
}

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

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

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

.intro-box {
    width: 100%;
    max-width: 58rem;
    margin: 0 auto 0.75rem auto;
    padding: 0.75rem;
    background-color: rgba(28, 22, 18, 0.75);
    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.8rem;
    font-weight: 500;
    color: #a8a29e;
    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(5, 1fr); }
}

@media (min-width: 1024px) {
    .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.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, border-color 0.2s;
    user-select: none;
}

.character-card:hover {
    transform: translateY(-4px) scale(1.03);
}

.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 6px 20px 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 6px 20px rgba(56, 189, 248, 0.2);
}

.card-bonus {
    border-color: rgba(251, 191, 36, 0.35);
}
.card-bonus:hover {
    border-color: #fbbf24;
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.2);
}

.card-threat {
    border-color: rgba(248, 113, 113, 0.35);
}
.card-threat:hover {
    border-color: #f87171;
    box-shadow: 0 6px 20px rgba(248, 113, 113, 0.2);
}

.card-caution {
    border-color: rgba(74, 222, 128, 0.35);
}
.card-caution:hover {
    border-color: #4ade80;
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.2);
}

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

.badge-hero { background: rgba(34, 211, 238, 0.2); color: #22d3ee; border: 1px solid rgba(34, 211, 238, 0.5); }
.badge-ally { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.5); }
.badge-bonus { background: rgba(251, 191, 36, 0.2); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.5); }
.badge-threat { background: rgba(248, 113, 113, 0.2); color: #f87171; border: 1px solid rgba(248, 113, 113, 0.5); }
.badge-caution { background: rgba(74, 222, 128, 0.2); color: #4ade80; border: 1px solid rgba(74, 222, 128, 0.5); }

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

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

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

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

.card-ability {
    font-size: 0.68rem;
    color: #d6d3d1;
    line-height: 1.25;
}

.player-name-input {
    width: 100%;
    max-width: 20rem;
    background: rgba(28, 22, 18, 0.9);
    border: 2px solid #574336;
    border-radius: 0.75rem;
    padding: 0.6rem 1rem;
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    color: #ffffff;
    text-align: center;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.player-name-input:focus {
    border-color: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.3);
}

.player-name-input::placeholder {
    color: #78716c;
}

.btn-primary {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #ffffff;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    padding: 0.65rem 1.75rem;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.6);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    background: rgba(28, 22, 18, 0.9);
    border: 2px solid #574336;
    color: #e7e5e4;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.6rem 1.4rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, transform 0.15s;
}

.btn-secondary:hover {
    border-color: #78716c;
    color: #ffffff;
    transform: translateY(-2px);
}

.tutorial-corner-btn {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(28, 22, 18, 0.8);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #7dd3fc;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.65rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    z-index: 50;
}

.tutorial-corner-btn:hover {
    background: rgba(56, 189, 248, 0.15);
    transform: scale(1.04);
}

.how-to-card,
.fact-card {
    background: rgba(24, 19, 16, 0.98);
    border: 2px solid #574336;
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 32rem;
    width: 90%;
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    animation: fact-pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fact-pop {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.how-to-header-badge {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #38bdf8;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
}

.tutorial-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    width: 100%;
    margin: 1rem 0;
}

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

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

.tutorial-step {
    position: absolute;
    top: 0.35rem;
    left: 0.35rem;
    width: 1.25rem;
    height: 1.25rem;
    background: rgba(56, 189, 248, 0.2);
    border: 1px solid #38bdf8;
    color: #38bdf8;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tutorial-step-img {
    width: 2.75rem;
    height: 2.75rem;
    object-fit: contain;
    margin: 0.25rem 0 0.5rem 0;
}

.tutorial-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.tutorial-desc {
    font-size: 0.7rem;
    color: #d6d3d1;
    line-height: 1.25;
    margin: 0;
}

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

.fact-close-btn {
    background: transparent;
    border: none;
    color: #a8a29e;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

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

.fact-portrait {
    width: 5.5rem;
    height: 5.5rem;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    margin-bottom: 0.85rem;
}

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

.fact-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.5rem;
}

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

.fact-btn {
    min-width: 8rem;
    padding: 0.65rem 1.5rem;
}

.game-over-fact-card {
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.12) 0%, rgba(20, 17, 15, 0.95) 100%);
    border: 1.5px solid rgba(34, 197, 94, 0.45);
    border-radius: 1rem;
    padding: 0.85rem 1.25rem;
    max-width: 32rem;
    width: 100%;
    margin: 0 auto;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(34, 197, 94, 0.2);
    box-sizing: border-box;
}

.game-over-fact-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.45rem;
}

.game-over-fact-badge {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.game-over-fact-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.game-over-fact-portrait {
    width: 3.25rem;
    height: 3.25rem;
    padding: 0.2rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(34, 197, 94, 0.2) 0%, rgba(0, 0, 0, 0.5) 100%);
    border: 2px solid rgba(34, 197, 94, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-over-fact-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.game-over-fact-info {
    text-align: center;
}

.game-over-fact-title {
    font-family: 'Fredoka', cursive, sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #4ade80;
    margin: 0 0 0.2rem 0;
}

.game-over-fact-text {
    font-family: 'Fredoka', cursive, sans-serif;
    font-size: 0.92rem;
    font-weight: 500;
    color: #e7e5e4;
    line-height: 1.4;
    margin: 0;
}

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

.leaderboard-box {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
    width: 100%;
    max-width: 24rem;
    margin: 0 auto;
}

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

.leaderboard-podium-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.5rem;
    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(35, 24, 15, 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(35, 24, 15, 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(35, 24, 15, 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-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-weight: 700;
    font-size: 0.95rem;
    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: #a8a29e;
    text-transform: uppercase;
}

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

.player-name-empty {
    color: #78716c;
    font-style: italic;
    font-size: 0.85rem;
}

.player-score-empty {
    color: #57534e;
}

.score-glow-1 {
    color: #facc15;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(250, 204, 21, 0.4);
}

.score-glow-2 {
    color: #e2e8f0;
    font-weight: 700;
}

.score-glow-3 {
    color: #fbbf24;
    font-weight: 700;
}

.leaderboard-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background-color 0.15s;
}

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

.leaderboard-row .rank-badge {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    color: #a8a29e;
    flex-shrink: 0;
}

.leaderboard-row .player-name {
    font-size: 0.88rem;
    color: #e7e5e4;
    font-weight: 600;
}

.leaderboard-row .player-score {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #d6d3d1;
}

.leaderboard-tip {
    margin-top: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: rgba(250, 204, 21, 0.08);
    border: 1px dashed rgba(250, 204, 21, 0.35);
    border-radius: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.75rem;
    color: #fef08a;
    line-height: 1.3;
}

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

.leaderboard-empty {
    padding: 1.5rem 0.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.leaderboard-trophy-badge {
    margin-bottom: 0.25rem;
}

.leaderboard-empty-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: #facc15;
    letter-spacing: 0.5px;
}

.leaderboard-subtext {
    font-size: 0.8rem;
    color: #a8a29e;
}

.hidden,
.modal.hidden,
#factModal.hidden,
#howToModal.hidden,
#startGameModal.hidden,
#gameOverModal.hidden,
#mainLeaderboardModal.hidden,
#soundOffIcon.hidden,
.hud-mute-button svg.hidden {
    display: none !important;
}

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

#rotate-warning {
    display: none;
    position: fixed;
    inset: 0;
    background-color: #14110f;
    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: #4ade80;
    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;
    }
    .mission-prompt {
        top: 6px;
        font-size: 0.65rem;
        padding: 0.2rem 0.6rem;
    }
    .in-game-controls {
        bottom: 6px;
        right: 6px;
        gap: 0.35rem;
    }
    .control-action-btn {
        padding: 0.35rem 0.65rem;
        border-radius: 0.5rem;
        touch-action: manipulation;
        min-height: 2.2rem;
    }
    .control-label {
        font-size: 0.64rem;
    }
    .control-badge {
        font-size: 0.58rem;
    }
    .canvas-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.08rem;
    }
    .card-ability {
        font-size: 0.56rem;
        line-height: 1.1;
    }
    .modal-footer {
        padding-top: 0.25rem;
    }
    .player-name-input {
        padding: 0.25rem 0.5rem;
        font-size: 0.78rem;
        max-width: 14rem;
    }
    .modal-footer-buttons {
        gap: 0.5rem;
        margin-top: 0.25rem;
    }
    .btn-primary, .btn-secondary {
        padding: 0.3rem 0.8rem;
        font-size: 0.78rem;
    }
    .game-over-fact-card {
        padding: 0.35rem 0.6rem !important;
        max-width: 28rem !important;
        margin-bottom: 0.2rem !important;
    }
    .game-over-fact-header {
        margin-bottom: 0.15rem !important;
    }
    .game-over-fact-badge {
        font-size: 0.58rem !important;
        padding: 0.05rem 0.3rem !important;
    }
    .game-over-fact-content {
        flex-direction: row !important;
        align-items: center !important;
        text-align: left !important;
        gap: 0.45rem !important;
    }
    .game-over-fact-portrait {
        width: 2.2rem !important;
        height: 2.2rem !important;
        flex-shrink: 0 !important;
        padding: 0.12rem !important;
        margin-bottom: 0 !important;
    }
    .game-over-fact-info {
        text-align: left !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }
    .game-over-fact-title {
        font-size: 0.8rem !important;
        margin-bottom: 0.08rem !important;
    }
    .game-over-fact-text {
        font-size: 0.64rem !important;
        line-height: 1.2 !important;
    }
    #mainLeaderboardModal .modal-body {
        max-height: 72vh !important;
        overflow-y: auto !important;
        padding: 0.15rem 0.25rem !important;
        width: 100% !important;
    }
    #mainLeaderboardModal .leaderboard-box {
        padding: 0.4rem 0.6rem !important;
        max-width: 26rem !important;
        width: 100% !important;
        margin: 0 auto !important;
    }
    #mainLeaderboardModal .leaderboard-podium-card {
        padding: 0.25rem 0.5rem !important;
        margin-bottom: 0.25rem !important;
    }
    #mainLeaderboardModal .leaderboard-row {
        padding: 0.22rem 0.5rem !important;
        margin-bottom: 0.2rem !important;
        font-size: 0.8rem !important;
    }
    #mainLeaderboardModal .podium-badge {
        width: 22px !important;
        height: 22px !important;
        font-size: 0.75rem !important;
    }
    #mainLeaderboardModal .player-score {
        font-size: 0.85rem !important;
    }
    #mainLeaderboardModal .modal-footer {
        padding-top: 0.2rem !important;
    }
    .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;
    }
}

@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%;
        margin: 0;
        padding: 0;
    }

    .leaderboard-panel {
        display: flex !important;
        flex-direction: column;
        background-color: rgba(28, 22, 18, 0.88);
        backdrop-filter: blur(8px);
        border-radius: 0.75rem;
        padding: 1rem;
        border: 2px solid #574336;
        min-height: 0;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    }

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

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

    .modal-footer-buttons {
        justify-content: center;
    }

    #startGameBtn {
        margin: 0 auto;
    }
}

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

footer {
    flex-direction: column;
    gap: 0.4rem;
}
