html, body {
    background: #000;
    overflow: hidden;
}

#renderCanvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    display: block;
    touch-action: none;
    outline: none;
}

/* ---- HUD superior ---- */
.hud {
    position: fixed;
    /* Por encima de los overlays (20) para que Salir y ♪ sigan accesibles
       con una ventana abierta; por debajo de la puerta (30) y el flash (35). */
    z-index: 25;
    color: var(--color-pale);
    font-family: var(--font-display);
    pointer-events: none;
}

.hud-top {
    top: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
}

.hud-link {
    pointer-events: auto;
    color: var(--color-pale);
    text-decoration: none;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid transparent;
    transition: border-color 0.2s var(--easing-soft), color 0.2s var(--easing-soft);
}

.hud-link:hover,
.hud-link:focus-visible {
    border-color: rgba(207, 220, 236, 0.4);
    color: var(--color-white);
    outline: none;
}

.hud-title {
    letter-spacing: 0.35em;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: rgba(207, 220, 236, 0.7);
}

.hud-preview {
    margin-left: 0.6rem;
    padding: 0.15rem 0.55rem;
    border: 1px solid rgba(251, 191, 36, 0.5);
    border-radius: 999px;
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    color: #fbbf24;
    white-space: nowrap;
}

.hud-acciones {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Compartir: icono fino, mismo lenguaje que el resto del HUD */
.hud-compartir {
    background: none;
    cursor: pointer;
    line-height: 1;
}

.hud-compartir svg { width: 16px; height: 16px; display: block; }

/* Menú de compartir (escritorio): panel discreto bajo el HUD */
.hud-share-menu {
    position: fixed;
    top: 3.6rem;
    right: 1.2rem;
    z-index: 26; /* justo sobre el HUD (25) */
    display: flex;
    flex-direction: column;
    min-width: 180px;
    padding: 0.45rem;
    border: 1px solid rgba(125, 211, 252, 0.25);
    border-radius: 12px;
    background: rgba(7, 18, 34, 0.92);
    backdrop-filter: blur(10px);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

.hud-share-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--color-mist);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
}

.hud-share-item:hover,
.hud-share-item:focus-visible {
    background: rgba(56, 189, 248, 0.12);
    color: var(--color-white);
    outline: none;
}

.hud-share-item svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Botón del hilo musical (♪): tachado y atenuado cuando está en silencio */
.hud-musica {
    background: none;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
}

.hud-musica--off {
    text-decoration: line-through;
    opacity: 0.5;
}

/* ---- Overlay inicial ---- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(10, 31, 61, 0.6) 0%, rgba(0, 0, 0, 0.85) 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: opacity 0.6s var(--easing-soft);
}

.overlay.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-card {
    text-align: center;
    color: var(--color-pale);
    max-width: 460px;
    padding: 2.5rem 2rem;
    border: 1px solid rgba(207, 220, 236, 0.18);
    background: rgba(10, 20, 36, 0.55);
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
}

.overlay-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.55em;
    color: var(--color-tech-soft);
    margin: 0 0 0.5rem;
    text-transform: uppercase;
}

.overlay-title {
    font-size: 2.4rem;
    font-weight: 600;
    color: var(--color-white);
    margin: 0 0 1rem;
}

.overlay-text {
    color: var(--color-mist);
    margin: 0 0 1.5rem;
    font-size: 1.05rem;
}

.overlay-keys {
    list-style: none;
    padding: 0;
    margin: 0 0 1.8rem;
    display: grid;
    gap: 0.5rem;
    color: var(--color-mist);
    font-size: 0.95rem;
}

.overlay-keys kbd {
    display: inline-block;
    min-width: 1.6em;
    padding: 0.1em 0.45em;
    margin: 0 0.1em;
    border: 1px solid rgba(207, 220, 236, 0.35);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--color-white);
}

/* Casilla del hilo musical en la ventana de instrucciones */
.overlay-check {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    margin: 0 0 1.8rem;
    color: var(--color-mist);
    font-size: 0.95rem;
    cursor: pointer;
}

.overlay-check input {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--color-tech-soft);
    cursor: pointer;
}

.overlay-check-nota {
    color: rgba(207, 220, 236, 0.45);
    font-size: 0.8rem;
}

.overlay-btn {
    background: transparent;
    border: 1px solid var(--color-soft);
    color: var(--color-white);
    font-family: var(--font-display);
    font-size: 1rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    padding: 0.8rem 2.2rem;
    cursor: pointer;
    transition: background 0.3s var(--easing-soft), letter-spacing 0.3s var(--easing-soft);
}

.overlay-btn:hover,
.overlay-btn:focus-visible {
    background: rgba(91, 141, 201, 0.18);
    letter-spacing: 0.45em;
    outline: none;
}

.overlay-exit {
    display: block;
    margin: 1.1rem auto 0;
    background: none;
    border: none;
    color: var(--color-soft);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    opacity: 0.8;
    transition: color 0.2s var(--easing-soft), opacity 0.2s var(--easing-soft);
}

.overlay-exit:hover,
.overlay-exit:focus-visible {
    color: var(--color-white);
    opacity: 1;
    outline: none;
}

/* ---- Aviso "mejor desde ordenador" (dispositivos táctiles) ---- */
.solo-escritorio {
    z-index: 40; /* por encima de la puerta y del resto de capas */
}

.badge-2d {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.4rem;
    height: 3.4rem;
    padding: 0 0.9rem;
    margin-bottom: 1.1rem;
    border-radius: 16px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.45rem;
    letter-spacing: 0.04em;
    color: #04101f;
    background: linear-gradient(135deg, var(--color-tech-soft), var(--color-tech));
    box-shadow: 0 0 28px rgba(56, 189, 248, 0.55);
}

.badge-soon {
    color: #3b2600;
    background: linear-gradient(135deg, #ffd27d, #f6a94b);
    box-shadow: 0 0 28px rgba(246, 169, 75, 0.5);
    font-size: 1.7rem;
}

.solo-escritorio .overlay-text kbd {
    display: inline-block;
    min-width: 1.5em;
    padding: 0.1em 0.4em;
    margin: 0 0.08em;
    text-align: center;
    border: 1px solid rgba(207, 220, 236, 0.35);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--color-white);
}
