/* =============================================
   팩맨 게임 스타일
   테마: 다크 + 팩맨 옐로우
   ============================================= */

html { background: #0a0a1a; }

.pm-body {
    overflow: hidden;
    height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #f0f0f0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Game Area */
.pm-game {
    width: 100%;
    height: 100dvh;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #0a0a1a;
}

/* Top Bar */
.pm-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    z-index: 10;
    flex-shrink: 0;
}
.pm-back {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}
.pm-back:hover { color: #fff; }
.pm-info-badge {
    font-size: 14px;
    font-weight: 700;
    color: #EAB308;
    padding: 4px 16px;
    border-radius: 20px;
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.2);
    white-space: nowrap;
}

/* Canvas Wrapper */
.pm-canvas-wrap {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    position: relative;
    flex-shrink: 0;
}
.pm-canvas-wrap canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    border: 1px solid #2d2d44;
    aspect-ratio: 1 / 1;
}

/* Content area (below canvas) */
.pm-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 16px 20px;
    overflow-y: auto;
}

/* ===== COUNTDOWN ===== */
.state-countdown { background: #0a0a1a; }
.state-countdown .pm-canvas-wrap { display: none; }
.state-countdown .pm-info-badge { display: none; }
.state-countdown .pm-content {
    justify-content: center;
    padding: 0;
}
.pm-countdown-wrap { text-align: center; }
.pm-countdown-num {
    font-size: 120px;
    font-weight: 900;
    color: #fff;
    line-height: 1;
    animation: pmCountPop 0.5s ease-out;
}
.pm-countdown-num.pm-countdown-pop {
    animation: pmCountPop 0.5s ease-out;
}
.pm-countdown-label {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 16px;
}
@keyframes pmCountPop {
    0% { transform: scale(1.6); opacity: 0.3; }
    50% { transform: scale(0.95); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== INTRO ===== */
.state-intro .pm-canvas-wrap { display: none; }
.state-intro .pm-info-badge { display: none; }
.state-intro .pm-dpad { display: none; }
.state-intro .pm-content {
    justify-content: center;
    padding-top: 0;
}

.pm-intro-emoji { font-size: 72px; margin-bottom: 16px; }
.pm-intro-title {
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 8px;
}
.pm-intro-desc {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.6;
    margin-bottom: 20px;
    text-align: center;
}
.pm-intro-desc strong { color: #EAB308; }

.pm-best {
    background: rgba(234, 179, 8, 0.1);
    border-radius: 10px;
    padding: 10px 18px;
    margin-bottom: 12px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.pm-challenge {
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 20px;
    font-size: 16px;
    color: #EAB308;
    text-align: center;
}
.pm-challenge strong { font-size: 22px; }

.pm-rules {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    justify-content: center;
}
.pm-rule-chip {
    padding: 8px 16px;
    background: rgba(234, 179, 8, 0.08);
    border: 1px solid rgba(234, 179, 8, 0.2);
    border-radius: 20px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

.pm-btn-start {
    display: inline-block;
    padding: 16px 48px;
    background: linear-gradient(135deg, #EAB308, #CA8A04);
    color: #0a0a1a;
    border: none;
    border-radius: 14px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}
.pm-btn-start:active { transform: scale(0.95); }

/* ===== D-pad ===== */
.pm-dpad {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 0;
    flex-shrink: 0;
}
.state-playing .pm-dpad { display: flex; }

.pm-dpad-mid {
    display: flex;
    align-items: center;
    gap: 4px;
}
.pm-dpad-center {
    width: 52px;
    height: 52px;
}
.pm-dpad-btn {
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 12px;
    background: rgba(234, 179, 8, 0.15);
    color: #EAB308;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    transition: background 0.1s;
}
.pm-dpad-btn:active {
    background: rgba(234, 179, 8, 0.4);
    transform: scale(0.92);
}

/* PC에서 D-pad 숨기기 */
@media (hover: hover) and (pointer: fine) {
    .pm-dpad { display: none !important; }
}

/* ===== PLAYING ===== */
.state-playing .pm-content { display: none; }

/* ===== GAMEOVER overlay ===== */
.pm-gameover-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 10, 26, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    animation: pmFadeIn 0.3s ease;
}
@keyframes pmFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pm-gameover-text {
    font-size: 32px;
    font-weight: 900;
    color: #EF4444;
    margin-bottom: 16px;
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.pm-gameover-score {
    font-size: 48px;
    font-weight: 900;
    color: #fff;
    margin-bottom: 4px;
}

.pm-gameover-detail {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 24px;
}

.pm-btn-result {
    padding: 16px 48px;
    background: linear-gradient(135deg, #EAB308, #CA8A04);
    color: #0a0a1a;
    border: none;
    border-radius: 14px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}
.pm-btn-result:active { transform: scale(0.95); }

/* ===== RESULT ===== */
.state-result .pm-canvas-wrap { display: none; }
.state-result .pm-info-badge { display: none; }
.state-result .pm-dpad { display: none; }
.state-result .pm-content {
    justify-content: flex-start;
    padding-top: 24px;
}

/* Toast */
.pm-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.pm-toast-show {
    opacity: 1;
    pointer-events: auto;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .pm-canvas-wrap {
        max-width: calc(100vw - 32px);
    }
    .pm-intro-title { font-size: 24px; }
    .pm-intro-emoji { font-size: 56px; }
    .pm-gameover-score { font-size: 40px; }
}

@media (max-width: 360px) {
    .pm-canvas-wrap {
        max-width: calc(100vw - 24px);
    }
    .pm-top-bar { padding: 10px 12px; }
    .pm-content { padding: 12px 16px; }
}
