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

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

/* ─── Goal progress bar ─────────────────────────────────────────────── */
#game-root .m3-goal { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.55rem; color: #fde9a8; font-weight: 700; font-size: 0.78rem; }
#game-root .m3-bar { flex: 1 1 auto; height: 9px; border-radius: 999px; background: rgba(0,0,0,0.4); overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.6); }
#game-root .m3-bar-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #16a34a, #f4c430); transition: width 0.3s ease; }

/* ─── Playfield + candy grid ────────────────────────────────────────── */
#game-root .m3-playfield {
    position: relative; padding: 12px; border: 3px solid #ffd66b; border-radius: 14px; overflow: hidden;
    background-image: url('/games/match-3-jul/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 .m3-grid {
    display: grid; gap: 4px; padding: 6px; border-radius: 10px;
    background: rgba(20, 10, 6, 0.4); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14), inset 0 0 18px rgba(0,0,0,0.45);
}
#game-root .m3-cell {
    position: relative; aspect-ratio: 1; border: none; cursor: pointer; border-radius: 9px; padding: 8%;
    background: linear-gradient(160deg, rgba(255,248,225,0.92), rgba(244,225,190,0.86));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 1px 2px rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.1s ease, box-shadow 0.12s ease, background 0.15s ease;
}
#game-root .m3-cell img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2)); }
#game-root .m3-cell:hover { background: linear-gradient(160deg, #fffdf5, #f7ecd2); }
#game-root .m3-cell--sel { background: linear-gradient(160deg, #ffe9a8, #ffd66b); transform: scale(1.08); box-shadow: 0 0 0 3px #ffd66b, 0 3px 8px rgba(0,0,0,0.4); z-index: 2; }
#game-root .m3-badge { position: absolute; top: 2px; right: 3px; font-size: 0.7rem; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4)); pointer-events: none; }
#game-root .m3-cell--bomb { box-shadow: inset 0 0 0 2px #dc2626, 0 0 10px rgba(220,38,38,0.6); animation: m3-bombpulse 1.1s ease-in-out infinite; }
@keyframes m3-bombpulse { 0%,100% { box-shadow: inset 0 0 0 2px #dc2626, 0 0 6px rgba(220,38,38,0.45); } 50% { box-shadow: inset 0 0 0 2px #ef4444, 0 0 14px rgba(220,38,38,0.85); } }
#game-root .m3-cell--star { box-shadow: inset 0 0 0 2px #f4c430, 0 0 12px rgba(244,196,48,0.75); animation: m3-starpulse 1.2s ease-in-out infinite; }
@keyframes m3-starpulse { 0%,100% { box-shadow: inset 0 0 0 2px #e0a92e, 0 0 8px rgba(244,196,48,0.5); } 50% { box-shadow: inset 0 0 0 2px #ffe066, 0 0 18px rgba(244,196,48,0.95); } }
#game-root .m3-cell.m3-pop { animation: m3-pop 0.19s ease-out forwards; }
@keyframes m3-pop { 0% { transform: scale(1); } 45% { transform: scale(1.25); filter: brightness(1.4); } 100% { transform: scale(0); opacity: 0; } }
#game-root .m3-cell.m3-shake { animation: m3-shake 0.22s ease; }
@keyframes m3-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
#game-root .m3-cell.m3-hint { animation: m3-hint 0.55s ease-in-out infinite; }
@keyframes m3-hint { 0%,100% { box-shadow: 0 0 0 0 rgba(255,224,102,0); } 50% { box-shadow: 0 0 0 3px #ffe066, 0 0 14px rgba(255,224,102,0.9); transform: scale(1.05); } }

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

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

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

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

/* ─── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #game-root .m3-wrap { padding: 0.6rem; }
    #game-root .m3-header { flex-wrap: wrap; gap: 0.3rem; }
    #game-root .m3-pill { flex: 1 1 28%; }
    #game-root .m3-val { font-size: 1rem; }
    #game-root .m3-vol { width: 44px; }
    #game-root .m3-mode { font-size: 0.74rem; padding: 0.3rem 0.4rem; }
    #game-root .m3-cell { border-radius: 7px; }
}
