/* CSS Variables */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --accent-gold: #ffd700;
    --accent-cyan: #00d4ff;
    --accent-purple: #a855f7;
    --accent-pink: #ff6b9d;
    --accent-green: #22c55e;
    --accent-orange: #ff8c00;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);

    /* Moon Cave specific */
    --game-bg: #1a1a2e;
    --game-accent: #88ddff;
    --game-highlight: #aaffcc;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

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

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

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

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

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

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

/* Container */
.container {
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 15px;
}

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

.back-btn {
    position: absolute;
    left: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

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

.back-btn svg {
    width: 18px;
    height: 18px;
}

header h1 {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--accent-cyan), var(--game-highlight));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Game Container */
.game-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.btn {
    font-family: 'Jua', sans-serif;
    padding: 10px 20px;
    font-size: 0.9rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    min-height: 44px;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.btn-new {
    background: linear-gradient(135deg, var(--accent-cyan), #0891b2);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

.btn-new:hover {
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.4);
}

/* Score Display */
.score-display {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.score-icon {
    font-size: 1.5rem;
}

.score-info {
    display: flex;
    flex-direction: column;
}

.score-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.3rem;
    color: var(--game-highlight);
}

.score-value.high {
    color: var(--accent-gold);
}

/* Game Wrapper */
.game-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/10;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
    touch-action: none;
}

/* HUD */
.hud {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

.hud-left, .hud-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.hud-icon {
    font-size: 1rem;
}

.hud-value {
    font-family: 'Orbitron', 'Noto Sans KR', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 10px rgba(150, 220, 255, 0.5);
}

.hud-value.score-value {
    font-size: 1.2rem;
    color: var(--game-highlight);
    text-shadow: 0 0 10px rgba(100, 255, 180, 0.5);
}

/* Game Overlay */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    opacity: 1;
    transition: opacity 0.3s;
    backdrop-filter: blur(4px);
}

.game-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.game-title {
    font-family: 'Orbitron', 'Black Han Sans', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    color: var(--game-accent);
    text-shadow: 0 0 30px var(--game-accent), 0 2px 0 #5588bb;
    margin-bottom: 8px;
    letter-spacing: 4px;
}

.game-subtitle {
    font-size: 0.75rem;
    color: rgba(255, 200, 220, 0.7);
    margin-bottom: 30px;
    letter-spacing: 2px;
}

.final-score-box {
    margin-bottom: 24px;
    text-align: center;
}

.final-label {
    font-size: 0.65rem;
    color: rgba(255, 200, 220, 0.6);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.final-value {
    font-family: 'Orbitron', 'Black Han Sans', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 15px #ffaacc;
}

.new-record {
    color: var(--accent-gold);
    font-size: 0.75rem;
    margin-top: 8px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.play-btn {
    font-family: 'Jua', sans-serif;
    padding: 14px 50px;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a2e;
    background: linear-gradient(180deg, var(--game-highlight), #66ddaa);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 25px rgba(100, 255, 180, 0.4);
    min-height: 50px;
}

.play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 35px rgba(100, 255, 180, 0.6);
}

.controls-hint {
    margin-top: 20px;
    font-size: 0.7rem;
    color: rgba(255, 220, 240, 0.5);
    text-align: center;
    line-height: 1.8;
}

.controls-hint span {
    color: var(--game-highlight);
    padding: 2px 8px;
    background: rgba(100, 255, 180, 0.15);
    border-radius: 4px;
}

/* Game Content Article */
.game-content {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-content h2 {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.3rem;
    color: var(--accent-gold);
    margin-bottom: 10px;
}

.game-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 15px;
}

.tip-box {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
}

.tip-box p {
    margin-bottom: 8px;
}

.tip-box p:last-child {
    margin-bottom: 0;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    margin-top: auto;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

footer a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--accent-gold);
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .container {
        padding: 15px 10px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .back-btn span {
        display: none;
    }

    .back-btn {
        padding: 8px;
    }

    .game-wrapper {
        border-radius: 8px;
    }

    .hud {
        top: 8px;
        left: 8px;
        right: 8px;
    }

    .hud-item {
        padding: 4px 8px;
    }

    .hud-value {
        font-size: 0.8rem;
    }

    .hud-value.score-value {
        font-size: 1rem;
    }

    .game-title {
        font-size: 1.6rem;
    }

    .final-value {
        font-size: 2rem;
    }

    .controls-hint {
        font-size: 0.65rem;
    }

    .game-content {
        display: none;
    }

    footer {
        display: none;
    }
}
