/* =================================================================
   JFun — "JSure Mission Control" game styles
   Loaded only on /{lang}/jfun. Relies on tokens from main.css.
   ================================================================= */

.jfun-hero { padding-bottom: clamp(40px, 6vw, 70px); }
.jfun-title { max-width: none; font-size: clamp(34px, 5.4vw, 64px); }
.jfun-hint { margin-top: 18px; font-size: 14px; color: rgba(255, 255, 255, .5); }
.jfun-hero .btn-primary svg:first-child { width: 18px; height: 18px; }

.jfun-arena { background: var(--paper); }
.jfun-keyhint { text-align: center; margin-top: 14px; font-size: 13px; color: var(--muted); }

/* ---------- Stage / console frame ---------- */
.jfun-stage {
    position: relative; overflow: hidden;
    background:
        linear-gradient(rgba(255, 255, 255, .03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px),
        radial-gradient(130% 130% at 50% -20%, #07294e, var(--navy) 55%, var(--navy-900));
    background-size: 44px 44px, 44px 44px, 100% 100%;
    border: 1px solid rgba(58, 188, 219, .25);
    border-radius: var(--radius-lg);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .3), 0 30px 70px rgba(8, 22, 48, .35), inset 0 0 60px rgba(0, 12, 32, .55);
    color: #fff;
    user-select: none; -webkit-user-select: none;
}

/* ---------- Top HUD ---------- */
.jfun-topbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 14px 16px; border-bottom: 1px solid rgba(58, 188, 219, .18);
    background: rgba(0, 12, 32, .45); backdrop-filter: blur(4px);
}
.jf-pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-family: var(--font-display); font-size: 12.5px; letter-spacing: .04em;
    color: rgba(255, 255, 255, .65);
    padding: 7px 12px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 999px;
    white-space: nowrap;
}
.jf-pill b { color: #fff; font-weight: 700; font-size: 14px; }
.jf-pill--wave { border-color: rgba(58, 188, 219, .4); color: var(--cyan); }
.jf-pill--wave b { color: var(--cyan); }
.jf-pill--combo { border-color: rgba(252, 184, 48, .45); color: #FCB830; }
.jf-pill--combo b { color: #FCB830; }

.jf-sat { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 180px; flex: 1 1 200px; max-width: 320px; }
.jf-sat-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .55); white-space: nowrap; }
.jf-sat-track { flex: 1; height: 9px; border-radius: 999px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.jf-sat-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #70B85C, #9BD06B); transition: width .35s var(--ease), background .35s; }
.jf-sat-fill.is-mid { background: linear-gradient(90deg, #FCB830, #f59f0a); }
.jf-sat-fill.is-low { background: linear-gradient(90deg, #E61F4A, #ff5c5c); }

.jf-controls { display: flex; gap: 8px; }
.jf-ctl {
    display: grid; place-items: center; width: 38px; height: 38px;
    border: 1px solid rgba(255, 255, 255, .16); border-radius: 11px; color: #fff;
    transition: background .2s, border-color .2s;
}
.jf-ctl:hover { background: rgba(255, 255, 255, .1); }
.jf-ctl svg { width: 18px; height: 18px; }
.jf-ico-muted { display: none; }
.jfun-stage.is-muted .jf-ico-muted { display: block; }
.jfun-stage.is-muted .jf-ico-sound { display: none; }

/* ---------- Belt ---------- */
.jfun-belt { position: relative; height: clamp(280px, 38vw, 380px); overflow: hidden; }
.jfun-lane { position: absolute; left: 0; right: 0; height: 1px; background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .14) 0 14px, transparent 14px 30px); }

.jfun-intake, .jfun-backlog {
    position: absolute; top: 0; bottom: 0; width: clamp(44px, 6vw, 64px); z-index: 1;
    display: grid; place-items: center; pointer-events: none;
}
.jfun-intake { left: 0; background: linear-gradient(90deg, rgba(58, 188, 219, .18), transparent); border-right: 1px dashed rgba(58, 188, 219, .35); }
.jfun-backlog { right: 0; background: linear-gradient(270deg, rgba(230, 31, 74, .22), transparent); border-left: 1px dashed rgba(230, 31, 74, .45); }
.jfun-intake i, .jfun-backlog i {
    writing-mode: vertical-rl; transform: rotate(180deg);
    font-style: normal; font-family: var(--font-display); font-weight: 600;
    font-size: 11.5px; letter-spacing: .22em; text-transform: uppercase;
}
.jfun-intake i { color: rgba(58, 188, 219, .8); }
.jfun-backlog i { color: rgba(255, 110, 134, .9); }
.jfun-backlog.is-hit { animation: backlogHit .45s; }
@keyframes backlogHit { 0% { background: rgba(230, 31, 74, .55); } 100% { background: linear-gradient(270deg, rgba(230, 31, 74, .22), transparent); } }

/* ---------- Item cards ---------- */
.jfun-item {
    position: absolute; left: 0; top: 0; z-index: 2;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 13px 9px 9px; border-radius: 13px;
    background: rgba(8, 26, 54, .92);
    border: 1.5px solid color-mix(in srgb, var(--c) 65%, transparent);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .35), inset 0 0 14px color-mix(in srgb, var(--c) 12%, transparent);
    cursor: pointer; will-change: transform;
    transition: box-shadow .2s, border-color .2s;
}
.jfun-item:hover { border-color: var(--c); }
.ji-ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: color-mix(in srgb, var(--c) 22%, transparent); color: var(--c); flex-shrink: 0; }
.ji-ico svg { width: 17px; height: 17px; }
.ji-label { font-family: var(--font-display); font-weight: 600; font-size: 12.5px; white-space: nowrap; color: #fff; }

.jfun-item.is-selected {
    border-color: #fff; z-index: 4;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 55%, transparent), 0 10px 26px rgba(0, 0, 0, .45);
}
.jfun-item.is-selected .ji-ico { background: var(--c); color: var(--navy-900); }

/* fraud tell */
.jfun-item.is-fraud { border-style: dashed; }
.ji-alert {
    position: absolute; top: -7px; right: -7px; width: 18px; height: 18px;
    display: grid; place-items: center; border-radius: 50%;
    background: #E61F4A; color: #fff; font-size: 11px; font-weight: 800;
    animation: fraudPulse 1.1s ease-in-out infinite;
}
@keyframes fraudPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(230, 31, 74, .55); } 50% { box-shadow: 0 0 0 6px rgba(230, 31, 74, 0); } }

/* routing / zapping states */
.jfun-item.is-routing { z-index: 5; transition: transform .5s cubic-bezier(.45, 0, .55, 1), opacity .5s; opacity: 0; pointer-events: none; }
.jfun-item.is-routing.is-auto { filter: drop-shadow(0 0 10px rgba(58, 188, 219, .8)); }
.jfun-item.is-zapped { z-index: 5; transition: transform .4s, opacity .4s; transform: scale(.2) rotate(8deg) !important; opacity: 0; pointer-events: none; filter: drop-shadow(0 0 12px #E61F4A); }
.jfun-item.is-missed { transition: transform .35s, opacity .35s; transform: translateX(30px) !important; opacity: 0; pointer-events: none; }

/* ---------- Dock ---------- */
.jfun-dock {
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 9px;
    padding: 13px 14px 15px; border-top: 1px solid rgba(58, 188, 219, .18);
    background: rgba(0, 12, 32, .5);
}
.jfun-module {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px;
    padding: 12px 6px 10px; border-radius: 13px;
    border: 1.5px solid color-mix(in srgb, var(--mc) 40%, transparent);
    background: color-mix(in srgb, var(--mc) 9%, rgba(8, 26, 54, .6));
    color: #fff; cursor: pointer;
    transition: transform .18s var(--ease), border-color .2s, background .2s, opacity .3s;
}
.jfun-module:not([disabled]):hover { transform: translateY(-3px); border-color: var(--mc); background: color-mix(in srgb, var(--mc) 18%, rgba(8, 26, 54, .6)); }
.jfun-module[disabled] { opacity: .28; cursor: not-allowed; filter: saturate(.4); }
.jfun-module.is-flash { animation: modFlash .45s; }
@keyframes modFlash { 30% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--mc) 60%, transparent); border-color: var(--mc); } }
.jfun-module.is-error { animation: modErr .4s; }
@keyframes modErr { 25%, 75% { transform: translateX(-5px); border-color: #E61F4A; } 50% { transform: translateX(5px); border-color: #E61F4A; } }

.jm-key {
    position: absolute; top: 6px; left: 8px; font-family: var(--font-display);
    font-size: 10px; font-weight: 700; color: rgba(255, 255, 255, .4);
    border: 1px solid rgba(255, 255, 255, .2); border-radius: 5px; padding: 1px 5px;
}
.jm-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: color-mix(in srgb, var(--mc) 26%, transparent); color: var(--mc); }
.jm-ico svg { width: 19px; height: 19px; }
.jm-name { font-family: var(--font-display); font-weight: 600; font-size: 11.5px; text-align: center; line-height: 1.2; }
.jm-meter { width: 80%; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.jm-meter i { display: block; height: 100%; background: var(--mc); border-radius: 999px; transition: width .3s var(--ease); }

.jm-auto {
    position: absolute; top: -8px; right: -6px;
    font-family: var(--font-display); font-size: 9.5px; font-weight: 700; letter-spacing: .08em;
    color: var(--navy-900); background: linear-gradient(120deg, var(--cyan), #8de4f7);
    padding: 3px 8px; border-radius: 999px; box-shadow: 0 3px 10px rgba(58, 188, 219, .5);
    animation: autoPop .45s var(--ease-out);
}
@keyframes autoPop { 0% { transform: scale(0); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
.jfun-module.is-auto { border-style: solid; border-color: color-mix(in srgb, var(--cyan) 55%, var(--mc)); }
.jfun-module.is-auto .jm-meter i { background: var(--cyan); }

/* ---------- Floating feedback text ---------- */
.jfun-float {
    position: absolute; z-index: 8; pointer-events: none;
    font-family: var(--font-display); font-weight: 700; font-size: 14px; white-space: nowrap;
    color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
    animation: floatUp 1s var(--ease-out) forwards;
}
.jfun-float.is-good { color: #8de98d; }
.jfun-float.is-bad { color: #ff7b95; }
.jfun-float.is-auto { color: var(--cyan); font-size: 12.5px; font-weight: 600; }
.jfun-float.is-gold { color: #FCB830; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(6px); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(-34px); } }

/* ---------- Overlay ---------- */
.jfun-overlay {
    position: absolute; inset: 0; z-index: 10;
    display: grid; place-items: center; padding: 24px;
    background: rgba(0, 10, 28, .78); backdrop-filter: blur(7px);
    opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s;
}
.jfun-overlay.is-open { opacity: 1; visibility: visible; }
.jfun-card { max-width: 560px; width: 100%; text-align: center; }
.jfun-card-kicker { font-family: var(--font-display); font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--cyan); }
.jfun-card-title { font-size: clamp(26px, 4vw, 40px); margin-top: 10px; color: #fff; }
.jfun-card-desc { margin-top: 12px; color: rgba(255, 255, 255, .75); font-size: 15.5px; max-width: 46ch; margin-inline: auto; }

.jfun-howto { display: flex; flex-direction: column; gap: 10px; margin: 24px auto 0; max-width: 430px; text-align: left; }
.jfun-how { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px; background: rgba(255, 255, 255, .05); font-size: 14px; color: rgba(255, 255, 255, .85); }
.jfun-how b { display: grid; place-items: center; flex-shrink: 0; width: 26px; height: 26px; border-radius: 8px; background: var(--cyan); color: var(--navy-900); font-family: var(--font-display); font-size: 13px; }

.jfun-newflow { display: inline-flex; align-items: center; gap: 10px; margin-top: 20px; padding: 12px 18px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--nf, var(--cyan)) 55%, transparent); background: color-mix(in srgb, var(--nf, var(--cyan)) 12%, transparent); font-family: var(--font-display); font-weight: 600; font-size: 14.5px; color: #fff; }
.jfun-newflow .nf-ico { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: color-mix(in srgb, var(--nf, var(--cyan)) 30%, transparent); color: var(--nf, var(--cyan)); }
.jfun-newflow .nf-ico svg { width: 16px; height: 16px; }
.jfun-newflow .nf-arrow { color: var(--nf, var(--cyan)); }

.jfun-overlay .btn { margin-top: 26px; }
.jfun-overlay .btn svg { width: 18px; height: 18px; }
.jfun-end-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.jfun-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 26px; }
.jfun-stat { padding: 12px 6px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 12px; background: rgba(255, 255, 255, .05); }
.jfun-stat b { display: block; font-family: var(--font-display); font-size: clamp(17px, 2.4vw, 24px); color: var(--cyan); }
.jfun-stat span { display: block; margin-top: 4px; font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: rgba(255, 255, 255, .55); }

.jfun-msg { margin: 22px auto 0; max-width: 46ch; padding: 14px 18px; border-left: 3px solid var(--cyan); background: rgba(58, 188, 219, .1); border-radius: 0 12px 12px 0; text-align: left; font-size: 15px; color: #fff; font-weight: 500; }

.jfun-trophy { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; background: linear-gradient(135deg, #FCB830, #f59f0a); color: var(--navy-900); box-shadow: 0 10px 30px rgba(252, 184, 48, .4); }
.jfun-trophy svg { width: 32px; height: 32px; }
.jfun-trophy.is-sad { background: linear-gradient(135deg, #E61F4A, #b3123a); color: #fff; box-shadow: 0 10px 30px rgba(230, 31, 74, .4); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .jfun-dock { grid-template-columns: repeat(3, 1fr); }
    .jf-sat { min-width: 100%; order: 10; max-width: none; }
    .jfun-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
    .jfun-belt { height: 300px; }
    .ji-label { font-size: 11px; }
    .ji-ico { width: 26px; height: 26px; }
    .jm-name { font-size: 10px; }
    .jm-key { display: none; }
    .jfun-stats { grid-template-columns: repeat(2, 1fr); }
    .jfun-keyhint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ji-alert, .jm-auto, .jfun-module.is-flash, .jfun-module.is-error, .jfun-backlog.is-hit { animation: none; }
}
