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

/* ─── Mode chips ────────────────────────────────────────────────────── */
#game-root .tp-modes { display: flex; gap: 0.3rem; margin-bottom: 0.6rem; }
#game-root .tp-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 .tp-mode:hover:not(.tp-mode--active) { background: rgba(0,0,0,0.42); color: #fff8d0; }
#game-root .tp-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 .tp-stage {
    position: relative;
    aspect-ratio: 480 / 620; max-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);
}
#game-root #tp-canvas { display: block; width: 100%; height: auto; touch-action: manipulation; }

/* fullscreen toggle button (top-right of the stage) */
#game-root .tp-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 .tp-fs:hover { background: rgba(0,0,0,0.68); }
#game-root .tp-fs:active { transform: scale(0.94); }

/* typed-letters pill near the bottom */
#game-root .tp-input {
    position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
    padding: 0.4rem 1.1rem;
    background: linear-gradient(180deg, #fff8e1 0%, #fbf0c8 100%);
    border: 1px solid rgba(150, 95, 40, 0.4);
    border-radius: 999px;
    font-family: Georgia, serif; font-size: 1.25rem; font-weight: 800;
    color: var(--jul-red-700, #8B0000);
    min-width: 90px; text-align: center;
    box-shadow: 0 3px 8px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.7);
    letter-spacing: 0.06em;
}
#game-root .tp-cursor { animation: tp-blink 1s steps(2) infinite; color: #b8870b; }
@keyframes tp-blink { 50% { opacity: 0; } }

#game-root .tp-hidden-input {
    position: absolute; opacity: 0; pointer-events: none;
    width: 1px; height: 1px; left: 50%; bottom: 0; font-size: 16px;
}

/* combo toast */
#game-root .tp-combo {
    position: absolute; top: 14%; left: 50%; transform: translateX(-50%);
    padding: 0.4rem 1rem; border-radius: 999px;
    background: #ffdd44; color: #4a1a05;
    font-weight: 800; font-size: 1.1rem;
    border: 2px solid #b8870b;
    box-shadow: 0 6px 18px rgba(0,0,0,0.4);
    pointer-events: none; white-space: nowrap;
}
#game-root .tp-combo[hidden] { display: none; }
#game-root .tp-combo--show { animation: tp-combo-pop 0.8s ease-out; }
@keyframes tp-combo-pop {
    0% { transform: translateX(-50%) scale(0.4); opacity: 0; }
    30% { transform: translateX(-50%) scale(1.12); opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateX(-50%) scale(1) translateY(-10px); opacity: 0; }
}

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

/* ─── Buttons ───────────────────────────────────────────────────────── */
#game-root .tp-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;
}
#game-root .tp-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 .tp-btn--primary:hover { background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%); transform: translateY(-1px); }
#game-root .tp-btn--primary:active { transform: translateY(1px); }

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

/* ─── Desktop scale-up ──────────────────────────────────────────────── */
@media (min-width: 720px) {
    #game-root .tp-wrap { max-width: 560px; padding: 1rem; }
    #game-root .tp-val { font-size: 1.3rem; }
    #game-root .tp-pill-icon { font-size: 1.3rem; }
    #game-root .tp-mode { padding: 0.42rem 0.7rem; font-size: 0.88rem; }
    #game-root .tp-input { font-size: 1.4rem; }
    #game-root .tp-overlay-card h2 { font-size: 1.4rem; }
}
@media (min-width: 1024px) {
    #game-root .tp-wrap { max-width: 620px; padding: 1.15rem; }
}

/* ─── Mobile ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #game-root .tp-wrap { padding: 0.6rem; }
    #game-root .tp-header { flex-wrap: wrap; gap: 0.3rem; }
    #game-root .tp-val { font-size: 1rem; }
    #game-root .tp-mode { font-size: 0.74rem; padding: 0.3rem 0.45rem; }
    #game-root .tp-input { font-size: 1.1rem; bottom: 8px; }
}
