:root {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --accent-color: #d4af37;
    --accent-glow: rgba(212, 175, 55, 0.4);
    --secondary-color: #1e1e1e;
    --card-bg: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.1);
    --font-heading: 'Cinzel', serif;
    --font-body: 'Noto Serif KR', 'Noto Serif JP', 'Noto Serif SC', serif;
}

body.light-mode {
    --bg-color: #f5f5f7;
    --text-color: #333333;
    --accent-color: #b8860b;
    --accent-glow: rgba(184, 134, 11, 0.2);
    --secondary-color: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.9);
    --border-color: rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    width: 100%;
    max-width: 1000px;
    padding: 2rem;
    text-align: center;
}

/* Theme Toggle */
.theme-switch {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.theme-btn {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.3s;
}

.theme-btn:hover {
    transform: rotate(30deg);
}

.lang-switch {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.lang-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background-color: var(--card-bg);
    cursor: pointer;
    font-size: 0;
    transition: all 0.2s;
    padding: 0;
    overflow: hidden;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
}

.lang-btn.kr {
    background-image: url('assets/flag_kr.png');
}

.lang-btn.en {
    background-image: url('assets/flag_us.png');
}

.lang-btn.jp {
    background-image: url('assets/flag_jp.png');
}

.lang-btn.cn {
    background-image: url('assets/flag_cn.png');
}

.lang-btn:hover,
.lang-btn.active {
    border-color: var(--accent-color);
    transform: scale(1.1);
    box-shadow: 0 0 10px var(--accent-glow);
}

header {
    margin-bottom: 2rem;
}

h1 {
    font-family: var(--font-heading);
    font-size: 3rem;
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-glow);
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.8;
}

/* Service Grid */
.service-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    max-width: 900px;
    margin: 2rem auto;
}

@media (max-width: 768px) {
    .service-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.8rem;
    }
}

.service-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1.5rem 0.8rem;
    text-align: center;
    transition: all 0.3s;
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.service-card:hover,
.service-card.active {
    background: rgba(212, 175, 55, 0.1);
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px var(--accent-glow);
    transform: translateY(-2px);
}

.service-icon {
    font-size: 3.5rem;
    margin-bottom: 0.8rem;
    display: block;
}

.service-title {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Upload Section */
.upload-section {
    margin: 2rem auto;
    max-width: 600px;
}

.upload-box {
    border: 2px dashed var(--accent-color);
    border-radius: 15px;
    padding: 3rem 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.03);
}

.upload-box:hover {
    background: rgba(212, 175, 55, 0.08);
    box-shadow: 0 0 15px var(--accent-glow);
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
}

.icon {
    font-size: 3rem;
}

.text {
    font-size: 1rem;
    opacity: 0.8;
}

/* Preview */
.preview-container {
    position: relative;
    margin: 1rem auto;
    /* Center align */
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    display: flex;
    justify-content: center;
}

#image-preview {
    max-width: 100%;
    display: block;
    border-radius: 15px;
}

#overlay-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
    animation: scan 2s infinite linear;
    display: none;
}

.scanning .scan-line {
    display: block;
}

@keyframes scan {
    0% {
        top: 0;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 100%;
        opacity: 0;
    }
}

/* Results */
.results-section {
    margin-top: 2rem;
    animation: fadeIn 0.5s;
}

.result-card {
    background: var(--secondary-color);
    border: 1px solid var(--accent-color);
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    text-align: left;
    line-height: 1.6;
}

.result-item {
    margin-bottom: 1rem;
}

.result-title {
    color: var(--accent-color);
    font-weight: bold;
    margin-bottom: 0.3rem;
    display: block;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.btn-primary {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 0.8rem 2rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 5px;
}

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

.btn-secondary {
    background: var(--accent-color);
    border: none;
    color: var(--bg-color);
    padding: 0.8rem 2rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 5px;
    font-weight: bold;
}

.btn-secondary:hover {
    background: #fff;
    color: var(--bg-color);
}

/* Utility */
.hidden {
    display: none !important;
}

.loading {
    margin: 2rem 0;
    color: var(--accent-color);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(212, 175, 55, 0.3);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ad Container */
.ad-container {
    width: 100%;
    min-height: 100px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2rem 0;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
}

footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Mobile */
@media (max-width: 480px) {
    h1 {
        font-size: 2rem;
    }

    .container {
        padding: 1rem;
    }

    .service-icon {
        font-size: 2rem;
    }

    .service-title {
        font-size: 0.8rem;
    }
}