/* SPACE PANIC — 에어락 방위전 (Phaser, 960x600) */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html { scrollbar-gutter: stable; }

:root {
    --bg-primary: var(--fc-bg, #0a0a1a);
    --bg-secondary: var(--fc-surface, #12122a);
    --text-primary: var(--fc-ink, #ffffff);
    --text-secondary: var(--fc-ink-2, rgba(255, 255, 255, 0.7));
    --accent: var(--fc-accent, #a855f7);
    --accent-gold: #ffd700;
    --accent-cyan: #00d4ff;
    --accent-pink: #ff6b9d;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text-primary);
}

.bg-effects {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.3;
    animation: float 15s ease-in-out infinite;
}

.bg-orb:nth-child(1) {
    width: 400px; height: 400px;
    background: var(--accent-cyan);
    top: -100px; left: -100px;
}

.bg-orb:nth-child(2) {
    width: 350px; height: 350px;
    background: var(--accent);
    bottom: -50px; right: -100px;
    animation-delay: -7s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 12px 16px;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 12px;
}

.header-top {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 4px;
}

.back-btn {
    position: absolute;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    border-radius: var(--fc-r-md, 8px);
    transition: color 0.3s, background 0.3s;
}

.back-btn:hover {
    color: var(--accent-cyan);
    background: rgba(255, 255, 255, 0.1);
}

.back-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

h1 {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 2rem;
    color: var(--accent-gold, #ffd700);
    text-shadow:
        0 0 10px rgba(255, 215, 0, 0.6),
        0 0 18px rgba(255, 107, 157, 0.35),
        3px 3px 0 #172c66;
}

.subtitle {
    color: var(--text-secondary);
    font-family: 'Jua', sans-serif;
    font-size: 0.9rem;
}

/* ===== Game area: 960x600 (8:5) Phaser canvas, Scale.FIT ===== */
.game-container {
    width: 100%;
    display: flex;
    justify-content: center;
    position: relative;
}

/* width is also capped by viewport height (8:5 kept by aspect-ratio) so the
   canvas bottom never slips below the fold on short screens */
#gameWrapper {
    position: relative;
    width: min(100%, calc((100vh - 10rem) * 8 / 5));
    width: min(100%, calc((100dvh - 10rem) * 8 / 5));
    aspect-ratio: 8 / 5;
    margin: 0 auto;
    background: #04060e;
    border-radius: var(--fc-r-md, 12px);
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.05), 0 20px 40px rgba(0,0,0,0.4);
    touch-action: none;
}

#game { width: 100%; height: 100%; }

#game canvas {
    display: block;
    margin: 0 auto;
    touch-action: none;
}

/* ===== Article / footer ===== */
.game-content {
    max-width: 760px;
    margin: 28px auto 0;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--fc-r-md, 12px);
    line-height: 1.7;
}

.game-content h2 {
    font-family: 'Jua', sans-serif;
    color: var(--accent-cyan);
    font-size: 1.15rem;
    margin-bottom: 10px;
}

.game-content p { color: var(--text-secondary); margin-bottom: 16px; font-size: 0.92rem; }

.tip-box {
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid var(--accent-pink);
    border-radius: var(--fc-r-sm, 6px);
    padding: 12px 14px;
}

.tip-box p { margin-bottom: 8px; }
.tip-box p:last-child { margin-bottom: 0; }
.tip-box strong { color: var(--accent-gold); }

footer {
    text-align: center;
    padding: 24px 0 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

footer a { color: var(--accent-cyan); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ===== Fullscreen mode ===== */
body.fullscreen-active #gameWrapper {
    width: min(100vw, calc(100vh * 8 / 5));
    width: min(100vw, calc(100dvh * 8 / 5));
    border-radius: 0;
}

body.fullscreen-active header,
body.fullscreen-active .game-content,
body.fullscreen-active footer,
body.fullscreen-active .ad-display {
    display: none;
}

/* ===== Mobile ===== */
@media (max-width: 600px) {
    .container { padding: 8px 10px; }
    header { margin-bottom: 8px; }
    h1 { font-size: 1.4rem; }
    .subtitle { display: none; }
    #gameWrapper { border-radius: 6px; }
    .game-content { padding: 14px; margin-top: 20px; }
}

/* mobile landscape: maximize the play area (header hidden per portal guideline) */
@media (orientation: landscape) and (max-height: 500px) {
    header, .game-content, footer, .ad-display, .bg-effects { display: none; }
    .container { padding: 4px; max-width: none; }
    #gameWrapper {
        width: min(100%, calc((100vh - 0.5rem) * 8 / 5));
        width: min(100%, calc((100dvh - 0.5rem) * 8 / 5));
        border-radius: 0;
    }
}
