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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
    padding: 20px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 30px;
    font-weight: 300;
    letter-spacing: 2px;
}

h2 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 20px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Settings Panel */
.settings-panel {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.3s ease;
}

.settings-panel.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.settings-panel.disabled #startStopBtn,
.settings-panel.disabled .audio-controls {
    pointer-events: auto;
    opacity: 1;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 500;
}

.form-group input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 1.1rem;
    color: #fff;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #3b82f6;
    background: rgba(255, 255, 255, 0.15);
}

.form-group input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Info Display */
.info-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    margin-bottom: 16px;
}

.info-label {
    font-size: 0.9rem;
    color: #94a3b8;
}

.info-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #3b82f6;
    font-variant-numeric: tabular-nums;
}

/* Forecast Button */
.btn-forecast {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    transition: all 0.2s ease;
    margin-bottom: 16px;
}

.btn-forecast:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

/* Forecast Panel */
.forecast-panel {
    display: none;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.forecast-panel.visible {
    display: block;
}

.forecast-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.forecast-header h3 {
    font-size: 0.95rem;
    font-weight: 500;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.btn-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

.btn-close:hover {
    color: #fff;
}

#forecastGraph {
    width: 100%;
    height: auto;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.forecast-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 12px;
    font-size: 0.8rem;
    color: #94a3b8;
}

.legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.legend-dot.speed {
    background: #f59e0b;
}

.legend-dot.time {
    background: #3b82f6;
}

/* Audio Controls */
.audio-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.sound-select {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sound-select label {
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 500;
    min-width: 80px;
}

.sound-select select {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 1rem;
    color: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.sound-select select:focus {
    outline: none;
    border-color: #3b82f6;
    background: rgba(255, 255, 255, 0.15);
}

.sound-select select option {
    background: #1a1a2e;
    color: #fff;
}

/* Toggle Control */
.toggle-control {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toggle-control > label:first-child {
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 500;
    min-width: 80px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.2);
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background: #fff;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.toggle-hint {
    font-size: 0.8rem;
    color: #64748b;
    font-style: italic;
}

/* Volume Control */
.volume-control {
    display: flex;
    align-items: center;
    gap: 16px;
}

.volume-control label {
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 500;
    min-width: 80px;
}

.volume-control input[type="range"] {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    outline: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.volume-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}

.volume-control input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.volume-control #volumeValue {
    font-size: 1rem;
    font-weight: 600;
    min-width: 45px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Buttons */
#startStopBtn {
    width: 100%;
    padding: 16px;
    font-size: 1.2rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn-start {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #fff;
}

.btn-start:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(34, 197, 94, 0.4);
}

.btn-stop {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
}

.btn-stop:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
}

/* Display Panel */
.display-panel {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.2s ease;
}

.stat-card.primary {
    grid-column: span 2;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(37, 99, 235, 0.2) 100%);
    border-color: rgba(59, 130, 246, 0.3);
}

.stat-card.primary .stat-value {
    font-size: 4rem;
}

.stat-card.visual-card {
    grid-column: span 2;
    padding: 16px;
}

.track-visual {
    width: 100%;
    height: auto;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stat-value small {
    font-size: 0.5em;
    font-weight: 400;
    opacity: 0.7;
}

/* Beep animation */
.stat-card.beep-flash {
    animation: beepFlash 0.3s ease;
}

@keyframes beepFlash {
    0% {
        background: rgba(34, 197, 94, 0.5);
        transform: scale(1.02);
    }
    100% {
        background: rgba(255, 255, 255, 0.05);
        transform: scale(1);
    }
}

/* Log Panel */
.log-panel {
    display: none;
    margin-top: 24px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.log-panel.visible {
    display: block;
}

.log-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.log-panel h3 {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-download {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    transition: all 0.2s ease;
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.log-header {
    display: grid;
    grid-template-columns: 80px 1fr 70px 70px 70px;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
}

.log-entries {
    max-height: 300px;
    overflow-y: auto;
}

.log-entry {
    display: grid;
    grid-template-columns: 80px 1fr 70px 70px 70px;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.event-start {
    color: #22c55e;
}

.log-entry.event-beep {
    color: #fff;
}

.log-entry.event-speed {
    color: #f59e0b;
    font-weight: 500;
}

.log-entry.event-stop {
    color: #ef4444;
}

.log-entries::-webkit-scrollbar {
    width: 6px;
}

.log-entries::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.log-entries::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.log-entries::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive - Tablet */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .stat-card.primary .stat-value {
        font-size: 3.5rem;
    }
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    body {
        padding: 8px;
    }

    h1 {
        font-size: 1.8rem;
        margin-bottom: 20px;
    }

    h2 {
        font-size: 0.95rem;
        margin-bottom: 16px;
    }

    /* Settings Panel */
    .settings-panel {
        padding: 16px;
        border-radius: 12px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .form-group label {
        font-size: 0.8rem;
    }

    .form-group input {
        padding: 14px;
        font-size: 1.2rem;
    }

    /* Info Display */
    .info-display {
        flex-direction: column;
        gap: 4px;
        text-align: center;
        padding: 10px;
    }

    .info-value {
        font-size: 1.3rem;
    }

    /* Audio Controls */
    .audio-controls {
        padding: 12px;
        gap: 14px;
    }

    .sound-select,
    .volume-control,
    .toggle-control {
        flex-wrap: wrap;
        gap: 10px;
    }

    .sound-select label,
    .volume-control label,
    .toggle-control > label:first-child {
        min-width: 70px;
        font-size: 0.8rem;
    }

    .sound-select select {
        padding: 12px;
        font-size: 1rem;
    }

    .toggle-hint {
        width: 100%;
        margin-top: -4px;
        font-size: 0.75rem;
    }

    /* Start/Stop Button */
    #startStopBtn {
        padding: 18px;
        font-size: 1.3rem;
        border-radius: 10px;
    }

    /* Display Panel */
    .display-panel {
        gap: 10px;
    }

    .stat-card {
        padding: 16px;
        border-radius: 12px;
    }

    .stat-card.primary {
        padding: 20px;
    }

    .stat-card.primary .stat-value {
        font-size: 3rem;
    }

    .stat-label {
        font-size: 0.7rem;
        margin-bottom: 6px;
    }

    .stat-value {
        font-size: 1.8rem;
    }

    .stat-value small {
        font-size: 0.55em;
    }

    /* Visual Card */
    .stat-card.visual-card {
        padding: 12px;
    }

    /* Log Panel */
    .log-panel {
        padding: 14px;
        margin-top: 16px;
    }

    .log-title-row {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .log-panel h3 {
        text-align: center;
    }

    .btn-download {
        width: 100%;
        padding: 12px;
    }

    .log-header {
        grid-template-columns: 65px 1fr 55px 55px 55px;
        gap: 8px;
        padding: 6px 8px;
        font-size: 0.7rem;
    }

    .log-entry {
        grid-template-columns: 65px 1fr 55px 55px 55px;
        gap: 8px;
        padding: 8px;
        font-size: 0.8rem;
    }

    .log-entries {
        max-height: 250px;
    }
}

/* Responsive - Mobile - Forecast */
@media (max-width: 480px) {
    .btn-forecast {
        padding: 14px;
        font-size: 1rem;
    }

    .forecast-panel {
        padding: 12px;
    }

    .forecast-legend {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .stat-card.primary .stat-value {
        font-size: 2.5rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .log-header,
    .log-entry {
        grid-template-columns: 55px 1fr 45px 45px 45px;
        font-size: 0.7rem;
    }
}
