/* ===== DESIGN TOKENS ===== */
:root {
    --bg-dark: #0a0a0a; --bg-card: #151515; --bg-card-hover: #1c1c1c;
    --bg-surface: #1a1a1a; --bg-input: #111111;
    --gold: #d4a847; --gold-dim: #b8922e; --gold-glow: rgba(212,168,71,0.3); --gold-bright: #f0c55b;
    --red: #c0392b; --red-dim: rgba(192,57,43,0.3);
    --green: #27ae60; --green-dim: rgba(39,174,96,0.2);
    --text: #e0e0e0; --text-dim: #888; --text-muted: #555;
    --border: #2a2a2a; --border-light: #333;
    --font-display: 'Cinzel', serif; --font-body: 'Inter', sans-serif;
    --radius: 8px; --radius-lg: 12px; --transition: 0.25s ease;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body); background: var(--bg-dark); color: var(--text); min-height: 100vh; overflow-x: hidden; line-height: 1.5; }

/* ===== SCREENS ===== */
.screen { display: none; min-height: 100vh; padding: 2rem; max-width: 1100px; margin: 0 auto; animation: fadeIn 0.4s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== BUTTONS ===== */
.btn { font-family: var(--font-body); font-weight: 600; border: none; border-radius: var(--radius); cursor: pointer; transition: all var(--transition); padding: 0.6rem 1.4rem; font-size: 0.9rem; }
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold-dim)); color: #0a0a0a; box-shadow: 0 2px 12px var(--gold-glow); }
.btn-gold:hover { background: linear-gradient(135deg, var(--gold-bright), var(--gold)); transform: translateY(-1px); box-shadow: 0 4px 20px var(--gold-glow); }
.btn-outline { background: transparent; color: var(--text); border: 1.5px solid var(--border-light); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 2.2rem; font-size: 1.05rem; letter-spacing: 0.04em; }

/* ===== LANDING ===== */
#screen-landing { display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: radial-gradient(ellipse at center, #1a1408 0%, #0a0a0a 70%); }
#screen-landing.active { display: flex; }
.landing-emblem { font-size: 5rem; margin-bottom: 1rem; animation: flicker 2s ease-in-out infinite alternate; filter: drop-shadow(0 0 20px rgba(212,168,71,0.5)); }
@keyframes flicker { 0% { opacity: 0.8; transform: scale(1); } 50% { opacity: 1; transform: scale(1.05); } 100% { opacity: 0.9; transform: scale(1.02); } }
.landing-title { font-family: var(--font-display); font-size: 3.5rem; font-weight: 900; color: var(--gold); letter-spacing: 0.15em; text-shadow: 0 0 30px var(--gold-glow); }
.landing-subtitle { font-family: var(--font-display); font-size: 1.6rem; font-weight: 400; color: var(--text-dim); letter-spacing: 0.35em; margin-top: 0.3rem; }
.landing-desc { color: var(--text-muted); margin-top: 1.5rem; font-style: italic; font-size: 1.05rem; }
.landing-buttons { margin-top: 2rem; display: flex; flex-direction: column; gap: 1rem; align-items: center; }
.join-row { display: flex; gap: 0.6rem; align-items: center; }
.input-code { width: 130px; padding: 0.75rem 1rem; text-align: center; font-size: 1.2rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; background: var(--bg-input); border: 2px solid var(--border-light); border-radius: var(--radius); color: var(--gold); font-family: var(--font-display); }
.input-code:focus { outline: none; border-color: var(--gold); }
.input-code::placeholder { color: var(--text-muted); font-size: 0.7rem; letter-spacing: 0.05em; }

/* ===== HEADERS / FOOTERS ===== */
.screen-header { text-align: center; margin-bottom: 2rem; }
.screen-header h1 { font-family: var(--font-display); font-size: 2rem; color: var(--gold); letter-spacing: 0.1em; }
.screen-header p { color: var(--text-dim); margin-top: 0.4rem; }
.screen-footer { text-align: center; margin-top: 2rem; padding: 1.5rem 0; display: flex; gap: 1rem; justify-content: center; align-items: center; flex-wrap: wrap; }

/* ===== ROOM CODE ===== */
.room-code-display { display: flex; align-items: center; justify-content: center; gap: 0.8rem; margin-top: 1rem; }
.room-code { font-family: var(--font-display); font-size: 2.5rem; font-weight: 900; color: var(--gold); letter-spacing: 0.25em; text-shadow: 0 0 15px var(--gold-glow); }

/* ===== LOBBY ===== */
.lobby-players { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; padding: 1rem 0; }
.lobby-player { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; text-align: center; animation: fadeIn 0.3s ease; position: relative; }
.lobby-player.is-gm::after { content: '👑 GM'; position: absolute; top: 6px; right: 8px; font-size: 0.6rem; background: var(--gold); color: #000; padding: 2px 6px; border-radius: 10px; font-weight: 700; }
.lobby-avatar { width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 0.5rem; border: 3px solid var(--border-light); overflow: hidden; background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: var(--text-dim); }
.lobby-avatar img { width: 100%; height: 100%; object-fit: cover; }
.lobby-name { font-size: 0.85rem; font-weight: 500; color: var(--text); }

/* ===== PROFILE FORM ===== */
.profile-form { max-width: 500px; margin: 0 auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; }
.profile-avatar-area { display: flex; gap: 1.5rem; align-items: flex-start; margin-bottom: 1.5rem; }
.profile-avatar { width: 100px; height: 100px; border-radius: 50%; border: 3px solid var(--gold); overflow: hidden; background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; color: var(--text-dim); flex-shrink: 0; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-inputs { flex: 1; }
.profile-fields { margin-bottom: 1.5rem; }
.text-input, .file-input { width: 100%; padding: 0.5rem 0.7rem; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text); font-family: var(--font-body); font-size: 0.85rem; margin-bottom: 0.6rem; transition: border-color var(--transition); }
.text-input:focus, .file-input:focus { outline: none; border-color: var(--gold); }
.profile-form label { font-size: 0.72rem; color: var(--text-dim); display: block; margin-bottom: 0.2rem; text-transform: uppercase; letter-spacing: 0.05em; }
.profile-form select { cursor: pointer; }
.profile-form select option { background: var(--bg-card); }
.profile-form .btn { width: 100%; margin-top: 0.5rem; }

/* ===== WAITING SECTION ===== */
.waiting-section { text-align: center; padding: 2rem; }
.waiting-text { color: var(--text-dim); font-style: italic; }
.waiting-spinner { width: 40px; height: 40px; border: 3px solid var(--border-light); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-counter { font-family: var(--font-display); font-size: 2rem; color: var(--gold); margin-top: 0.5rem; text-shadow: 0 0 10px var(--gold-glow); }

/* ===== DISTRICT SELECTION ===== */
.district-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.district-box { background: var(--bg-card); border: 2px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; text-align: center; cursor: pointer; transition: all var(--transition); min-height: 160px; }
.district-box:hover { border-color: var(--gold); transform: translateY(-2px); }
.district-box.selected { border-color: var(--gold); box-shadow: 0 0 15px var(--gold-glow); }
.district-box .district-title { font-family: var(--font-display); font-size: 0.9rem; letter-spacing: 0.1em; margin-bottom: 0.8rem; }
.district-slots { display: flex; gap: 0.8rem; justify-content: center; min-height: 70px; align-items: center; }
.district-slot { width: 60px; height: 60px; border-radius: 50%; border: 2px dashed var(--border-light); display: flex; align-items: center; justify-content: center; font-size: 0.7rem; color: var(--text-muted); overflow: hidden; background: var(--bg-input); }
.district-slot.filled { border-style: solid; }
.district-slot img { width: 100%; height: 100%; object-fit: cover; }
.district-slot-name { font-size: 0.7rem; color: var(--text-dim); margin-top: 0.3rem; text-align: center; }
.district-slot-wrapper { display: flex; flex-direction: column; align-items: center; }

/* ===== STATS (SOLO) ===== */
.stats-tabs { display: flex; gap: 0; justify-content: center; margin-bottom: 1.5rem; border-bottom: 2px solid var(--border); }
.tab-btn { font-family: var(--font-body); font-weight: 600; font-size: 0.9rem; padding: 0.8rem 1.5rem; background: none; color: var(--text-dim); border: none; cursor: pointer; transition: all var(--transition); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--gold); border-bottom-color: var(--gold); }
.stats-main-solo { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; max-height: 500px; overflow-y: auto; }

/* ===== RATING BAR ===== */
.rating-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.rating-row:last-child { border-bottom: none; }
.rating-label { width: 150px; flex-shrink: 0; font-size: 0.85rem; font-weight: 500; display: flex; align-items: center; gap: 0.4rem; }
.rating-label .help-icon { width: 18px; height: 18px; border-radius: 50%; background: var(--border-light); display: inline-flex; align-items: center; justify-content: center; font-size: 0.65rem; color: var(--text-dim); cursor: pointer; transition: all var(--transition); flex-shrink: 0; }
.rating-label .help-icon:hover { background: var(--gold); color: #000; }
.rating-bar { display: flex; gap: 3px; flex: 1; }
.rating-box { width: 32px; height: 32px; border: 2px solid var(--border-light); border-radius: 4px; cursor: pointer; transition: all 0.15s ease; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; color: transparent; font-weight: 600; }
.rating-box:hover { border-color: var(--gold); transform: scale(1.08); }
.rating-box.filled { background: var(--gold); border-color: var(--gold); color: #0a0a0a; }
.rating-box.filled-end { box-shadow: 0 0 8px var(--gold-glow); }
.rating-value { width: 30px; text-align: center; font-weight: 700; color: var(--gold); font-size: 0.95rem; }
.friendship-row { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.7rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.friendship-row .friend-avatar { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 0.75rem; color: var(--text-dim); flex-shrink: 0; border: 2px solid var(--border); }
.friendship-row .friend-avatar img { width: 100%; height: 100%; object-fit: cover; }
.friendship-row .friend-name { width: 100px; flex-shrink: 0; font-size: 0.82rem; }

/* ===== SIMULATION ===== */
.sim-header { text-align: center; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid var(--border); }
.sim-phase-title { font-family: var(--font-display); font-size: 2.2rem; color: var(--gold); letter-spacing: 0.1em; text-shadow: 0 0 20px var(--gold-glow); }
.sim-info { display: flex; align-items: center; justify-content: center; gap: 1.5rem; margin-top: 0.8rem; }
.sim-alive { color: var(--green); font-weight: 600; font-size: 0.95rem; }
.sim-events { display: flex; flex-direction: column; gap: 0.5rem; }
.event-card { display: flex; align-items: center; gap: 1rem; padding: 0.8rem 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); animation: slideIn 0.3s ease; }
.event-card:hover { background: var(--bg-card-hover); }
.event-card.fatal { border-left: 3px solid var(--red); background: rgba(192,57,43,0.05); }
@keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
.event-avatars { display: flex; flex-shrink: 0; }
.event-avatars .evt-avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; border: 2px solid var(--border-light); background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--text-dim); margin-left: -8px; }
.event-avatars .evt-avatar:first-child { margin-left: 0; }
.event-avatars .evt-avatar img { width: 100%; height: 100%; object-fit: cover; }
.event-avatars .evt-avatar.dead-avatar { opacity: 0.5; border-color: var(--red); }
.event-text { font-size: 0.9rem; line-height: 1.45; }
.sim-footer { text-align: center; margin-top: 2rem; padding: 1.5rem 0; display: flex; gap: 1rem; justify-content: center; align-items: center; }

/* ===== FALLEN ===== */
.fallen-header { text-align: center; margin-bottom: 2rem; }
.fallen-header h1 { font-family: var(--font-display); font-size: 2rem; color: var(--red); letter-spacing: 0.1em; }
.fallen-cannon { font-size: 1.1rem; color: var(--text-dim); margin-top: 0.5rem; font-style: italic; }
.fallen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 1.2rem; justify-items: center; }
.fallen-tribute { text-align: center; animation: fadeIn 0.5s ease; }
.fallen-tribute .fallen-avatar { width: 80px; height: 80px; border-radius: 50%; overflow: hidden; border: 3px solid var(--red); margin: 0 auto 0.5rem; background: var(--bg-input); filter: grayscale(100%); opacity: 0.7; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; color: var(--text-muted); }
.fallen-tribute .fallen-avatar img { width: 100%; height: 100%; object-fit: cover; }
.fallen-tribute .fallen-name { font-size: 0.85rem; font-weight: 600; color: var(--text-dim); }
.fallen-tribute .fallen-district { font-size: 0.7rem; color: var(--text-muted); }

/* ===== STATUS OVERLAY ===== */
.overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.85); z-index: 100; overflow-y: auto; animation: fadeIn 0.2s ease; }
.overlay.active { display: block; }
.overlay-content { max-width: 900px; margin: 2rem auto; padding: 2rem; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.overlay-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.overlay-header h2 { font-family: var(--font-display); color: var(--gold); letter-spacing: 0.08em; }
.status-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.status-district { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.status-district-title { font-family: var(--font-display); font-size: 0.8rem; color: var(--gold); letter-spacing: 0.08em; margin-bottom: 0.7rem; text-transform: uppercase; }
.status-tribute { display: flex; align-items: center; gap: 0.7rem; padding: 0.4rem 0; }
.status-tribute.dead { opacity: 0.4; }
.status-tribute .st-avatar { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; border: 2px solid var(--border-light); background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 0.75rem; color: var(--text-dim); flex-shrink: 0; }
.status-tribute .st-avatar img { width: 100%; height: 100%; object-fit: cover; }
.status-tribute.dead .st-avatar { filter: grayscale(100%); border-color: var(--red); }
.status-tribute .st-name { font-size: 0.85rem; font-weight: 500; flex: 1; }
.status-tribute.dead .st-name { text-decoration: line-through; color: var(--text-muted); }
.status-tribute .st-kills { font-size: 0.75rem; color: var(--red); font-weight: 600; }
.st-status-badge { font-size: 0.65rem; padding: 0.15rem 0.5rem; border-radius: 20px; font-weight: 600; }
.st-status-badge.alive { background: var(--green-dim); color: var(--green); }
.st-status-badge.dead-badge { background: var(--red-dim); color: var(--red); }

/* ===== WINNER ===== */
#screen-winner { text-align: center; }
.winner-content { padding: 3rem 0; }
.winner-crown { font-size: 4rem; margin-bottom: 1rem; animation: flicker 1.5s ease-in-out infinite alternate; }
.winner-title { font-family: var(--font-display); font-size: 2.4rem; color: var(--gold); letter-spacing: 0.12em; margin-bottom: 0.5rem; }
.winner-name { font-family: var(--font-display); font-size: 1.8rem; color: var(--text); margin-bottom: 0.3rem; }
.winner-district { color: var(--text-dim); font-size: 1rem; margin-bottom: 2rem; }
.winner-avatar-lg { width: 140px; height: 140px; border-radius: 50%; margin: 0 auto 1.5rem; border: 4px solid var(--gold); overflow: hidden; box-shadow: 0 0 40px var(--gold-glow); background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 3rem; color: var(--text-dim); }
.winner-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.placements { margin-top: 2rem; text-align: left; max-width: 500px; margin-left: auto; margin-right: auto; }
.placements h3 { font-family: var(--font-display); color: var(--gold); margin-bottom: 1rem; }
.placement-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.placement-row .place-num { width: 30px; font-weight: 700; color: var(--gold); }
.placement-row .place-avatar { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; border: 2px solid var(--border); background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 0.6rem; color: var(--text-dim); }
.placement-row .place-avatar img { width: 100%; height: 100%; object-fit: cover; }
.placement-row .place-name { flex: 1; }
.placement-row .place-kills { color: var(--red); font-weight: 600; font-size: 0.8rem; }

/* ===== HELP ===== */
.overlay-help-content { max-width: 600px; }
.help-body { font-size: 0.88rem; line-height: 1.7; }
.help-body .help-level { display: flex; gap: 0.6rem; margin-bottom: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.help-body .help-level-num { width: 28px; height: 28px; border-radius: 4px; background: var(--gold); color: #0a0a0a; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.8rem; }

/* ===== ERROR TOAST ===== */
.error-toast { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--red); color: #fff; padding: 0.8rem 1.5rem; border-radius: var(--radius); font-weight: 600; z-index: 200; transition: transform 0.3s ease; pointer-events: none; }
.error-toast.show { transform: translateX(-50%) translateY(0); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .screen { padding: 1rem; }
    .landing-title { font-size: 2.2rem; }
    .status-grid { grid-template-columns: 1fr; }
    .rating-box { width: 26px; height: 26px; }
    .rating-label { width: 110px; font-size: 0.78rem; }
    .district-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
