:root {
    --pink:      #ff4dd8;
    --cyan:      #00cfff;
    --yellow:    #ffe600;
    --green:     #00ff99;
    --bg:        #0a0a0a;
    --ui-bg:     rgba(14,14,14,0.88);
    --ui-border: rgba(255,255,255,0.1);
    --font:      'Courier New', monospace;
}

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

body {
    background: var(--bg);
    color: #fff;
    font-family: var(--font);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* Color the shared navbar to match this tool's pink theme */
.navbar { border-color: var(--pink); color: var(--pink); }
.hamburger span { background: var(--pink); }
.nav-menu a:hover { color: var(--pink); }
.nav-menu a.active { color: var(--pink); }
.back-home { color: var(--pink); border-bottom-color: var(--pink); }

/* ── App ─────────────────────────────────────────────────── */
#app { position: fixed; inset: 0; }

#draw-canvas,
#skeleton-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: block;
}
#draw-canvas     { z-index: 1; background: #0a0a0a; }
#skeleton-canvas { z-index: 3; pointer-events: none; }

#webcam {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    pointer-events: none;
    z-index: 0;
    opacity: 0;
}
#webcam.camera-bg {
    opacity: 1;
}

/* ── HUD ─────────────────────────────────────────────────── */
#hud {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}
#hud > * { pointer-events: auto; }

/* ── Status bar ──────────────────────────────────────────── */
#status-bar {
    position: absolute;
    top: 14px;
    right: 20px;
    transform: none;
    left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    backdrop-filter: blur(14px);
    padding: 7px 18px;
    border-radius: 100px;
    pointer-events: none;
    white-space: nowrap;
}

#active-tool {
    font-size: 10px;
    letter-spacing: 4px;
    color: var(--pink);
    font-weight: bold;
    min-width: 44px;
}

#status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: rgba(255,255,255,0.4);
    letter-spacing: 1px;
}

#status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #333;
    flex-shrink: 0;
    transition: background 0.3s;
}
#status-dot.ready    { background: #00ff88; box-shadow: 0 0 6px #00ff88; }
#status-dot.tracking { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }

/* ── Toolbar (top, horizontal) ───────────────────────────── */
#toolbar {
    position: absolute;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    backdrop-filter: blur(16px);
    padding: 8px 12px;
    border-radius: 100px;
    white-space: nowrap;
}

.toolbar-divider {
    width: 1px;
    height: 28px;
    background: var(--ui-border);
    margin: 0 4px;
    flex-shrink: 0;
}

/* Color swatch in toolbar */
#color-swatch-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px;
    border-radius: 10px;
    transition: background 0.15s;
}
#color-swatch-wrap:hover,
#color-swatch-wrap.hover { background: rgba(255,255,255,0.06); }

#color-swatch {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.25);
    background: #ff4dd8;
    transition: box-shadow 0.2s, border-color 0.2s;
    flex-shrink: 0;
}
#color-swatch.hover {
    border-color: #fff;
    box-shadow: 0 0 12px currentColor;
}

#bg-swatch-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px;
    border-radius: 10px;
    transition: background 0.15s;
}
#bg-swatch-wrap:hover,
#bg-swatch-wrap.hover { background: rgba(255,255,255,0.06); }

#bg-swatch {
    width: 32px; height: 32px;
    border-radius: 6px;
    border: 2px solid rgba(255,255,255,0.25);
    background: #0a0a0a;
    transition: box-shadow 0.2s, border-color 0.2s;
    flex-shrink: 0;
    /* checkerboard corner hint so pure-black is visible */
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
#bg-swatch.hover {
    border-color: #fff;
    box-shadow: 0 0 12px rgba(255,255,255,0.4);
}

/* Tool buttons */
.tool-btn {
    width: 44px; height: 40px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: rgba(255,255,255,0.35);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.15s;
    padding: 0;
    flex-shrink: 0;
}
.tool-btn svg {
    width: 20px; height: 20px;
    stroke: currentColor;
    flex-shrink: 0;
}
.tool-btn:hover,
.tool-btn.hover {
    color: #fff;
    background: rgba(255,255,255,0.07);
    border-color: var(--ui-border);
}
.tool-btn.active {
    color: var(--pink);
    background: rgba(255,77,216,0.12);
    border-color: var(--pink);
}
.tool-btn.hover.active { box-shadow: 0 0 10px var(--pink); }

/* Layer buttons */
.layer-btn {
    width: 36px; height: 28px;
    background: transparent;
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    color: rgba(255,255,255,0.35);
    font-family: var(--font);
    font-size: 9px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}
.layer-btn:hover,
.layer-btn.hover {
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}
.layer-btn.active {
    color: var(--cyan);
    border-color: var(--cyan);
    background: rgba(0,207,255,0.1);
}

/* Action buttons (undo, export) */
.action-btn {
    width: 40px; height: 40px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: rgba(255,255,255,0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.action-btn svg { width: 18px; height: 18px; stroke: currentColor; }
.action-btn:hover { color: var(--yellow); border-color: var(--yellow); }

.tool-label {
    font-size: 7px;
    letter-spacing: 1px;
    color: inherit;
    opacity: 0.6;
}

/* ── Toolbar row wrapper (desktop: transparent passthrough) ── */
#toolbar-row-main {
    display: contents;
}

/* ── Size button icon scales with active size ────────────── */
#size-btn svg circle { transition: r 0.15s; }

/* ── Size picker panel ───────────────────────────────────── */
#size-panel {
    position: absolute;
    top: 112px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    backdrop-filter: blur(16px);
    padding: 12px 18px;
    border-radius: 100px;
    z-index: 50;
}
#size-panel.hidden { display: none; }

.size-opt {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    transition: border-color 0.15s;
    flex-shrink: 0;
}
.size-opt:hover,
.size-opt.hover { border-color: rgba(255,255,255,0.3); }
.size-opt.active { border-color: var(--pink); }

.size-dot {
    display: block;
    border-radius: 50%;
    background: rgba(255,255,255,0.6);
    flex-shrink: 0;
    transition: transform 0.1s;
}
.size-opt.active .size-dot { background: var(--pink); }

/* Each dot size matching the 5 presets */
.size-opt:nth-child(1) .size-dot { width:  6px; height:  6px; }
.size-opt:nth-child(2) .size-dot { width: 10px; height: 10px; }
.size-opt:nth-child(3) .size-dot { width: 16px; height: 16px; }
.size-opt:nth-child(4) .size-dot { width: 22px; height: 22px; }
.size-opt:nth-child(5) .size-dot { width: 30px; height: 30px; }

/* ── Recent colors ───────────────────────────────────────── */
#recent-colors {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    backdrop-filter: blur(14px);
    padding: 8px 14px;
    border-radius: 100px;
    pointer-events: none;
}
.recent-dot {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
}

/* ── Layer panel ─────────────────────────────────────────── */
#layer-panel {
    position: absolute;
    bottom: 60px;
    right: 76px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    backdrop-filter: blur(14px);
    padding: 8px;
    border-radius: 12px;
    pointer-events: none;
}
.layer-item {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.35;
    transition: opacity 0.2s;
    font-size: 9px;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.5);
}
.layer-item.active { opacity: 1; color: var(--cyan); }
.layer-thumb {
    width: 56px; height: 36px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.02);
    display: block;
}
.layer-item.active .layer-thumb { border-color: var(--cyan); }

/* ── Gesture guide ───────────────────────────────────────── */
#gesture-guide {
    position: absolute;
    right: 16px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    backdrop-filter: blur(14px);
    padding: 12px 14px;
    border-radius: 12px;
    pointer-events: none;
}
.g-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    color: rgba(255,255,255,0.45);
}
.g-icon { font-size: 13px; width: 24px; text-align: center; flex-shrink: 0; }

/* ── Color panel (drops from toolbar) ────────────────────── */
#color-panel {
    position: absolute;
    top: 112px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
}
#color-panel.hidden { display: none; }

#cp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}
#cp-header > span {
    font-size: 9px;
    letter-spacing: 4px;
    color: rgba(255,255,255,0.3);
}

#cp-close-zone {
    position: relative;
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
}
#cp-close-zone:hover { background: rgba(255,255,255,0.06); }

#cp-close-ring-svg {
    position: absolute;
    inset: -2px;
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    transform: rotate(-90deg);
}
#cp-close-ring-svg circle {
    fill: none;
    stroke: var(--pink);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-dasharray: 81.7;
    stroke-dashoffset: 81.7;
}
#cp-close-x {
    font-size: 14px;
    color: rgba(255,255,255,0.45);
    line-height: 1;
    position: relative;
    z-index: 1;
}

/* Camera background button */
#cp-camera-row {
    display: flex;
}
#cp-camera-row.hidden { display: none; }
#cp-camera-btn {
    width: 100%;
    background: transparent;
    border: 1px solid var(--cyan);
    color: var(--cyan);
    font-family: var(--font);
    font-size: 9px;
    letter-spacing: 2px;
    padding: 9px 14px;
    border-radius: 100px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    overflow: hidden;
}
#cp-camera-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 100px;
    background: conic-gradient(
        rgba(0,207,255,0.5) calc(var(--dp, 0) * 360deg),
        transparent 0deg
    );
    pointer-events: none;
}
#cp-camera-btn.cp-hover {
    background: rgba(0,207,255,0.08);
}

/* Swatch grid */
#cp-grid {
    display: grid;
    grid-template-columns: repeat(6, 40px);
    gap: 6px;
}

.cp-swatch {
    width: 40px; height: 40px;
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.08);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.1s, border-color 0.1s;
    flex-shrink: 0;
}

.cp-swatch::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: conic-gradient(
        rgba(255,255,255,0.7) calc(var(--dp, 0) * 360deg),
        transparent 0deg
    );
    opacity: 0;
    transition: opacity 0.1s;
}

.cp-swatch.cp-hover::after { opacity: 1; }
.cp-swatch.cp-hover {
    border-color: rgba(255,255,255,0.6);
    transform: scale(1.12);
    z-index: 2;
}
.cp-swatch.cp-confirmed {
    border-color: #fff;
    box-shadow: 0 0 14px #fff;
}
.cp-swatch-sm {
    width: 28px; height: 28px;
    border-radius: 6px;
}

/* Section label */
.cp-section-label {
    font-size: 8px;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.25);
    align-self: center;
    white-space: nowrap;
}

/* Recent row */
#cp-recent-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* Preview strip */
#cp-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0 2px;
    border-top: 1px solid var(--ui-border);
}
#cp-preview-swatch {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
}
#cp-preview-label {
    font-size: 10px;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.45);
    font-family: var(--font);
}

/* ── Export dialog ───────────────────────────────────────── */
#export-dialog {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10,10,10,0.85);
    backdrop-filter: blur(20px);
    z-index: 100;
}
#export-dialog.hidden { display: none; }
#export-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 36px;
    background: rgba(20,20,20,0.95);
    border: 1px solid var(--ui-border);
    border-radius: 16px;
    min-width: 220px;
    text-align: center;
}
#export-box h2 {
    font-size: 11px;
    letter-spacing: 6px;
    color: var(--yellow);
    margin-bottom: 6px;
}
.exp-btn {
    background: transparent;
    border: 1px solid var(--ui-border);
    color: rgba(255,255,255,0.6);
    font-family: var(--font);
    font-size: 10px;
    letter-spacing: 2px;
    padding: 11px 18px;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.15s;
}
.exp-btn:hover,
.exp-btn.hover { border-color: var(--yellow); color: var(--yellow); }
.exp-btn.cancel:hover,
.exp-btn.cancel.hover { border-color: rgba(255,255,255,0.2); color: rgba(255,255,255,0.4); }

/* ── Help button + dialog ────────────────────────────────── */
#help-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(14,14,14,0.88);
    border: 1.5px solid var(--pink);
    color: var(--pink);
    font-family: var(--font);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    backdrop-filter: blur(14px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 90;
    transition: all 0.15s;
}
#help-btn:hover,
#help-btn.hover {
    background: var(--pink);
    color: #000;
    box-shadow: 0 0 14px rgba(255,77,216,0.5);
}

#help-dialog {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10,10,10,0.85);
    backdrop-filter: blur(20px);
    z-index: 200;
    padding: 24px;
}
#help-dialog.hidden { display: none; }
#help-box {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 32px 28px;
    background: rgba(20,20,20,0.95);
    border: 2px solid var(--pink);
    border-radius: 18px;
    max-width: 340px;
    width: 100%;
    text-align: left;
}
#help-box h2 {
    font-size: 11px;
    letter-spacing: 6px;
    color: var(--pink);
    text-align: center;
    margin-bottom: 6px;
}
.help-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255,255,255,0.75);
}
.help-icon {
    font-size: 22px;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}
#help-close {
    margin-top: 10px;
    align-self: center;
}

/* ── Start screen ────────────────────────────────────────── */
@font-face {
    font-family: 'Comico';
    src: url('../../assets/fonts/Comico-Regular.otf') format('opentype');
}

#start-screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10,10,10,0.96);
    z-index: 300;
    backdrop-filter: blur(24px);
}

#start-content {
    text-align: center;
    max-width: 480px;
    width: 100%;
    padding: 48px 40px;
    border: 3px solid var(--pink);
    border-radius: 24px;
    background: rgba(14, 14, 14, 0.9);
    box-shadow: 0 0 40px rgba(255,77,216,0.12);
    margin: 0 20px;
}

#start-content h1 {
    font-family: 'Comico', cursive;
    font-size: clamp(2.8rem, 10vw, 5rem);
    letter-spacing: 4px;
    color: var(--pink);
    margin-bottom: 20px;
    line-height: 1.1;
}

#start-content p {
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    line-height: 1.9;
    margin-bottom: 36px;
    letter-spacing: 0.5px;
}

#start-btn {
    background: transparent;
    color: var(--pink);
    border: 2px solid var(--pink);
    font-family: 'Comico', cursive;
    font-size: 1.1rem;
    letter-spacing: 2px;
    font-weight: bold;
    padding: 16px 36px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-bottom: 16px;
    display: block;
    width: 100%;
}
#start-btn:hover {
    background: var(--pink);
    color: #000;
    transform: scale(1.03) rotate(-1deg);
    box-shadow: 0 0 30px rgba(255,77,216,0.5);
}

.note {
    font-size: 10px;
    color: rgba(255,255,255,0.2);
    letter-spacing: 1px;
}

/* ── Dwell ring ──────────────────────────────────────────── */
.dwell-ring {
    position: absolute;
    inset: -6px;
    pointer-events: none;
    z-index: 10;
}
.dwell-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.dwell-ring circle {
    fill: none;
    stroke: var(--cyan);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-dasharray: 106.8;
    stroke-dashoffset: 106.8;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 600px) {
    #gesture-guide { display: none; }
    #layer-panel   { display: none; }

    /* Toolbar: single compact row */
    #toolbar {
        top: 58px;
        flex-direction: row;
        align-items: center;
        gap: 2px;
        padding: 5px 8px;
        border-radius: 20px;
        max-width: calc(100vw - 16px);
        overflow-x: auto;
        scrollbar-width: none;
    }
    #toolbar::-webkit-scrollbar { display: none; }

    /* Size panel: below toolbar on mobile */
    #size-panel {
        top: 116px;
        gap: 6px;
        padding: 10px 14px;
    }

    /* Status bar: bottom center */
    #status-bar {
        top: auto;
        bottom: 14px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        font-size: 9px;
        padding: 5px 14px;
    }

    /* Color panel: anchor below toolbar, full-safe width */
    #color-panel {
        top: 116px;
        left: 8px;
        right: 8px;
        transform: none;
        max-width: none;
    }
    #cp-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    .cp-swatch { width: 100%; height: 36px; }

    .tool-btn  { width: 36px; height: 36px; }
    .action-btn { width: 36px; height: 36px; }
    #color-swatch { width: 28px; height: 28px; }
    #bg-swatch    { width: 28px; height: 28px; }
    #color-swatch-wrap { gap: 0; flex-shrink: 0; }
    #bg-swatch-wrap    { gap: 0; flex-shrink: 0; }
    .tool-label { display: none; }

    /* Start screen: add desktop-hint note */
    #mobile-hint { display: block; }

    /* Help button visible on mobile only */
    #help-btn { display: flex; }
}

@media (min-width: 601px) {
    #mobile-hint { display: none; }
}
