* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: #000;
    color: #0f0;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    width: 100vw;
    height: 100dvh;
    touch-action: none;
}

/* --- Start overlay --- */

#start-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    z-index: 100;
}

#start-content {
    text-align: center;
    padding: 1rem;
}

#start-content h1 {
    font-size: clamp(2rem, 10vw, 4rem);
    color: #0ff;
    margin-bottom: 1rem;
    letter-spacing: 0.5em;
}

#start-content p {
    font-size: clamp(0.8rem, 3vw, 1.2rem);
    margin-bottom: 0.5rem;
    color: #0a0;
}

#start-content .controls {
    font-size: clamp(0.6rem, 2.5vw, 0.9rem);
    color: #080;
    margin-bottom: 2rem;
}

#start-btn {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    padding: 0.8rem 2rem;
    background: none;
    border: 1px solid #0ff;
    color: #0ff;
    cursor: pointer;
}

#start-btn:hover {
    background: #0ff;
    color: #000;
}

/* --- Game container --- */

#game {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* --- Map canvas (main view) --- */

#map {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
}

/* --- HUD overlay --- */

#hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 10;
}

#hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
}

#hud-top span {
    font-size: clamp(0.8rem, 3vw, 1.1rem);
}

#compass {
    color: #0ff;
    font-size: clamp(1rem, 4vw, 1.5rem) !important;
    font-weight: bold;
}

#level, #score {
    color: #0a0;
}

#hud-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 1rem 1rem;
    gap: 0.2rem;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
}

#pairs {
    font-size: clamp(0.9rem, 3.5vw, 1.2rem);
    color: #0ff;
}

#prompt {
    font-size: clamp(0.7rem, 2.5vw, 1rem);
    color: #080;
}

#cooldown {
    font-size: clamp(0.6rem, 2vw, 0.8rem);
    color: #060;
}

/* --- Touch controls --- */

#touch-controls {
    display: none;
    position: absolute;
    bottom: 3rem;
    left: 0;
    right: 0;
    padding: 0 1rem;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 20;
    pointer-events: none;
}

@media (pointer: coarse), (max-width: 768px) {
    #touch-controls {
        display: flex;
    }
    #hud-bottom {
        padding-bottom: 10rem;
    }
}

#touch-left {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 0.3rem;
    pointer-events: auto;
}

#touch-left .touch-btn[data-action="turnLeft"]  { grid-column: 1; grid-row: 1; }
#touch-left .touch-btn[data-action="forward"]   { grid-column: 2; grid-row: 1; }
#touch-left .touch-btn[data-action="turnRight"]  { grid-column: 3; grid-row: 1; }
#touch-left .touch-btn[data-action="backward"]  { grid-column: 2; grid-row: 2; }

#touch-right {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    pointer-events: auto;
}

.touch-btn {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    width: 3.5rem;
    height: 3.5rem;
    background: rgba(0, 40, 0, 0.6);
    border: 1px solid #0a0;
    color: #0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.3rem;
    user-select: none;
}

.touch-btn:active {
    background: rgba(0, 80, 0, 0.8);
    border-color: #0ff;
    color: #0ff;
}

.touch-action {
    width: 4.5rem;
    font-size: 0.9rem;
    font-weight: bold;
}

.touch-action[data-action="ping"] {
    border-color: #0ff;
    color: #0ff;
    height: 4rem;
}

/* --- Level complete --- */

#level-complete {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    z-index: 50;
}

#level-complete h2 {
    font-size: clamp(1.5rem, 6vw, 2rem);
    color: #0ff;
    margin-bottom: 1rem;
}

#level-complete p {
    font-size: clamp(0.8rem, 3vw, 1rem);
    color: #0a0;
    margin-bottom: 0.5rem;
}

.hidden {
    display: none !important;
}
