/* Reading-contest step-by-step tutorial */
#tutorial-root,
#skill-tutorial-root {
    position: fixed;
    inset: 0;
    z-index: 2001;
    pointer-events: none;
}

#tutorial-root > *,
#skill-tutorial-root > * {
    pointer-events: auto;
}

.tutorial-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
}

.tutorial-spotlight {
    position: absolute;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    z-index: 1;
}

.tutorial-highlight {
    position: relative;
    z-index: 2002;
}

.tutorial-lift {
    z-index: 2002 !important;
}

.tutorial-card {
    position: absolute;
    background: var(--panel);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 1.25rem;
    max-width: 360px;
    box-shadow: var(--shadow), 0 0 24px rgba(0, 212, 240, 0.15);
    z-index: 2003;
    animation: tutorialPop 0.25s ease-out;
}

.tutorial-center {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

@keyframes tutorialPop {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tutorial-step-count {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.tutorial-text {
    margin: 0 0 1rem 0;
    color: var(--text);
    line-height: 1.5;
    font-size: 1rem;
}

.tutorial-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.tutorial-hint {
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
}

@media (max-width: 640px) {
    .media-grid {
        grid-template-columns: 1fr;
    }
    .media-video-screen {
        height: 200px;
    }
}

.fx-scanner {
    border: 1px solid rgba(0, 212, 240, 0.5);
    box-shadow: inset 0 0 20px rgba(0, 212, 240, 0.25);
    background: linear-gradient(90deg, transparent 40%, rgba(0, 212, 240, 0.25) 50%, transparent 60%);
    background-size: 200% 100%;
    animation: scannerSweep 0.55s ease-in-out;
}

@keyframes scannerSweep {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.fx-correct {
    animation: correctFlash 0.6s ease;
}

.fx-wrong {
    animation: wrongShake 0.5s ease;
}

@keyframes correctFlash {
    0%, 100% { box-shadow: inset 0 0 0 0 rgba(105, 240, 174, 0); }
    50% { box-shadow: inset 0 0 30px 4px rgba(105, 240, 174, 0.35); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.fx-core-burst {
    animation: coreBurst 0.6s ease;
}

@keyframes coreBurst {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 212, 240, 0.5); }
    50% { transform: scale(1.15); box-shadow: 0 0 30px 10px rgba(0, 212, 240, 0.2); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 212, 240, 0); }
}

.fx-train-pulse {
    animation: trainPulse 1.4s ease-in-out;
}

@keyframes trainPulse {
    0%, 100% { opacity: 0.15; transform: translate(-50%, -50%) scale(0.9); }
    50% { opacity: 0.45; transform: translate(-50%, -50%) scale(1.1); }
}

.fx-flash {
    animation: avatarFlash 0.4s ease;
}

@keyframes avatarFlash {
    0%, 100% { filter: drop-shadow(0 0 16px rgba(255, 152, 0, 0.35)); }
    50% { filter: drop-shadow(0 0 40px rgba(255, 152, 0, 0.9)); }
}

.fx-particle {
    position: absolute;
    pointer-events: none;
    box-shadow: 0 0 6px currentColor;
    transition: transform 0.5s ease-out, opacity 0.5s ease-out;
}

.fx-hub-confetti {
    position: absolute;
    pointer-events: none;
    box-shadow: 0 0 8px currentColor;
    transition: transform 1.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 1.4s ease-out;
    z-index: 1001;
}

.fx-glitch {
    animation: glitchShake 0.5s steps(4) both;
}

@keyframes glitchShake {
    0%, 100% { transform: translate(0); filter: none; }
    20% { transform: translate(-3px, 2px); filter: drop-shadow(2px 0 var(--error)); }
    40% { transform: translate(3px, -2px); filter: drop-shadow(-2px 0 var(--accent)); }
    60% { transform: translate(-2px, -1px); filter: drop-shadow(2px 0 var(--error)); }
    80% { transform: translate(2px, 1px); filter: drop-shadow(-2px 0 var(--accent)); }
}

.fx-phase-flash {
    animation: phaseFlash 0.5s ease;
}

@keyframes phaseFlash {
    0%, 100% { box-shadow: inset 0 0 0 0 rgba(0, 212, 240, 0); }
    50% { box-shadow: inset 0 0 60px 10px rgba(0, 212, 240, 0.08); }
}

.fx-phase-pulse {
    animation: phasePulse 0.8s ease;
}

@keyframes phasePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); background: rgba(0, 212, 240, 0.2); }
}

.fx-reaction-pop {
    animation: reactionPop 0.5s ease;
}

@keyframes reactionPop {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

/* Mood ring around Entropy */
.entropy-avatar::before {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px solid rgba(255, 152, 0, 0.4);
    animation: moodSpin 8s linear infinite;
    pointer-events: none;
}

.entropy-avatar.happy::before { border-color: rgba(105, 240, 174, 0.55); }
.entropy-avatar.concerned::before { border-color: rgba(255, 82, 82, 0.55); }
.entropy-avatar.thinking::before { border-color: rgba(255, 179, 0, 0.55); animation-duration: 2s; }
.entropy-avatar.confused::before { border-color: rgba(255, 152, 0, 0.4); animation-direction: reverse; }

@keyframes moodSpin {
    to { transform: rotate(360deg); }
}

/* Typing cursor for Entropy message */
.entropy-panel .message.typing::after {
    content: '|';
    color: var(--accent);
    animation: blink 0.8s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Entrance animations */
.field-grid .source-card,
.quality-card,
.chart-container,
.report-option,
.reaction-card {
    animation: cardIn 0.4s ease both;
}

.field-grid .source-card:nth-child(1) { animation-delay: 0.05s; }
.field-grid .source-card:nth-child(2) { animation-delay: 0.1s; }
.field-grid .source-card:nth-child(3) { animation-delay: 0.15s; }
.field-grid .source-card:nth-child(4) { animation-delay: 0.2s; }

.quality-card:nth-of-type(1) { animation-delay: 0.05s; }
.quality-card:nth-of-type(2) { animation-delay: 0.1s; }
.quality-card:nth-of-type(3) { animation-delay: 0.15s; }

.report-option:nth-child(1) { animation-delay: 0.05s; }
.report-option:nth-child(2) { animation-delay: 0.1s; }
.report-option:nth-child(3) { animation-delay: 0.15s; }

.reaction-card:nth-child(1) { animation-delay: 0.1s; }
.reaction-card:nth-child(2) { animation-delay: 0.2s; }
.reaction-card:nth-child(3) { animation-delay: 0.3s; }

@keyframes cardIn {
    from { opacity: 0.92; transform: translateY(10px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Active phase icon glow */
.phase-list li.active .phase-icon {
    animation: iconGlow 2s ease-in-out infinite;
}

.reaction-card:nth-child(1) { animation-delay: 0.1s; }
.reaction-card:nth-child(2) { animation-delay: 0.2s; }
.reaction-card:nth-child(3) { animation-delay: 0.3s; }

@keyframes cardIn {
    from { opacity: 0.92; transform: translateY(10px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Active phase icon glow */
.phase-list li.active .phase-icon {
    animation: iconGlow 2s ease-in-out infinite;
}

@keyframes iconGlow {
    0%, 100% { filter: drop-shadow(0 0 2px rgba(0, 212, 240, 0.4)); }
    50% { filter: drop-shadow(0 0 8px rgba(0, 212, 240, 0.8)); }
}

/* Onboarding tour */
#onboarding-root {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
}

#onboarding-root > * {
    pointer-events: auto;
}

.onboard-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    animation: fadeIn 0.3s ease;
}

.onboard-spotlight {
    position: absolute;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    animation: spotlightIn 0.3s ease;
    pointer-events: none;
}

@keyframes spotlightIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.onboard-highlight {
    position: relative;
    z-index: 201;
}

.onboard-card {
    position: absolute;
    width: 320px;
    background: var(--panel);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 212, 240, 0.15);
    animation: cardPop 0.3s ease;
    z-index: 202;
}

@keyframes cardPop {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.onboard-step-count {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.onboard-card h3 {
    margin: 0 0 0.5rem 0;
    color: var(--accent);
    font-size: 1.25rem;
}

.onboard-card p {
    margin: 0 0 1rem 0;
    color: var(--text);
    line-height: 1.55;
}

.onboard-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.onboard-spacer {
    flex: 1;
}

/* How to play and Settings: kit windows (static/js/house.mjs) in the game's type. */
.ee-window { width: min(640px, calc(100vw - 2rem)); max-height: 84vh; color: var(--text); }
.ee-window::backdrop { background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(4px); }
.ee-window .tn-window-bar h2 { margin: 0; font-size: 1.2rem; color: var(--accent); }
.ee-window h3 { color: var(--entropy); margin: 1.25rem 0 0.5rem; }
.ee-window .tn-window-body > h3:first-child { margin-top: 0; }
.ee-window ul { padding-left: 1.25rem; line-height: 1.6; margin: 0; }
.ee-window li { margin-bottom: 0.35rem; }
.ee-window .tn-btn { min-height: var(--tap); }
.ee-settings { width: min(420px, calc(100vw - 2rem)); }

@media (max-width: 640px) {
    .onboard-card {
        width: calc(100vw - 2rem);
        left: 1rem !important;
        right: 1rem;
        top: 50% !important;
        transform: translateY(-50%);
    }
}



/* The first case's walkthrough (static/js/first_case.js): a card beside the lit control, nothing covered. */
#first-case-root .first-case-card {
    position: fixed;
    z-index: 2003;
    width: min(360px, calc(100vw - 32px));
    background: var(--panel);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow), 0 0 24px rgba(0, 212, 240, 0.15);
    animation: tutorialPop 0.25s ease-out;
}

#first-case-root .first-case-card.docked {
    left: 16px !important;
    right: 16px;
    top: auto !important;
    bottom: 16px;
    width: auto;
    max-height: 40vh;
    overflow-y: auto;
}

/* Its top line is the bar it is dragged by (engine core/dragwin.mjs). */
#first-case-root .first-case-bar {
    cursor: grab;
    touch-action: none;
    user-select: none;
}

body.dw-grabbing, body.dw-grabbing * { cursor: grabbing !important; }

#first-case-root .first-case-card.dw-ease { transition: translate var(--dw-ease) ease-out; }

.first-case-lit {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
    border-radius: 6px;
    animation: firstCasePulse 1.6s ease-in-out infinite;
}

@keyframes firstCasePulse {
    50% { outline-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    .first-case-lit { animation: none; }
}

.first-case-later {
    display: none !important;
}
