/* Portal-style CSS variables */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: #1a1a2e;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-dim: #666;
    --accent-gold: #ffd700;
    --accent-cyan: #00d4ff;
    --accent-purple: #a855f7;
    --accent-pink: #ff6b9d;
    --accent-green: #22c55e;
    --accent-orange: #ff8c00;
    --accent-red: #ff4444;
    --border-color: #333355;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

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

/* Background Effects */
.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(80px);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

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

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

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-30px) rotate(5deg); }
}

/* Container */
.container {
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

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

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 8px;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    position: absolute;
    left: 16px;
}

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

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

header h1 {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 2rem;
    color: var(--accent-orange);
    text-shadow: 0 0 30px rgba(255, 140, 0, 0.5);
}

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

/* Game Container */
.game-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 20px;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    gap: 8px;
    margin-bottom: 10px;
    font-family: 'Fira Code', monospace;
}

.status-left, .status-right {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    gap: 4px;
    color: var(--text-dim);
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
}

.stat-hp { color: #ff6666; }
.stat-atk { color: var(--accent-orange); }
.stat-def { color: var(--accent-cyan); }
.stat-gold { color: var(--accent-gold); }
.stat-floor { color: var(--accent-green); }

/* Game Display */
.game-display {
    background: #000;
    border: 3px solid var(--border-color);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: 100%;
    image-rendering: pixelated;
}

/* Message Log */
.message-log {
    height: 60px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.5;
    margin-top: 10px;
    font-family: 'Fira Code', monospace;
}

.msg { color: var(--text-dim); }
.msg-combat { color: #ff8888; }
.msg-item { color: #88ff88; }
.msg-special { color: var(--accent-gold); }
.msg-danger { color: var(--accent-red); }

/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 52px);
    gap: 4px;
}

.d-spacer {
    /* Empty spacer for plus-shaped D-pad layout */
}

.d-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 52px;
    min-height: 52px;
}

.d-btn:hover {
    background: rgba(255, 140, 0, 0.2);
    border-color: var(--accent-orange);
}

.d-btn:active {
    background: var(--accent-orange);
    color: #000;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.action-btn {
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Jua', sans-serif;
    min-height: 48px;
}

.action-btn:hover {
    background: rgba(255, 140, 0, 0.2);
    border-color: var(--accent-orange);
    color: var(--text-primary);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-orange);
    border-radius: 12px;
    padding: 20px;
    min-width: 280px;
    max-width: 90%;
    box-shadow: 0 0 30px rgba(255, 140, 0, 0.3);
}

.modal-title {
    color: var(--accent-gold);
    font-family: 'Black Han Sans', sans-serif;
    font-size: 18px;
    margin-bottom: 15px;
    text-align: center;
}

.inv-item {
    padding: 8px 12px;
    background: var(--bg-card);
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.inv-item:hover {
    background: rgba(255, 140, 0, 0.2);
    color: var(--text-primary);
    border-color: var(--accent-orange);
}

.inv-empty {
    color: var(--text-dim);
    text-align: center;
    padding: 20px;
    font-size: 12px;
}

.modal-close {
    margin-top: 15px;
    width: 100%;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--accent-orange);
    color: #000;
    border-color: var(--accent-orange);
}

/* Title Screen */
.title-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 26, 0.98);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.title-screen.hidden {
    display: none;
}

.title-logo {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 24px;
    color: var(--accent-orange);
    margin-bottom: 8px;
    text-shadow: 0 0 20px var(--accent-orange);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 20px var(--accent-orange); }
    to { text-shadow: 0 0 40px var(--accent-orange), 0 0 60px var(--accent-gold); }
}

.title-sub {
    color: var(--text-dim);
    font-size: 12px;
    margin-bottom: 25px;
}

.title-btn {
    padding: 12px 40px;
    background: rgba(255, 140, 0, 0.15);
    border: 2px solid var(--accent-orange);
    border-radius: 6px;
    color: var(--accent-orange);
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.title-btn:hover {
    background: var(--accent-orange);
    color: #000;
    box-shadow: 0 0 30px rgba(255, 140, 0, 0.5);
}

.title-legend {
    color: var(--text-dim);
    font-size: 11px;
    line-height: 1.6;
    text-align: center;
    margin-top: 20px;
}

/* Game Content Article */
.game-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

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

.game-content h2:first-child {
    margin-top: 0;
}

.game-content p {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.95rem;
}

.tip-box {
    background: var(--bg-card);
    border-left: 3px solid var(--accent-orange);
    padding: 16px;
    border-radius: 0 8px 8px 0;
    margin-top: 12px;
}

.tip-box p {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

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

.tip-box strong {
    color: var(--accent-orange);
}

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

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

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

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

    .back-btn {
        position: relative;
        left: 0;
        margin-bottom: 10px;
    }

    .header-top {
        flex-direction: column;
        gap: 8px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .status-bar {
        font-size: 10px;
        padding: 6px 10px;
    }

    .d-pad {
        grid-template-columns: repeat(3, 56px);
        grid-template-rows: repeat(3, 56px);
    }

    .d-btn {
        font-size: 28px;
        min-width: 56px;
        min-height: 56px;
    }

    .action-btn {
        font-size: 16px;
        padding: 12px 16px;
        min-height: 52px;
    }

    .game-content {
        display: none;
    }

    footer {
        display: none;
    }
}

/* Continue Modal */
.continue-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.continue-modal.active {
    opacity: 1;
    visibility: visible;
}

.continue-modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    border: 2px solid var(--accent-orange);
    box-shadow: 0 10px 40px rgba(255, 140, 0, 0.3);
    max-width: 320px;
    width: 90%;
}

.continue-modal-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.continue-modal-info {
    font-family: 'Fira Code', monospace;
    font-size: 1.1rem;
    color: var(--accent-gold);
    margin-bottom: 25px;
}

.continue-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.continue-modal .continue-btn {
    padding: 14px 30px;
    font-family: 'Jua', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-orange), #cc7000);
    color: #000;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.continue-modal .continue-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 5px 20px rgba(255, 140, 0, 0.5);
}

.continue-modal .newgame-btn {
    padding: 12px 25px;
    font-family: 'Jua', sans-serif;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.continue-modal .newgame-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}
