/* Control the Protocol — dark theme with bright orange accents */

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

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #0a0a0a 0%, #201409 50%, #0a0a0a 100%);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #e0e0e0;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(255, 122, 26, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(255, 180, 60, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.hidden { display: none !important; }

.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    padding: 2rem 1rem;
    text-align: center;
}

.logo {
    max-width: 320px;
    width: 60vw;
    height: auto;
    filter: drop-shadow(0 0 20px rgba(255, 122, 26, 0.3));
}

h1 { font-size: 2.2rem; color: #ffc078; }
.subtitle { color: #aaa; font-size: 1.1rem; max-width: 520px; }
.subtitle a { color: #ffb066; }

/* ---- code card ---- */
.code-card {
    background: rgba(30, 22, 14, 0.55);
    border: 1px solid rgba(255, 122, 26, 0.25);
    border-radius: 12px;
    padding: 1.6rem 2.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.code-display {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: 0.35rem;
    color: #ffc078;
    text-shadow: 0 0 18px rgba(255, 122, 26, 0.6);
    user-select: all;
}

.code-status { color: #888; font-size: 0.95rem; min-height: 1.2em; }
.code-status.warn { color: #ffb300; }
.code-status.good { color: #6fdc8c; }

.steps {
    text-align: left;
    color: #aaa;
    max-width: 460px;
    line-height: 1.9;
    padding-left: 1.4rem;
}
.steps strong { color: #ffc078; }

/* ---- buttons ---- */
.btn-primary {
    padding: 0.85rem 2.2rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #ff7a1a 0%, #e85d04 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 122, 26, 0.4);
}
.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 122, 26, 0.6);
    background: linear-gradient(135deg, #ffa040 0%, #ff7a1a 100%);
}

.btn-secondary {
    padding: 0.5rem 1.2rem;
    font-size: 0.95rem;
    color: #ccc;
    background: rgba(30, 22, 14, 0.8);
    border: 1px solid rgba(255, 122, 26, 0.35);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-secondary:hover { background: rgba(255, 122, 26, 0.25); color: #fff; }

/* ---- active control screen ---- */
#screen-active { gap: 0.6rem; justify-content: flex-start; padding-top: 1rem; }

.hud {
    display: flex;
    align-items: center;
    gap: 1.4rem;
}
.logo-mini { height: 42px; width: auto; filter: drop-shadow(0 0 10px rgba(255, 122, 26, 0.4)); }

.session-timer {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 1.6rem;
    font-weight: 700;
    color: #ffc078;
    min-width: 4.5ch;
}
.session-timer.low { color: #f44336; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.stage-wrap {
    position: relative;
    width: min(96vw, calc((100vh - 140px) * 16 / 9));
    aspect-ratio: 16 / 9;
    background: rgba(14, 10, 6, 0.75);
    border: 1px solid rgba(255, 122, 26, 0.45);
    border-radius: 8px;
    overflow: hidden;
    cursor: none;
    touch-action: none;
    box-shadow: 0 0 35px rgba(255, 122, 26, 0.25);
}

#stage-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.sticker-layer {
    position: absolute;
    inset: 0;
    pointer-events: none; /* individual stickers re-enable */
}

.protocol-sticker {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: calc(4.5vw * var(--sticker-scale, 1));
    line-height: 1;
    pointer-events: auto;
    cursor: grab;
    user-select: none;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.55));
    /* land with a pop, then jiggle for the rest of the session */
    animation: stickerPop 0.35s ease, stickerJiggle 1.6s ease-in-out 0.35s infinite;
}
.protocol-sticker:active { cursor: grabbing; }
@keyframes stickerPop {
    0% { transform: translate(-50%, -50%) scale(0.2); }
    70% { transform: translate(-50%, -50%) scale(1.25); }
    100% { transform: translate(-50%, -50%) scale(1); }
}
@keyframes stickerJiggle {
    0%, 100% { transform: translate(-50%, -50%) rotate(-4deg); }
    50% { transform: translate(-50%, -50%) rotate(4deg); }
}

.stage-hint { color: #666; font-size: 0.9rem; }

/* ---- treasure chest ---- */
.chest-btn {
    position: absolute;
    right: 14px;
    bottom: 14px;
    width: 58px;
    height: 58px;
    font-size: 1.9rem;
    background: rgba(30, 22, 14, 0.85);
    border: 1px solid rgba(255, 122, 26, 0.5);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    z-index: 20;
}
.chest-btn:hover { transform: scale(1.12); box-shadow: 0 0 18px rgba(255, 122, 26, 0.7); }

.chest-panel {
    position: absolute;
    right: 14px;
    bottom: 84px;
    width: 300px;
    max-height: 70%;
    overflow-y: auto;
    background: rgba(22, 15, 8, 0.95);
    border: 1px solid rgba(255, 122, 26, 0.45);
    border-radius: 12px;
    padding: 0.8rem;
    z-index: 21;
    cursor: default;
    text-align: left;
}

.chest-tabs { display: flex; gap: 0.4rem; margin-bottom: 0.7rem; }
.chest-tab {
    flex: 1;
    padding: 0.45rem 0.3rem;
    background: rgba(30, 22, 14, 0.8);
    border: 1px solid rgba(255, 122, 26, 0.25);
    border-radius: 8px;
    color: #aaa;
    cursor: pointer;
    font-size: 0.85rem;
}
.chest-tab.active { background: rgba(255, 122, 26, 0.35); color: #fff; border-color: #ff7a1a; }

.chest-hint { color: #888; font-size: 0.8rem; margin-bottom: 0.5rem; }

#chest-tab-sounds { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
.sound-btn {
    padding: 0.6rem 0.4rem;
    background: rgba(30, 22, 14, 0.85);
    border: 1px solid rgba(255, 122, 26, 0.3);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.sound-btn:hover { background: rgba(255, 122, 26, 0.3); }
.sound-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.sticker-palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.palette-sticker {
    font-size: 1.9rem;
    text-align: center;
    padding: 0.35rem 0;
    background: rgba(30, 22, 14, 0.85);
    border: 1px solid rgba(255, 122, 26, 0.25);
    border-radius: 8px;
    cursor: grab;
    user-select: none;
    transition: all 0.15s ease;
}
.palette-sticker:hover { background: rgba(255, 122, 26, 0.3); transform: scale(1.08); }

.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #ccc;
    padding: 0.45rem 0.2rem;
    cursor: pointer;
    font-size: 0.95rem;
}
.toggle-row input { accent-color: #ff7a1a; width: 18px; height: 18px; }
