/* ─── Container (wine-red console) ──────────────────────────────────── */
#game-root .mj-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 .mj-header { display: flex; align-items: stretch; gap: 0.4rem; margin-bottom: 0.55rem; }
#game-root .mj-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 .mj-pill-icon { font-size: 1.1rem; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15)); }
#game-root .mj-pill-body { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
#game-root .mj-lbl { font-size: 0.58rem; letter-spacing: 0.08em; color: #8a5a1a; text-transform: uppercase; font-weight: 700; }
#game-root .mj-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 .mj-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 .mj-mute { background: transparent; border: 0; width: 26px; height: 26px; cursor: pointer; font-size: 0.95rem; padding: 0; }
#game-root .mj-vol { width: 52px; cursor: pointer; accent-color: var(--jul-red-700, #8B0000); }

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

/* ─── Playfield + scaling board ─────────────────────────────────────── */
#game-root .mj-playfield {
    position: relative; padding: 12px; border: 3px solid #ffd66b; border-radius: 14px; overflow: hidden;
    background-image: url('/games/jule-mahjong/background.jpg'); background-size: cover; background-position: center;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.4), inset 0 0 16px rgba(0,0,0,0.3);
}
#game-root .mj-board { position: relative; width: 100%; min-height: 220px; }
#game-root .mj-stage { position: absolute; top: 0; left: 50%; transform-origin: top center; }

/* ─── Tiles (cream top, green base) ─────────────────────────────────── */
#game-root .mj-tile {
    position: absolute; border: 0; padding: 0; cursor: pointer; border-radius: 7px;
    background: linear-gradient(158deg, #fffdf6 0%, #f4ead0 70%, #ece0c0 100%);
    box-shadow: 0 4px 0 #2f6b3a, 0 5px 0 #234e29, 0 9px 8px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.85);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.08s ease, filter 0.12s ease, box-shadow 0.12s ease;
}
#game-root .mj-tile img { width: 72%; height: 72%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.18)); }
#game-root .mj-tile--blocked { filter: brightness(0.74) saturate(0.92); cursor: default; }
#game-root .mj-tile--free:hover { filter: brightness(1.06); transform: translateY(-1px); }
#game-root .mj-tile--sel {
    filter: none; transform: translateY(-4px); z-index: 9999 !important;
    box-shadow: 0 8px 0 #2f6b3a, 0 9px 0 #234e29, 0 13px 11px rgba(0,0,0,0.55), 0 0 0 3px #ffd66b;
}
#game-root .mj-tile--hint { animation: mj-hint 0.65s ease-in-out infinite; }
@keyframes mj-hint {
    0%, 100% { box-shadow: 0 4px 0 #2f6b3a, 0 5px 0 #234e29, 0 9px 8px rgba(0,0,0,0.45), 0 0 0 3px rgba(255,224,102,0.0); }
    50% { box-shadow: 0 4px 0 #2f6b3a, 0 5px 0 #234e29, 0 9px 14px rgba(255,224,102,0.7), 0 0 0 3px rgba(255,224,102,0.95); filter: brightness(1.12); }
}

/* ─── Fullscreen toggle ─────────────────────────────────────────────── */
#game-root .mj-fs {
    position: absolute; top: 18px; left: 18px; z-index: 5; 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 .mj-fs:hover { background: rgba(0,0,0,0.68); }
#game-root .mj-fs:active { transform: scale(0.94); }

/* ─── Buttons / actions ─────────────────────────────────────────────── */
#game-root .mj-actions { display: flex; gap: 0.4rem; justify-content: center; flex-wrap: wrap; margin-top: 0.6rem; }
#game-root .mj-btn {
    display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.5rem 1rem;
    font-size: 0.9rem; font-weight: 700; border-radius: 999px; cursor: pointer;
    transition: transform 0.08s ease, background 0.2s ease;
}
#game-root .mj-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 .mj-btn--primary:hover { background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%); transform: translateY(-1px); }
#game-root .mj-btn--primary:active { transform: translateY(1px); }
#game-root .mj-btn--ghost { background: rgba(255, 248, 225, 0.95); color: #4a1a05; border: 1px solid rgba(0,0,0,0.12); box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 2px 4px rgba(0,0,0,0.18); }
#game-root .mj-btn--ghost:hover { background: #fff; transform: translateY(-1px); }
#game-root .mj-btn--ghost:active { transform: translateY(1px); }

/* ─── Start gate + win overlay ──────────────────────────────────────── */
#game-root .mj-overlay { position: absolute; inset: 0; z-index: 6; 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 .mj-overlay[hidden] { display: none; }
#game-root .mj-start { position: absolute; inset: 0; z-index: 7; 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 .mj-start[hidden] { display: none; }
#game-root .mj-wrap.mj-prestart .mj-actions { display: none; }
#game-root .mj-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: mj-pop 0.3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes mj-pop { 0% { transform: scale(0.85); opacity: 0; } 100% { transform: none; opacity: 1; } }
#game-root .mj-overlay-card h2 { margin: 0 0 0.4rem; color: var(--jul-red-700, #8B0000); font-size: 1.4rem; }
#game-root .mj-overlay-card p { margin: 0 0 0.95rem; color: #4a2a10; font-size: 0.95rem; }
#game-root .mj-rekord { color: #16a34a; }

/* ─── Confetti ──────────────────────────────────────────────────────── */
#game-root .mj-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 8; }
#game-root .mj-confetti-piece { position: absolute; top: 28%; left: 50%; width: 8px; height: 13px; border-radius: 2px; animation: mj-confetti-fall 1.6s ease-out forwards; }
@keyframes mj-confetti-fall { 0% { transform: translate(0,0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), 320px) rotate(var(--rot)); opacity: 0; } }

#game-root .mj-msg { text-align: center; margin-top: 0.5rem; min-height: 1.3em; font-weight: 600; color: #fde9a8; }

/* ─── Fullscreen layout ─────────────────────────────────────────────── */
#game-root .mj-wrap.mj-fs-on {
    width: 100vw; height: 100vh; max-width: none; border-radius: 0; padding: 0.7rem;
    display: flex; flex-direction: column; align-items: center; overflow: auto;
    background: linear-gradient(180deg, #2a1010 0%, #5a1818 100%);
}
#game-root .mj-wrap.mj-fs-on .mj-header,
#game-root .mj-wrap.mj-fs-on .mj-modes,
#game-root .mj-wrap.mj-fs-on .mj-actions { width: 100%; max-width: 760px; flex: 0 0 auto; }
#game-root .mj-wrap.mj-fs-on .mj-playfield { width: 100%; max-width: min(96vw, 1100px); flex: 1 1 auto; margin: 0.4rem 0; display: flex; align-items: center; }
#game-root .mj-wrap.mj-fs-on .mj-board { width: 100%; }

/* ─── Responsive ────────────────────────────────────────────────────── */
@media (min-width: 720px) { #game-root .mj-wrap { padding: 1rem; } #game-root .mj-val { font-size: 1.3rem; } }
@media (max-width: 480px) {
    #game-root .mj-wrap { padding: 0.6rem; }
    #game-root .mj-header { flex-wrap: wrap; gap: 0.3rem; }
    #game-root .mj-pill { flex: 1 1 28%; }
    #game-root .mj-val { font-size: 1rem; }
    #game-root .mj-vol { width: 44px; }
    #game-root .mj-mode { font-size: 0.74rem; padding: 0.3rem 0.4rem; }
    #game-root .mj-btn { padding: 0.45rem 0.8rem; font-size: 0.82rem; }
    #game-root .mj-fs { top: 14px; left: 14px; }
}
