body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100dvh; /* Dynamic viewport fixes mobile URL bar cutoffs */
    overflow: hidden;
    background-color: #d3d3d3;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Prevents mobile swipe-to-refresh */
    overscroll-behavior: none;
}

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

/* Portrait Warning (Now a non-blocking banner) */
#portrait-warning {
    display: none;
    position: absolute;
    top: 0; 
    left: 0; 
    width: 100%; 
    background-color: rgba(30, 30, 30, 0.85);
    color: #ccff00;
    z-index: 2000;
    text-align: center;
    padding: 8px 10px;
    font-size: 0.9rem;
    font-weight: bold;
    box-sizing: border-box;
    pointer-events: none; /* Allows clicks to pass through to the game */
}

@media (orientation: portrait) and (max-width: 768px) {
    #portrait-warning { display: block; }
    #ui { top: 45px !important; }
}

/* HUD Overlay */
#ui {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    color: #333;
    pointer-events: none;
    z-index: 10;
    display: none;
    justify-content: space-between;
    align-items: flex-start;
}

.stats-bar {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: rgba(255, 255, 255, 0.7);
    padding: 10px 15px;
    border-radius: 10px;
    border: 2px solid #333;
}

h2 {
    margin: 0;
    font-size: 1.2rem;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

@media (min-width: 768px) {
    h2 { font-size: 1.5rem; }
    .stats-bar { padding: 10px 20px; }
}

.button-group {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.button-group button {
    padding: 10px 15px;
    font-size: 0.9rem;
    background-color: #333;
    color: white;
    border: 2px solid #fff;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.button-group button:hover { background-color: #555; }

/* Tutorial Text Overlay */
#tutorial-text {
    position: absolute;
    top: 30%;
    width: 100%;
    text-align: center;
    color: #fff;
    font-size: 2rem;
    text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000;
    z-index: 5;
    pointer-events: none;
    display: none;
}

/* On-Screen Arrow Controls */
#on-screen-controls {
    display: none;
    position: absolute;
    bottom: max(20px, env(safe-area-inset-bottom)); 
    right: max(20px, env(safe-area-inset-right));
    z-index: 15;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.arrow-row {
    display: flex;
    gap: 5px;
}

.arrow-btn {
    width: 55px;
    height: 55px;
    border-radius: 10px;
    background-color: rgba(51, 51, 51, 0.6);
    color: white;
    border: 2px solid white;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    cursor: pointer;
}

.arrow-btn:active, .arrow-btn.simulated-active {
    background-color: rgba(204, 255, 0, 0.8); 
    color: #333;
    border-color: #333;
}

@media (max-width: 1024px) {
    #on-screen-controls { display: flex; }
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(211, 211, 211, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}

/* Bigger Outline for Main Titles */
.overlay h1 {
    font-size: 3rem;
    color: #a4cc00;
    margin-bottom: 10px;
    text-shadow: 
        -3px -3px 0 #222,  
         3px -3px 0 #222,
        -3px  3px 0 #222,
         3px  3px 0 #222,
         5px  5px 8px rgba(0,0,0,0.6);
}

.overlay p {
    font-size: 1.1rem;
    color: #333;
    margin: 5px 0;
}

/* Specifically bolded, black text with light grey outline for status description */
#status-desc {
    font-size: 1.3rem;
    font-weight: 900;
    color: #000;
    text-shadow: 
        -1.5px -1.5px 0 #e0e0e0,  
         1.5px -1.5px 0 #e0e0e0,
        -1.5px  1.5px 0 #e0e0e0,
         1.5px  1.5px 0 #e0e0e0;
    margin: 15px 0;
}

.overlay button {
    margin-top: 30px;
    padding: 15px 30px;
    font-size: 1.2rem;
    background-color: #ccff00;
    color: #333;
    border: 3px solid #333;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.1s, background-color 0.2s;
}

.overlay button:hover { background-color: #b3e600; transform: scale(1.05); }
.overlay button:active { transform: scale(0.95); }

@media (min-width: 768px) {
    .overlay h1 { font-size: 4rem; }
    .overlay p { font-size: 1.2rem; }
    .overlay button { padding: 15px 40px; font-size: 1.5rem; }
}
