:root {
    --primary: #4F46E5;
    --primary-light: #818CF8;
    --primary-glow: rgba(79, 70, 229, 0.4);
    --secondary: #06B6D4;
    --accent: #FB7185;
    --bg-color: oklch(98% 0.01 250);
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --card-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
    --nav-height: 70px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Pretendard', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Background --- */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: 
        radial-gradient(circle at 10% 10%, #EEF2FF 0%, transparent 40%),
        radial-gradient(circle at 90% 90%, #FDF2F8 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, #ECFEFF 0%, transparent 50%);
    filter: blur(60px);
}

.bg-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* --- Navigation --- */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    height: 100%;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.3s;
}

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

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 10px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--primary-glow);
    color: var(--primary);
}

.badge {
    background: var(--primary-light);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* --- Layout --- */
.container {
    max-width: 900px;
    margin: calc(var(--nav-height) + 3rem) auto 5rem;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 4rem;
}

.section {
    scroll-margin-top: calc(var(--nav-height) + 2rem);
}

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: var(--card-shadow);
}

.section-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.step-label {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: var(--primary-glow);
    color: var(--primary);
    border-radius: 100px;
    font-weight: 800;
    font-size: 0.75rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.section-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* --- Step 1: Upload & Table --- */
.upload-container {
    background: rgba(255, 255, 255, 0.4);
    border: 2px dashed #D1D5DB;
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    transition: all 0.3s;
}

.upload-container:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.6);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--primary-light);
    margin-bottom: 1.5rem;
}

.data-table-wrapper {
    margin-top: 3rem;
    animation: slideUp 0.5s ease-out;
}

.table-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.table-container {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #E5E7EB;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #F9FAFB;
    padding: 1rem;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid #E5E7EB;
}

td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #F3F4F6;
}

td input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
}

td input:focus {
    outline: none;
    border-color: var(--primary-light);
    background: #F5F7FF;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* --- Step 2: Preview --- */
.preview-controls {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.control-group {
    flex: 1;
    min-width: 250px;
}

.control-group label {
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.tab-buttons {
    display: flex;
    background: #F3F4F6;
    padding: 0.3rem;
    border-radius: 12px;
}

.tab-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.preview-frame {
    background: #525659;
    padding: 2rem;
    border-radius: 16px;
    min-height: 500px;
    display: flex;
    justify-content: center;
}

.preview-paper {
    background: white;
    width: 100%;
    max-width: 600px;
    min-height: 700px;
    padding: 3rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.paper-header {
    text-align: center;
    border-bottom: 2px solid #333;
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
}

.paper-header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.75rem;
}

.paper-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 600;
}

.paper-body {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.preview-row {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    font-size: 1.1rem;
}

.preview-row .num { font-weight: 800; color: #999; width: 25px; }
.preview-row .q { flex: 1; border-bottom: 1px solid #EEE; padding-bottom: 2px; }
.preview-row .a { flex: 1; border-bottom: 1px solid #333; padding-bottom: 2px; min-height: 24px; }
.preview-row .a.answer-text { color: #E11D48; font-weight: 700; }

/* --- Step 3: Game --- */
.game-wrapper {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1.5rem;
}

.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stat-box {
    background: white;
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
    border: 1px solid #E5E7EB;
}

.stat-box .label { font-size: 0.75rem; font-weight: 800; color: var(--text-muted); display: block; margin-bottom: 0.5rem; }
.stat-box .value { font-family: 'Outfit', sans-serif; font-size: 1.8rem; font-weight: 800; color: var(--primary); }

.game-settings select {
    width: 100%;
    padding: 0.8rem;
    border-radius: 12px;
    border: 1px solid #D1D5DB;
    font-weight: 600;
}

.game-canvas-area {
    position: relative;
    background: #0F172A;
    border-radius: 20px;
    height: 450px;
    overflow: hidden;
}

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

.game-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
}

.game-input-container {
    grid-column: 2;
    margin-top: 1rem;
}

#game-input {
    width: 100%;
    padding: 1.2rem;
    border-radius: 16px;
    border: 2px solid #E5E7EB;
    font-size: 1.2rem;
    text-align: center;
    transition: all 0.3s;
}

#game-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-primary {
    background: var(--primary);
    color: white;
    padding: 0.8rem 1.5rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--primary-glow);
}

.btn-secondary {
    background: #F3F4F6;
    color: var(--text-main);
    padding: 0.6rem 1.2rem;
}

.btn-glow {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.3);
}

.btn-full { width: 100%; padding: 1.2rem; }

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: slideUp 0.8s ease-out forwards; }

.footer {
    text-align: center;
    padding: 4rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(79, 70, 229, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

@media (max-width: 768px) {
    .game-wrapper { grid-template-columns: 1fr; }
    .game-input-container { grid-column: 1; }
    .nav-links { display: none; }
}
