/* ─── Container ─────────────────────────────────────────────────────── */
#game-root .sd-wrap {
    position: relative;
    padding: 0.75rem;
    max-width: 720px;
    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 .sd-header { display: flex; align-items: stretch; gap: 0.4rem; margin-bottom: 0.55rem; }
#game-root .sd-pill {
    flex: 1 1 0; min-width: 0;
    display: flex; align-items: center; gap: 0.45rem;
    padding: 0.32rem 0.65rem;
    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 .sd-pill-icon { font-size: 1.2rem; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15)); }
#game-root .sd-pill-body { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
#game-root .sd-lbl { font-size: 0.6rem; letter-spacing: 0.08em; color: #8a5a1a; text-transform: uppercase; font-weight: 700; }
#game-root .sd-val {
    font-size: 1.2rem; 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 .sd-audio {
    display: flex; align-items: center; gap: 0.3rem;
    padding: 0.28rem 0.5rem;
    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 .sd-mute { background: transparent; border: 0; width: 26px; height: 26px; cursor: pointer; font-size: 0.95rem; padding: 0; }
#game-root .sd-vol { width: 60px; cursor: pointer; accent-color: var(--jul-red-700, #8B0000); }

/* ─── Mode chips ────────────────────────────────────────────────────── */
#game-root .sd-modes { display: flex; gap: 0.3rem; margin-bottom: 0.6rem; }
#game-root .sd-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 .sd-mode:hover:not(.sd-mode--active) { background: rgba(0,0,0,0.42); color: #fff8d0; }
#game-root .sd-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);
}

/* ─── Stage / canvas ────────────────────────────────────────────────── */
#game-root .sd-stage {
    position: relative;
    aspect-ratio: 640 / 360; width: 100%;
    border: 3px solid #ffd66b;
    border-radius: 12px; overflow: hidden;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.4), inset 0 0 16px rgba(0,0,0,0.3);
    touch-action: manipulation;
}
#game-root #sd-canvas { display: block; width: 100%; height: 100%; cursor: pointer; }

#game-root .sd-fs {
    position: absolute; top: 8px; right: 8px; z-index: 6;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.45); color: #fde9a8;
    border: 1px solid rgba(255, 221, 100, 0.4); border-radius: 9px;
    font-size: 1rem; line-height: 1; cursor: pointer;
    transition: background 0.15s ease, transform 0.08s ease;
}
#game-root .sd-fs:hover { background: rgba(0,0,0,0.68); }
#game-root .sd-fs:active { transform: scale(0.94); }

/* ─── Start / game-over overlay ─────────────────────────────────────── */
#game-root .sd-overlay {
    position: absolute; inset: 0; z-index: 5;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    background: rgba(20, 10, 10, 0.5);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
#game-root .sd-overlay[hidden] { display: none; }
#game-root .sd-overlay-card {
    max-width: 380px; width: 100%; text-align: center;
    padding: 1.3rem 1.3rem;
    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: sd-pop 0.3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes sd-pop { 0% { transform: scale(0.85); opacity: 0; } 100% { transform: none; opacity: 1; } }
#game-root .sd-overlay-card h2 { margin: 0 0 0.4rem; color: var(--jul-red-700, #8B0000); font-size: 1.4rem; }
#game-root .sd-overlay-card p { margin: 0 0 0.95rem; color: #4a2a10; font-size: 0.92rem; line-height: 1.45; }
#game-root .sd-overlay-card strong { color: var(--jul-red-700, #8B0000); }

/* ─── Buttons ───────────────────────────────────────────────────────── */
#game-root .sd-btn {
    display: inline-block; padding: 0.6rem 1.6rem;
    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 .sd-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 .sd-btn--primary:hover:not(:disabled) { background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%); transform: translateY(-1px); }
#game-root .sd-btn--primary:active:not(:disabled) { transform: translateY(1px); }
#game-root .sd-btn--primary:disabled { opacity: 0.6; cursor: default; }

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

/* ─── Desktop scale-up ──────────────────────────────────────────────── */
@media (min-width: 720px) {
    #game-root .sd-wrap { max-width: 820px; }
    #game-root .sd-val { font-size: 1.35rem; }
    #game-root .sd-mode { padding: 0.42rem 0.7rem; font-size: 0.86rem; }
    #game-root .sd-overlay-card h2 { font-size: 1.5rem; }
}

/* ─── Mobile ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #game-root .sd-wrap { padding: 0.6rem; }
    #game-root .sd-header { flex-wrap: wrap; gap: 0.3rem; }
    #game-root .sd-val { font-size: 1.05rem; }
    #game-root .sd-mode { font-size: 0.74rem; padding: 0.3rem 0.45rem; }
    #game-root .sd-overlay-card { padding: 1rem; }
    #game-root .sd-overlay-card h2 { font-size: 1.2rem; }
}
