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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #121212;
    color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

#canvas-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    touch-action: none;
}

#start-screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    background: rgba(0, 0, 0, 0.75);
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 16px;
}

#start-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: flex !important;
}

#win-modal {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    background: rgba(0, 0, 0, 0.65);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 2.0s ease, visibility 2.0s ease;
    padding: 16px;
}

#win-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: flex !important;
}

.dialog-box {
    background: #1c1c1c;
    border: 1px solid #333333;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    padding: 22px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    max-height: 90vh;
    overflow-y: auto;
}

.dialog-box h1 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 18px;
    color: #ffffff;
}

.dialog-box h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: #f59e0b;
}

.field-group {
    margin-bottom: 16px;
}

.field-group label {
    display: block;
    font-size: 0.8rem;
    color: #aaaaaa;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-group-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 8px 0;
    border-top: 1px solid #282828;
    border-bottom: 1px solid #282828;
}

.field-group-inline label {
    font-size: 0.85rem;
    color: #cccccc;
}

.field-group-inline input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #d97706;
    cursor: pointer;
}

.preset-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.btn-preset {
    background: #262626;
    border: 1px solid #383838;
    color: #cccccc;
    padding: 10px 0;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    min-height: 40px;
}

.btn-preset:hover {
    background: #333333;
    color: #ffffff;
}

.btn-preset.active {
    background: #3a3224;
    border-color: #d97706;
    color: #f59e0b;
    font-weight: 600;
}

.custom-row input {
    width: 100%;
    background: #141414;
    border: 1px solid #333333;
    border-radius: 4px;
    padding: 10px 12px;
    color: #ffffff;
    font-size: 0.85rem;
    outline: none;
    min-height: 40px;
}

.custom-row input:focus {
    border-color: #666666;
}

.btn-start {
    width: 100%;
    background: #d97706;
    border: none;
    border-radius: 4px;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.1s;
    min-height: 44px;
}

.btn-start:hover {
    background: #b45309;
}

.btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 18px;
}

.btn-subtle {
    background: #262626;
    border: 1px solid #383838;
    border-radius: 4px;
    color: #cccccc;
    font-size: 0.85rem;
    padding: 10px;
    cursor: pointer;
    min-height: 44px;
}

.btn-subtle:hover {
    background: #333333;
    color: #ffffff;
}

.results-table {
    background: #141414;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 12px;
}

.res-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.85rem;
    border-bottom: 1px solid #222222;
}

.res-row:last-child {
    border-bottom: none;
}

.res-row span {
    color: #888888;
}

.res-row strong {
    color: #ffffff;
}

#hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 20;
}

#hud.hidden {
    display: none;
}

.hud-corner {
    position: absolute;
    pointer-events: auto !important;
    z-index: 25;
}

.hud-corner.top-left {
    top: 14px;
    left: 14px;
    background: rgba(24, 24, 24, 0.85);
    border: 1px solid #333333;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.82rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hud-corner.top-right {
    top: 14px;
    right: 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.timer-display {
    background: rgba(24, 24, 24, 0.85);
    border: 1px solid #333333;
    border-radius: 4px;
    padding: 6px 12px;
    font-family: monospace;
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffffff;
}

.detector-minimal {
    background: rgba(24, 24, 24, 0.85);
    border: 1px solid #333333;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.detector-bar-bg {
    width: 60px;
    height: 6px;
    background: #333333;
    border-radius: 3px;
    overflow: hidden;
}

.detector-bar-fill {
    width: 0%;
    height: 100%;
    background: #3b82f6;
    transition: width 0.1s;
}

.stat-label {
    color: #888888;
}

.hud-corner.bottom-left {
    bottom: 14px;
    left: 14px;
}

.hint-text {
    font-size: 0.75rem;
    color: #888888;
    background: rgba(18, 18, 18, 0.8);
    padding: 5px 8px;
    border-radius: 3px;
    max-width: 320px;
}

.hud-corner.bottom-right {
    bottom: 14px;
    right: 14px;
    display: flex;
    gap: 6px;
}

.btn-mini {
    background: rgba(28, 28, 28, 0.9);
    border: 1px solid #3a3a3a;
    color: #cccccc;
    font-size: 0.75rem;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-mini:hover {
    background: #383838;
    color: #ffffff;
}

.btn-mini-danger {
    color: #f87171;
    border-color: #552828;
}

.btn-mini-danger:hover {
    background: #451a1a;
    color: #fca5a5;
}

@media (max-width: 600px) {
    .dialog-box {
        padding: 18px 14px;
    }

    .dialog-box h1 {
        font-size: 1.2rem;
        margin-bottom: 14px;
    }

    .hud-corner.top-left {
        top: 10px;
        left: 10px;
        font-size: 0.75rem;
        padding: 6px 8px;
    }

    .hud-corner.top-right {
        top: 10px;
        right: 10px;
    }

    .timer-display {
        font-size: 0.85rem;
        padding: 4px 8px;
    }

    .detector-minimal {
        font-size: 0.72rem;
        padding: 4px 6px;
    }

    .detector-bar-bg {
        width: 45px;
    }

    .hud-corner.bottom-left {
        display: none;
    }

    .hud-corner.bottom-right {
        bottom: 10px;
        right: 10px;
        gap: 4px;
    }

    .btn-mini {
        padding: 6px 8px;
        font-size: 0.7rem;
    }
}
