/* 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;
    justify-content: center;
    gap: 1.4rem;
    position: relative;
    width: min(96vw, calc((100vh - 140px) * 16 / 9));
}

/* speaker toggle — top-right corner, just outside the viewport */
.speaker-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff7a1a;
    background: rgba(30, 22, 14, 0.85);
    border: 1px solid rgba(255, 122, 26, 0.5);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.speaker-btn:hover { transform: translateY(-50%) scale(1.1); box-shadow: 0 0 14px rgba(255, 122, 26, 0.6); }
.speaker-btn.muted { color: #8a6a4a; border-color: rgba(255, 122, 26, 0.25); }
.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; }
.stage-warning { color: #ffb300; font-size: 0.85rem; opacity: 0.85; }

/* ---- treasure chest ---- */
.chest-btn {
    position: absolute;
    right: 14px;
    bottom: 14px;
    width: 174px;
    height: 174px;
    padding: 10px;
    background: rgba(30, 22, 14, 0.85);
    border: 1px solid rgba(255, 122, 26, 0.5);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    z-index: 20;
}
.chest-btn img { width: 100%; height: 100%; object-fit: contain; display: block; }
.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: 14px;
    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;
}

/* onboarding callout: jiggly arrow + tooltip over the lootbox (15s at session start) */
.chest-callout {
    position: absolute;
    right: 14px;
    bottom: 198px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    z-index: 19;
}
.callout-tip {
    background: rgba(22, 15, 8, 0.96);
    border: 1px solid rgba(255, 122, 26, 0.55);
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
    color: #e0e0e0;
    font-size: 0.85rem;
    line-height: 1.45;
    max-width: 300px;
    text-align: left;
    box-shadow: 0 0 18px rgba(255, 122, 26, 0.3);
    margin-bottom: 4px;
}
.callout-arrow {
    font-size: 2.6rem;
    margin-right: 62px; /* centers over the chest */
    filter: drop-shadow(0 0 10px rgba(255, 122, 26, 0.8));
    animation: calloutBounce 0.9s ease-in-out infinite;
}
@keyframes calloutBounce {
    0%, 100% { transform: translateY(0) rotate(-6deg); }
    50% { transform: translateY(10px) rotate(6deg); }
}

/* floating zoom preview beside the chest menu */
.hover-preview {
    position: absolute;
    right: 336px;
    bottom: 20px;
    min-width: 150px;
    padding: 0.9rem;
    background: rgba(22, 15, 8, 0.95);
    border: 1px solid rgba(255, 122, 26, 0.45);
    border-radius: 12px;
    text-align: center;
    pointer-events: none;
    z-index: 22;
}
.hover-preview .hp-glyph { font-size: 5rem; line-height: 1.1; }
.hover-preview img { width: 120px; height: 120px; object-fit: contain; display: block; margin: 0 auto; }
.hover-preview .hp-name { color: #ffc078; font-size: 0.85rem; margin-top: 0.4rem; }

.chest-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 1rem;
    cursor: pointer;
    z-index: 1;
}
.chest-close:hover { color: #ff7a1a; }

.chest-tabs { display: flex; gap: 0.4rem; margin-bottom: 0.7rem; padding-right: 26px; }
.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); }

/* collectible rewards divider in the sticker tab */
.collect-divider {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #ffb066;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0.7rem 0 0.45rem;
}
.collect-divider::before, .collect-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(255, 122, 26, 0.35);
}
.palette-sticker img { width: 1.9rem; height: 1.9rem; object-fit: contain; display: block; margin: 0 auto; }

/* cursor skin picker */
.cursor-palette { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
.cursor-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    background: rgba(30, 22, 14, 0.85);
    border: 1px solid rgba(255, 122, 26, 0.25);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.cursor-option:hover { background: rgba(255, 122, 26, 0.3); }
.cursor-option.active { border-color: #ff7a1a; background: rgba(255, 122, 26, 0.35); color: #fff; }
.cursor-option .cur-preview { font-size: 1.3rem; }

.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; }
