/* ===== Error Scene System ===== */

/* --- Base --- */
.error-scene {
    --err-color: #7c5cbf;
    --err-color-alt: #5a3d9e;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    overflow: hidden;
    background: var(--background-color, #f0f1f3);
    font-family: var(--font, 'Poppins', sans-serif);
}

.error-scene::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 25% 50%, color-mix(in srgb, var(--err-color) 5%, transparent) 0%, transparent 55%),
        radial-gradient(ellipse at 75% 50%, color-mix(in srgb, var(--err-color-alt) 5%, transparent) 0%, transparent 55%);
    pointer-events: none;
}

/* Partículas */
.err-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    transition: transform 0.3s ease-out;
}

.err-particle {
    position: absolute;
    border-radius: 50%;
    background: var(--err-color);
    opacity: 0;
    animation: errFloat linear infinite;
}

@keyframes errFloat {
    0%   { opacity: 0; transform: translateY(0) scale(0.4); }
    10%  { opacity: 0.3; }
    90%  { opacity: 0.08; }
    100% { opacity: 0; transform: translateY(-400px) scale(0.1); }
}

/* Conteúdo */
.err-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 20px;
    width: 100%;
    transition: transform 0.2s ease-out;
}

/* Palco da cena */
.err-stage {
    position: relative;
    width: 100%;
    height: 220px;
    margin-bottom: 20px;
    overflow: hidden;
}

/* Chão compartilhado */
.err-ground {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: color-mix(in srgb, var(--err-color) 30%, transparent);
    border-radius: 2px;
}

/* Texto */
.err-title {
    font-size: clamp(20px, 3.5vw, 28px);
    font-weight: 700;
    color: var(--text-color, #2c2c3a);
    margin: 0 0 8px;
    opacity: 0;
    animation: errFadeIn 0.6s ease-out 0.3s forwards;
}

.err-subtitle {
    font-size: clamp(13px, 2vw, 16px);
    color: color-mix(in srgb, var(--text-color, #2c2c3a) 55%, transparent);
    line-height: 1.7;
    margin: 0 0 28px;
    opacity: 0;
    animation: errFadeIn 0.6s ease-out 0.5s forwards;
}

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

.err-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 8px;
}

.err-btn-secondary {
    border-color: color-mix(in srgb, var(--err-color) 45%, #888);
    color: color-mix(in srgb, var(--err-color) 70%, #555);
}

/* Botão */
.err-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    border: 1.5px solid var(--err-color);
    border-radius: 10px;
    background: transparent;
    color: var(--err-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    animation: errFadeIn 0.6s ease-out 0.7s forwards;
    text-decoration: none;
    font-family: inherit;
}

.err-btn:hover {
    background: var(--err-color);
    color: #fff;
    box-shadow: 0 4px 20px color-mix(in srgb, var(--err-color) 30%, transparent);
    transform: translateY(-2px);
}

.err-btn svg {
    width: 16px;
    height: 16px;
}


/* ===== CENA 404 — Explorador perdido ===== */

/* Terreno ondulado — camadas de profundidade */
.err-terrain {
    position: absolute;
    bottom: 0;
    left: -5%;
    right: -5%;
    height: 35px;
    background: color-mix(in srgb, var(--err-color) 12%, #d5cfc5);
    border-radius: 80% 80% 0 0 / 18px 18px 0 0;
}

.err-terrain-back {
    position: absolute;
    bottom: 18px;
    left: -5%;
    right: -5%;
    height: 25px;
    background: color-mix(in srgb, var(--err-color) 8%, #e0dbd2);
    border-radius: 60% 70% 0 0 / 14px 14px 0 0;
    z-index: 0;
}

/* Nuvens */
.err-cloud {
    position: absolute;
    background: color-mix(in srgb, var(--err-color) 10%, transparent);
    border-radius: 50px;
    height: 12px;
}

.err-cloud::before, .err-cloud::after {
    content: '';
    position: absolute;
    background: inherit;
    border-radius: 50%;
}

.err-cloud::before { width: 16px; height: 16px; top: -9px; left: 10px; }
.err-cloud::after  { width: 11px; height: 11px; top: -5px; right: 8px; }

.err-cloud-1 { width: 55px; top: 15px; animation: errCloudMove 20s linear infinite; }
.err-cloud-2 { width: 40px; top: 38px; opacity: 0.5; animation: errCloudMove 26s linear infinite; animation-delay: -10s; }
.err-cloud-3 { width: 30px; top: 55px; opacity: 0.35; animation: errCloudMove 22s linear infinite; animation-delay: -16s; }

@keyframes errCloudMove {
    0%   { left: -80px; }
    100% { left: 110%; }
}

/* Estrelas piscando */
.err-star {
    position: absolute;
    width: 3px;
    height: 3px;
    background: color-mix(in srgb, var(--err-color) 40%, #aaa);
    border-radius: 50%;
    animation: errStarBlink 3s ease-in-out infinite;
}

.err-star-1 { top: 12px; left: 20%; animation-delay: 0s; }
.err-star-2 { top: 28px; left: 75%; animation-delay: 1s; }
.err-star-3 { top: 8px;  left: 55%; animation-delay: 2s; width: 2px; height: 2px; }
.err-star-4 { top: 40px; left: 35%; animation-delay: 0.5s; width: 2px; height: 2px; }
.err-star-5 { top: 18px; left: 88%; animation-delay: 1.5s; }

@keyframes errStarBlink {
    0%, 100% { opacity: 0.2; }
    50%      { opacity: 0.8; }
}

/* Placa 404 na bifurcação */
.err-sign {
    position: absolute;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.err-sign-post {
    width: 4px;
    height: 65px;
    background: color-mix(in srgb, var(--err-color) 45%, #8b7355);
    margin: 0 auto;
    border-radius: 1px;
}

.err-sign-board {
    width: 80px;
    height: 34px;
    background: color-mix(in srgb, var(--err-color) 15%, #e8e0d4);
    border: 2px solid color-mix(in srgb, var(--err-color) 35%, #8b7355);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 900;
    color: var(--err-color);
    letter-spacing: 2px;
    transform-origin: bottom center;
    animation: errSignSway 4s ease-in-out infinite;
}

@keyframes errSignSway {
    0%, 100% { transform: rotate(-1.5deg); }
    50%      { transform: rotate(1.5deg); }
}

/* Setas da bifurcação (quebradas) */
.err-sign-arrows {
    position: absolute;
    top: 38px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    display: flex;
    justify-content: space-between;
}

.err-sign-arrow {
    width: 22px;
    height: 3px;
    background: color-mix(in srgb, var(--err-color) 30%, #8b7355);
    border-radius: 1px;
    position: relative;
}

.err-sign-arrow::after {
    content: '';
    position: absolute;
    top: -3px;
    width: 8px;
    height: 8px;
    border-top: 2.5px solid color-mix(in srgb, var(--err-color) 30%, #8b7355);
}

.err-sign-arrow-l::after { left: 0; border-left: 2.5px solid color-mix(in srgb, var(--err-color) 30%, #8b7355); transform: rotate(-45deg); }
.err-sign-arrow-r::after { right: 0; border-right: 2.5px solid color-mix(in srgb, var(--err-color) 30%, #8b7355); transform: rotate(45deg); }

/* Risco nas setas (quebradas) */
.err-sign-arrow::before {
    content: '';
    position: absolute;
    top: -4px;
    width: 16px;
    height: 10px;
    border-bottom: 2px solid color-mix(in srgb, var(--err-color) 25%, #c44);
    transform: rotate(-20deg);
}

.err-sign-arrow-l::before { left: 2px; }
.err-sign-arrow-r::before { right: 2px; transform: rotate(20deg); }

/* Tumbleweed */
.err-tumbleweed {
    position: absolute;
    bottom: 28px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--err-color) 25%, #a89070);
    background: color-mix(in srgb, var(--err-color) 8%, transparent);
    animation: errTumble 12s linear infinite;
    z-index: 1;
}

.err-tumbleweed::before {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    border: 1.5px dashed color-mix(in srgb, var(--err-color) 15%, #a89070);
}

@keyframes errTumble {
    0%   { left: 110%; transform: rotate(0deg); opacity: 0; }
    5%   { opacity: 0.7; }
    90%  { opacity: 0.5; }
    100% { left: -30px; transform: rotate(-720deg); opacity: 0; }
}

/* Personagem 404 */
.err-person {
    position: absolute;
    bottom: 28px;
    z-index: 3;
    animation: errPersonWalk 12s ease-in-out infinite;
}

@keyframes errPersonWalk {
    0%        { left: -30px; }
    25%       { left: calc(50% - 65px); }
    100%      { left: calc(50% - 65px); }
}

/* Cabeça */
.err-person-head {
    width: 16px;
    height: 16px;
    background: color-mix(in srgb, var(--err-color) 60%, #555);
    border-radius: 50%;
    margin: 0 auto 2px;
    position: relative;
    animation: errHeadLook 12s ease-in-out infinite;
}

@keyframes errHeadLook {
    0%, 25%   { transform: translateX(0); }
    35%       { transform: translateX(-3px); }
    42%       { transform: translateX(3px); }
    50%, 100% { transform: translateX(0); }
}

/* Corpo */
.err-person-body {
    width: 10px;
    height: 22px;
    background: color-mix(in srgb, var(--err-color) 45%, #666);
    border-radius: 3px 3px 0 0;
    margin: 0 auto;
    position: relative;
}

/* Mochila */
.err-backpack {
    position: absolute;
    top: 2px;
    right: -7px;
    width: 7px;
    height: 12px;
    background: color-mix(in srgb, var(--err-color) 35%, #8b7355);
    border-radius: 2px;
    border: 1px solid color-mix(in srgb, var(--err-color) 25%, #6b5535);
}

/* Pernas */
.err-person-legs {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.err-person-leg {
    width: 4px;
    height: 18px;
    background: color-mix(in srgb, var(--err-color) 35%, #777);
    border-radius: 0 0 2px 2px;
    transform-origin: top center;
}

.err-person-leg-l { animation: errLegLeft 0.6s ease-in-out infinite; }
.err-person-leg-r { animation: errLegRight 0.6s ease-in-out infinite; }

@keyframes errLegLeft {
    0%, 100% { transform: rotate(15deg); }
    50%      { transform: rotate(-15deg); }
}

@keyframes errLegRight {
    0%, 100% { transform: rotate(-15deg); }
    50%      { transform: rotate(15deg); }
}

.err-person.paused .err-person-leg-l,
.err-person.paused .err-person-leg-r {
    animation-play-state: paused;
}

/* Braço com mapa */
.err-arm-map {
    position: absolute;
    top: 4px;
    left: -6px;
    width: 5px;
    height: 12px;
    background: color-mix(in srgb, var(--err-color) 50%, #666);
    border-radius: 2px;
    transform-origin: top center;
    transform: rotate(5deg);
    opacity: 0;
    animation: errArmMap 12s ease-in-out infinite;
}

@keyframes errArmMap {
    0%, 25%  { opacity: 0; transform: rotate(5deg); }
    30%      { opacity: 1; transform: rotate(-40deg); }
    50%      { opacity: 1; transform: rotate(-40deg); }
    55%      { opacity: 1; transform: rotate(5deg); }
    60%      { opacity: 0; }
    100%     { opacity: 0; }
}

/* Mapa na ponta do braço */
.err-map {
    position: absolute;
    bottom: -2px;
    left: -8px;
    width: 14px;
    height: 11px;
    background: color-mix(in srgb, var(--err-color) 10%, #f5e6c8);
    border: 1px solid color-mix(in srgb, var(--err-color) 25%, #c9a96e);
    border-radius: 1px;
}

.err-map::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 2px;
    right: 2px;
    height: 1px;
    background: color-mix(in srgb, var(--err-color) 20%, #c9a96e);
    box-shadow: 0 3px 0 color-mix(in srgb, var(--err-color) 15%, #c9a96e);
}

/* Interrogação */
.err-question {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    font-weight: 900;
    color: var(--err-color);
    opacity: 0;
    animation: errQuestion 12s ease-in-out infinite;
}

@keyframes errQuestion {
    0%, 32%  { opacity: 0; transform: translateX(-50%) translateY(0); }
    36%      { opacity: 1; transform: translateX(-50%) translateY(-6px); }
    48%      { opacity: 1; transform: translateX(-50%) translateY(-6px); }
    52%      { opacity: 0; transform: translateX(-50%) translateY(-12px); }
    100%     { opacity: 0; }
}

/* Coçar cabeça — mão aparece no topo */
.err-scratch {
    position: absolute;
    top: -2px;
    right: -4px;
    width: 5px;
    height: 5px;
    background: color-mix(in srgb, var(--err-color) 55%, #666);
    border-radius: 50%;
    opacity: 0;
    animation: errScratch 12s ease-in-out infinite;
}

@keyframes errScratch {
    0%, 44%  { opacity: 0; }
    46%      { opacity: 1; transform: translateX(0); }
    48%      { transform: translateX(-2px); }
    50%      { transform: translateX(1px); }
    52%      { transform: translateX(-1px); }
    54%      { opacity: 1; transform: translateX(0); }
    56%      { opacity: 0; }
    100%     { opacity: 0; }
}

/* Encolher ombros */
.err-shrug-l, .err-shrug-r {
    position: absolute;
    top: 2px;
    width: 5px;
    height: 8px;
    background: color-mix(in srgb, var(--err-color) 45%, #666);
    border-radius: 2px;
    transform-origin: bottom center;
    opacity: 0;
}

.err-shrug-l { left: -5px; animation: errShrugL 12s ease-in-out infinite; }
.err-shrug-r { right: -5px; animation: errShrugR 12s ease-in-out infinite; }

@keyframes errShrugL {
    0%, 56%  { opacity: 0; transform: rotate(0deg) translateY(0); }
    60%      { opacity: 1; transform: rotate(-10deg) translateY(-3px); }
    68%      { opacity: 1; transform: rotate(-10deg) translateY(-3px); }
    72%      { opacity: 0; transform: rotate(0deg) translateY(0); }
    100%     { opacity: 0; }
}

@keyframes errShrugR {
    0%, 56%  { opacity: 0; transform: rotate(0deg) translateY(0); }
    60%      { opacity: 1; transform: rotate(10deg) translateY(-3px); }
    68%      { opacity: 1; transform: rotate(10deg) translateY(-3px); }
    72%      { opacity: 0; transform: rotate(0deg) translateY(0); }
    100%     { opacity: 0; }
}

/* Sentado (pernas mudam de posição) */
.err-person.sitting .err-person-legs {
    gap: 8px;
}

.err-person.sitting .err-person-leg {
    height: 10px;
    transform: rotate(0deg) !important;
    animation: none !important;
}

.err-person.sitting .err-person-body {
    height: 18px;
}

/* Suspiro (bolinha sobe) */
.err-sigh {
    position: absolute;
    top: -8px;
    left: -10px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1.5px solid color-mix(in srgb, var(--err-color) 30%, transparent);
    opacity: 0;
    animation: errSigh 12s ease-out infinite;
}

@keyframes errSigh {
    0%, 76%  { opacity: 0; transform: translateY(0) scale(0.5); }
    80%      { opacity: 0.6; transform: translateY(-8px) scale(0.8); }
    88%      { opacity: 0; transform: translateY(-25px) scale(1.2); }
    100%     { opacity: 0; }
}


/* ===== CENA 500 — Engrenagens (1 cima, 2 baixo) ===== */

/* Container */
.err-gears-group {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 130px;
    height: 105px;
}

/* 500 acima */
.err-gear-code {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 32px;
    font-weight: 900;
    color: var(--err-color);
    letter-spacing: 3px;
    z-index: 3;
    animation: errGlitch 10s ease-in-out infinite;
}

@keyframes errGlitch {
    0%, 18%, 26%, 100% { transform: translateX(-50%); filter: none; }
    20% { transform: translateX(calc(-50% - 3px)) skewX(-2deg); filter: hue-rotate(30deg); }
    22% { transform: translateX(calc(-50% + 3px)) skewX(2deg); filter: hue-rotate(-30deg); }
    24% { transform: translateX(calc(-50% - 1px)); filter: none; }
}

/* Engrenagem base */
.err-gear {
    position: absolute;
    width: 48px;
    height: 48px;
}

.err-gear svg {
    width: 100%;
    height: 100%;
    color: color-mix(in srgb, var(--err-color) 50%, #888);
}

/* Triângulo invertido: 1 em cima centro, 2 embaixo (mais juntas) */
.err-gear-top {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.err-gear-bl {
    bottom: 0;
    left: 2px;
}

.err-gear-br {
    bottom: 0;
    right: 2px;
}

/* Rotações: vizinhas em sentidos opostos */
.err-gear-top svg { animation: errGearCW 4s linear infinite; }
.err-gear-bl svg  { animation: errGearCCW 4s linear infinite; }
.err-gear-br svg  { animation: errGearCW 4s linear infinite; }

@keyframes errGearCW  { to { transform: rotate(360deg); } }
@keyframes errGearCCW { to { transform: rotate(-360deg); } }

/* Engrenagem direita-baixo cai (loop 10s) */
.err-gear-br.err-gear-fall {
    animation: errGearFall 10s ease-in-out infinite;
}

/* Rotação normal — JS adiciona/remove .err-gear-stopped pra pausar */
.err-gear-br svg {
    animation: errGearCW 4s linear infinite;
}

.err-gear-stopped svg {
    animation-play-state: paused !important;
}

@keyframes errGearFall {
    0%, 20%  { bottom: 0; right: 2px; transform: rotate(0deg); opacity: 1; }
    28%      { bottom: -8px; right: -5px; transform: rotate(15deg); opacity: 1; }
    35%      { bottom: -25px; right: -20px; transform: rotate(35deg); opacity: 0.7; }
    38%, 72% { bottom: -25px; right: -20px; transform: rotate(35deg); opacity: 0.7; }
    80%      { bottom: 0; right: 2px; transform: rotate(0deg); opacity: 1; }
    100%     { bottom: 0; right: 2px; transform: rotate(0deg); opacity: 1; }
}

/* Faíscas — saem da engrenagem direita-baixo, mais visíveis */
.err-spark {
    position: absolute;
    width: 5px;
    height: 5px;
    background: #ffaa00;
    border-radius: 50%;
    opacity: 0;
    box-shadow: 0 0 6px 2px #ffd700, 0 0 12px 4px #ff6600;
}

.err-spark-1, .err-spark-2, .err-spark-3,
.err-spark-4, .err-spark-5 {
    bottom: 45px;
    left: calc(50% + 25px);
}

.err-spark-1 { animation: errSparkA 10s ease-out infinite; }
.err-spark-2 { animation: errSparkB 10s ease-out infinite; }
.err-spark-3 { animation: errSparkC 10s ease-out infinite; }
.err-spark-4 { animation: errSparkD 10s ease-out infinite; }
.err-spark-5 { animation: errSparkE 10s ease-out infinite; }

@keyframes errSparkA {
    0%, 18%  { opacity: 0; transform: translate(0,0); }
    20%      { opacity: 1; transform: translate(10px, -18px); }
    26%      { opacity: 0; transform: translate(22px, -35px); }
    100%     { opacity: 0; }
}

@keyframes errSparkB {
    0%, 19%  { opacity: 0; transform: translate(0,0); }
    21%      { opacity: 1; transform: translate(18px, -10px); }
    27%      { opacity: 0; transform: translate(32px, -20px); }
    100%     { opacity: 0; }
}

@keyframes errSparkC {
    0%, 19.5% { opacity: 0; transform: translate(0,0); }
    22%       { opacity: 1; transform: translate(5px, -25px); }
    28%       { opacity: 0; transform: translate(12px, -42px); }
    100%      { opacity: 0; }
}

@keyframes errSparkD {
    0%, 20.5% { opacity: 0; transform: translate(0,0); }
    23%       { opacity: 1; transform: translate(14px, -14px); }
    29%       { opacity: 0; transform: translate(26px, -28px); }
    100%      { opacity: 0; }
}

@keyframes errSparkE {
    0%, 18.5% { opacity: 0; transform: translate(0,0); }
    21%       { opacity: 1; transform: translate(20px, -6px); }
    26%       { opacity: 0; transform: translate(35px, -15px); }
    100%      { opacity: 0; }
}

/* Fumaça no ponto de queda */
.err-smoke {
    position: absolute;
    border-radius: 50%;
    background: color-mix(in srgb, var(--text-color, #555) 15%, transparent);
    opacity: 0;
}

.err-smoke-1 { width: 14px; height: 14px; bottom: 55px; left: calc(50% + 30px); animation: errSmoke 10s ease-out infinite; }
.err-smoke-2 { width: 10px; height: 10px; bottom: 50px; left: calc(50% + 40px); animation: errSmoke 10s ease-out infinite 0.4s; }

@keyframes errSmoke {
    0%, 24%  { opacity: 0; transform: translateY(0) scale(0.5); }
    30%      { opacity: 0.25; }
    42%      { opacity: 0; transform: translateY(-40px) scale(1.8); }
    100%     { opacity: 0; }
}

/* Técnico: entra pela direita, para na engrenagem caída (direita), conserta, sai pela direita */
.err-technician {
    position: absolute;
    bottom: 3px;
    right: -40px;
    animation: errTechWalk 10s ease-in-out infinite;
}

@keyframes errTechWalk {
    0%, 30%  { right: -40px; opacity: 0; }
    32%      { right: -40px; opacity: 1; }
    48%      { right: calc(50% - 90px); opacity: 1; }
    70%      { right: calc(50% - 90px); opacity: 1; }
    84%      { right: -40px; opacity: 1; }
    87%      { right: -40px; opacity: 0; }
    100%     { right: -40px; opacity: 0; }
}

/* Pausa pernas quando consertando */
.err-technician.paused .err-person-leg-l,
.err-technician.paused .err-person-leg-r {
    animation-play-state: paused;
}

.err-technician .err-person-head {
    background: color-mix(in srgb, var(--err-color) 50%, #666);
}

.err-technician .err-person-body {
    background: color-mix(in srgb, var(--err-color) 35%, #777);
}

/* Ferramenta — balança quando consertando */
.err-tech-tool {
    position: absolute;
    top: 10px;
    left: -10px;
    width: 14px;
    height: 6px;
    background: color-mix(in srgb, var(--err-color) 40%, #999);
    border-radius: 1px;
    transform: rotate(-30deg);
    animation: errToolWork 10s ease-in-out infinite;
}

@keyframes errToolWork {
    0%, 48%  { transform: rotate(-30deg); }
    52%      { transform: rotate(-55deg); }
    55%      { transform: rotate(-15deg); }
    58%      { transform: rotate(-55deg); }
    61%      { transform: rotate(-15deg); }
    64%      { transform: rotate(-50deg); }
    67%      { transform: rotate(-20deg); }
    70%      { transform: rotate(-30deg); }
    100%     { transform: rotate(-30deg); }
}


/* ===== CENA 403 — Porta trancada ===== */

/* Porta */
.err-door {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 120px;
    background: color-mix(in srgb, var(--err-color) 18%, #d4c8b8);
    border: 2px solid color-mix(in srgb, var(--err-color) 30%, #a08c78);
    border-radius: 4px 4px 0 0;
    border-bottom: none;
}

/* Moldura da porta */
.err-door-frame {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 82px;
    height: 128px;
    border: 3px solid color-mix(in srgb, var(--err-color) 25%, #8b7d6b);
    border-radius: 6px 6px 0 0;
    border-bottom: none;
}

/* Maçaneta */
.err-door-knob {
    position: absolute;
    right: 8px;
    top: 55px;
    width: 8px;
    height: 8px;
    background: color-mix(in srgb, var(--err-color) 40%, #c9a96e);
    border-radius: 50%;
    box-shadow: 0 0 3px rgba(0,0,0,0.2);
}

/* Cadeado */
.err-padlock {
    position: absolute;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    animation: errPadlockPulse 2s ease-in-out infinite;
}

.err-padlock-body {
    width: 22px;
    height: 16px;
    background: var(--err-color);
    border-radius: 3px;
    margin: 0 auto;
}

.err-padlock-shackle {
    width: 14px;
    height: 12px;
    border: 3px solid var(--err-color);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    margin: 0 auto;
}

@keyframes errPadlockPulse {
    0%, 100% { transform: translateX(-50%) scale(1); filter: drop-shadow(0 0 0 transparent); }
    50%      { transform: translateX(-50%) scale(1.1); filter: drop-shadow(0 0 8px color-mix(in srgb, var(--err-color) 40%, transparent)); }
}

/* Porta tremendo quando personagem tenta abrir */
.err-door-shake {
    animation: errDoorShake 6s ease-in-out infinite;
}

@keyframes errDoorShake {
    0%, 30%, 50%, 100% { transform: translateX(-50%); }
    35% { transform: translateX(calc(-50% + 3px)); }
    37% { transform: translateX(calc(-50% - 3px)); }
    39% { transform: translateX(calc(-50% + 2px)); }
    41% { transform: translateX(calc(-50% - 1px)); }
    43% { transform: translateX(-50%); }
}

/* Personagem 403 */
.err-person-403 {
    position: absolute;
    bottom: 3px;
    left: calc(50% - 65px);
    animation: errPerson403 6s ease-in-out infinite;
}

@keyframes errPerson403 {
    0%   { left: calc(50% - 100px); }
    25%  { left: calc(50% - 65px); }
    30%  { left: calc(50% - 60px); }
    42%  { left: calc(50% - 60px); }
    55%  { left: calc(50% - 70px); }
    100% { left: calc(50% - 70px); }
}

/* Braços cruzados (aparece depois da tentativa) */
.err-arms-crossed {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 4px;
    background: color-mix(in srgb, var(--err-color) 40%, #777);
    border-radius: 2px;
    opacity: 0;
    animation: errArmsCross 6s ease-in-out infinite;
}

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

/* Sombra no chão */
.err-shadow {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 6px;
    background: color-mix(in srgb, var(--text-color, #333) 8%, transparent);
    border-radius: 50%;
}


/* ===== CENA 401 — Cadê o crachá? ===== */

/* Balcão */
.err-desk {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 45px;
    background: color-mix(in srgb, var(--err-color) 20%, #c4b5a0);
    border: 2px solid color-mix(in srgb, var(--err-color) 30%, #a08c78);
    border-radius: 4px 4px 0 0;
    border-bottom: none;
}

/* Placa no balcão */
.err-desk-sign {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 700;
    color: var(--err-color);
    letter-spacing: 1px;
    white-space: nowrap;
}

/* Segurança atrás do balcão */
.err-guard {
    position: absolute;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
}

.err-guard .err-person-head {
    background: color-mix(in srgb, var(--err-color) 55%, #555);
}

.err-guard .err-person-body {
    background: color-mix(in srgb, var(--err-color) 40%, #555);
    width: 12px;
    height: 20px;
}

/* Mão estendida do segurança */
.err-guard-hand {
    position: absolute;
    top: 22px;
    left: -12px;
    width: 14px;
    height: 5px;
    background: color-mix(in srgb, var(--err-color) 50%, #888);
    border-radius: 3px;
    transform-origin: right center;
    animation: errHandExtend 5s ease-in-out infinite;
}

@keyframes errHandExtend {
    0%, 20%  { transform: rotate(0deg); }
    30%      { transform: rotate(-15deg); }
    70%      { transform: rotate(-15deg); }
    80%      { transform: rotate(0deg); }
    100%     { transform: rotate(0deg); }
}

/* Visitante */
.err-visitor {
    position: absolute;
    bottom: 3px;
    left: calc(50% - 85px);
    animation: errVisitorApproach 5s ease-in-out infinite;
}

@keyframes errVisitorApproach {
    0%   { left: calc(50% - 120px); }
    30%  { left: calc(50% - 85px); }
    100% { left: calc(50% - 85px); }
}

/* Revirando bolsos */
.err-visitor-arms {
    position: absolute;
    top: 20px;
    width: 100%;
}

.err-visitor-arm-l, .err-visitor-arm-r {
    position: absolute;
    width: 4px;
    height: 10px;
    background: color-mix(in srgb, var(--err-color) 35%, #888);
    border-radius: 2px;
    transform-origin: top center;
}

.err-visitor-arm-l {
    left: -2px;
    animation: errArmSearch 1.5s ease-in-out infinite;
}

.err-visitor-arm-r {
    right: -2px;
    animation: errArmSearch 1.5s ease-in-out infinite;
    animation-delay: 0.4s;
}

@keyframes errArmSearch {
    0%, 100% { transform: rotate(10deg); }
    50%      { transform: rotate(-20deg); }
}

/* Interrogação do visitante */
.err-visitor-question {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: 900;
    color: var(--err-color);
    opacity: 0;
    animation: errVisitorQ 5s ease-in-out infinite;
}

@keyframes errVisitorQ {
    0%, 35%  { opacity: 0; }
    45%      { opacity: 1; transform: translateX(-50%) translateY(-3px); }
    85%      { opacity: 1; }
    95%      { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    100%     { opacity: 0; }
}


/* ===== CENA 503 — Em obras ===== */

/* Barreira listrada */
.err-barrier {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 30px;
    background: repeating-linear-gradient(
        -45deg,
        #f5c518,
        #f5c518 8px,
        #222 8px,
        #222 16px
    );
    border-radius: 3px;
    border: 2px solid #333;
}

/* Pernas da barreira */
.err-barrier-leg {
    position: absolute;
    bottom: -20px;
    width: 4px;
    height: 20px;
    background: #666;
    border-radius: 0 0 2px 2px;
}

.err-barrier-leg-l { left: 15px; }
.err-barrier-leg-r { right: 15px; }

/* Cones */
.err-cone {
    position: absolute;
    bottom: 3px;
}

.err-cone-body {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 28px solid #ff6b35;
    margin: 0 auto;
}

.err-cone-stripe {
    position: absolute;
    left: 3px;
    right: 3px;
    height: 4px;
    background: white;
    top: 16px;
}

.err-cone-base {
    width: 24px;
    height: 4px;
    background: #ff6b35;
    border-radius: 1px;
    margin: 0 auto;
}

.err-cone-1 { left: calc(50% - 100px); }
.err-cone-2 { right: calc(50% - 100px); }

/* Guindaste */
.err-crane {
    position: absolute;
    bottom: 35px;
    right: calc(50% - 130px);
}

.err-crane-tower {
    width: 6px;
    height: 80px;
    background: #f5c518;
    margin: 0 auto;
    border-radius: 1px;
}

.err-crane-arm {
    position: absolute;
    top: 0;
    left: -30px;
    width: 70px;
    height: 4px;
    background: #f5c518;
    border-radius: 1px;
}

.err-crane-cable {
    position: absolute;
    top: 4px;
    left: -25px;
    width: 2px;
    height: 30px;
    background: #888;
    animation: errCableMove 4s ease-in-out infinite;
    transform-origin: top center;
}

@keyframes errCableMove {
    0%, 100% { height: 30px; }
    50%      { height: 45px; }
}

.err-crane-hook {
    position: absolute;
    bottom: -8px;
    left: -3px;
    width: 8px;
    height: 8px;
    border: 2px solid #888;
    border-top: none;
    border-radius: 0 0 4px 4px;
}

/* Placa "Voltamos logo" */
.err-maintenance-sign {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 14px;
    background: color-mix(in srgb, var(--err-color) 12%, #fff);
    border: 2px solid var(--err-color);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--err-color);
    white-space: nowrap;
    animation: errMaintSign 3s ease-in-out infinite;
}

@keyframes errMaintSign {
    0%, 100% { transform: translateX(-50%) rotate(-2deg); }
    50%      { transform: translateX(-50%) rotate(2deg); }
}

/* Poeira */
.err-dust {
    position: absolute;
    bottom: 8px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--text-color, #555) 10%, transparent);
    opacity: 0;
}

.err-dust-1 {
    width: 8px; height: 8px;
    left: calc(50% - 40px);
    animation: errDust 3s ease-out infinite;
}

.err-dust-2 {
    width: 6px; height: 6px;
    left: calc(50% + 30px);
    animation: errDust 3s ease-out infinite;
    animation-delay: 1s;
}

.err-dust-3 {
    width: 10px; height: 10px;
    left: calc(50% - 10px);
    animation: errDust 3s ease-out infinite;
    animation-delay: 2s;
}

@keyframes errDust {
    0%   { opacity: 0; transform: translateY(0) scale(0.5); }
    30%  { opacity: 0.25; }
    100% { opacity: 0; transform: translateY(-30px) scale(1.5); }
}


/* ===== CENA 402 — Carteira vazia ===== */

.err-wallet-scene {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
}

.err-wallet-body {
    width: 60px;
    height: 40px;
    background: color-mix(in srgb, var(--err-color) 35%, #a08060);
    border: 2px solid color-mix(in srgb, var(--err-color) 45%, #7a6040);
    border-radius: 6px;
    position: relative;
    animation: errWalletOpen 4s ease-in-out infinite;
}

.err-wallet-flap {
    position: absolute;
    top: -12px;
    left: -2px;
    right: -2px;
    height: 14px;
    background: color-mix(in srgb, var(--err-color) 30%, #b89070);
    border: 2px solid color-mix(in srgb, var(--err-color) 45%, #7a6040);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    transform-origin: bottom center;
    animation: errFlapOpen 4s ease-in-out infinite;
}

@keyframes errWalletOpen {
    0%, 100% { transform: translateX(-50%) rotate(0deg); }
    50%      { transform: translateX(-50%) rotate(-3deg); }
}

@keyframes errFlapOpen {
    0%, 30%  { transform: rotateX(0deg); }
    50%      { transform: rotateX(-40deg); }
    70%, 100% { transform: rotateX(0deg); }
}

/* Moeda caindo */
.err-coin {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--err-color);
    background: color-mix(in srgb, var(--err-color) 20%, #ffd700);
    opacity: 0;
}

.err-coin-1 {
    top: 0;
    left: 10px;
    animation: errCoinFall 4s ease-in infinite;
    animation-delay: 1.5s;
}

.err-coin-2 {
    top: 0;
    left: 35px;
    animation: errCoinFall 4s ease-in infinite;
    animation-delay: 1.8s;
}

@keyframes errCoinFall {
    0%, 30% { opacity: 0; transform: translateY(0) rotate(0deg); }
    35%     { opacity: 1; }
    60%     { opacity: 0.3; transform: translateY(50px) rotate(180deg); }
    65%     { opacity: 0; }
    100%    { opacity: 0; }
}

/* Pessoa triste */
.err-person-402 {
    position: absolute;
    bottom: 3px;
    left: calc(50% - 60px);
}

.err-person-402 .err-person-head::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 3px;
    width: 10px;
    height: 5px;
    border-bottom: 2px solid color-mix(in srgb, var(--err-color) 80%, #333);
    border-radius: 0 0 50% 50%;
    transform: rotate(180deg);
}

/* ===== Responsivo ===== */

@media (max-width: 480px) {
    .err-stage {
        height: 180px;
    }

    .err-content {
        padding: 16px 12px;
    }

    .err-sign-board {
        width: 70px;
        height: 28px;
        font-size: 16px;
    }

    .err-door {
        width: 55px;
        height: 95px;
    }

    .err-door-frame {
        width: 65px;
        height: 100px;
    }

    .err-barrier {
        width: 100px;
    }

    .err-desk {
        width: 90px;
        height: 35px;
    }

    .err-gear {
        width: 38px;
        height: 38px;
    }

    .err-gears-group {
        width: 115px;
        height: 95px;
    }

    .err-gear-code {
        font-size: 20px;
    }

    .err-crane {
        display: none;
    }
}
