:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --background: #0f172a;
    --surface: #1e293b;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --border: #334155;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 16px;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
}

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

h1, h2 {
    font-weight: 600;
    letter-spacing: -0.025em;
}

h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.section {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: transform 0.2s ease;
}

@media (min-width: 481px) {
    .section:hover {
        transform: translateY(-1px);
    }
}

.mobile-nav {
    display: none;
}

button {
    padding: 14px 20px;
    margin: 5px;
    min-height: 48px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

header {
    margin-bottom: 2rem;
}

header h1 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

button i {
    margin-right: 0.5rem;
    font-size: 1.1em;
    vertical-align: -0.1em;
}

button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    background: var(--primary);
    transform: none;
}

.progress-container {
    margin-bottom: 20px;
}

.progress-status {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.progress-bar {
    height: 8px;
    background: var(--background);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

#progress-fill {
    height: 100%;
    width: 0;
    background: var(--primary);
    transition: width 0.3s ease;
}

.matrix-preview {
    display: grid;
    gap: 4px;
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 16px;
}

.matrix-cell {
    aspect-ratio: 1;
    background: var(--surface);
    border-radius: 4px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.matrix-cell i {
    color: var(--text-secondary);
    font-size: 14px;
    opacity: 0.5;
}

.matrix-cell.completed {
    background: var(--primary);
}

.matrix-cell.completed i {
    color: white;
    opacity: 0.8;
}

.manual-control {
    margin-top: 16px;
}

.tilt-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 16px;
    align-items: stretch;
}

.tilt-buttons {
    display: flex;
    gap: 12px;
}

.tilt-buttons button {
    flex: 1;
}

.tilt-step {
    background: var(--background);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.tilt-step label {
    display: flex;
    align-items: center;
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 12px;
}

.tilt-step input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: var(--surface);
    border-radius: 4px;
    margin: 8px 0;
}

.tilt-step input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--background);
    box-shadow: 0 0 0 2px var(--border);
    transition: all 0.2s ease;
}

.tilt-step input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

.tilt-step input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
}

#step-value {
    font-weight: 500;
    color: var(--text);
}

.button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

#stop-btn {
    background: var(--danger);
}

#stop-btn:hover {
    background: var(--danger-hover);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

label i {
    margin-right: 0.5rem;
    color: var(--text-secondary);
}

.setting {
    margin-bottom: 16px;
}

.setting label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.setting input {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    transition: border-color 0.2s ease;
}

.setting input:focus {
    outline: none;
    border-color: var(--primary);
}

#status-bar {
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 24px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#status-bar i {
    font-size: 1.1em;
}

#message-log {
    height: 120px;
    overflow-y: auto;
    background: var(--background);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

@media (max-width: 480px) {
    body {
        padding: 12px;
    }
    
    .section {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    button {
        width: 100%;
        margin: 4px 0;
        font-size: 16px;
    }

    .settings-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .setting {
        margin-bottom: 8px;
    }

    .setting label {
        font-size: 12px;
        margin-bottom: 4px;
    }

    .setting input {
        padding: 6px 8px;
        font-size: 14px;
        height: 32px;
    }

    .mobile-nav {
        display: flex;
        justify-content: space-around;
        background: var(--surface);
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 8px;
        border-top: 1px solid var(--border);
        z-index: 100;
    }

    .mobile-nav .tab-btn {
        background: none;
        border: none;
        color: var(--text-secondary);
        min-height: 44px;
        width: auto;
        margin: 0;
        padding: 8px 16px;
        border-radius: 8px;
    }

    .mobile-nav .tab-btn.active {
        background: var(--primary);
        color: white;
    }

    .mobile-nav .tab-btn i {
        margin: 0;
        font-size: 20px;
    }

    .tab-content {
        display: none;
    }

    .tab-content.active {
        display: block;
    }

    body {
        padding-bottom: 70px;
    }

    h1 {
    font-size: 1.75rem;
}

#status-bar {
        margin-bottom: 16px;
    }

    .manual-control {
        grid-template-columns: 1fr;
    }
}

.update-notification {
    position: fixed;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 1000;
    border: 1px solid var(--border);
}

.update-notification p {
    margin: 0;
}

.update-notification button {
    background-color: white;
    color: var(--primary);
    border: none;
    padding: 8px 16px;
    margin: 0;
    min-height: unset;
}

.update-notification button:hover {
    background-color: #f0f0f0;
}

@media (max-width: 480px) {
    .update-notification {
        width: calc(100% - 32px);
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
}
