/* 우주 탐험 대소동 — 다크 우주 톤 + 프로젝트 토큰(blue #2563eb / green #16a34a / gold #f59e0b) */

:root {
    --pm-bg: #0b1020;
    --pm-panel: #131a30;
    --pm-line: #25304f;
    --pm-blue: #2563eb;
    --pm-green: #16a34a;
    --pm-gold: #f59e0b;
    --pm-text: #e7ecf7;
    --pm-dim: #93a0bd;
}

.pm-body {
    background: var(--pm-bg);
    color: var(--pm-text);
    font-family: 'Pretendard Variable', Pretendard, sans-serif;
}

/* 셸: 게임 화면만 100dvh 고정(.pm-game), 로비/대기실은 자연 스크롤 (5.5절) */
body.pm-body { min-height: 100dvh; margin: 0; }

.pm-screen { display: none; }
.pm-screen.active { display: block; }
main.pm-game.active {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

/* ───── 로비 ───── */
#scr-lobby.active, #scr-wait.active, #scr-single-setup.active {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 4.5rem 1rem 2rem;
    box-sizing: border-box;
}

.pm-lobby-card, .pm-wait-card {
    width: min(420px, 100%);
    background: var(--pm-panel);
    border: 1px solid var(--pm-line);
    border-radius: 20px;
    padding: 2rem 1.75rem;
    text-align: center;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.pm-logo {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; margin-bottom: 0.75rem; font-size: 1.6rem;
}
.pm-logo-hero, .pm-logo-foe {
    width: 34px; height: 34px; image-rendering: auto;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
}
.pm-logo-hero { animation: pmBob 2s ease-in-out infinite; }
.pm-logo-foe { animation: pmFloat 1.6s ease-in-out infinite; }
@keyframes pmBob { 50% { transform: translateY(-3px); } }
.pm-logo-dots i {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: #fcd34d; margin: 0 4px; vertical-align: middle;
    animation: pmDot 1.2s ease-in-out infinite;
}
.pm-logo-dots i:nth-child(2) { animation-delay: 0.2s; }
.pm-logo-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes pmDot { 50% { opacity: 0.2; } }
@keyframes pmFloat { 50% { transform: translateY(-4px); } }

h1 { margin: 0 0 0.4rem; font-size: 1.7rem; font-weight: 800; }
.pm-sub { margin: 0 0 1.5rem; color: var(--pm-dim); font-size: 0.92rem; }

.pm-label {
    display: block; text-align: left; font-size: 0.82rem;
    font-weight: 700; color: var(--pm-dim); margin: 0 0 0.35rem 0.2rem;
}
.pm-input {
    width: 100%; box-sizing: border-box;
    background: #0d1428; color: var(--pm-text);
    border: 1.5px solid var(--pm-line); border-radius: 12px;
    padding: 0.8rem 1rem; font-size: 1rem; font-family: inherit;
    margin-bottom: 1rem; outline: none; transition: border-color 0.15s;
}
.pm-input:focus { border-color: var(--pm-blue); }

.pm-btn {
    border: none; border-radius: 12px; padding: 0.85rem 1.3rem;
    font-size: 1rem; font-weight: 800; font-family: inherit;
    cursor: pointer; transition: transform 0.1s, filter 0.15s;
}
.pm-btn:active { transform: scale(0.97); }
.pm-btn:hover { filter: brightness(1.1); }
.pm-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pm-btn-primary { background: var(--pm-blue); color: #fff; width: 100%; }
.pm-btn-green { background: var(--pm-green); color: #fff; }
.pm-btn-ghost { background: transparent; color: var(--pm-dim); border: 1.5px solid var(--pm-line); }

.pm-divider {
    display: flex; align-items: center; gap: 10px;
    color: var(--pm-dim); font-size: 0.8rem; margin: 1.2rem 0;
}
.pm-divider::before, .pm-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--pm-line);
}

.pm-join-row { display: flex; gap: 8px; }
.pm-join-row .pm-btn { margin-bottom: 1rem; }
.pm-code-input {
    flex: 1; text-align: center; letter-spacing: 0.5em;
    font-size: 1.4rem; font-weight: 800;
}
.pm-msg { min-height: 1.2em; margin: 0; color: #f87171; font-size: 0.88rem; }

/* ───── 대기실 ───── */
.pm-wait-label { margin: 0; color: var(--pm-dim); font-size: 0.85rem; font-weight: 700; }
.pm-wait-code {
    font-size: 3.4rem; font-weight: 900; letter-spacing: 0.18em;
    color: var(--pm-gold); margin: 0.2rem 0;
    text-shadow: 0 0 30px rgba(245, 158, 11, 0.35);
}
.pm-wait-hint { margin: 0 0 1.4rem; color: var(--pm-dim); font-size: 0.88rem; }

.pm-player-list { list-style: none; margin: 0 0 0.6rem; padding: 0; display: grid; gap: 8px; }
.pm-player-list li {
    display: flex; align-items: center; gap: 10px;
    background: #0d1428; border: 1px solid var(--pm-line);
    border-radius: 10px; padding: 0.6rem 0.9rem; font-weight: 600;
    text-align: left;
}
.pm-player-list li .pm-p-icon { font-size: 1.1rem; }
.pm-player-list li .pm-p-host {
    margin-left: auto; font-size: 0.72rem; font-weight: 800;
    color: var(--pm-gold); border: 1px solid var(--pm-gold);
    border-radius: 999px; padding: 0.1rem 0.5rem;
}
.pm-player-list li.pm-p-me { border-color: var(--pm-blue); }
.pm-spec-count { margin: 0 0 1rem; color: var(--pm-dim); font-size: 0.82rem; }
.pm-wait-status { color: var(--pm-dim); font-size: 0.9rem; min-height: 1.3em; margin: 0 0 1rem; }
.pm-wait-actions { display: grid; gap: 8px; }

/* ───── 게임 HUD ───── */
.pm-hud {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 0.55rem 0.9rem 0.55rem 6rem; /* back-pill 겹침 방지 */
    background: var(--pm-panel);
    border-bottom: 1px solid var(--pm-line);
}
.pm-hud-left { display: flex; gap: 6px; }
.pm-chip {
    background: #0d1428; border: 1px solid var(--pm-line);
    border-radius: 999px; padding: 0.25rem 0.7rem;
    font-size: 0.82rem; font-weight: 700; white-space: nowrap;
}
.pm-chip-time { color: var(--pm-gold); min-width: 4.6em; text-align: center; }
.pm-role {
    grid-column: 2; justify-self: center;
    font-weight: 800; font-size: 0.95rem; white-space: nowrap;
}
.pm-hud-scores {
    justify-self: end; display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end;
}
.pm-hud-scores .pm-chip { font-size: 0.74rem; padding: 0.18rem 0.55rem; }
.pm-hud-scores .pm-chip.me { border-color: var(--pm-blue); }

/* ───── 보드 ───── */
.pm-board-frame {
    flex: 1; position: relative;
    display: flex; align-items: center; justify-content: center;
    padding: 8px; min-height: 0;
}
#game-canvas { display: block; }

/* ───── 오버레이 ───── */
.pm-overlay {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: rgba(7, 10, 22, 0.72);
    backdrop-filter: blur(2px);
    text-align: center; padding: 1rem;
}
.pm-overlay[hidden] { display: none; }
.pm-countdown {
    font-size: 6rem; font-weight: 900; color: var(--pm-gold);
    text-shadow: 0 0 40px rgba(245, 158, 11, 0.5);
    animation: pmPop 0.9s ease infinite;
}
@keyframes pmPop { 0% { transform: scale(0.7); opacity: 0.4; } 30% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); } }
.pm-countdown-role { font-size: 1.3rem; font-weight: 800; margin-top: 0.5rem; }

.pm-overlay-panel h2 { margin: 0 0 0.3rem; font-size: 1.6rem; }
#roundend-reason { margin: 0 0 1rem; color: var(--pm-dim); font-weight: 600; }
.pm-ranking {
    list-style: none; margin: 0; padding: 0;
    width: min(320px, 90%); display: grid; gap: 6px;
}
.pm-ranking li {
    display: flex; align-items: center; gap: 10px;
    background: var(--pm-panel); border: 1px solid var(--pm-line);
    border-radius: 10px; padding: 0.5rem 0.9rem; font-weight: 700;
}
.pm-ranking li .rk { width: 1.6em; text-align: center; }
.pm-ranking li .sc { margin-left: auto; color: var(--pm-gold); font-variant-numeric: tabular-nums; }
.pm-ranking li.me { border-color: var(--pm-blue); }
.pm-ranking-final li:first-child {
    border-color: var(--pm-gold);
    box-shadow: 0 0 18px rgba(245, 158, 11, 0.25);
}
.pm-next-hint { margin-top: 1rem; color: var(--pm-dim); font-size: 0.9rem; }
.pm-final-actions { display: flex; gap: 8px; margin-top: 1.2rem; flex-wrap: wrap; justify-content: center; }

/* ───── 토스트 ───── */
.pm-toast {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
    background: #1f2a44; color: var(--pm-text);
    border: 1px solid var(--pm-line); border-radius: 12px;
    padding: 0.7rem 1.2rem; font-weight: 700; font-size: 0.9rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 50; animation: pmToast 0.25s ease;
}
@keyframes pmToast { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ───── 혼자 연습 (싱글 모드) ───── */
.pm-btn-block { width: 100%; }

.pm-diff-list { display: grid; gap: 10px; margin-bottom: 1rem; }
.pm-diff-btn {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    background: #0d1428; border: 1.5px solid var(--pm-line); border-radius: 12px;
    padding: 0.75rem 1rem; cursor: pointer; text-align: left;
    font-family: inherit; color: var(--pm-text);
    transition: border-color 0.15s, transform 0.1s;
}
.pm-diff-btn:hover { border-color: var(--pm-blue); }
.pm-diff-btn:active { transform: scale(0.98); }
.pm-diff-name { font-size: 1.05rem; font-weight: 800; }
.pm-diff-desc { font-size: 0.82rem; color: var(--pm-dim); }

.pm-chip-lives { color: #fb7185; letter-spacing: 1px; min-width: 3.4em; text-align: center; }
.pm-hud-scores-single { align-items: center; }

.pm-single-banner { background: rgba(7, 10, 22, 0.42); }
.pm-single-banner .pm-countdown-role {
    font-size: 2rem; color: var(--pm-gold);
    text-shadow: 0 0 30px rgba(245, 158, 11, 0.5);
    animation: pmPop 0.5s ease;
}

.pm-single-stat { display: flex; gap: 2.4rem; justify-content: center; margin: 1.2rem 0 0.3rem; }
.pm-stat { display: flex; flex-direction: column; gap: 3px; align-items: center; }
.pm-stat-label { font-size: 0.8rem; color: var(--pm-dim); font-weight: 700; }
.pm-stat-val { font-size: 1.9rem; font-weight: 900; color: var(--pm-gold); font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
    .pm-hud { padding-left: 5rem; }
    .pm-hud-scores { display: none; } /* 좁은 화면에선 점수 칩 생략 (라운드 결과에서 확인) */
    .pm-countdown { font-size: 4.2rem; }
    .pm-hud-scores-single { display: flex; } /* 싱글은 점수·최고기록 유지(칩 2개뿐) */
}
