:root {
    /* Color Palette - 세계관의 신비로움과 기계적인 느낌을 혼합 */
    --primary-color: #d4af37; /* Gold - 신성함, 권위 */
    --secondary-color: #2c3e50; /* Dark Blue-Grey - 무게감, 행정 */
    --accent-color: #e74c3c; /* Red - 갈등, 에너지 */
    --bg-dark: #1a1a1a; /* Deep Black - 배경 */
    --bg-light: #f4f4f4; /* Light Grey - 텍스트 배경 */
    --text-main: #ffffff;
    --text-muted: #cccccc;
    --transition-speed: 0.3s;

    /* 문명별 테마 색상 (2단계에서 확장 예정) */
    --color-human: #8b4513; /* Dieselpunk - Brown */
    --color-dwarf: #cd7f32; /* Steampunk - Bronze */
    --color-elf: #00ffcc;    /* Cyberpunk - Neon Cyan */
    --color-orc: #4b5320;    /* Biopunk - Olive */
    --color-dragon: #9370db; /* Magic - Purple */
    /* Missing variables used elsewhere */
    --bg-card: #232323;
    --glass-border: #444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-weight: bold; /* make all text bold */
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
    /* Set wallpaper as page background */
    background: url('../assets/images/backgrounds/wallpaper.jpg') center/cover no-repeat fixed;
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative; /* for overlay pseudo‑element */
}

/* Dark translucent overlay over the wallpaper */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8); /* more opaque dark layer */
    backdrop-filter: blur(5px); /* blur effect */
    pointer-events: none;
    z-index: -1;
}

/* Ensure content isn't hidden behind fixed navbar */
main { padding-top: 90px; }

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-speed);
}

ul {
    list-style: none;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 10%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--primary-color);
}

.logo a {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    letter-spacing: 2px;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary-color);
}

/* Hero Section */
.hero {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)), url('../assets/images/backgrounds/main_bg.jpg') center/cover no-repeat;
    padding: 0 20px;
}

.hero-content h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
}

.hero-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: var(--text-muted);
}

.hero-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.btn {
    padding: 0.8rem 2rem;
    border-radius: 5px;
    font-weight: bold;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.btn:hover {
    transform: translateY(-3px);
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--bg-dark);
}

.btn-secondary {
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

/* Intro Section */
/* Card layout for world page: image + description on a single centered row */
.civ-card {
    display: flex;
    flex-direction: row;
    justify-content: center;   /* center the row contents horizontally */
    align-items: center;       /* vertically align image and text */
    gap: 1rem;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1.5rem;
    width: 100%;
    margin: 0 auto;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--glass-border);
    border-left: 8px solid transparent;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    text-align: center;       /* center text inside the card */
}
footer {
    padding: 2rem;
    text-align: center;
    background: #111;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid #333;
}

    /* --------------------------------------------------- */
    /* Responsive Layout (Mobile / Tablet) */
    /* --------------------------------------------------- */
    @media (max-width: 768px) {
        .navbar {
            flex-direction: column;
            padding: 1rem 5%;
            align-items: center;
        }
        /* Keep navigation links in a single row on small screens */
        .nav-links {
            flex-direction: row;
            flex-wrap: nowrap;
            gap: 0.5rem;
            margin-top: 0.5rem;
            overflow-x: auto; /* allow scrolling if needed */
            font-size: 0.9rem; /* slightly smaller font */
        }
        .hero {
            height: 70vh;
            padding: 0 5%;
        }
        .hero-content h1 {
            font-size: 2.5rem;
        }
        .hero-content p {
            font-size: 1rem;
        }
        .hero-buttons {
            flex-direction: column;
        }
        .btn {
            width: 100%;
            text-align: center;
        }
        .intro {
            padding: 3rem 5%;
        }
        .civilization-grid {
            grid-template-columns: 1fr;
        }
    }

    /* --------------------------------------------------- */
    /* Simple Fade‑In Animation */
    /* --------------------------------------------------- */
    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(10px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .fade-in {
        animation: fadeIn 0.6s ease-out forwards;
        opacity: 0; /* start hidden, animation will reveal */
    }

    /* Apply fade‑in to dynamically injected cards */
    .civ-card {
        animation: fadeIn 0.5s ease-out;
    }
/* --------------------------------------------------- */
/* Wiki / System Guide Specific Styles */
/* --------------------------------------------------- */
.wiki {
    padding: 5rem 10%;
    max-width: none; /* remove fixed max‑width to allow markdown to expand */
    margin: 0 auto;
}

.wiki h1 {
    font-size: 3rem;
    color: var(--primary-color);
    /* Align headings to the left for better readability */
    text-align: left;
    margin-bottom: 3rem;
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.wiki section {
    background: #222;
    padding: 2rem;
    border-radius: 15px;
    margin-bottom: 3rem;
    border-left: 5px solid var(--primary-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: fadeIn 0.8s ease-out;
}

.wiki h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wiki p {
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.wiki ul, .wiki ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.wiki li {
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.wiki code {
    background: #333;
    color: var(--color-elf);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
}

.wiki pre {
    background: #111;
    padding: 1.5rem;
    border-radius: 10px;
    overflow-x: auto;
    border: 1px solid #444;
    margin: 1rem 0;
}

.wiki pre code {
    background: transparent;
    color: #ddd;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.wiki details {
    background: #2a2a2a;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid #333;
    transition: all 0.3s ease;
}

.wiki details[open] {
    border-color: var(--primary-color);
}

.wiki summary {
    font-weight: bold;
    cursor: pointer;
    color: var(--text-main);
    outline: none;
    user-select: none;
}

.wiki summary:hover {
    color: var(--primary-color);
}

.wiki .note {
    text-align: center;
    margin-top: 4rem;
    font-style: italic;
    color: var(--text-muted);
}

.wiki .note a {
    color: var(--primary-color);
    text-decoration: underline;
}

/* World overview: left-align content specifically (overrides .intro center alignment) */
#world-overview {
    text-align: left;
}
#world-overview .world-hero img {
    display: block;
    margin: 0 0 1rem 0;
    /* Apply same width reduction as .world-hero-banners */
    max-width: 80%;
    height: auto;
    object-fit: contain;
    width: auto;
}

/* Make the hero container width match the markdown width */
#world-overview .world-hero {
    width: 100%;
    margin: 0 auto;
}

/* New container for race banner images */
.world-hero-banners {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
}

.world-hero-banners img {
    max-width: 100%;
    height: auto;
    width: auto;
}

@media (min-width: 600px) and (max-width: 899px) {
    #world-overview .world-hero { width: 600px; }
}

@media (min-width: 900px) {
    #world-overview .world-hero { width: calc(66.666vw); max-width: none; }
}
#world-overview #world-markdown {
    line-height: 1.75;
}

/* Markdown content styles for readability */
#world-markdown h1, #world-markdown h2, #world-markdown h3 {
    color: var(--primary-color);
}

#world-markdown h1 { font-size: 2rem; margin: 2rem 0 1rem; }
#world-markdown h2 { font-size: 1.4rem; margin: 1.5rem 0 0.8rem; }
#world-markdown h3 { font-size: 1.1rem; margin: 1rem 0; }

/* Ensure headings inside description sections also have vertical spacing */
.description h3 {
    font-size: 1.1rem;
    margin: 1rem 0;
}

#world-markdown p { margin: 0.8rem 0; color: var(--text-muted); }
#world-markdown hr { border: none; border-top: 1px solid #444; margin: 2rem 0; }
#world-markdown strong { color: var(--text-main); }
#world-markdown ul { margin-left: 1.2rem; }

/* Unordered and ordered list styling for markdown content (including description sections) */
#world-markdown ul,
.description ul {
    margin-left: 1.5rem;
    padding-left: 0.5rem;
    list-style-type: disc;
    color: var(--text-muted);
}

#world-markdown ol,
.description ol {
    margin-left: 1.5rem;
    padding-left: 0.5rem;
    list-style-type: decimal;
    color: var(--text-muted);
}

/* Blockquote styling for markdown content */
#world-markdown blockquote,
.description blockquote {
    margin: 1rem 0;
    padding-left: 1rem;
    border-left: 4px solid var(--primary-color);
    color: var(--text-muted);
    font-style: italic;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
}

/* Character page controls and improved cards */
.character-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 3rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}
.search-input, .filter-select {
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--bg-card);
    color: var(--text-main);
    outline: none;
    backdrop-filter: blur(10px);
    transition: border-color 0.3s ease;
}
.search-input:focus, .filter-select:focus {
    border-color: var(--primary-color);
}
.search-input::placeholder { color: #64748b; }

.civ-card {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1rem;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1.5rem;
    /* width = 50% of viewport, centered; shrink with viewport but not below 300px */
        /* Default: full width for very small screens */
        width: 100%;
        margin: 0 auto;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--glass-border);
    border-left: 8px solid transparent;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    text-align: left;
}

/* New class for character page cards – same layout as world page cards */
.civ-card-characters {
    display: flex;
    flex-direction: column; /* stack image then description */
    align-items: center;   /* center image horizontally */
    gap: 1rem;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1.5rem;
    width: 100%;
    margin: 0 auto;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--glass-border);
    border-left: 8px solid transparent;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    text-align: left;
}

/* Image inside character cards: scale with card width, max 75% of its natural size */
.civ-card-characters img {
    max-width: 55%;         /* never exceed 75% of its natural size */
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
    align-self: center;      /* keep centered in column layout */
}

/* Ensure description takes remaining space */
.civ-card-characters .civ-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    text-align: left;
}
    /* 600px ≤ viewport < 900px : fixed 600px width */
    @media (min-width: 600px) and (max-width: 899px) {
        .civ-card {
            width: 600px;
        }
    }

    /* viewport ≥ 900px : width = 2/3 of viewport */
    @media (min-width: 900px) {
        .civ-card {
            width: calc(66.666vw);
            max-width: none;
        }
    }
    /* Apply same responsive width rules to character page cards */
    @media (min-width: 600px) and (max-width: 899px) {
        .civ-card-characters {
            width: 600px;
        }
    }

    @media (min-width: 900px) {
        .civ-card-characters {
            width: calc(66.666vw);
            max-width: none;
        }
    }

/* Image size for civilization cards */
.civ-card .civ-img {
    width: 120px;
    height: auto;
    object-fit: cover;
    border-radius: 8px;
}
.civ-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    background: rgba(45, 55, 72, 0.8);
}
.civ-card img {
    width: 75%;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.civ-card .civ-body {
    /* Ensure description stays centered */
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    text-align: center;
    flex: 1;
}

/* Characters page: force single-column list (one item per row) and ensure text wraps inside cards */
.characters-page .civilization-grid {
    grid-template-columns: 1fr;
}
/* Character page specific card adjustments */
.characters-page .civ-card-characters {
    white-space: normal;
    word-break: break-word;
}
.characters-page .civ-card-characters img {
    object-fit: cover;
}

/* On larger screens keep world page cards side‑by‑side, but allow character page cards to stack vertically */
@media (min-width: 768px) {
    .characters-page .civ-card {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* World page: force single column grid */
.world-page .civilization-grid {
    grid-template-columns: 1fr;
}

/* Markdown content width synchronized with civilization description width (75% of container) */
#world-markdown,
#world-overview #world-markdown {
    /* default: full width for very small screens */
    width: 100%;
    margin: 0 auto;
}

/* 600px ≤ viewport < 900px : fixed 600px width */
@media (min-width: 600px) and (max-width: 899px) {
    #world-markdown,
    #world-overview #world-markdown {
        width: 600px;
    }
}

/* viewport ≥ 900px : width = 2/3 of viewport */
@media (min-width: 900px) {
    #world-markdown,
    #world-overview #world-markdown {
        width: calc(66.666vw);
        max-width: none;
    }
}

/* subtle utility */
.muted { color: var(--text-muted); }