:root {
    --bg-dark: #090c10;
    --primary: #00f2fe;
    --secondary: #4facfe;
    --accent: #ff0844;
    --glass-bg: rgba(15, 23, 42, 0.65);
    --glass-border: rgba(255, 255, 255, 0.12);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'Space Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: var(--font-heading);
    color: var(--text-main);
}

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

.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr;
    padding: 16px;
    gap: 16px;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.header {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(15, 23, 42, 0.75);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header .subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.video-preview-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    opacity: 0.85;
}

#landmark-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: scaleX(-1);
    pointer-events: none;
}

.status-tag {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--primary);
}

.controls-panel {
    grid-column: 1;
    grid-row: 2;
    align-self: end;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: auto;
}

.timer-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.timer-card .label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    text-transform: uppercase;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    border-radius: 4px;
    transition: width 0.05s linear;
}

.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: #fff;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.action-hint {
    font-size: 0.78rem;
    text-align: center;
    color: var(--text-muted);
    line-height: 1.4;
    padding: 6px 0;
}

.key-badge, .touch-badge {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    color: #fff;
    font-size: 0.72rem;
}

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

.action-btn {
    flex: 1;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn.sm {
    padding: 6px 8px;
    font-size: 0.72rem;
}

.action-btn.icon-btn {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.action-btn:hover, .action-btn:active {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--accent), #ff5252);
    border: none;
    box-shadow: 0 4px 15px rgba(255, 8, 68, 0.4);
}

.action-btn.primary:hover, .action-btn.primary:active {
    box-shadow: 0 6px 20px rgba(255, 8, 68, 0.6);
}

/* Slide-Up Settings Drawer */
.settings-drawer {
    position: absolute;
    bottom: -100%;
    left: 50%;
    transform: translateX(-50%);
    width: min(90vw, 420px);
    z-index: 1000;
    transition: bottom 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.settings-drawer.open {
    bottom: 0;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.drawer-header h2 {
    font-size: 1.05rem;
    color: var(--primary);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

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

.drawer-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 65vh;
    overflow-y: auto;
    padding-right: 4px;
}

.setting-item label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.setting-item label.checkbox-label {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.setting-item label.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.setting-item label span strong {
    color: var(--primary);
    font-family: var(--font-mono);
}

.setting-item input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
    cursor: pointer;
}

.settings-section-title {
    font-size: 0.82rem;
    color: var(--secondary);
    margin-top: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-weight: 600;
}

/* Mobile & Touch responsiveness */
@media (max-width: 768px) {
    .ui-layer {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        padding: 12px;
        gap: 12px;
        overflow-y: auto;
    }

    .controls-panel {
        grid-column: 1;
        grid-row: 3;
        width: 100%;
    }
}
