* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    background: radial-gradient(
        circle at center,
        #352044,
        #140d1c 70%
    );

    color: #f5d9a4;
    font-family: Georgia, serif;

    display: flex;
    justify-content: center;
    align-items: center;
}

.scene {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    gap: 18px;
    padding: 20px;
    overflow: hidden;
}
@media (max-height: 700px) {
    .scene { gap: 10px; padding: 12px; }
    .toy-container { width: min(500px, 85vw); }
}
@media (max-height: 520px) {
    .scene { gap: 6px; padding: 8px; }
    #jackBox { max-height: 62dvh; }
}
h1 {
    font-family: "Jolly Lodger", system-ui;
    font-weight: 400;
    font-style: normal;

    letter-spacing: 4px;
    text-align: center;
    color: orange;

    font-size: clamp(22px, min(5vw, 7dvh), 48px);
    transform-origin: 50% 50%;
    animation:
        titlePop 1.2s both,
        titleGlow 3s ease-in-out 1.2s infinite;
}
/* Brillo que respira */
@keyframes titleGlow {
    0%, 100% {
        text-shadow:
            0 0 6px  rgba(255, 170, 70, 0.45),
            0 0 18px rgba(233, 120, 40, 0.35);
    }
    50% {
        text-shadow:
            0 0 10px rgba(255, 190, 90, 0.95),
            0 0 28px rgba(255, 130, 40, 0.75),
            0 0 56px rgba(255, 110, 30, 0.45);
    }
}
/* Se agranda y se reduce en su lugar, cada vez con menos fuerza */
@keyframes titlePop {
    0%   { opacity: 0; transform: scale(0.3);
           animation-timing-function: ease-out; }
    35%  { opacity: 1; transform: scale(1.25);
           animation-timing-function: ease-in-out; }
    55%  { transform: scale(0.9);
           animation-timing-function: ease-in-out; }
    75%  { transform: scale(1.08);
           animation-timing-function: ease-in-out; }
    90%  { transform: scale(0.98);
           animation-timing-function: ease-in-out; }
    100% { opacity: 1; transform: scale(1); }
}

.subtitle {
    color: #c6a9cf;
    font-style: italic;
    text-align: center;
    font-size: clamp(12px, 2.2dvh, 16px);
}

.toy-container {
    width: min(900px, 95vw);
    height: max-content;
    flex: 0 1 auto;
    min-height: 0;
    touch-action: none;
}

#jackBox {
    display: block;
    width: 100%;
    height: auto;
    max-height: 50vh;
    max-height: 50dvh;   /* la caja nunca ocupa más de la mitad del alto */
}

.instruction {
    color: #e9a84c;
    letter-spacing: 1px;
    margin-top: 10px;
}
.instruction {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: clamp(16px, 2.6vw, 20px);
    font-style: italic;
    color: #ffc766;
    text-shadow: 0 0 8px rgba(233, 168, 76, 0.7);
    animation: hintPulse 2.2s ease-in-out infinite;
}

/* Flecha circular que gira en sentido horario */
.instruction::before {
    content: "↻";
    font-style: normal;
    font-size: 1.5em;
    display: inline-block;
    animation: hintSpin 2.5s linear infinite;
}

/* Si el texto está vacío (caja abierta), no mostrar la flecha */
.instruction:empty::before { content: none; }

/* Tras el primer toque, se calma */
.instruction.calm {
    animation: none;
    opacity: 0.6;
    text-shadow: none;
}
.instruction.calm::before { animation-duration: 8s; }

@keyframes hintPulse {
    0%, 100% { opacity: 0.65; transform: translateY(0);    text-shadow: 0 0 4px rgba(233, 168, 76, 0.3); }
    50%      { opacity: 1;    transform: translateY(-3px); text-shadow: 0 0 14px rgba(255, 190, 90, 0.95); }
}

@keyframes hintSpin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .instruction,
    .instruction::before { animation: none; }
}
#crank {
    transform-origin: 550px 245px;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}