body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #050505;
    overflow: hidden; /* Prevent scrolling */
    font-family: 'Courier New', Courier, monospace;
    touch-action: none; /* Prevent default touch gestures */
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

#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;
    color: #ffffff;
    text-align: center;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
    padding: 20px;
    box-sizing: border-box;
}

.logo-container {
    margin-bottom: 2vh;
    opacity: 0.9;
    transform: scale(0.9);
}

.title {
    font-size: clamp(2rem, 5vw, 3rem); /* Responsive font size */
    font-weight: 700;
    letter-spacing: 0.2em;
    margin-bottom: 10px;
    color: #ffffff;
    text-transform: uppercase;
}

.subtitle {
    font-size: clamp(0.7rem, 3vw, 0.9rem);
    font-weight: 300;
    opacity: 0.8;
    margin-top: 5px;
    color: #eee;
    max-width: 90%;
    line-height: 1.4;
}

.instruction {
    margin-top: 3vh;
    font-size: clamp(0.75rem, 3.5vw, 0.9rem);
    line-height: 1.6;
    opacity: 0.8;
    background: rgba(20, 20, 20, 0.85);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    color: #ffffff;
    text-align: left; 
    width: 90%;
    max-width: 450px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    pointer-events: auto; /* Allow text selection if needed */
}

/* Footer Links */
.footer-links {
    margin-top: 20px;
    font-size: 0.8rem;
    opacity: 0.7;
    pointer-events: auto;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap; /* Wrap on small screens */
}

.footer-link {
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
    color: #ffffff;
}

.footer-link:hover {
    color: #4cc9f0;
}

.tap-prompt {
    margin-top: 4vh;
    font-size: 0.8rem;
    opacity: 0.5;
    animation: pulseText 2s infinite ease-in-out;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #ffffff;
}

#score-container {
    position: absolute;
    top: 30px;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.5s;
    color: #ffffff;
}

#score-display {
    font-size: 1.5rem;
    letter-spacing: 0.2em;
    font-weight: bold;
}

#highscore-display {
    font-size: 0.8rem;
    opacity: 0.6;
    margin-top: 5px;
    letter-spacing: 0.1em;
}

#toast {
    position: absolute;
    top: 20%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #ffffff;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    letter-spacing: 2px;
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    white-space: nowrap;
}

#toast.show {
    opacity: 1;
    transform: scale(1.1);
}

#health-bar-container {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 10px; 
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    opacity: 0;
    transition: opacity 1s;
}

#health-bar {
    width: 100%;
    height: 100%;
    background: #ffffff;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.4); 
    border-radius: 5px;
    transition: width 0.2s cubic-bezier(0.25, 0.1, 0.25, 1), background-color 0.3s;
}

/* Modal Styles */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #111;
    border: 1px solid #444;
    padding: 25px;
    border-radius: 10px;
    width: 85%;
    max-width: 500px;
    text-align: left;
    position: relative;
    font-family: sans-serif; /* Cleaner font for reading */
    line-height: 1.5;
    font-size: 0.9rem;
    color: #ffffff; /* Explicit White Text */
}

.modal-content p {
    color: #cccccc;
}

.modal-content h2 {
    margin-top: 0;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-family: 'Courier New', Courier, monospace;
    text-transform: uppercase;
    color: #ffffff;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
}

.close-btn:hover { color: #fff; }

.about-link {
    color: #4cc9f0;
    text-decoration: none;
    font-weight: bold;
}

@keyframes pulseText {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Overlay for start/gameover */
#overlay {
    pointer-events: auto; /* Allow clicking start */
    cursor: pointer;
    transition: opacity 0.5s;
    background: rgba(0,0,0,0.85); /* Slightly darker for better contrast */
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

/* Updated .hidden to use display: none for strict removal */
.hidden {
    display: none !important;
}

@media (max-width: 400px) {
    .logo-container { transform: scale(0.7); margin-bottom: 10px; }
    .instruction { padding: 15px; width: 95%; }
    .modal-content { width: 90%; padding: 20px; }
}