:root {
    --bg-dark: #000000;
    --panel-bg: #000000;
    --panel-border: rgba(255, 255, 255, 0.15);
    --accent-blue: #00d4ff;
    --accent-orange: #ffaa00;
    --accent-green: #00ff9d;
    --text-main: #ffffff;
    --text-muted: #8b9bb4;
    --glass-blur: 16px;
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    /* Prevent selection while dragging */
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: rgba(20, 20, 30, 0.95);
    border: 1px solid var(--accent-blue);
    padding: 2rem;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    color: var(--text-main);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.2);
}

.modal-content h2 {
    font-family: var(--font-heading);
    color: var(--accent-orange);
    margin-bottom: 1rem;
}

.modal-content p,
.modal-content li {
    line-height: 1.6;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.modal-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
}

#closeHelpBtn {
    width: 100%;
    margin-top: 1rem;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Background */
.metal-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1a1d21 0%, #0a0b0c 100%);
    z-index: 0;
    pointer-events: none;
}

/* Canvas Layer */
.canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: none;
    /* We will draw our own cursor */
    touch-action: none;
    /* detailed interaction */
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* UI Overlay */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--panel-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
}

.main-header {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1200px;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.logo h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo .version {
    font-size: 0.8rem;
    background: var(--accent-orange);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
}

.header-controls .icon-btn {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.header-controls .icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Control Panel (Bottom/Side) */
.control-panel {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    z-index: 10;
}

.control-panel h2 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-right: 10px;
}

.process-selector {
    display: flex;
    gap: 1rem;
}

.process-card {
    position: relative;
    cursor: pointer;
}

.process-card input {
    display: none;
}

.card-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    text-align: center;
    transition: all 0.2s;
}

.process-card input:checked+.card-content {
    background: rgba(0, 212, 255, 0.15);
    border-color: var(--accent-blue);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

.p-icon {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.2rem;
}

.p-name {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Settings & Controls */
.settings-group {
    display: flex;
    gap: 1.5rem;
    padding-right: 1.5rem;
    border-right: 1px solid var(--panel-border);
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-item label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.control-item label span {
    color: var(--accent-orange);
    font-weight: bold;
    margin-left: 5px;
}

/* Custom Range Slider */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 140px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Custom Select */
select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 0.4rem;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

select:focus {
    border-color: var(--accent-blue);
}

/* Range Info */
.range-info {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: -4px;
    font-family: var(--font-heading);
}

/* Speed Indicator */
.speed-indicator-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.traffic-light {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #444;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5) inset;
    transition: background 0.2s, box-shadow 0.2s;
}

.traffic-light.red {
    background: #ff0055;
    box-shadow: 0 0 10px #ff0055;
}

.traffic-light.orange {
    background: #ffaa00;
    box-shadow: 0 0 10px #ffaa00;
}

.traffic-light.green {
    background: #00ff9d;
    box-shadow: 0 0 10px #00ff9d;
}

.status-display {
    display: flex;
    gap: 1.5rem;
    /* Removed padding-left/border-left as it is next to settings now */
    padding-left: 0;
    border-left: none;
}

.action-btn {
    background: var(--accent-blue);
    color: #000;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-heading);
    transition: transform 0.1s;
}

.action-btn:active {
    transform: scale(0.95);
}

/* Feedback Panel */
.feedback-panel {
    position: absolute;
    right: 30px;
    top: 100px;
    width: 300px;
    padding: 1.5rem;
    z-index: 20;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
}

.feedback-panel.hidden {
    transform: translateX(120%);
    opacity: 0;
    pointer-events: none;
}

/* Header & Nav */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--panel-border);
    /* backdrop-filter: blur(10px); Removed for solid black */
    background: var(--panel-bg);
}

.logo {
    display: flex;
    align-items: center;
}

.logo-img {
    height: 44px;
    width: auto;
    object-fit: contain;
    margin-right: 12px;
}

.logo-tag {
    background-color: #ffd700;
    /* Yellow */
    color: #000;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    margin-right: 20px;
    /* Space between SIMULATOR and Version */
    text-transform: uppercase;
}

.app-version {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    /* Smaller */
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
    opacity: 0.8;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#helpBtn {
    background-color: #ff0055;
    border-color: #ff0055;
    color: white;
    /* pure flat, no shadow */
}

#helpBtn:hover {
    background-color: #e6004c;
    border-color: #e6004c;
    transform: translateY(-1px);
}

.lang-select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.lang-select:focus {
    border-color: var(--accent-blue);
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.score-circle {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.circular-chart {
    display: block;
    margin: 10px auto;
    max-width: 80%;
    max-height: 250px;
}

.circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 3.8;
}

.circle {
    fill: none;
    stroke: var(--accent-green);
    stroke-width: 2.8;
    stroke-linecap: round;
    animation: progress 1s ease-out forwards;
}

.percentage {
    fill: var(--text-main);
    font-family: var(--font-heading);
    font-weight: bold;
    font-size: 0.5em;
    text-anchor: middle;
}

.detail-item {
    margin-bottom: 10px;
}

.d-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    background: var(--accent-blue);
    transition: width 0.5s ease-out;
}

.tips-box {
    margin-top: 20px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 6px;
}

.tips-box h3 {
    font-size: 0.8rem;
    color: var(--accent-orange);
    margin-bottom: 5px;
}

.tips-box ul {
    list-style: none;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.screen-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 50;
    transition: opacity 0.05s;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {

    body,
    html {
        overflow-x: hidden;
        width: 100%;
        position: fixed;
        /* Prevent mobile scroll bounce */
    }

    header {
        padding: 0.5rem 1rem;
        flex-direction: column;
        gap: 0.2rem;
        width: 100%;
        box-sizing: border-box;
    }

    .logo-img {
        height: 32px;
    }

    .logo-tag {
        font-size: 0.6rem;
        padding: 2px 4px;
        margin-right: 10px;
    }

    .app-version {
        font-size: 0.6rem;
    }

    .header-controls {
        width: 100%;
        justify-content: center;
    }

    .control-panel {
        bottom: 0;
        left: 0;
        transform: none;
        width: 100%;
        /* Use 100% relative to body */
        max-width: 100%;
        box-sizing: border-box;
        /* Fix padding adding to width */
        padding: 10px;
        padding-bottom: 80px;
        /* Safe area for hidden buttons usually at bottom */
        flex-direction: column;
        gap: 0.8rem;
        border-radius: 12px 12px 0 0;
        max-height: 50vh;
        /* Increase height slightly */
        overflow-y: auto;
        overflow-x: hidden;
        align-items: stretch;
    }

    .control-panel h2 {
        text-align: center;
        margin-right: 0;
        margin-bottom: 0.5rem;
    }

    .settings-group {
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
        padding-right: 0;
        padding-bottom: 1rem;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        /* Allow wrapping */
        justify-content: space-between;
        gap: 0.5rem;
    }

    .control-item {
        flex: 1 1 45%;
        /* 2 items per row */
        min-width: 120px;
    }

    .control-item label {
        font-size: 0.65rem;
    }

    select,
    input[type="range"] {
        font-size: 0.8rem;
    }

    .process-selector {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
    }

    .process-card {
        width: 70px;
        height: 70px;
    }

    .p-icon {
        font-size: 1rem;
    }

    .p-name {
        font-size: 0.65rem;
    }

    /* Feedback Panel Compact Mode */
    .feedback-panel {
        width: 90%;
        right: 5%;
        top: 80px;
    }

    .score-circle {
        width: 80px;
        height: 80px;
    }
}



.screen-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 50;
    transition: opacity 0.05s;
}