:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --border-radius: 24px;
    --gauge-bg: #334155;
    --gauge-color-safe: #4ade80;
    --gauge-color-warn: #fbbf24;
    --gauge-color-danger: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at 50% 0%, #1e293b, var(--bg-color));
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.app-container {
    background: var(--card-bg);
    width: 100%;
    max-width: 420px;
    border-radius: var(--border-radius);
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(16px);
}

header {
    text-align: center;
    margin-bottom: 2.5rem;
}

h1 {
    font-weight: 800;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #60a5fa, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.05em;
}

header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

/* Gauge */
.meter-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2.5rem;
    position: relative;
}

.gauge {
    width: 280px;
    height: 140px;
    position: relative;
    overflow: hidden;
}

.gauge-svg {
    width: 100%;
    height: 100%;
    transform: scale(1.05);
}

.gauge-bg, .gauge-value {
    stroke-width: 7;
    stroke-linecap: round;
}

.gauge-bg {
    stroke: var(--gauge-bg);
}

.gauge-value {
    stroke: var(--gauge-color-safe);
    transition: stroke-dashoffset 0.1s ease-out, stroke 0.3s ease, filter 0.3s ease;
    filter: drop-shadow(0 0 10px rgba(74, 222, 128, 0.4));
}

.gauge-value.warn {
    stroke: var(--gauge-color-warn);
    filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.4));
}

.gauge-value.danger {
    stroke: var(--gauge-color-danger);
    filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.4));
}

.db-display {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

#db-value {
    font-size: 4.5rem;
    font-weight: 800;
    line-height: 0.9;
    letter-spacing: -0.05em;
}

.db-unit {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-left: 2px;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.threshold-badge {
    background: rgba(255,255,255,0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: #a78bfa;
    cursor: pointer;
    margin-top: -9px;
    box-shadow: 0 0 15px rgba(167, 139, 250, 0.6);
    transition: transform 0.1s ease;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--gauge-bg);
    border-radius: 3px;
}

.select-wrapper {
    position: relative;
    width: 100%;
}

select {
    width: 100%;
    appearance: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

select:hover, select:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

select option {
    background: var(--card-bg);
    color: var(--text-primary);
}

.select-wrapper::after {
    content: "▼";
    font-size: 0.8rem;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-secondary);
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent-color), #60a5fa);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 16px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    box-shadow: 0 10px 20px -10px rgba(59, 130, 246, 0.5);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px -10px rgba(59, 130, 246, 0.6);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn.active {
    background: var(--gauge-bg);
    color: var(--text-secondary);
    box-shadow: none;
}

.primary-btn.danger-btn {
    background: linear-gradient(135deg, var(--danger-color), #f87171);
    box-shadow: 0 10px 20px -10px rgba(239, 68, 68, 0.5);
}
.primary-btn.danger-btn:hover {
    box-shadow: 0 15px 25px -10px rgba(239, 68, 68, 0.6);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 100;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--card-bg);
    padding: 2.5rem 2rem;
    border-radius: var(--border-radius);
    text-align: center;
    max-width: 360px;
    width: 90%;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(239, 68, 68, 0.4);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.05);
}

.modal-overlay.show .modal-content {
    transform: translateY(0) scale(1);
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse 1.5s infinite alternate ease-in-out;
}

.modal-content h2 {
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-size: 1.5rem;
    font-weight: 800;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.6;
    font-size: 0.95rem;
}

.modal-content p span {
    color: var(--danger-color);
    font-weight: 700;
    font-size: 1.1rem;
}

@keyframes pulse {
    0% { transform: scale(1) rotate(-5deg); text-shadow: 0 0 20px rgba(239,68,68,0.5); }
    100% { transform: scale(1.1) rotate(5deg); text-shadow: 0 0 40px rgba(239,68,68,0.8); }
}
