/* ============================================================
   HUD — 인게임 HUD + 매치 흐름
   (상단 스코어/타이머, 메뉴, 스탯 스트립, 필살기 버튼, 콜아웃,
    카운트다운, VS 스플래시, 결과/캠페인 결과, 튜토리얼, 업적 토스트)
   컨셉: 3D 코트 위에 얹는 통통한 카툰 HUD. 코트는 가리지 않고,
         숫자/버튼은 크게, 굵은 잉크 외곽선.
   z-index 는 구 style.css 값을 그대로 유지한다.
   ============================================================ */
:root {
    /* 큰 콜아웃 글자용 8방향 잉크 외곽선 (3px) + 아래 그림자 */
    --hud-ol3: -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink),
               0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink),
               0 7px 0 var(--ink);
    --hud-ol2: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink),
               0 -2px 0 var(--ink), 0 2px 0 var(--ink), -2px 0 0 var(--ink), 2px 0 0 var(--ink),
               0 4px 0 var(--ink);
    --hud-top: calc(var(--sa-t) + 14px);     /* HUD 상단 여백 (왕관 여유 포함) */
    --hud-h: 52px;                           /* 스코어 캡슐 높이 */
    --skill-sz: 76px;                        /* 필살기 버튼 지름 */
}

/* ===== HUD (Top Bar) ===== */
#hud {
    position: fixed; top: 0; left: 0; right: 0;
    display: flex; align-items: center; justify-content: center;
    padding: var(--hud-top) calc(var(--sa-r) + 60px) 0 calc(var(--sa-l) + 60px);
    z-index: 100;
    pointer-events: none;
}

/* Menu button — 좌상단 고정, 44px 터치 타깃 */
#menu-btn {
    position: absolute;
    top: calc(var(--hud-top) + (var(--hud-h) - 46px) / 2);
    left: calc(var(--sa-l) + 8px);
    width: 46px; height: 46px;
    display: none; align-items: center; justify-content: center;
    padding: 0 0 4px; line-height: 1;
    border: var(--line) solid var(--ink); border-radius: 14px;
    background: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0) 50%), var(--panel-2);
    box-shadow: inset 0 -4px 0 rgba(0,0,0,0.35), 0 3px 0 rgba(0,0,0,0.3);
    color: #fff; font-size: 20px; font-weight: 900;
    pointer-events: auto;
    z-index: 101;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}
#menu-btn.visible { display: flex; }
#menu-btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(0,0,0,0.35), 0 1px 0 rgba(0,0,0,0.3); }

/* Score capsules — 타이머 양옆에 붙는 스코어보드 */
.score-panel {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex: 0 1 104px; min-width: 76px; height: var(--hud-h);
    border: var(--line) solid var(--ink);
    box-shadow: inset 0 -5px 0 rgba(0,0,0,0.22), inset 0 2px 0 rgba(255,255,255,0.3), 0 4px 0 rgba(0,0,0,0.3);
    transition: box-shadow 0.25s ease;
}
.score-panel.enemy {
    background: linear-gradient(180deg, var(--c-enemy-light), var(--red) 55%, var(--red-d));
    border-radius: var(--r-md) 0 0 var(--r-md);
    margin-right: -14px; padding-right: 14px;
}
.score-panel.player {
    background: linear-gradient(180deg, var(--c-player-light), var(--blue) 55%, var(--blue-d));
    border-radius: 0 var(--r-md) var(--r-md) 0;
    margin-left: -14px; padding-left: 14px;
}
.score-panel .label {
    font-size: 10px; font-weight: 900; letter-spacing: 1px; line-height: 1;
    color: #fff; opacity: 0.95;
    text-shadow: 0 1px 0 rgba(0,0,0,0.45);
    margin-top: 1px;
}
.score-panel .ball-count {
    font-family: var(--font-display);
    font-size: 28px; font-weight: 900; line-height: 1; color: #fff;
    text-shadow: var(--hud-ol2);
    font-variant-numeric: tabular-nums;
    transition: color 0.25s;
    margin-top: 2px; padding-bottom: 4px;
}

/* 이기는 쪽(공이 적은 쪽) = 왕관 + 금색 테두리 발광 */
.score-panel::after {
    content: '\1F451';
    position: absolute; top: -17px;
    font-size: 20px; line-height: 1;
    transform: scale(0) rotate(0deg);
    transition: transform 0.3s var(--ease-bounce);
    filter: drop-shadow(0 2px 0 var(--ink));
    pointer-events: none;
}
.score-panel.enemy::after  { left: -6px; }
.score-panel.player::after { right: -6px; }
.score-panel.enemy.leading::after  { transform: scale(1) rotate(-22deg); }
.score-panel.player.leading::after { transform: scale(1) rotate(22deg); }
.score-panel.leading {
    box-shadow: inset 0 -5px 0 rgba(0,0,0,0.22), inset 0 2px 0 rgba(255,255,255,0.3),
                0 0 0 3px var(--yellow), 0 0 18px 4px rgba(255,203,61,0.65), 0 4px 0 rgba(0,0,0,0.3);
    z-index: 1;
}

/* Timer — 가운데 큰 시계 배지 */
#timer-display {
    position: relative; z-index: 2;
    flex: none;
    min-width: 72px; height: calc(var(--hud-h) + 12px);
    padding: 0 8px 4px;
    display: flex; align-items: center; justify-content: center;
    border: var(--line) solid var(--ink); border-radius: 22px;
    background: linear-gradient(180deg, var(--panel-3), var(--bg-0) 85%);
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.22), inset 0 -5px 0 rgba(0,0,0,0.35), 0 4px 0 rgba(0,0,0,0.3);
    font-family: var(--font-display);
    font-size: 34px; font-weight: 900; line-height: 1; color: #fff;
    text-shadow: var(--hud-ol2);
    font-variant-numeric: tabular-nums;
}
#timer-display.warning { color: var(--yellow); animation: timerFlash 0.4s ease-out; }
#timer-display.danger  { color: var(--c-enemy-light); background: linear-gradient(180deg, var(--red), var(--red-d)); animation: timerFlash 0.4s ease-out; }
#timer-display.rush    { color: var(--orange); animation: timerFlash 0.4s ease-out; }
@keyframes timerFlash {
    0%   { transform: scale(1.2); }
    50%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* ===== DYNAMIC IN-GAME FEEDBACK ===== */
/* Score pop: 내 공이 줄면 초록(좋음), 늘면 빨강 */
@keyframes countPopUp {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.5); color: var(--c-accent-soft); }
    100% { transform: scale(1); }
}
@keyframes countPopDown {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.5); color: var(--green); }
    100% { transform: scale(1); }
}
.score-panel .ball-count.count-pop-up   { animation: countPopUp 0.42s ease-out; }
.score-panel .ball-count.count-pop-down { animation: countPopDown 0.42s ease-out; }

/* 마지막 몇 초 위험 비네트 (HUD 아래, 캔버스 위) */
body.time-critical::after {
    content: '';
    position: fixed; inset: 0;
    pointer-events: none;
    z-index: 90;
    box-shadow: inset 0 0 130px 35px rgba(255,40,40,0.55);
    animation: dangerVignette 0.5s ease-in-out infinite alternate;
}
@keyframes dangerVignette { from { opacity: 0.3; } to { opacity: 0.85; } }

/* ===== 콜아웃 공통: 굵은 카툰 레터링 ===== */
.rush-text, .close-game-text, .nearmiss-callout, .reversal-stamp, #countdown-text {
    font-family: var(--font-display);
    font-weight: 900; font-style: italic;
    line-height: 1.05; white-space: nowrap;
    text-shadow: var(--hud-ol3);
    letter-spacing: 1px;
}

/* RUSH overlay (blowout / golden-ball 안내도 같은 컨테이너) */
.rush-overlay {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    padding-bottom: 18vh;                 /* 코트 중앙보다 살짝 위 — 필살기 버튼과 겹치지 않게 */
    z-index: 500; pointer-events: none;
    transition: opacity 0.6s;
}
.rush-text {
    font-size: clamp(64px, 23vw, 130px);
    color: var(--orange);
    transform: rotate(-5deg);
    animation: rushPop 0.5s var(--ease-bounce) both;
}
@keyframes rushPop {
    0%   { transform: scale(3) rotate(-5deg); opacity: 0; }
    50%  { transform: scale(0.9) rotate(-5deg); opacity: 1; }
    100% { transform: scale(1) rotate(-5deg); opacity: 1; }
}
.mercy-text { color: var(--red); font-size: clamp(56px, 19vw, 120px); animation-duration: 0.4s; }
.golden-announce { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.golden-text { color: var(--yellow); font-size: clamp(40px, 12.5vw, 96px); }
.golden-sub {
    padding: 6px 16px;
    border: var(--line) solid var(--ink); border-radius: var(--r-pill);
    background: var(--yellow); color: var(--text-on-bright);
    box-shadow: 0 4px 0 rgba(0,0,0,0.3);
    font-size: clamp(14px, 4.4vw, 20px); font-weight: 900;
    animation: hudPopIn 0.45s var(--ease-bounce) 0.15s both;
}
@keyframes hudPopIn { from { transform: scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== MENU DROPDOWN ===== */
.menu-dropdown {
    position: fixed;
    top: calc(var(--hud-top) + var(--hud-h) + 8px);
    left: calc(var(--sa-l) + 8px);
    display: flex; flex-direction: column; gap: 6px;
    min-width: 180px; padding: 8px;
    border: var(--line) solid var(--ink); border-radius: var(--r-md);
    background: var(--panel);
    box-shadow: var(--shadow-md), 0 16px 32px rgba(0,0,0,0.4);
    z-index: 200;
    transform-origin: top left;
    animation: menuSlideIn 0.2s var(--ease-bounce);
}
.menu-dropdown.hidden { display: none; }
@keyframes menuSlideIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.9); }
    to   { opacity: 1; transform: none; }
}
.menu-dropdown-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; min-height: var(--tap); padding: 0 16px;
    border: 2px solid var(--ink); border-radius: var(--r-sm);
    background: var(--panel-2);
    box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25);
    color: #fff; font-size: var(--fs-md); font-weight: 900; text-align: left;
}
.menu-dropdown-item:active { transform: translateY(2px); box-shadow: none; }
.menu-dropdown-item.menu-exit { background: var(--red); box-shadow: inset 0 -3px 0 var(--red-d); }

/* ===== STAT STRIPS (HUD 아래, 팀별 캐릭터 칩) ===== */
.stat-strip {
    position: fixed;
    top: calc(var(--hud-top) + var(--hud-h) + 20px);
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;   /* 세로 화면: 가장자리에 세로로 쌓기 (3v3 도 겹치지 않게) */
    max-width: 47%;
    z-index: 99;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}
.stat-strip:empty { display: none; }
.stat-strip.hidden-in-game { opacity: 0; transform: translateY(-8px); }
.stat-strip.cpu-strip    { left: calc(var(--sa-l) + 8px); }
.stat-strip.player-strip { right: calc(var(--sa-r) + 8px); align-items: flex-end; }
.strip-npc {
    display: flex; align-items: center; gap: 5px;
    height: 28px; padding: 0 7px 0 4px;
    border: 2px solid var(--ink); border-radius: var(--r-pill);
    background: rgba(18,11,51,0.78);
    min-width: 0;
}
.cpu-strip .strip-npc    { box-shadow: inset 0 -2px 0 var(--red-d); }
.player-strip .strip-npc { box-shadow: inset 0 -2px 0 var(--blue-d); }
.stat-strip .strip-name, .stat-strip .strip-npc-sep { display: none; }
.stat-strip .strip-bars { display: flex; flex-direction: column; gap: 3px; order: 2; }
.stat-strip .strip-stat { display: flex; align-items: center; gap: 3px; }
.stat-strip .strip-stat-label {
    width: 7px; font-size: 8px; font-weight: 900; line-height: 1;
    color: var(--text-dim);
}
.stat-strip .strip-stat-bar {
    width: 26px; height: 5px;
    border-radius: var(--r-pill); background: rgba(255,255,255,0.16); overflow: hidden;
}
.strip-stat-fill { display: block; height: 100%; border-radius: inherit; transition: width 0.3s ease; }
.strip-stat-fill.spd, .blue-fill { background: var(--blue); }
.strip-stat-fill.pow, .red-fill  { background: var(--pink); }
.stat-strip .strip-skill { position: relative; display: flex; align-items: center; justify-content: center; order: 1; width: 20px; height: 20px; flex: none; }
.stat-strip .strip-skill-icon { font-size: 15px; line-height: 1; }
.stat-strip .strip-skill-cd {
    position: absolute; inset: -1px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: rgba(18,11,51,0.72);
    font-size: 11px; font-weight: 900; color: var(--yellow);
    font-variant-numeric: tabular-nums;
}
.stat-strip .strip-skill-cd:empty { display: none; }

/* ===== SKILL SLOTS ===== */
.skill-slots { display: flex; gap: 14px; align-items: flex-end; }
.skill-slot {
    position: relative;
    width: 40px; height: 40px; border-radius: 50%;
    border: var(--line) solid var(--ink);
    background: var(--panel-2);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; line-height: 1;
    pointer-events: none;
}
.skill-slot .skill-slot-icon { position: relative; z-index: 0; }
.skill-slot .skill-cd-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    height: 0%; z-index: 1;
    background: rgba(18,11,51,0.78);
    transition: height 0.1s linear;
}
.skill-slot .skill-cd-text {
    position: absolute; z-index: 2;
    font-family: var(--font-display); font-weight: 900;
    font-size: 14px; color: #fff;
    text-shadow: var(--hud-ol2);
    font-variant-numeric: tabular-nums;
}

/* ===== PLAYER SKILL BAR (하단 중앙, 엄지 영역) ===== */
#player-skill-bar {
    position: fixed;
    bottom: calc(var(--sa-b) + 22px);
    left: 50%; transform: translateX(-50%);
    z-index: 100;
    display: flex;
}
#player-skill-bar .skill-slots { margin: 0; }
#player-skill-bar .skill-slot {
    --r-in: calc(var(--skill-sz) / 2 - 4px);
    width: var(--skill-sz); height: var(--skill-sz);
    border-width: 4px;
    font-size: calc(var(--skill-sz) * 0.46);
    cursor: pointer; pointer-events: auto;
    touch-action: manipulation;
    background: radial-gradient(circle at 50% 28%, var(--panel-3), var(--panel) 70%);
    box-shadow: inset 0 -6px 0 rgba(0,0,0,0.3), 0 5px 0 rgba(0,0,0,0.35);
    transition: transform 0.12s var(--ease-bounce), box-shadow 0.12s ease;
}
/* 쿨다운 가림막을 원 안쪽으로 클립 (슬롯은 overflow visible: READY 배지/후광 때문에) */
#player-skill-bar .skill-slot .skill-cd-overlay {
    clip-path: circle(var(--r-in) at 50% calc(100% - var(--r-in)));
}
#player-skill-bar .skill-slot .skill-cd-text { font-size: calc(var(--skill-sz) * 0.42); text-shadow: var(--hud-ol3); }
#player-skill-bar .skill-slot.on-cooldown { cursor: default; }
#player-skill-bar .skill-slot.on-cooldown .skill-slot-icon { opacity: 0.55; filter: grayscale(0.6); }
/* READY: 노란 버튼 + 후광 펄스 + 통통 튀기 + 배지 */
#player-skill-bar .skill-slot.ready {
    background: radial-gradient(circle at 50% 26%, #fff, var(--yellow) 48%, var(--orange) 100%);
    box-shadow: inset 0 -7px 0 var(--yellow-d), 0 5px 0 rgba(0,0,0,0.35), 0 0 0 0 rgba(255,203,61,0.85);
    animation: skillReady 1.1s ease-in-out infinite;
}
#player-skill-bar .skill-slot.ready::before {
    content: '';
    position: absolute; inset: -14px; z-index: -1;
    border-radius: 50%;
    background: repeating-conic-gradient(from 0deg, rgba(255,203,61,0.9) 0 12deg, transparent 12deg 30deg);
    -webkit-mask: radial-gradient(circle, transparent 54%, #000 56%, transparent 72%);
            mask: radial-gradient(circle, transparent 54%, #000 56%, transparent 72%);
    animation: skillRays 4s linear infinite;
    pointer-events: none;
}
#player-skill-bar .skill-slot.ready::after {
    content: 'READY';
    position: absolute; left: 50%; bottom: -13px;
    transform: translateX(-50%);
    padding: 3px 9px 4px;
    border: 2px solid var(--ink); border-radius: var(--r-pill);
    background: var(--green); color: #06331c;
    box-shadow: 0 2px 0 rgba(0,0,0,0.35);
    font-size: 11px; font-weight: 900; letter-spacing: 1px; line-height: 1;
    pointer-events: none;
}
#player-skill-bar .skill-slot.ready:active { transform: scale(0.9) translateY(3px); animation: none; }
@keyframes skillReady {
    0%, 100% { transform: translateY(0) scale(1);
               box-shadow: inset 0 -7px 0 var(--yellow-d), 0 5px 0 rgba(0,0,0,0.35), 0 0 0 0 rgba(255,203,61,0.8); }
    50%      { transform: translateY(-5px) scale(1.06);
               box-shadow: inset 0 -7px 0 var(--yellow-d), 0 10px 0 rgba(0,0,0,0.25), 0 0 0 12px rgba(255,203,61,0); }
}
@keyframes skillRays { to { transform: rotate(360deg); } }

/* ===== COUNTDOWN ===== */
#countdown-overlay {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
#countdown-overlay.active { opacity: 1; background: radial-gradient(circle at 50% 50%, rgba(18,11,51,0.5), rgba(18,11,51,0) 60%); }
#countdown-text {
    font-size: min(42vw, 46vh, 220px);
    color: var(--yellow);
    text-shadow: var(--hud-ol3), 0 12px 0 rgba(0,0,0,0.35), 0 0 60px rgba(255,203,61,0.55);
    animation: countPop 0.6s ease-out;     /* JS 가 'countPop' 이름으로 재실행 */
}
@keyframes countPop {
    0%   { transform: scale(2.6) rotate(-10deg); opacity: 0; }
    50%  { transform: scale(0.88) rotate(3deg); opacity: 1; }
    100% { transform: scale(1) rotate(-3deg); opacity: 1; }
}

/* ===== CLOSE GAME OVERLAY ===== */
.close-game-overlay {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 550;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease-in;
}
.close-game-overlay.active { opacity: 1; }
.close-game-overlay.fade-out { opacity: 0; transition: opacity 0.6s ease-out; }
.close-game-text {
    font-size: clamp(60px, 22vw, 120px);
    color: var(--yellow);
    letter-spacing: 4px;
    animation: closeGamePop 0.6s ease-out both;
}
@keyframes closeGamePop {
    0%   { transform: scale(3) rotate(-10deg); opacity: 0; }
    50%  { transform: scale(0.9) rotate(-2deg); opacity: 1; }
    70%  { transform: scale(1.05) rotate(-6deg); opacity: 1; }
    100% { transform: scale(1) rotate(-5deg); opacity: 1; }
}

/* ===== VS SPLASH SCREEN ===== */
.vs-splash-overlay {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 550;
    background: linear-gradient(100deg, var(--blue-d) 0 49.2%, var(--ink) 49.2% 50.8%, var(--red-d) 50.8% 100%);
    opacity: 0;
    transition: opacity 0.3s ease-out;
    overflow: hidden;
}
.vs-splash-overlay::before {      /* 방사형 스피드 라인 */
    content: '';
    position: absolute; inset: -50%;
    background: repeating-conic-gradient(from 0deg, rgba(255,255,255,0.09) 0 6deg, transparent 6deg 16deg);
    animation: skillRays 14s linear infinite;
    pointer-events: none;
}
.vs-splash-overlay.active { opacity: 1; }
.vs-splash-overlay.exit { opacity: 0; transition: opacity 0.3s ease-in; }
.vs-splash-side {
    position: relative;
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 14px; padding: 16px 8px;
}
.vs-splash-left {
    transform: translateX(-60px); opacity: 0;
    transition: transform 0.5s var(--ease-bounce), opacity 0.4s ease;
}
.vs-splash-right {
    transform: translateX(60px); opacity: 0;
    transition: transform 0.5s var(--ease-bounce) 0.1s, opacity 0.4s ease 0.1s;
}
.vs-splash-overlay.active .vs-splash-left,
.vs-splash-overlay.active .vs-splash-right { transform: none; opacity: 1; }
.vs-splash-badge {
    position: relative; z-index: 1; flex: none;
    margin: 0 -20px;
    font-family: var(--font-display);
    font-size: clamp(64px, 20vw, 120px); font-weight: 900; font-style: italic; line-height: 1;
    color: var(--yellow);
    text-shadow: var(--hud-ol3), 0 0 40px rgba(255,203,61,0.6);
    transform: scale(0) rotate(-8deg);
    transition: transform 0.4s var(--ease-bounce) 0.3s;
}
.vs-splash-overlay.active .vs-splash-badge { transform: scale(1) rotate(-8deg); }
.vs-splash-char { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.vs-splash-char img, .vs-splash-circle {
    width: 84px; height: 84px;
    border-radius: 50%;
    border: 4px solid var(--ink);
    background: rgba(255,255,255,0.92);
    box-shadow: 0 0 0 3px #fff, 0 6px 0 3px rgba(0,0,0,0.3);
    object-fit: cover;
}
.vs-splash-name {
    font-family: var(--font-display);
    font-size: var(--fs-lg); font-weight: 900; color: #fff;
    text-shadow: var(--hud-ol2);
}

/* ===== POWER-UP EFFECT TEXT ===== */
.powerup-effect-text {
    position: fixed;
    font-family: var(--font-display);
    font-size: 24px; font-weight: 900; font-style: italic;
    letter-spacing: 1px; white-space: nowrap;
    text-shadow: var(--hud-ol2);
    z-index: 200;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    transition: transform 0.3s var(--ease-bounce), opacity 0.3s ease;
}
.powerup-effect-text.active { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.powerup-effect-text.fade-out {
    transform: translate(-50%, -110%) scale(0.85); opacity: 0;
    transition: transform 0.6s ease, opacity 0.6s ease;
}

/* ===== ACHIEVEMENT POPUP (toast) ===== */
.achievement-popup {
    position: fixed;
    top: -120px; left: 50%;
    transform: translateX(-50%);
    z-index: 800;
    display: flex; align-items: center; gap: 12px;
    width: max-content; max-width: min(92vw, 420px);
    padding: 10px 18px 12px 10px;
    border: var(--line) solid var(--ink); border-radius: var(--r-md);
    background: linear-gradient(180deg, var(--panel-3), var(--panel));
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.18), 0 0 0 3px var(--yellow), 0 8px 0 3px rgba(0,0,0,0.3);
    pointer-events: none;
    transition: top 0.5s var(--ease-bounce);
}
.achievement-popup.show { top: calc(var(--hud-top) + var(--hud-h) + 22px); }   /* HUD 스코어를 가리지 않게 바로 아래 */
.achievement-popup.hidden { display: none; }
.achievement-popup-icon {
    flex: none; width: 52px; height: 52px;
    display: flex; align-items: center; justify-content: center;
    border: var(--line) solid var(--ink); border-radius: 50%;
    background: radial-gradient(circle at 50% 30%, #fff, var(--yellow) 60%, var(--orange));
    font-size: 28px; line-height: 1;
}
.achievement-popup-info { display: flex; flex-direction: column; min-width: 0; }
.achievement-popup-title { font-size: var(--fs-md); font-weight: 900; color: var(--yellow); text-shadow: var(--text-shadow); }
.achievement-popup-desc { font-size: var(--fs-sm); color: var(--text-dim); margin-top: 2px; }

/* ===== 첫 매치 힌트 배너 ===== */
.first-match-hint {
    position: fixed;
    top: calc(var(--hud-top) + var(--hud-h) + 58px);
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    width: max-content; max-width: min(360px, 92vw);
    padding: 10px 16px;
    border: var(--line) solid var(--ink); border-radius: var(--r-md);
    background: var(--panel);
    box-shadow: 0 0 0 3px var(--yellow), 0 6px 0 3px rgba(0,0,0,0.3);
    z-index: 850;
    text-align: center;
    opacity: 0;
    transition: opacity 0.4s, transform 0.4s var(--ease-bounce);
    pointer-events: none;
}
.first-match-hint.show { opacity: 1; transform: translateX(-50%); }
.first-match-hint-line { font-size: var(--fs-md); color: #fff; line-height: 1.6; }
.first-match-hint-line b { color: var(--yellow); }

/* ============================================================
   RESULT SCREEN (+ CAMPAIGN RESULT)
   ============================================================ */
#result-overlay, .campaign-result-overlay {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    padding: calc(var(--sa-t) + 12px) calc(var(--sa-r) + 12px) calc(var(--sa-b) + 12px) calc(var(--sa-l) + 12px);
    background: var(--scrim);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    animation: fadeIn 0.4s;
}
#result-overlay { z-index: 600; }
#result-overlay.hidden { display: none; }
.campaign-result-overlay { z-index: 650; }

#result-box, .campaign-result-box {
    position: relative;
    width: 100%; max-width: 400px; max-height: 100%;
    overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch; touch-action: pan-y;
    padding: 0 16px 16px;
    text-align: center;
    border: var(--line) solid var(--ink); border-radius: var(--r-lg);
    background: linear-gradient(180deg, var(--panel-2), var(--panel) 40%);
    box-shadow: var(--shadow-lg);
    animation: ui-pop 0.35s var(--ease-bounce) both;
}

/* WIN / LOSE 배너 */
#result-title, .campaign-result-title {
    position: relative;
    margin: 0 -16px;
    padding: 18px 12px 26px;
    border-bottom: var(--line) solid var(--ink);
    background: var(--gray-d);
    font-family: var(--font-display);
    font-size: clamp(34px, 12vw, 50px); font-weight: 900; font-style: italic; line-height: 1.05;
    letter-spacing: 2px; color: #fff;
    text-shadow: var(--hud-ol3);
    overflow: hidden;
}
#result-title::before, .campaign-result-title::before {   /* 배너 햇살 */
    content: '';
    position: absolute; left: 50%; top: 50%; width: 600px; height: 600px;
    margin: -300px 0 0 -300px;
    background: repeating-conic-gradient(from 0deg, rgba(255,255,255,0.16) 0 8deg, transparent 8deg 20deg);
    animation: skillRays 24s linear infinite;
    pointer-events: none; z-index: -1;
}
#result-title, .campaign-result-title { z-index: 0; }
#result-title.win,  .campaign-result-title.win  { background: linear-gradient(180deg, var(--green), var(--green-d)); color: #fff6c9; }
#result-title.lose, .campaign-result-title.lose { background: linear-gradient(180deg, var(--red), var(--red-d)); }
#result-title.draw { background: linear-gradient(180deg, var(--yellow), var(--yellow-d)); }
#result-title.lose::before, .campaign-result-title.lose::before { opacity: 0.4; animation: none; }

/* 캐릭터 리액션 이모지 — 배너 아래 모서리에 걸친 메달 */
.result-reaction {
    position: relative; z-index: 1;
    width: 56px; height: 56px; margin: -24px auto 0;
    display: flex; align-items: center; justify-content: center;
    border: var(--line) solid var(--ink); border-radius: 50%;
    background: var(--panel-3);
    box-shadow: 0 4px 0 rgba(0,0,0,0.3);
    font-size: 30px; line-height: 1;
    animation: reactionPop 0.5s ease-out;
}
@keyframes reactionPop {
    0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
    60%  { transform: scale(1.3) rotate(5deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* 스코어 줄 */
#result-detail, .campaign-result-score {
    display: inline-block;
    margin: 12px auto 0; padding: 7px 18px;
    border: 2px solid var(--ink); border-radius: var(--r-pill);
    background: rgba(18,11,51,0.7);
    font-size: var(--fs-md); font-weight: 900; color: #fff;
    font-variant-numeric: tabular-nums;
}

/* 등급 스탬프 (S/A/B/C) */
.grade-stamp {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 92px; height: 92px; margin: 18px auto 12px;
    border: 4px solid var(--ink); border-radius: 50%;
    background: radial-gradient(circle at 50% 28%, rgba(255,255,255,0.95), currentColor 62%);
    box-shadow: 0 0 0 4px currentColor, 0 0 0 7px var(--ink), 0 7px 0 7px rgba(0,0,0,0.3);
    animation: gradeSlam 0.6s cubic-bezier(0.2, 1.3, 0.3, 1) both;
    animation-delay: 0.35s;
}
.grade-stamp-label {
    font-size: 10px; font-weight: 900; letter-spacing: 2px; line-height: 1;
    color: var(--ink); opacity: 0.75;
    margin-top: 4px;
}
.grade-stamp-letter {
    font-family: var(--font-display);
    font-size: 54px; font-weight: 900; font-style: italic; line-height: 1;
    color: #fff;
    text-shadow: var(--hud-ol2);
    padding-right: 4px;
}
.grade-stamp.grade-s { color: var(--yellow); }
.grade-stamp.grade-a { color: var(--green); }
.grade-stamp.grade-b { color: var(--blue); }
.grade-stamp.grade-c { color: var(--gray); }
@keyframes gradeSlam {
    0%   { transform: scale(2.4) rotate(-20deg); opacity: 0; }
    55%  { transform: scale(0.9) rotate(-2deg); opacity: 1; }
    75%  { transform: scale(1.06) rotate(-10deg); }
    100% { transform: scale(1) rotate(-8deg); opacity: 1; }
}
.grade-stamp.grade-s { animation: gradeSlam 0.6s cubic-bezier(0.2, 1.3, 0.3, 1) 0.35s both, gradeSShine 1.6s ease-in-out 1s infinite; }
@keyframes gradeSShine {
    0%, 100% { box-shadow: 0 0 0 4px currentColor, 0 0 0 7px var(--ink), 0 7px 0 7px rgba(0,0,0,0.3), 0 0 0 0 rgba(255,203,61,0.7); }
    50%      { box-shadow: 0 0 0 4px currentColor, 0 0 0 7px var(--ink), 0 7px 0 7px rgba(0,0,0,0.3), 0 0 30px 14px rgba(255,203,61,0.55); }
}

/* 엔드리스 결과 */
.result-endless {
    margin: 10px 0 0;
    font-size: var(--fs-md); font-weight: 800; color: var(--text-dim); line-height: 1.6;
}
.result-endless b { color: var(--c-brand-light); font-size: var(--fs-lg); }
.result-endless .endless-coins { color: var(--yellow); }

/* 보상 카드: XP / 코인 / 보너스 태그 / XP 바 */
.result-progression {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    margin: 12px 0 0; padding: 12px;
    border: 2px solid var(--ink); border-radius: var(--r-md);
    background: rgba(18,11,51,0.45);
}
.result-reward-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.reward-xp, .reward-coins, .campaign-result-xp, .campaign-result-coins {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 36px; padding: 0 14px;
    border: 2px solid var(--ink); border-radius: var(--r-pill);
    font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 900;
    font-variant-numeric: tabular-nums;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2);
}
.reward-xp, .campaign-result-xp { background: var(--purple); color: #fff; text-shadow: var(--text-shadow); }
.reward-coins, .campaign-result-coins { background: var(--yellow); color: var(--text-on-bright); }
.reward-xp::before, .campaign-result-xp::before { content: '\2B50'; font-size: 0.9em; }
.reward-coins::before, .campaign-result-coins::before { content: '\1FA99'; font-size: 0.9em; }

.result-bonus-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 6px; }
.result-bonus-tag {
    position: relative; overflow: hidden;
    display: inline-flex; align-items: center;
    min-height: 26px; padding: 0 10px;
    border: 2px solid var(--ink); border-radius: var(--r-sm);
    background: var(--panel-3); color: #fff;
    box-shadow: 0 3px 0 rgba(0,0,0,0.3);
    font-size: 12px; font-weight: 900; letter-spacing: 0.3px;
    text-shadow: var(--text-shadow);
    animation: bonusTagIn 0.4s var(--ease-bounce) 0.5s both;
}
.result-bonus-tag:nth-child(odd)  { --tilt: -3deg; }
.result-bonus-tag:nth-child(even) { --tilt: 2.5deg; animation-delay: 0.62s; }
.result-bonus-tag:nth-child(3)    { animation-delay: 0.74s; }
.result-bonus-tag:nth-child(n+4)  { animation-delay: 0.86s; }
@keyframes bonusTagIn {
    from { transform: scale(2) rotate(calc(var(--tilt, 0deg) * 4)); opacity: 0; }
    to   { transform: scale(1) rotate(var(--tilt, 0deg)); opacity: 1; }
}
/* 특별 보너스 스티커 (데일리 / 콤보 / 연승): 그라디언트 + 광택 스윕 */
.result-bonus-tag.daily-bonus-tag,
.result-bonus-tag.combo-bonus-tag,
.result-bonus-tag.streak-bonus-tag {
    min-height: 32px; padding: 0 12px 2px;
    border-width: var(--line); border-radius: 12px;
    font-size: 13px; font-style: italic;
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.45), inset 0 -4px 0 rgba(0,0,0,0.2), 0 4px 0 rgba(0,0,0,0.3);
}
.result-bonus-tag.daily-bonus-tag  { background: linear-gradient(180deg, #fff3b8, var(--yellow) 55%, var(--yellow-d)); color: var(--text-on-bright); text-shadow: 0 1px 0 rgba(255,255,255,0.5); }
.result-bonus-tag.combo-bonus-tag  { background: linear-gradient(180deg, var(--yellow), var(--orange) 50%, var(--red)); text-shadow: var(--hud-ol2); padding-bottom: 5px; min-height: 36px; font-size: 14px; }
.result-bonus-tag.streak-bonus-tag { background: linear-gradient(180deg, var(--pink), var(--red) 50%, var(--red-d)); text-shadow: var(--hud-ol2); padding-bottom: 5px; min-height: 36px; font-size: 14px; }
.result-bonus-tag.daily-bonus-tag::after,
.result-bonus-tag.combo-bonus-tag::after,
.result-bonus-tag.streak-bonus-tag::after {
    content: '';
    position: absolute; top: -20%; bottom: -20%; left: -40%; width: 30%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.75), transparent);
    transform: skewX(-20deg);
    animation: tagShine 2.4s ease-in-out 1.2s infinite;
    pointer-events: none;
}
@keyframes tagShine { 0% { left: -40%; } 35%, 100% { left: 120%; } }

.result-xp-bar-container { display: flex; align-items: center; gap: 10px; width: 100%; }
.result-xp-bar {
    flex: 1; height: 16px;
    border: 2px solid var(--ink); border-radius: var(--r-pill);
    background: rgba(18,11,51,0.75); overflow: hidden;
}
.result-xp-fill {
    height: 100%; border-radius: inherit;
    background: linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0) 55%), var(--purple);
    transition: width 1s ease;
}
.result-xp-label {
    flex: none; min-width: 92px; text-align: right; white-space: nowrap;
    font-size: var(--fs-sm); font-weight: 900; color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
.result-levelup {
    font-family: var(--font-display);
    font-size: var(--fs-xl); font-weight: 900; font-style: italic;
    color: var(--yellow); text-shadow: var(--hud-ol2);
    animation: levelUpPop 0.6s ease-out;
}
@keyframes levelUpPop {
    0%   { transform: scale(0.5); opacity: 0; }
    60%  { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1);   opacity: 1; }
}
.result-unlock, .campaign-result-unlock, .campaign-result-newbest {
    font-size: var(--fs-md); font-weight: 900;
    color: var(--green);
    animation: unlockSlide 0.5s ease-out;
}
@keyframes unlockSlide { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 랭크 판정 */
.result-ranked-verdict {
    display: block;
    margin: 10px 0 0; padding: 9px 14px;
    border: 2px solid var(--ink); border-radius: var(--r-md);
    font-size: var(--fs-md); font-weight: 900;
    animation: hudPopIn 0.4s var(--ease-bounce);
}
.result-ranked-verdict.up   { background: var(--green); color: #06331c; }
.result-ranked-verdict.down { background: var(--red); color: #fff; }
.result-ranked-verdict.void { background: var(--gray-d); color: #fff; }

/* 버튼들 (ui-btn 기반) */
#result-box > .ui-btn { margin-top: 10px; }
#result-box > #replay-btn, #result-box > .next-stage-btn { margin-top: 14px; }
#result-box > .next-stage-btn + #replay-btn { margin-top: 10px; }
/* 다음 스테이지가 있으면 '다시 하기'는 보조 버튼으로 */
#result-box > .next-stage-btn ~ #replay-btn {
    --btn: var(--blue); --btn-d: var(--blue-d); --btn-text: #fff; --depth: 5px;
    min-height: var(--tap); font-size: var(--fs-md); border-radius: var(--r-md);
    text-shadow: var(--text-shadow);
}
.result-ad-btn { font-size: var(--fs-md); }
.result-ad-btn b {
    padding: 2px 8px; border-radius: var(--r-pill);
    background: var(--ink); color: var(--yellow); text-shadow: none;
}
.result-ad-btn.claimed { --btn: var(--yellow); --btn-d: var(--yellow-d); --btn-text: var(--text-on-bright); cursor: default; }

/* ===== CAMPAIGN RESULT ===== */
.campaign-result-box > :not(.campaign-result-title) { margin-left: auto; margin-right: auto; }
.campaign-result-score { display: table; margin-top: 14px; }
.campaign-result-stars {
    display: flex; justify-content: center; align-items: flex-end; gap: 6px;
    margin-top: 12px;
}
.campaign-result-star {
    font-size: 46px; line-height: 1;
    -webkit-text-stroke: 0;
    text-shadow: var(--hud-ol2);
}
.campaign-result-star:nth-child(2) { font-size: 58px; }
.campaign-result-star.earned { color: var(--yellow); animation: starPop 0.5s var(--ease-bounce) both; }
.campaign-result-star.earned:nth-child(2) { animation-delay: 0.18s; }
.campaign-result-star.earned:nth-child(3) { animation-delay: 0.36s; }
.campaign-result-star.empty { color: var(--panel-3); }
@keyframes starPop {
    0%   { transform: scale(0) rotate(-40deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.campaign-result-xp, .campaign-result-coins { display: flex; width: max-content; margin-top: 10px; }
.campaign-result-box .result-levelup,
.campaign-result-box .result-unlock,
.campaign-result-unlock, .campaign-result-newbest { margin-top: 8px; }
.campaign-result-newbest { color: var(--yellow); font-style: italic; letter-spacing: 1px; text-shadow: var(--text-shadow); }
.campaign-result-unlock { color: var(--c-player-light); }
.campaign-result-zone-bonus {
    display: table;
    margin-top: 10px; padding: 8px 16px;
    border: 2px solid var(--ink); border-radius: var(--r-md);
    background: linear-gradient(180deg, #fff3b8, var(--yellow)); color: var(--text-on-bright);
    box-shadow: 0 3px 0 rgba(0,0,0,0.3);
    font-size: var(--fs-md); font-weight: 900;
    animation: hudPopIn 0.5s var(--ease-bounce);
}
.campaign-result-buttons { display: flex; gap: 10px; margin-top: 16px; }
.campaign-result-buttons .ui-btn { flex: 1.7 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; white-space: nowrap; }
.campaign-result-buttons .campaign-result-map-btn { flex: 1 1 0; min-height: 64px; }
.campaign-result-buttons .ui-btn--lg { font-size: var(--fs-lg); }
.campaign-result-map-btn:only-child { flex: 1; }

/* ===== COIN FLY ===== */
.coin-fly {
    position: fixed;
    font-size: 26px;
    z-index: 900;
    pointer-events: none;
    filter: drop-shadow(0 2px 0 var(--ink));
    transition: left 0.6s var(--ease-bounce), top 0.6s var(--ease-bounce), opacity 0.6s ease, transform 0.6s ease;
    transform: scale(1);
}
.coin-fly.fly { opacity: 0; transform: scale(0.3); }

/* ============================================================
   TUTORIAL (FTUE) — 바텀시트형 카드 + 인매치 넛지
   ============================================================ */
.tutorial-overlay {
    position: fixed; inset: 0;
    z-index: 950;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    gap: 14px;
    padding: calc(var(--sa-t) + 70px) calc(var(--sa-r) + 12px) calc(var(--sa-b) + 22px) calc(var(--sa-l) + 12px);
    background: var(--scrim);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}
.tutorial-overlay.show { opacity: 1; }
.tutorial-overlay.out { opacity: 0; }
.tutorial-card {
    width: 100%; max-width: 420px;
    padding: 0 20px 18px;
    text-align: center;
    border: var(--line) solid var(--ink); border-radius: var(--r-lg);
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    box-shadow: var(--shadow-lg);
}
.tutorial-card.pop { animation: tutorialPop 0.35s var(--ease-bounce); }
@keyframes tutorialPop {
    0%   { transform: translateY(40px) scale(0.92); opacity: 0.4; }
    100% { transform: none; opacity: 1; }
}
.tutorial-card-icon {
    width: 88px; height: 88px; margin: -44px auto 10px;
    display: flex; align-items: center; justify-content: center;
    border: var(--line) solid var(--ink); border-radius: 50%;
    background: radial-gradient(circle at 50% 30%, #fff, var(--yellow) 60%, var(--orange));
    box-shadow: 0 5px 0 rgba(0,0,0,0.3);
    font-size: 46px; line-height: 1;
}
.tutorial-card-title {
    font-family: var(--font-display);
    font-size: var(--fs-xl); font-weight: 900;
    color: var(--yellow); text-shadow: var(--hud-ol2);
    margin-bottom: 10px;
}
.tutorial-card-body { font-size: 17px; font-weight: 700; line-height: 1.6; color: #fff; }
.tutorial-card-body b { color: var(--green); font-weight: 900; }
.tutorial-card-next {
    display: flex; align-items: center; justify-content: center;
    min-height: 54px; margin-top: 16px; padding-bottom: 5px;
    border: var(--line) solid var(--ink); border-radius: var(--r-md);
    background: linear-gradient(180deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0) 46%), var(--yellow);
    box-shadow: inset 0 -5px 0 var(--yellow-d), 0 4px 0 rgba(0,0,0,0.3);
    color: var(--text-on-bright);
    font-size: var(--fs-lg); font-weight: 900;
    animation: tutorialBlink 1.2s ease-in-out infinite;
}
@keyframes tutorialBlink {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.035); }
}
.tutorial-dots { display: flex; gap: 8px; }
.tutorial-dot {
    width: 12px; height: 12px; border-radius: 50%;
    border: 2px solid var(--ink);
    background: var(--panel-3);
    transition: background 0.2s, transform 0.2s;
}
.tutorial-dot.on { background: var(--yellow); transform: scale(1.3); }
/* 건너뛰기: 우상단 고정 — 카드에 갇힌 느낌이 들지 않게 항상 보이는 출구 */
.tutorial-skip {
    position: absolute;
    top: calc(var(--sa-t) + 12px); right: calc(var(--sa-r) + 12px);
    min-height: 46px; padding: 0 18px 3px;
    border: var(--line) solid var(--ink); border-radius: var(--r-pill);
    background: var(--panel-2);
    box-shadow: inset 0 -4px 0 rgba(0,0,0,0.3), 0 3px 0 rgba(0,0,0,0.3);
    color: #fff; font-size: var(--fs-md); font-weight: 900;
}
.tutorial-skip::after { content: ' \00BB'; }
.tutorial-skip:active { transform: translateY(2px); }

/* 인매치 넛지 */
.tutorial-nudge {
    position: fixed; left: 50%;
    transform: translateX(-50%) translateY(8px);
    padding: 10px 18px;
    border: var(--line) solid var(--ink); border-radius: var(--r-pill);
    background: var(--green); color: #06331c;
    box-shadow: 0 4px 0 rgba(0,0,0,0.3);
    font-size: var(--fs-md); font-weight: 900;
    z-index: 840;
    opacity: 0;
    transition: opacity 0.35s, transform 0.35s var(--ease-bounce);
    pointer-events: none;
    white-space: nowrap; max-width: 94vw;
}
.tutorial-nudge.show { opacity: 1; transform: translateX(-50%); }
.tutorial-nudge-tap { bottom: 42%; animation: tutorialNudgePulse 1.2s ease-in-out infinite; }
.tutorial-nudge-skill {
    bottom: calc(var(--sa-b) + var(--skill-sz) + 62px);
    background: var(--yellow); color: var(--text-on-bright);
}
.tutorial-nudge-skill::after {       /* 버튼을 가리키는 꼬리 */
    content: '';
    position: absolute; left: 50%; bottom: -9px; width: 14px; height: 14px;
    margin-left: -7px;
    background: inherit;
    border-right: var(--line) solid var(--ink); border-bottom: var(--line) solid var(--ink);
    transform: rotate(45deg);
}
@keyframes tutorialNudgePulse {
    0%, 100% { box-shadow: 0 4px 0 rgba(0,0,0,0.3), 0 0 0 0 rgba(62,224,138,0.6); }
    50%      { box-shadow: 0 4px 0 rgba(0,0,0,0.3), 0 0 0 12px rgba(62,224,138,0); }
}

/* ============================================================
   IMPACT PACK — near-miss / clutch / reversal
   ============================================================ */
.nearmiss-flash {
    position: fixed; inset: 0;
    pointer-events: none;
    z-index: 480;
    background: radial-gradient(circle at center, rgba(255,255,255,0.55), rgba(255,255,255,0) 70%);
    animation: nearmissFlash 0.4s ease-out forwards;
}
@keyframes nearmissFlash { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }
.nearmiss-callout {
    position: fixed; top: 34%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 500;
    font-size: clamp(40px, 13vw, 68px);
    color: var(--c-accent-soft);
    animation: nearmissCallout 0.9s ease-out forwards;
}
@keyframes nearmissCallout {
    0%   { transform: translate(-50%, -50%) scale(0.4) rotate(-8deg); opacity: 0; }
    25%  { transform: translate(-50%, -50%) scale(1.15) rotate(-4deg); opacity: 1; }
    45%  { transform: translate(-50%, -50%) scale(1) rotate(-3deg); opacity: 1; }
    100% { transform: translate(-50%, -60%) scale(1) rotate(-3deg); opacity: 0; }
}
body.clutch-active::before {
    content: '';
    position: fixed; inset: 0;
    pointer-events: none;
    z-index: 88;
    box-shadow: inset 0 0 90px 18px rgba(255,40,60,0.5);
    animation: clutchPulse 0.85s ease-in-out infinite;
}
@keyframes clutchPulse { 0%, 100% { opacity: 0.28; } 50% { opacity: 0.72; } }
body.clutch-active #timer-display {
    color: #fff !important;
    background: linear-gradient(180deg, var(--red), var(--red-d));
    animation: clutchTimer 0.85s ease-in-out infinite;
}
@keyframes clutchTimer { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.reversal-stamp {
    position: fixed; top: 40%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 505;
    font-size: clamp(64px, 22vw, 110px);
    color: var(--red);
    letter-spacing: 2px;
    text-shadow: var(--hud-ol3), 0 0 0 transparent;
    animation: reversalSlam 1.3s cubic-bezier(0.2, 1.2, 0.3, 1) forwards;
}
.reversal-stamp::before {            /* 도장 뒤 폭발 버스트 */
    content: '';
    position: absolute; left: 50%; top: 50%; width: 2.6em; height: 2.6em;
    margin: -1.3em 0 0 -1.3em; z-index: -1;
    background: repeating-conic-gradient(from 0deg, var(--yellow) 0 10deg, transparent 10deg 24deg);
    -webkit-mask: radial-gradient(circle, #000 20%, transparent 68%);
            mask: radial-gradient(circle, #000 20%, transparent 68%);
    opacity: 0.85;
}
@keyframes reversalSlam {
    0%   { transform: translate(-50%, -50%) scale(2.6) rotate(12deg); opacity: 0; }
    18%  { transform: translate(-50%, -50%) scale(0.86) rotate(-10deg); opacity: 1; }
    32%  { transform: translate(-50%, -50%) scale(1.08) rotate(-6deg); opacity: 1; }
    45%, 82% { transform: translate(-50%, -50%) scale(1) rotate(-7deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1) rotate(-7deg); opacity: 0; }
}

/* ============================================================
   COMBO COUNTER — 아케이드식 콤보 카운터
   우상단(스탯 스트립 아래)에 기울여 배치: 코트 중앙/필살기 버튼을 가리지 않는다.
   구조: .combo-callout > .combo-burst + .combo-num[data-n] + .combo-label(COMBO <small>N연속!</small>)
   ============================================================ */
.combo-callout {
    --c-hi: #fff; --c-mid: var(--yellow); --c-lo: var(--orange); --c-glow: rgba(255,203,61,0.75);
    --num: clamp(64px, 20vw, 92px);
    position: fixed;
    top: calc(var(--hud-top) + var(--hud-h) + 62px);
    right: calc(var(--sa-r) + 14px);
    z-index: 502;
    pointer-events: none;
    display: flex; flex-direction: column; align-items: center;
    isolation: isolate;
    transform-origin: 70% 60%;
    animation: comboCallout 0.9s ease-out forwards;
}
.combo-callout.combo-t2 { --c-mid: var(--orange); --c-lo: var(--red); --c-glow: rgba(255,138,61,0.8); --num: clamp(78px, 24vw, 112px); }
.combo-callout.combo-t3 { --c-hi: #fff3b8; --c-mid: var(--red); --c-lo: var(--pink-d); --c-glow: rgba(255,93,98,0.85); --num: clamp(92px, 28vw, 132px); }

/* 숫자: 본체 = 두꺼운 잉크 외곽선 레이어, ::before = 그라디언트 채움, ::after = 하이라이트 */
.combo-num {
    position: relative; z-index: 1;
    padding: 0 0.14em 0 0.08em;
    font-family: var(--font-display);
    font-size: var(--num); font-weight: 900; font-style: italic; line-height: 0.95;
    letter-spacing: -2px;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    -webkit-text-stroke: 12px var(--ink);
    text-shadow: 0 7px 0 var(--ink), 0 0 26px var(--c-glow);
    animation: comboNumHit 0.45s var(--ease-bounce) both;
}
.combo-num::before, .combo-num::after {
    content: attr(data-n);
    position: absolute; left: 0; top: 0;
    padding: inherit;
    -webkit-text-stroke: 0 transparent;
    text-shadow: none;
    -webkit-background-clip: text; background-clip: text;
    color: transparent; -webkit-text-fill-color: transparent;
}
.combo-num::before { background-image: linear-gradient(180deg, var(--c-hi) 10%, var(--c-mid) 50%, var(--c-lo) 90%); }
.combo-num::after  { background-image: linear-gradient(170deg, rgba(255,255,255,0.8) 0 30%, transparent 32%); opacity: 0.6; }
/* COMBO 리본 */
.combo-label {
    position: relative; z-index: 2;
    display: flex; align-items: baseline; gap: 6px;
    margin-top: -4px; padding: 3px 12px 5px;
    border: var(--line) solid var(--ink); border-radius: 10px;
    background: linear-gradient(180deg, var(--c-mid), var(--c-lo));
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.45), 0 4px 0 var(--ink);
    transform: skewX(-10deg);
    font-family: var(--font-display);
    font-size: calc(var(--num) * 0.26); font-weight: 900; font-style: italic; line-height: 1;
    letter-spacing: 2px; color: #fff;
    text-shadow: var(--hud-ol2);
    white-space: nowrap;
    animation: comboLabelIn 0.35s var(--ease-bounce) 0.08s both;
}
.combo-label small {
    font-size: 0.62em; letter-spacing: 0;
    color: var(--c-accent-soft);
}
/* 뒤 폭발 버스트 */
.combo-burst {
    position: absolute; left: 50%; top: 42%; z-index: 0;
    width: calc(var(--num) * 2.3); height: calc(var(--num) * 2.3);
    margin: calc(var(--num) * -1.15) 0 0 calc(var(--num) * -1.15);
    background: repeating-conic-gradient(from 0deg, var(--c-mid) 0 9deg, transparent 9deg 22.5deg);
    -webkit-mask: radial-gradient(circle, transparent 26%, #000 30%, #000 44%, transparent 66%);
            mask: radial-gradient(circle, transparent 26%, #000 30%, #000 44%, transparent 66%);
    animation: comboBurst 0.6s ease-out both;
}
/* 스파크 (4각 별) */
.combo-callout::before, .combo-callout::after {
    content: '';
    position: absolute; z-index: 3;
    width: calc(var(--num) * 0.3); height: calc(var(--num) * 0.3);
    background: #fff;
    clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
    filter: drop-shadow(0 0 6px var(--c-glow));
    animation: comboSpark 0.7s ease-out both;
}
.combo-callout::before { left: -8%; top: 2%; --sx: -16px; --sy: -14px; }
.combo-callout::after  { right: -6%; top: 48%; --sx: 18px; --sy: 8px; width: calc(var(--num) * 0.22); height: calc(var(--num) * 0.22); animation-delay: 0.1s; }
/* 7+ : 뜨겁게 떨리는 숫자 */
.combo-t3 .combo-num { animation: comboNumHit 0.45s var(--ease-bounce) both, comboShake 0.12s linear 0.45s 3; }

@keyframes comboCallout {
    0%   { transform: rotate(-9deg) scale(0.3); opacity: 0; }
    14%  { transform: rotate(-9deg) scale(1.18); opacity: 1; }
    26%  { transform: rotate(-9deg) scale(0.96); }
    36%, 78% { transform: rotate(-9deg) scale(1); opacity: 1; }
    100% { transform: rotate(-9deg) translateY(-18px) scale(0.92); opacity: 0; }
}
@keyframes comboNumHit {
    0%   { transform: scale(2.4) rotate(14deg); }
    55%  { transform: scale(0.88) rotate(-4deg); }
    100% { transform: none; }
}
@keyframes comboLabelIn {
    from { transform: skewX(-10deg) translateX(40px) scale(0.6); opacity: 0; }
    to   { transform: skewX(-10deg); opacity: 1; }
}
@keyframes comboBurst {
    0%   { transform: scale(0.2) rotate(0deg); opacity: 0; }
    25%  { opacity: 0.95; }
    100% { transform: scale(1.25) rotate(40deg); opacity: 0; }
}
@keyframes comboSpark {
    0%   { transform: translate(0, 0) scale(0) rotate(0deg); opacity: 0; }
    35%  { transform: translate(var(--sx), var(--sy)) scale(1.2) rotate(40deg); opacity: 1; }
    100% { transform: translate(calc(var(--sx) * 1.8), calc(var(--sy) * 1.8)) scale(0) rotate(90deg); opacity: 0; }
}
@keyframes comboShake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-3px, 2px) rotate(-2deg); }
    75% { transform: translate(3px, -2px) rotate(2deg); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* 아주 좁은 화면 (≤ 374px) */
@media (max-width: 374px) {
    :root { --hud-h: 48px; --skill-sz: 70px; }
    #hud { padding-left: calc(var(--sa-l) + 54px); padding-right: calc(var(--sa-r) + 54px); }
    #menu-btn { width: 44px; height: 44px; left: calc(var(--sa-l) + 6px); }
    .score-panel { min-width: 68px; }
    .score-panel .ball-count { font-size: 25px; }
    #timer-display { min-width: 64px; font-size: 30px; }
    .stat-strip .strip-stat-bar { width: 20px; }
    .strip-npc { padding: 0 5px 0 3px; gap: 3px; }
    .skill-slots { gap: 10px; }
    .vs-splash-char img, .vs-splash-circle { width: 72px; height: 72px; }
    .result-xp-label { min-width: 84px; font-size: 12px; }
}

/* 넓은 화면 (태블릿 / 데스크톱 / CrazyGames iframe) */
@media (min-width: 700px) and (min-height: 501px) {
    :root { --hud-h: 60px; --skill-sz: 84px; }
    .score-panel { flex-basis: 150px; }
    .score-panel .label { font-size: 12px; }
    .score-panel .ball-count { font-size: 34px; }
    #timer-display { min-width: 96px; font-size: 42px; }
    #menu-btn { left: calc(var(--sa-l) + 14px); }
    .menu-dropdown { left: calc(var(--sa-l) + 14px); }
    /* 스트립을 HUD 줄과 같은 높이의 좌우로 */
    .stat-strip { top: calc(var(--hud-top) + (var(--hud-h) - 32px) / 2); max-width: 32%; flex-direction: row; align-items: center; }
    .stat-strip.player-strip { flex-direction: row-reverse; align-items: center; }
    .stat-strip.cpu-strip { left: calc(var(--sa-l) + 74px); }
    .stat-strip.player-strip { right: calc(var(--sa-r) + 14px); }
    .strip-npc { height: 32px; padding: 0 9px 0 5px; }
    .stat-strip .strip-stat-bar { width: 36px; height: 6px; }
    .stat-strip .strip-skill { width: 24px; height: 24px; }
    .stat-strip .strip-skill-icon { font-size: 18px; }
    .first-match-hint { top: calc(var(--hud-top) + var(--hud-h) + 24px); }
    .combo-callout { top: calc(var(--hud-top) + var(--hud-h) + 40px); right: 12%; }
    #result-box, .campaign-result-box { max-width: 440px; }
    .tutorial-overlay { justify-content: center; }
    .powerup-effect-text { font-size: 30px; }
}

/* ===== LANDSCAPE (모바일 가로, 높이 ≤ 500px) ===== */
@media (max-height: 500px) and (orientation: landscape) {
    :root { --hud-top: calc(var(--sa-t) + 12px); --hud-h: 42px; --skill-sz: 62px; }
    .score-panel { flex-basis: 96px; flex-direction: row; gap: 8px; }
    .score-panel .label { margin: 0; }
    .score-panel .ball-count { font-size: 26px; margin: 0; padding-bottom: 3px; }
    #timer-display { min-width: 70px; height: calc(var(--hud-h) + 8px); font-size: 28px; border-radius: 18px; }
    .score-panel::after { top: -15px; font-size: 17px; }
    #menu-btn { width: 44px; height: 44px; top: calc(var(--hud-top) - 1px); }
    .menu-dropdown { top: calc(var(--hud-top) + 50px); }
    .stat-strip { top: calc(var(--hud-top) + (var(--hud-h) - 28px) / 2); max-width: 28%; flex-direction: row; align-items: center; }
    .stat-strip.player-strip { flex-direction: row-reverse; align-items: center; }
    .stat-strip .strip-stat-bar { width: 18px; }
    .stat-strip.cpu-strip { left: calc(var(--sa-l) + 62px); }
    .stat-strip.player-strip { right: calc(var(--sa-r) + 10px); }
    #player-skill-bar { bottom: calc(var(--sa-b) + 18px); }
    .rush-overlay { padding-bottom: 6vh; }
    .rush-text { font-size: min(34vh, 110px); }
    .mercy-text { font-size: min(30vh, 100px); }
    .golden-text { font-size: min(22vh, 80px); }
    .close-game-text { font-size: min(32vh, 110px); }
    .reversal-stamp { font-size: min(30vh, 100px); }
    .nearmiss-callout { font-size: min(18vh, 60px); }
    .first-match-hint { top: calc(var(--hud-top) + var(--hud-h) + 14px); }
    .combo-callout { --num: min(22vh, 84px); top: calc(var(--hud-top) + var(--hud-h) + 26px); right: calc(var(--sa-r) + 9%); }
    .combo-callout.combo-t2 { --num: min(26vh, 96px); }
    .combo-callout.combo-t3 { --num: min(30vh, 110px); }
    .tutorial-nudge-tap { bottom: 58%; }
    .tutorial-nudge-skill { bottom: calc(var(--sa-b) + var(--skill-sz) + 52px); }

    /* 결과: 낮은 화면에선 배너/스탬프를 줄이고 폭을 넓힌다 (내부 스크롤 유지) */
    #result-overlay, .campaign-result-overlay { padding-top: calc(var(--sa-t) + 8px); padding-bottom: calc(var(--sa-b) + 8px); }
    #result-box, .campaign-result-box { max-width: 520px; }
    #result-title, .campaign-result-title { font-size: 32px; padding: 10px 12px 12px; }
    /* 리액션/등급 스탬프는 배너 모서리에 얹어 세로 공간을 아낀다 */
    .result-reaction { position: absolute; z-index: 2; top: 7px; left: 14px; width: 44px; height: 44px; margin: 0; font-size: 24px; }
    .grade-stamp { position: absolute; z-index: 2; top: 9px; right: 18px; width: 62px; height: 62px; margin: 0; }
    .grade-stamp-label { font-size: 8px; margin-top: 2px; }
    .grade-stamp-letter { font-size: 36px; }
    #result-detail, .campaign-result-score { margin-top: 10px; }
    .result-progression { margin-top: 8px; padding: 8px 12px; gap: 6px; }
    #result-box > #replay-btn, #result-box > .next-stage-btn { margin-top: 10px; }
    #result-box > .ui-btn { margin-top: 8px; }
    .campaign-result-stars { margin-top: 6px; }
    .campaign-result-buttons { margin-top: 10px; }
    .campaign-result-star { font-size: 36px; }
    .campaign-result-star:nth-child(2) { font-size: 46px; }
    #result-box > .ui-btn--lg, .campaign-result-buttons .ui-btn--lg { min-height: 52px; }
    .campaign-result-buttons .campaign-result-map-btn { min-height: 52px; }

    /* VS: 캐릭터를 가로로 */
    .vs-splash-side { flex-direction: row; flex-wrap: wrap; gap: 10px 14px; }
    .vs-splash-char img, .vs-splash-circle { width: 72px; height: 72px; }
    .vs-splash-badge { font-size: min(34vh, 110px); }

    /* 튜토리얼: 가운데 낮은 카드 */
    .tutorial-overlay { justify-content: center; gap: 8px; padding-top: calc(var(--sa-t) + 44px); padding-bottom: calc(var(--sa-b) + 8px); }
    .tutorial-card { max-width: 520px; padding: 0 18px 12px; }
    .tutorial-card-icon { width: 60px; height: 60px; margin: -30px auto 4px; font-size: 32px; }
    .tutorial-card-title { font-size: var(--fs-lg); margin-bottom: 4px; }
    .tutorial-card-body { font-size: var(--fs-md); line-height: 1.45; }
    .tutorial-card-next { min-height: 46px; margin-top: 10px; }
}

/* ============================================================
   COMBO BOOST CHIP — 콤보 부스트 표시 (js/ui/combo.js _setChip)
   콤보 3+ 동안 필살기 충전 가속 중임을 알리는 칩 ("⚡x1.5" / "⚡x2").
   #player-skill-bar 의 오른쪽 위 모서리에 얹힌다 (탭 방해 금지).
   ============================================================ */
.combo-boost-chip {
    position: absolute; z-index: 3;
    top: -14px; right: -22px;
    padding: 4px 9px 5px;
    border: var(--line) solid var(--ink); border-radius: var(--r-pill);
    background: linear-gradient(180deg, var(--yellow), var(--orange));
    color: var(--text-on-bright);
    box-shadow: var(--shadow-sm);
    font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 900; line-height: 1;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0; transform: scale(0.4) rotate(6deg);
}
.combo-boost-chip.show { opacity: 1; transform: rotate(6deg); animation: comboChipIn 0.35s var(--ease-bounce) both; }
.combo-boost-chip.max { background: linear-gradient(180deg, var(--orange), var(--red)); color: var(--text); text-shadow: var(--text-shadow); }
.combo-boost-chip.show.ending { animation: comboChipBlink 0.4s steps(2, jump-none) infinite; }
@keyframes comboChipIn {
    from { opacity: 0; transform: scale(0.4) rotate(-10deg); }
    to   { opacity: 1; transform: scale(1) rotate(6deg); }
}
@keyframes comboChipBlink {
    from { opacity: 1; }
    to   { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
    .combo-boost-chip.show, .combo-boost-chip.show.ending { animation: none; }
}
