body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    background-color: #000;
    font-family: 'Press Start 2P', monospace;
    user-select: none;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Cursed CRT Scanline Effect */
@keyframes scanlines {
    0% { background-position: 0 0; }
    100% { background-position: 0 4px; }
}

#crt-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(rgba(5, 0, 20, 0) 50%, rgba(0, 0, 0, 0.4) 50%),
                linear-gradient(90deg, rgba(255, 0, 255, 0.08), rgba(0, 255, 255, 0.04), rgba(255, 232, 0, 0.05));
    background-size: 100% 4px, 3px 100%;
    pointer-events: none;
    z-index: 5;
    animation: scanlines 0.3s linear infinite;
}

#ui-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.hidden { display: none !important; }

.message-box {
    background: #000000;
    border: 5px solid #ffe800;
    color: #ffffff;
    padding: 30px 50px;
    text-align: center;
    pointer-events: auto;
    text-transform: uppercase;
    box-shadow: 10px 10px 0px #ff00ff;
    transform: rotate(-1deg);
}

@keyframes titleFloat {
    0%   { transform: translateY(0px)  rotate(-3deg) scale(1);    text-shadow: 4px 4px #ff00ff, -2px -2px 0 #ffe800; }
    50%  { transform: translateY(-5px) rotate(2deg)  scale(1.05); text-shadow: 6px 6px #ff00ff, -3px -3px 0 #ffe800; }
    100% { transform: translateY(0px)  rotate(-3deg) scale(1);    text-shadow: 4px 4px #ff00ff, -2px -2px 0 #ffe800; }
}

.message-box h1 {
    margin: 0 0 15px 0;
    font-size: 3.5rem;
    color: #ffffff;
    font-family: 'UnifrakturMaguntia', cursive;
    animation: titleFloat 3s ease-in-out infinite;
    text-transform: lowercase;
    letter-spacing: 2px;
}

.message-box p {
    margin: 8px 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #ffe800;
}

.btn {
    background: #ffe800;
    color: #000000;
    border: 2px solid #ff00ff;
    padding: 12px 25px;
    font-size: 1rem;
    margin-top: 20px;
    cursor: pointer;
    font-family: 'Rubik Glitch', 'Press Start 2P', monospace;
    transition: all 0.1s;
    text-transform: uppercase;
    box-shadow: 4px 4px 0px #ff00ff;
}

.btn:hover {
    background: #ff00ff;
    color: #ffe800;
    box-shadow: -4px -4px 0px #ffe800;
    transform: translate(2px, 2px);
}

.controls-hint {
    color: #ffffff;
    font-size: 0.75rem;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px dashed #ff00ff;
    line-height: 2;
}

.enemy-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    text-align: left;
    margin: 15px 0;
    font-size: 0.5rem;
    color: #ffffff;
    line-height: 1.5;
}

.enemy-legend span { font-weight: bold; font-family: 'Courier New', Courier, monospace; }

@keyframes popIn {
    0%   { transform: scale(0.3) rotate(10deg); opacity: 0; }
    70%  { transform: scale(1.1) rotate(-2deg); opacity: 1; }
    100% { transform: scale(1)   rotate(-1deg); opacity: 1; }
}

.pop-in {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.high-scores {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px dashed #ff00ff;
    text-align: left;
    font-size: 1.1rem;
    width: 100%;
}

.high-scores h3 {
    color: #ffe800;
    margin: 0 0 10px 0;
    text-align: center;
    font-size: 1.5rem;
    font-family: 'UnifrakturMaguntia', cursive;
    text-transform: lowercase;
}

.high-scores ol {
    padding-left: 20px;
    margin: 0;
    color: #ff00ff;
    list-style-position: inside;
}

.high-scores li {
    margin-bottom: 5px;
    padding-left: 10px;
}

.high-scores .new-score {
    font-weight: bold;
    background: #ff00ff;
    color: #000;
    animation: pulse 0.5s infinite alternate;
    padding: 0 5px;
}

@keyframes pulse {
    from { opacity: 0.8; }
    to   { opacity: 1; transform: scale(1.05) rotate(1deg); display: inline-block; }
}

/* --- Ad slot scaffolding (reserves space to avoid CLS) --- */
.ad-slot {
    pointer-events: auto;
    display: none; /* toggled to flex when an ad is actually injected */
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    color: #666;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}
#ad-top    { top: 0;    width: min(728px, 100%); height: 90px; }
#ad-bottom { bottom: 0; width: min(728px, 100%); height: 90px; }
.ad-slot.active { display: flex; }

/* --- Site footer (ad-policy compliance: visible nav to legal pages) --- */
#site-footer {
    text-align: center;
    padding: 12px 8px 20px;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    color: #666;
    background: rgba(0, 0, 0, 0.6);
}

#site-footer a {
    color: #ffe800;
    text-decoration: none;
    margin: 0 6px;
}

#site-footer a:hover { color: #ff00ff; }

/* --- Audio toggles (fixed right side, below the lives/ship display) --- */
#audio-toggles {
    position: fixed;
    top: 52px;
    right: 8px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#audio-toggles button {
    width: 32px;
    height: 32px;
    background: #000;
    border: 2px solid #ffe800;
    color: #ffe800;
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#audio-toggles button:hover {
    box-shadow: 2px 2px 0 #ff00ff;
}

#audio-toggles button[data-muted="true"] {
    opacity: 0.45;
    border-color: #666;
    color: #666;
    text-decoration: line-through;
}

/* --- Below-the-fold FAQ section --- */
.faq-section {
    max-width: 760px;
    margin: 2rem auto;
    padding: 1.5rem 1.25rem;
    background: #000;
    border-top: 3px solid #ff00ff;
    border-bottom: 3px solid #ff00ff;
    color: #e8e8e8;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    line-height: 1.6;
}

.faq-section h2 {
    font-family: 'UnifrakturMaguntia', cursive;
    color: #ff00ff;
    text-transform: lowercase;
    font-size: 2.2rem;
    margin: 1.5rem 0 0.75rem;
    text-shadow: 2px 2px 0 #ffe800;
}

.faq-section h2:first-child { margin-top: 0; }

.faq-section p { margin: 0.5rem 0; }

.faq-section .controls-block p {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.8rem;
    color: #ffe800;
    margin: 0.35rem 0;
}

.faq-section .warning {
    color: #ffe800;
    background: #ff0000;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.78rem;
    font-weight: bold;
    margin-top: 1rem;
    padding: 0.45rem 0.75rem;
    display: inline-block;
    border: 2px solid #ffe800;
    line-height: 1.6;
}

.faq-section .faq-legend {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.4rem 1rem;
}

.faq-section .faq-legend li {
    padding: 2px 0;
    border-bottom: 1px dashed #333;
}

.faq-section .faq-dl dt {
    color: #ffe800;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.85rem;
    margin-top: 1rem;
}

.faq-section .faq-dl dd {
    margin: 0.35rem 0 0.5rem;
    padding-left: 0.5rem;
}

.faq-section .faq-dl a,
.faq-section .faq-links a {
    color: #ffe800;
    text-decoration: underline;
}

.faq-section .faq-dl a:hover,
.faq-section .faq-links a:hover {
    color: #ff00ff;
}

.faq-section .faq-links {
    margin-top: 1.5rem;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.75rem;
}

.faq-section .faq-links a {
    margin: 0 0.75rem;
    text-decoration: none;
}

/* Boss/teacher screen overlay — deliberately plain, Wikipedia-like. */
#boss-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #ffffff;
    color: #000000;
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 15px;
    line-height: 1.55;
    overflow-y: auto;
    padding: 40px 60px;
    text-transform: none;
}
#boss-screen .boss-page {
    max-width: 780px;
    margin: 0 auto;
}
#boss-screen h1 {
    font-size: 28px;
    font-weight: normal;
    border-bottom: 1px solid #a2a9b1;
    padding-bottom: 6px;
    margin: 0 0 4px;
    font-family: Georgia, "Times New Roman", Times, serif;
    color: #000;
    text-shadow: none;
    animation: none;
    letter-spacing: normal;
    text-transform: none;
}
#boss-screen h2 {
    font-size: 20px;
    font-weight: normal;
    border-bottom: 1px solid #a2a9b1;
    padding-bottom: 4px;
    margin: 24px 0 8px;
    color: #000;
    font-family: Georgia, "Times New Roman", Times, serif;
}
#boss-screen .boss-subtitle {
    color: #54595d;
    font-size: 13px;
    font-style: italic;
    margin: 0 0 20px;
}
#boss-screen .boss-toc {
    background: #f8f9fa;
    border: 1px solid #a2a9b1;
    padding: 10px 16px;
    margin: 16px 0;
    font-size: 14px;
}
#boss-screen .boss-toc ol {
    margin: 6px 0 0 20px;
    padding: 0;
}
#boss-screen p {
    margin: 10px 0;
    text-align: justify;
    color: #000;
}
#boss-screen em {
    font-style: italic;
}
#boss-screen .boss-footnote {
    color: #54595d;
    font-size: 12px;
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 10px;
}
