/* ─── Container ─────────────────────────────────────────────────────── */
#game-root .hn-wrap {
    position: relative;
    padding: 0.75rem;
    max-width: 560px;
    margin: 0 auto;
    background: linear-gradient(180deg, #2a1010 0%, #5a1818 100%);
    border-radius: var(--jul-radius-lg, 20px);
    user-select: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

/* ─── HUD pills ─────────────────────────────────────────────────────── */
#game-root .hn-header { display: flex; align-items: stretch; gap: 0.4rem; margin-bottom: 0.55rem; }
#game-root .hn-pill {
    flex: 1 1 0; min-width: 0;
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.32rem 0.55rem;
    background: linear-gradient(180deg, #fff8e1 0%, #fbf0c8 100%);
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 2px 4px rgba(0,0,0,0.18);
}
#game-root .hn-pill-icon { font-size: 1.1rem; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15)); }
#game-root .hn-pill-body { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
#game-root .hn-lbl { font-size: 0.56rem; letter-spacing: 0.07em; color: #8a5a1a; text-transform: uppercase; font-weight: 700; }
#game-root .hn-val {
    font-size: 1.1rem; font-weight: 800;
    color: var(--jul-red-700, #8B0000);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}
#game-root .hn-audio {
    display: flex; align-items: center; gap: 0.28rem;
    padding: 0.26rem 0.4rem;
    background: linear-gradient(180deg, #fff8e1 0%, #fbf0c8 100%);
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 2px 4px rgba(0,0,0,0.18);
}
#game-root .hn-mute { background: transparent; border: 0; width: 24px; height: 24px; cursor: pointer; font-size: 0.9rem; padding: 0; }
#game-root .hn-vol { width: 46px; cursor: pointer; accent-color: var(--jul-red-700, #8B0000); }

/* ─── Mode chips ────────────────────────────────────────────────────── */
#game-root .hn-modes { display: flex; gap: 0.3rem; margin-bottom: 0.55rem; }
#game-root .hn-mode {
    flex: 1 1 0;
    padding: 0.32rem 0.55rem;
    font-size: 0.8rem; font-weight: 700;
    color: #fde9a8;
    background: rgba(0,0,0,0.28);
    border: 1px solid rgba(255, 221, 100, 0.18);
    border-radius: 999px;
    cursor: pointer; letter-spacing: 0.02em;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
#game-root .hn-mode:hover:not(.hn-mode--active) { background: rgba(0,0,0,0.42); color: #fff8d0; }
#game-root .hn-mode--active {
    background: linear-gradient(180deg, #fbd24a 0%, #d99b1e 100%);
    color: #4a1a05; border-color: #b8870b;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 4px rgba(0,0,0,0.3);
}

/* ─── Task bar (find the nisse + help) ──────────────────────────────── */
#game-root .hn-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.5rem; margin-bottom: 0.5rem;
    padding: 0.35rem 0.6rem;
    background: rgba(255, 248, 225, 0.95);
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}
#game-root .hn-task { display: flex; align-items: center; gap: 0.4rem; color: #4a2a10; font-size: 0.92rem; }
#game-root .hn-task strong { color: var(--jul-red-700, #8B0000); }
#game-root .hn-task-icon { height: 26px; width: auto; vertical-align: middle; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25)); }
#game-root .hn-help {
    flex: 0 0 auto;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem; font-weight: 700;
    color: #fff;
    background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
    border: 1px solid #7f1d1d; border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
    transition: transform 0.08s ease, background 0.2s ease;
}
#game-root .hn-help:hover { background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%); transform: translateY(-1px); }
#game-root .hn-help:active { transform: translateY(1px); }
#game-root .hn-bar-btns { display: flex; align-items: center; gap: 0.4rem; flex: 0 0 auto; }
#game-root .hn-icon-btn {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; line-height: 1; cursor: pointer;
    color: #5a3010;
    background: rgba(255, 248, 225, 0.95);
    border: 1px solid rgba(0,0,0,0.15); border-radius: 9px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 2px 4px rgba(0,0,0,0.18);
    transition: background 0.15s ease, transform 0.08s ease;
}
#game-root .hn-icon-btn:hover { background: #fff; transform: translateY(-1px); }
#game-root .hn-icon-btn:active { transform: translateY(1px); }

/* ─── Stage ─────────────────────────────────────────────────────────── */
#game-root .hn-stage {
    position: relative;
    aspect-ratio: 4 / 3; width: 100%;
    border: 3px solid #ffd66b;
    border-radius: 12px; overflow: hidden;
    background-size: cover; background-position: center;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.4), inset 0 0 18px rgba(0,0,0,0.3);
    touch-action: manipulation;
}
#game-root .hn-loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; background: rgba(20,10,10,0.6);
    font-weight: 700;
}

/* sprites */
#game-root .hn-sprite {
    position: absolute;
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
    padding: 0; border: 0; background: transparent; cursor: pointer;
    line-height: 0;
    transition: transform 0.1s ease, filter 0.1s ease;
}
#game-root .hn-sprite img {
    width: 100%; height: auto; display: block;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.45));
    pointer-events: none;
}
#game-root .hn-sprite:hover { filter: brightness(1.06); }
#game-root .hn-sprite--miss { animation: hn-miss 0.4s ease; }
@keyframes hn-miss {
    0%,100% { transform: translate(-50%,-50%) rotate(var(--rot,0deg)); }
    25% { transform: translate(-58%,-50%) rotate(var(--rot,0deg)); }
    75% { transform: translate(-42%,-50%) rotate(var(--rot,0deg)); }
}
#game-root .hn-nisse--found {
    z-index: 20;
    animation: hn-found 0.6s ease;
}
#game-root .hn-nisse--found img {
    filter: drop-shadow(0 0 0 #fde047) drop-shadow(0 0 14px rgba(253,224,71,0.95)) drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
@keyframes hn-found {
    0% { transform: translate(-50%,-50%) scale(1) rotate(var(--rot,0deg)); }
    50% { transform: translate(-50%,-50%) scale(1.5) rotate(0deg); }
    100% { transform: translate(-50%,-50%) scale(1.3) rotate(0deg); }
}

/* help ring */
#game-root .hn-ring {
    position: absolute; width: 16%; aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border: 4px solid #fde047; border-radius: 50%;
    box-shadow: 0 0 16px rgba(253,224,71,0.9), inset 0 0 14px rgba(253,224,71,0.6);
    pointer-events: none; z-index: 18;
}
#game-root .hn-ring[hidden] { display: none; }
#game-root .hn-ring--show { animation: hn-ring 1.3s ease-out; }
@keyframes hn-ring {
    0% { opacity: 0; transform: translate(-50%,-50%) scale(2.4); }
    25% { opacity: 1; transform: translate(-50%,-50%) scale(1.3); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%,-50%) scale(1.1); }
}

/* miss ripple on empty background */
#game-root .hn-ripple {
    position: absolute; width: 28px; height: 28px;
    transform: translate(-50%, -50%);
    border: 3px solid rgba(220,38,38,0.8); border-radius: 50%;
    pointer-events: none; z-index: 17;
    animation: hn-ripple 0.6s ease-out forwards;
}
@keyframes hn-ripple {
    0% { opacity: 0.9; transform: translate(-50%,-50%) scale(0.4); }
    100% { opacity: 0; transform: translate(-50%,-50%) scale(1.8); }
}

/* win toast */
#game-root .hn-toast {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    padding: 0.7rem 1.4rem; border-radius: 14px;
    font-weight: 800; font-size: 1.3rem; color: #2a1500;
    background: #ffdd44; border: 2px solid #b8870b;
    box-shadow: 0 8px 28px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.8);
    z-index: 25; white-space: nowrap; pointer-events: none;
}
#game-root .hn-toast[hidden] { display: none; }
#game-root .hn-toast--show { animation: hn-toast 0.45s cubic-bezier(.34,1.56,.64,1); }
@keyframes hn-toast {
    0% { transform: translate(-50%,-50%) scale(0.4); opacity: 0; }
    60% { transform: translate(-50%,-50%) scale(1.12); opacity: 1; }
    100% { transform: translate(-50%,-50%) scale(1); }
}

/* confetti */
#game-root .hn-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 22; }
#game-root .hn-confetti-piece {
    position: absolute; width: 8px; height: 12px; border-radius: 2px;
    transform: translate(-50%,-50%);
    animation: hn-confetti-fall 1.4s ease-out forwards;
}
@keyframes hn-confetti-fall {
    0% { transform: translate(-50%,-50%) rotate(0); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx)), 240px) rotate(var(--rot)); opacity: 0; }
}

/* ─── Fullscreen layout ─────────────────────────────────────────────── */
#game-root .hn-wrap.hn-fs-on {
    width: 100vw; height: 100vh; max-width: none;
    border-radius: 0; padding: 0.9rem;
    display: flex; flex-direction: column; align-items: center;
    overflow: hidden;
    background: linear-gradient(180deg, #2a1010 0%, #5a1818 100%);
}
#game-root .hn-wrap.hn-fs-on .hn-header,
#game-root .hn-wrap.hn-fs-on .hn-modes,
#game-root .hn-wrap.hn-fs-on .hn-bar {
    width: 100%; max-width: 900px; flex: 0 0 auto;
}
#game-root .hn-wrap.hn-fs-on .hn-stage {
    flex: 0 1 auto;
    height: calc(100vh - 175px);
    width: auto;
    max-width: 96vw;
    aspect-ratio: 4 / 3;
    margin-top: 0.3rem;
}

/* ─── Start overlay ─────────────────────────────────────────────────── */
#game-root .hn-overlay {
    position: absolute; inset: 0; z-index: 30;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    background: rgba(20, 10, 10, 0.55);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
#game-root .hn-overlay[hidden] { display: none; }
#game-root .hn-overlay-card {
    max-width: 340px; width: 100%; text-align: center;
    padding: 1.3rem 1.2rem;
    background: linear-gradient(180deg, #fff8e1 0%, #fbf0c8 100%);
    border: 1px solid rgba(150, 95, 40, 0.45); border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.7);
    animation: hn-card-pop 0.3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes hn-card-pop { 0% { transform: scale(0.85); opacity: 0; } 100% { transform: none; opacity: 1; } }
#game-root .hn-overlay-nisse { width: 66px; height: auto; margin-bottom: 0.3rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }
#game-root .hn-overlay-trophy { font-size: 2.8rem; line-height: 1; margin-bottom: 0.2rem; }
#game-root .hn-overlay-card h2 { margin: 0 0 0.4rem; color: var(--jul-red-700, #8B0000); font-size: 1.35rem; }
#game-root .hn-overlay-card p { margin: 0 0 0.95rem; color: #4a2a10; font-size: 0.92rem; line-height: 1.45; }
#game-root .hn-overlay-btns { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
#game-root .hn-btn {
    display: inline-block; padding: 0.6rem 1.5rem;
    font-size: 1rem; font-weight: 700; border-radius: 999px; cursor: pointer;
    transition: transform 0.08s ease, background 0.2s ease, opacity 0.2s ease;
}
#game-root .hn-btn--primary {
    background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
    color: #fff; border: 1px solid #7f1d1d;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}
#game-root .hn-btn--primary:hover:not(:disabled) { background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%); transform: translateY(-1px); }
#game-root .hn-btn--primary:active:not(:disabled) { transform: translateY(1px); }
#game-root .hn-btn--primary:disabled { opacity: 0.6; cursor: default; }
#game-root .hn-btn--ghost {
    background: rgba(255, 248, 225, 0.95); color: #5a3010;
    border: 1px solid rgba(0,0,0,0.15);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 2px 4px rgba(0,0,0,0.18);
}
#game-root .hn-btn--ghost:hover { background: #fff; transform: translateY(-1px); }
#game-root .hn-btn--ghost:active { transform: translateY(1px); }

/* ─── Desktop scale-up ──────────────────────────────────────────────── */
@media (min-width: 720px) {
    #game-root .hn-wrap { max-width: 640px; padding: 1rem; }
    #game-root .hn-val { font-size: 1.25rem; }
    #game-root .hn-pill-icon { font-size: 1.25rem; }
    #game-root .hn-mode { padding: 0.42rem 0.7rem; font-size: 0.86rem; }
    #game-root .hn-task { font-size: 1rem; }
    #game-root .hn-task-icon { height: 30px; }
}
@media (min-width: 1024px) {
    #game-root .hn-wrap { max-width: 760px; padding: 1.15rem; }
}

/* ─── Mobile ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #game-root .hn-wrap { padding: 0.6rem; }
    #game-root .hn-header { flex-wrap: wrap; gap: 0.3rem; }
    #game-root .hn-val { font-size: 0.95rem; }
    #game-root .hn-mode { font-size: 0.74rem; padding: 0.3rem 0.45rem; }
    #game-root .hn-toast { font-size: 1.05rem; }
    #game-root .hn-task { font-size: 0.82rem; }
}
