/* ============================================================
   Idle RPG - Dark Fantasy Theme
   ============================================================ */

:root {
    /* Color Palette */
    --bg-dark: #0d1117;
    --bg-card: #161b22;
    --bg-elevated: #1c2333;
    --bg-modal: rgba(0, 0, 0, 0.85);
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --accent-gold: #ffd700;
    --accent-blue: #58a6ff;
    --accent-purple: #bc8cff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-orange: #d29922;
    /* Rarity Colors */
    --rarity-N: #8b949e;
    --rarity-R: #58a6ff;
    --rarity-E: #bc8cff;
    --rarity-L: #ffd700;
    /* Sizing */
    --nav-height: 60px;
    --header-height: 48px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ── Screens ── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ── Auth Screen ── */
#screen-auth {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #1a1040 100%);
}
.auth-container {
    width: 90%;
    max-width: 360px;
    text-align: center;
}
.auth-logo {
    font-size: 64px;
    margin-bottom: 8px;
    animation: float 3s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.auth-title {
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.auth-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 14px;
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.auth-form input {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: 'Outfit', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}
.auth-form input:focus {
    border-color: var(--accent-blue);
}
.error-msg {
    color: var(--accent-red);
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
}

/* ── Buttons ── */
.btn {
    border: none;
    border-radius: 12px;
    padding: 14px 24px;
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #3d8bfd);
    color: white;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-sm { padding: 10px 20px; font-size: 13px; }
.btn-upgrade {
    background: linear-gradient(135deg, var(--accent-green), #2ea043);
    color: white;
    padding: 8px 14px;
    font-size: 12px;
    border-radius: 8px;
}
.btn-party {
    background: var(--bg-elevated);
    color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
    padding: 6px 12px;
    font-size: 11px;
    border-radius: 8px;
}
.btn-party.in-party {
    background: var(--accent-blue);
    color: white;
}

/* ── Resource Bar ── */
.resource-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
    flex-shrink: 0;
}
.resource-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.res-icon { font-size: 18px; }
.res-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-gold);
    min-width: 50px;
}

/* ── Offline Banner ── */
.offline-banner {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-modal);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}
.offline-banner.hidden { display: none; }
.offline-content {
    background: var(--bg-elevated);
    border: 1px solid var(--accent-gold);
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    width: 85%;
    max-width: 320px;
    animation: slideUp 0.35s ease;
}
@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.offline-content h3 { margin-bottom: 12px; color: var(--accent-gold); }
#offline-details {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.8;
}

/* ── Tab Content ── */
.tab-content-area {
    flex: 1;
    overflow-y: auto;
    padding-bottom: calc(var(--nav-height) + 16px);
}
.tab-pane { display: none; padding: 16px; }
.tab-pane.active { display: block; }

/* ── Combat Tab ── */
.combat-stage-label {
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--accent-gold);
    padding: 12px 0 8px;
    letter-spacing: 2px;
}
.combat-arena {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px 16px;
    text-align: center;
}
.monster-area { margin-bottom: 20px; }
.monster-hp-container { margin-bottom: 12px; position: relative; }
.hp-bar {
    width: 100%;
    height: 14px;
    background: var(--bg-dark);
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.hp-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--accent-red), #f97583);
    border-radius: 7px;
    transition: width 0.3s ease;
}
.hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.monster-sprite {
    font-size: 72px;
    margin: 16px 0;
    animation: monsterIdle 2s ease-in-out infinite;
}
@keyframes monsterIdle {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
.monster-count {
    color: var(--text-secondary);
    font-size: 13px;
}
.combat-info {
    display: flex;
    justify-content: space-around;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.info-row { text-align: center; }
.info-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.info-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-gold);
}
.auto-combat-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 13px;
}
.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-green);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

/* ── Character Tab ── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.section-header h2 { font-size: 18px; font-weight: 700; }
.party-atk-label {
    font-size: 13px;
    color: var(--text-secondary);
}
.party-atk-label strong { color: var(--accent-gold); }
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.char-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    text-align: center;
    transition: border-color 0.2s;
}
.char-card:hover { border-color: var(--accent-blue); }
.char-card.rarity-N { border-left: 3px solid var(--rarity-N); }
.char-card.rarity-R { border-left: 3px solid var(--rarity-R); }
.char-card.rarity-E { border-left: 3px solid var(--rarity-E); }
.char-card.rarity-L { border-left: 3px solid var(--rarity-L); }
.char-emoji { font-size: 36px; margin-bottom: 6px; }
.char-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.char-rarity {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 6px;
}
.char-stats {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.char-actions { display: flex; flex-direction: column; gap: 6px; }
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    font-size: 15px;
}

/* ── Gacha Tab ── */
.gacha-header { text-align: center; margin-bottom: 20px; }
.gacha-header h2 { font-size: 22px; font-weight: 700; }
.gacha-desc { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }
.gacha-rate-info {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.rate-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.rate-badge.rarity-N { background: rgba(139,148,158,0.15); color: var(--rarity-N); }
.rate-badge.rarity-R { background: rgba(88,166,255,0.15); color: var(--rarity-R); }
.rate-badge.rarity-E { background: rgba(188,140,255,0.15); color: var(--rarity-E); }
.rate-badge.rarity-L { background: rgba(255,215,0,0.15); color: var(--rarity-L); }
.gacha-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 300px;
    margin: 0 auto;
}
.btn-gacha {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 14px;
}
.btn-gacha:hover { border-color: var(--accent-purple); }
.btn-gacha-premium {
    background: linear-gradient(135deg, #1a1040, #2d1b69);
    border-color: var(--accent-purple);
}
.gacha-label { font-weight: 600; }
.gacha-cost {
    font-size: 13px;
    color: var(--accent-purple);
    font-weight: 700;
}

/* ── Gacha Modal ── */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
}
.modal.hidden { display: none; }
.modal-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-modal);
}
.modal-content {
    position: relative;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.35s ease;
}
.gacha-result-modal h3 { text-align: center; margin-bottom: 16px; }
.gacha-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.gacha-card {
    background: var(--bg-dark);
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
    border: 1px solid var(--border);
    animation: cardReveal 0.4s ease both;
}
.gacha-card.new-char { border-color: var(--accent-green); }
.gacha-card.dupe-char { border-color: var(--text-muted); }
@keyframes cardReveal {
    from { transform: scale(0.5) rotateY(90deg); opacity: 0; }
    to { transform: scale(1) rotateY(0); opacity: 1; }
}
.gacha-card .char-emoji { font-size: 28px; }
.gacha-card .char-name { font-size: 10px; margin-top: 4px; }
.gacha-card .dupe-label { font-size: 9px; color: var(--accent-orange); margin-top: 2px; }

/* ── Bottom Navigation ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    height: var(--nav-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 50;
}
.nav-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 16px;
    transition: color 0.2s;
}
.nav-btn.active { color: var(--accent-gold); }
.nav-icon { font-size: 22px; }
.nav-label { font-size: 11px; font-weight: 600; font-family: 'Outfit', sans-serif; }

/* ── Toast ── */
#toast-container {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 13px;
    color: var(--text-primary);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
    white-space: nowrap;
}
.toast.success { border-color: var(--accent-green); }
.toast.error { border-color: var(--accent-red); }
@keyframes toastIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes toastOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* ── Hit Effect ── */
.hit-effect {
    position: absolute;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-red);
    pointer-events: none;
    animation: hitFloat 0.8s ease-out forwards;
}
@keyframes hitFloat {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-40px) scale(0.6); }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
