* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    margin: 0;
    padding: 0;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #121820;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #e0e6ed;
    touch-action: none;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#ui-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#hud-top {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hud-card {
    background: rgba(18, 24, 32, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 8px;
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    pointer-events: auto;
}

#viewport-labels {
    position: absolute;
    top: 64px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    pointer-events: none;
}

.v-label {
    background: rgba(10, 14, 20, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8da2b5;
}

#mobile-mode-bar {
    display: none;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
    pointer-events: auto;
}

#hud-bottom {
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    pointer-events: auto;
}

.control-cluster {
    background: rgba(18, 24, 32, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px;
    border-radius: 8px;
    display: flex;
    gap: 6px;
}

.btn {
    background: #232d3b;
    color: #e0e6ed;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: background 0.15s, border-color 0.15s;
    touch-action: manipulation;
}

.btn:hover {
    background: #313f52;
    border-color: rgba(255, 255, 255, 0.2);
}

.btn:active {
    background: #1b232e;
}

.btn-primary {
    background: #1e7e68;
    color: #ffffff;
    border-color: #2ec4b6;
}

.btn-primary:hover {
    background: #259d82;
}

.icon-btn {
    min-width: 36px;
    padding: 8px 10px;
}

.btn-select {
    background: #232d3b;
    color: #e0e6ed;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.mode-btn {
    flex: 1;
    max-width: 140px;
    padding: 10px;
}

.mode-btn.active {
    background: #2ec4b6;
    color: #0d1e1c;
    border-color: #ffffff;
}

.modal {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 20, 0.8);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.modal.hidden {
    display: none;
}

.modal-card {
    background: #1a232f;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 28px 36px;
    text-align: center;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
}

#result-grade {
    font-size: 22px;
    margin-bottom: 8px;
    color: #2ec4b6;
}

#result-score-large {
    font-size: 54px;
    font-weight: 800;
    margin-bottom: 8px;
}

#result-details {
    color: #8da2b5;
    font-size: 14px;
    margin-bottom: 16px;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 14px;
    font-size: 12px;
    margin-bottom: 24px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-green { background: #4caf50; }
.dot-orange { background: #ff9800; }
.dot-red { background: #f44336; }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

@media (max-width: 768px) {
    #viewport-labels {
        flex-direction: column;
        align-items: center;
        gap: 38vh;
        top: 60px;
    }
    #mobile-mode-bar {
        display: flex;
    }
    #hud-bottom {
        padding: 8px;
        gap: 6px;
    }
    .btn {
        padding: 8px 10px;
        font-size: 11px;
    }
}