/* ============================================
   ANIMAL TYCOON - Styles
   Created by JH Games
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;900&family=Share+Tech+Mono&display=swap');

/* ---- RESET & BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-dark: #0a0a0f;
    --bg-panel: #12121a;
    --bg-card: #1a1a2a;
    --bg-hover: #22223a;
    --text: #e8e8f0;
    --text-dim: #888899;
    --accent: #FFD700;
    --accent2: #FF6B35;
    --green: #44FF88;
    --blue: #4488FF;
    --purple: #BB44FF;
    --red: #FF2244;
    --common: #888888;
    --uncommon: #44FF88;
    --rare: #4488FF;
    --epic: #BB44FF;
    --legendary: #FFD700;
    --mythic: #FF2244;
    --secret: linear-gradient(90deg, #FF0000, #FF7F00, #FFFF00, #00FF00, #0000FF, #8B00FF, #FF0000);
    --op-white: #FFFFFF;
    --admin-gold: #FFD700;
    --font-main: 'Barlow Condensed', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
    --radius: 8px;
    --shadow: 0 4px 20px rgba(0,0,0,0.5);
}

html, body {
    width: 100%; height: 100%;
    background: var(--bg-dark);
    color: var(--text);
    font-family: var(--font-main);
    overflow: hidden;
}

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

/* ---- UTILITY ---- */
.hidden { display: none !important; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-col { display: flex; flex-direction: column; }

/* ---- SCREENS ---- */
.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.screen.active { display: flex; }

/* ---- LOGIN SCREEN ---- */
#login-screen {
    background: radial-gradient(ellipse at center, #1a1a2f 0%, #0a0a0f 100%);
    justify-content: center;
    align-items: center;
}

.login-container {
    width: 400px;
    max-width: 90vw;
    background: var(--bg-panel);
    border: 1px solid #2a2a3a;
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: var(--shadow), 0 0 60px rgba(255,215,0,0.05);
    text-align: center;
}

.login-logo {
    font-size: 48px;
    margin-bottom: 4px;
}

.login-title {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 2px;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 28px;
    font-family: var(--font-mono);
}

.login-container input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: var(--bg-dark);
    border: 1px solid #2a2a3a;
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.login-container input:focus {
    border-color: var(--accent);
}

.login-container input::placeholder {
    color: #555;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #000;
    width: 100%;
    margin-bottom: 10px;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid #2a2a3a;
    width: 100%;
    margin-bottom: 10px;
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    width: 100%;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-green { background: var(--green); color: #000; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-gold { background: var(--accent); color: #000; }

.login-error {
    color: var(--red);
    font-size: 13px;
    margin-bottom: 10px;
    min-height: 20px;
    font-family: var(--font-mono);
}

.login-footer {
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

/* ---- SERVER BROWSER ---- */
#server-screen {
    background: var(--bg-dark);
}

.server-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #1a1a2a;
    background: var(--bg-panel);
}

.server-header h1 {
    font-size: 24px;
    font-weight: 900;
    color: var(--accent);
    letter-spacing: 2px;
}

.server-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.server-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-panel);
    border: 1px solid #1a1a2a;
    border-radius: var(--radius);
    padding: 16px 20px;
    transition: all 0.2s;
    cursor: pointer;
}

.server-card:hover {
    border-color: var(--accent);
    background: var(--bg-card);
}

.server-info h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.server-info span {
    font-size: 13px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.server-players {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--green);
    margin-right: 20px;
}

.server-empty {
    text-align: center;
    padding: 60px 0;
    color: var(--text-dim);
    font-size: 18px;
}

/* Create Server Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-panel);
    border: 1px solid #2a2a3a;
    border-radius: 16px;
    padding: 32px;
    width: 420px;
    max-width: 90vw;
    box-shadow: var(--shadow);
}

.modal h2 {
    font-size: 22px;
    font-weight: 900;
    color: var(--accent);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal input, .modal select {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: var(--bg-dark);
    border: 1px solid #2a2a3a;
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 14px;
    outline: none;
}

.modal input:focus, .modal select:focus { border-color: var(--accent); }

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.modal-actions .btn { flex: 1; }

/* ---- MAIN GAME SCREEN ---- */
#game-screen {
    background: var(--bg-dark);
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-panel);
    border-bottom: 1px solid #1a1a2a;
    min-height: 60px;
    flex-shrink: 0;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.top-bar-user {
    font-weight: 700;
    font-size: 16px;
    color: var(--accent);
}

.top-bar-server {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-dim);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.cash-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    font-weight: 900;
    color: var(--accent);
    font-family: var(--font-mono);
}

.cash-display .cash-icon { font-size: 24px; }

.income-display {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--green);
}

.top-bar-leave {
    padding: 6px 14px;
    font-size: 12px;
}

/* Base Area */
.base-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.base-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dim);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.base-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

/* Animal Card */
.animal-card {
    position: relative;
    background: var(--bg-card);
    border: 2px solid #2a2a3a;
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}

.animal-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.animal-card.tier-common { border-color: var(--common); }
.animal-card.tier-uncommon { border-color: var(--uncommon); }
.animal-card.tier-rare { border-color: var(--rare); }
.animal-card.tier-epic { border-color: var(--epic); }
.animal-card.tier-legendary { border-color: var(--legendary); box-shadow: 0 0 15px rgba(255,215,0,0.2); }
.animal-card.tier-mythic { border-color: var(--mythic); box-shadow: 0 0 15px rgba(255,34,68,0.2); }

.animal-card.tier-secret {
    border-image: linear-gradient(90deg, #FF0000, #FF7F00, #FFFF00, #00FF00, #0000FF, #8B00FF, #FF0000) 1;
    animation: rainbow-border 3s linear infinite;
}

.animal-card.tier-op {
    border-color: #fff;
    box-shadow: 0 0 20px rgba(255,255,255,0.4), 0 0 40px rgba(255,255,255,0.1);
}

.animal-card.tier-admin {
    border: 2px solid;
    border-image: linear-gradient(135deg, #000, #FFD700, #000, #FFD700) 1;
    animation: admin-border 2s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255,215,0,0.3);
}

@keyframes rainbow-border {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

@keyframes admin-border {
    0%, 100% { box-shadow: 0 0 20px rgba(255,215,0,0.3); }
    50% { box-shadow: 0 0 30px rgba(255,215,0,0.6), 0 0 60px rgba(255,215,0,0.2); }
}

.animal-emoji {
    font-size: 48px;
    margin-bottom: 8px;
    display: block;
    line-height: 1.2;
}

.animal-name {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.animal-species {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.animal-tier-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.badge-common { background: rgba(136,136,136,0.2); color: var(--common); }
.badge-uncommon { background: rgba(68,255,136,0.15); color: var(--uncommon); }
.badge-rare { background: rgba(68,136,255,0.15); color: var(--rare); }
.badge-epic { background: rgba(187,68,255,0.15); color: var(--epic); }
.badge-legendary { background: rgba(255,215,0,0.15); color: var(--legendary); }
.badge-mythic { background: rgba(255,34,68,0.15); color: var(--mythic); }
.badge-secret { background: rgba(255,255,255,0.1); color: #fff; }
.badge-op { background: rgba(255,255,255,0.2); color: #fff; font-weight: 900; }
.badge-admin { background: rgba(255,215,0,0.2); color: var(--admin-gold); }

.animal-income {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--green);
    margin-bottom: 4px;
}

.animal-level {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.animal-xp-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-dark);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}

.animal-xp-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 2px;
    transition: width 0.3s;
}

.animal-mutation {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
}

/* Mutation Visual Effects */
.mutation-shiny { color: var(--accent); text-shadow: 0 0 8px rgba(255,215,0,0.6); }
.mutation-shiny .animal-emoji { animation: shiny-shimmer 2s ease-in-out infinite; }

@keyframes shiny-shimmer {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.4) drop-shadow(0 0 8px rgba(255,215,0,0.8)); }
}

.mutation-neon { text-shadow: 0 0 10px currentColor; }
.mutation-neon .animal-emoji { animation: neon-glow 2s ease-in-out infinite; }

@keyframes neon-glow {
    0% { filter: drop-shadow(0 0 6px #ff0066); }
    33% { filter: drop-shadow(0 0 6px #00ffcc); }
    66% { filter: drop-shadow(0 0 6px #3366ff); }
    100% { filter: drop-shadow(0 0 6px #ff0066); }
}

.mutation-shadow .animal-emoji { animation: shadow-aura 2s ease-in-out infinite; }

@keyframes shadow-aura {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(128,0,255,0.5)); }
    50% { filter: drop-shadow(0 0 20px rgba(128,0,255,0.8)) brightness(0.8); }
}

.mutation-cosmic .animal-emoji { animation: cosmic-sparkle 1.5s ease-in-out infinite; }

@keyframes cosmic-sparkle {
    0%, 100% { filter: drop-shadow(0 0 6px rgba(100,100,255,0.5)) brightness(1); }
    25% { filter: drop-shadow(2px -2px 4px rgba(255,200,100,0.7)) brightness(1.2); }
    50% { filter: drop-shadow(-2px 2px 6px rgba(200,100,255,0.7)) brightness(1.1); }
    75% { filter: drop-shadow(0 0 8px rgba(100,255,200,0.6)) brightness(1.15); }
}

.mutation-void .animal-emoji { animation: void-effect 2s ease-in-out infinite; }

@keyframes void-effect {
    0%, 100% { filter: brightness(0.7) drop-shadow(0 0 10px rgba(0,0,0,0.8)); transform: scale(1); }
    50% { filter: brightness(0.4) drop-shadow(0 0 20px rgba(50,0,80,0.9)); transform: scale(0.95); }
}

.mutation-rainbow .animal-emoji { animation: rainbow-cycle 3s linear infinite; }

@keyframes rainbow-cycle {
    0% { filter: hue-rotate(0deg) drop-shadow(0 0 6px rgba(255,0,0,0.5)); }
    100% { filter: hue-rotate(360deg) drop-shadow(0 0 6px rgba(255,0,0,0.5)); }
}

.mutation-glitch .animal-emoji { animation: glitch-effect 0.5s steps(2) infinite; }

@keyframes glitch-effect {
    0% { transform: translate(0); filter: none; }
    25% { transform: translate(-2px, 1px); filter: hue-rotate(90deg); }
    50% { transform: translate(2px, -1px); filter: hue-rotate(180deg); }
    75% { transform: translate(-1px, -1px); filter: hue-rotate(270deg); }
    100% { transform: translate(0); filter: none; }
}

/* OP Particle effect */
.animal-card.tier-op::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.1) 0%, transparent 50%),
                radial-gradient(circle at 70% 70%, rgba(255,255,255,0.08) 0%, transparent 50%);
    animation: op-particles 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes op-particles {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Empty Slot */
.animal-slot-empty {
    background: var(--bg-card);
    border: 2px dashed #2a2a3a;
    border-radius: 12px;
    padding: 30px 12px;
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
}

.animal-slot-empty .slot-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.3;
}

.animal-slot-locked {
    opacity: 0.4;
}

.animal-slot-locked .slot-icon::after {
    content: ' 🔒';
}

/* Bottom Bar */
.bottom-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-panel);
    border-top: 1px solid #1a1a2a;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.bottom-bar .btn {
    font-size: 13px;
    padding: 10px 18px;
}

/* ---- HATCH SCREEN / OVERLAY ---- */
.hatch-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 500;
    flex-direction: column;
}
.hatch-overlay.active { display: flex; }

.egg-selection {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.egg-card {
    background: var(--bg-panel);
    border: 2px solid #2a2a3a;
    border-radius: 16px;
    padding: 24px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    width: 180px;
}

.egg-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
}

.egg-card .egg-emoji { font-size: 56px; display: block; margin-bottom: 10px; }
.egg-card .egg-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.egg-card .egg-cost { font-family: var(--font-mono); color: var(--accent); font-size: 16px; margin-bottom: 8px; }
.egg-card .egg-desc { font-size: 12px; color: var(--text-dim); line-height: 1.4; }

.egg-card-basic { }
.egg-card-basic:hover { box-shadow: 0 0 20px rgba(136,136,136,0.3); }

.egg-card-premium { border-color: #2a3a2a; }
.egg-card-premium:hover { border-color: var(--green); box-shadow: 0 0 20px rgba(68,255,136,0.2); }

.egg-card-mythic { border-color: #2a1a2a; }
.egg-card-mythic:hover { border-color: var(--mythic); box-shadow: 0 0 20px rgba(255,34,68,0.2); }

.hatch-close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 28px;
    color: var(--text-dim);
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font-main);
}

/* Hatching Animation */
.hatch-animation {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.hatch-animation.active { display: flex; }

.hatch-egg {
    font-size: 120px;
    line-height: 1;
    margin-bottom: 20px;
    position: relative;
}

.hatch-egg.shaking {
    animation: egg-shake 0.15s ease-in-out infinite;
}

@keyframes egg-shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-8deg); }
    75% { transform: rotate(8deg); }
}

.hatch-egg.cracking {
    animation: egg-crack 0.5s ease-out forwards;
}

@keyframes egg-crack {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.1); filter: brightness(2); }
    100% { transform: scale(0); filter: brightness(3); opacity: 0; }
}

.hatch-reveal {
    display: none;
    flex-direction: column;
    align-items: center;
    animation: reveal-pop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.hatch-reveal.active { display: flex; }

@keyframes reveal-pop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.reveal-emoji { font-size: 100px; line-height: 1; margin-bottom: 16px; }
.reveal-name { font-size: 28px; font-weight: 900; margin-bottom: 4px; }
.reveal-species { font-size: 16px; color: var(--text-dim); margin-bottom: 12px; }

.reveal-tier {
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    padding: 6px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.reveal-income { font-family: var(--font-mono); font-size: 16px; color: var(--green); margin-bottom: 8px; }
.reveal-mutation { font-size: 14px; font-weight: 700; margin-bottom: 20px; }

/* Tier color explosion backgrounds */
.hatch-overlay.tier-flash-common { background: rgba(136,136,136,0.15); }
.hatch-overlay.tier-flash-uncommon { background: rgba(68,255,136,0.12); }
.hatch-overlay.tier-flash-rare { background: rgba(68,136,255,0.15); }
.hatch-overlay.tier-flash-epic { background: rgba(187,68,255,0.15); }
.hatch-overlay.tier-flash-legendary { background: rgba(255,215,0,0.15); }
.hatch-overlay.tier-flash-mythic { background: rgba(255,34,68,0.2); }
.hatch-overlay.tier-flash-secret { background: rgba(255,255,255,0.15); }
.hatch-overlay.tier-flash-op { background: rgba(255,255,255,0.25); }
.hatch-overlay.tier-flash-admin { background: rgba(255,215,0,0.25); }

.tier-flash {
    animation: flash-bg 0.6s ease-out;
}

@keyframes flash-bg {
    0% { opacity: 0; }
    30% { opacity: 1; }
    100% { opacity: 1; }
}

/* ---- SHOP OVERLAY ---- */
.shop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 500;
}
.shop-overlay.active { display: flex; }

.shop-panel {
    background: var(--bg-panel);
    border: 1px solid #2a2a3a;
    border-radius: 16px;
    padding: 32px;
    width: 600px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.shop-panel h2 {
    font-size: 24px;
    font-weight: 900;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
    text-align: center;
}

.shop-section h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    margin-top: 16px;
}

.shop-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 1px solid #2a2a3a;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    transition: border-color 0.2s;
}

.shop-item:hover { border-color: #3a3a4a; }

.shop-item-info h4 { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.shop-item-info p { font-size: 12px; color: var(--text-dim); }

.shop-item .btn { flex-shrink: 0; margin-left: 12px; }

/* ---- LEADERBOARD OVERLAY ---- */
.leaderboard-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 500;
}
.leaderboard-overlay.active { display: flex; }

.leaderboard-panel {
    background: var(--bg-panel);
    border: 1px solid #2a2a3a;
    border-radius: 16px;
    padding: 32px;
    width: 500px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.leaderboard-panel h2 {
    font-size: 24px;
    font-weight: 900;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
    text-align: center;
}

.lb-entry {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 6px;
    gap: 14px;
}

.lb-rank {
    font-size: 20px;
    font-weight: 900;
    width: 36px;
    text-align: center;
    color: var(--text-dim);
}

.lb-rank.top1 { color: #FFD700; }
.lb-rank.top2 { color: #C0C0C0; }
.lb-rank.top3 { color: #CD7F32; }

.lb-name { flex: 1; font-weight: 700; font-size: 15px; }
.lb-cash { font-family: var(--font-mono); color: var(--accent); font-size: 14px; }

/* ---- EVENTS OVERLAY ---- */
.events-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 500;
}
.events-overlay.active { display: flex; }

.events-panel {
    background: var(--bg-panel);
    border: 1px solid #2a2a3a;
    border-radius: 16px;
    padding: 32px;
    width: 550px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.events-panel h2 {
    font-size: 24px;
    font-weight: 900;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
    text-align: center;
}

.event-active {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.event-active h3 { font-size: 18px; color: var(--accent); margin-bottom: 6px; }
.event-active p { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.event-timer { font-family: var(--font-mono); color: var(--green); font-size: 16px; }

.event-none {
    text-align: center;
    color: var(--text-dim);
    padding: 30px;
    font-size: 15px;
}

.event-history-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.event-history-item .event-name { font-weight: 700; font-size: 14px; }
.event-history-item .event-time { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }

/* ---- ANIMAL DETAIL MODAL ---- */
.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 600;
}
.detail-overlay.active { display: flex; }

.detail-panel {
    background: var(--bg-panel);
    border: 1px solid #2a2a3a;
    border-radius: 16px;
    padding: 32px;
    width: 380px;
    max-width: 90vw;
    text-align: center;
}

.detail-emoji { font-size: 80px; line-height: 1; margin-bottom: 12px; display: block; }
.detail-name { font-size: 24px; font-weight: 900; margin-bottom: 2px; }
.detail-name input {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text);
    font-family: var(--font-main);
    font-size: 24px;
    font-weight: 900;
    text-align: center;
    width: 100%;
    outline: none;
    border-radius: var(--radius);
    padding: 4px;
}
.detail-name input:focus { border-color: var(--accent); }

.detail-species { font-size: 14px; color: var(--text-dim); margin-bottom: 12px; }

.detail-stats {
    text-align: left;
    margin: 16px 0;
}

.detail-stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #1a1a2a;
    font-size: 14px;
}

.detail-stat-label { color: var(--text-dim); }
.detail-stat-value { font-weight: 700; font-family: var(--font-mono); }

.detail-xp-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-dark);
    border-radius: 4px;
    margin: 12px 0;
    overflow: hidden;
}

.detail-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--purple));
    border-radius: 4px;
    transition: width 0.3s;
}

/* ---- ADMIN PANEL ---- */
.admin-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 700;
}
.admin-overlay.active { display: flex; }

.admin-panel {
    background: #0d0d15;
    border: 2px solid var(--accent);
    border-radius: 16px;
    padding: 32px;
    width: 600px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(255,215,0,0.15);
}

.admin-panel h2 {
    font-size: 24px;
    font-weight: 900;
    color: var(--accent);
    text-align: center;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.admin-subtitle {
    text-align: center;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 12px;
    margin-bottom: 20px;
}

.admin-section {
    margin-bottom: 20px;
}

.admin-section h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #2a2a3a;
}

.admin-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.admin-row select, .admin-row input {
    flex: 1;
    min-width: 120px;
    padding: 10px 12px;
    background: var(--bg-dark);
    border: 1px solid #2a2a3a;
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
}

.admin-row select:focus, .admin-row input:focus { border-color: var(--accent); }

.admin-row .btn {
    flex-shrink: 0;
}

.admin-event-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}

.admin-event-btn {
    padding: 12px 8px;
    background: var(--bg-card);
    border: 1px solid #2a2a3a;
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.admin-event-btn:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

/* ---- EVENT BANNER ---- */
.event-banner {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(255,215,0,0.15), rgba(255,107,53,0.15));
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 10px 24px;
    font-weight: 700;
    font-size: 14px;
    color: var(--accent);
    z-index: 400;
    display: none;
    text-align: center;
    box-shadow: 0 4px 20px rgba(255,215,0,0.15);
    animation: banner-pulse 2s ease-in-out infinite;
}
.event-banner.active { display: block; }

@keyframes banner-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(255,215,0,0.15); }
    50% { box-shadow: 0 4px 30px rgba(255,215,0,0.3); }
}

/* ---- NOTIFICATION TOAST ---- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-panel);
    border: 1px solid #2a2a3a;
    border-radius: var(--radius);
    padding: 12px 20px;
    font-size: 14px;
    color: var(--text);
    box-shadow: var(--shadow);
    animation: toast-in 0.3s ease-out;
    max-width: 320px;
}

.toast.toast-success { border-color: var(--green); }
.toast.toast-error { border-color: var(--red); }
.toast.toast-event { border-color: var(--accent); }

@keyframes toast-in {
    0% { transform: translateX(100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

.toast.toast-out {
    animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-out {
    0% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(100%); opacity: 0; }
}

/* ---- INVENTORY OVERLAY ---- */
.inventory-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 500;
}
.inventory-overlay.active { display: flex; }

.inventory-panel {
    background: var(--bg-panel);
    border: 1px solid #2a2a3a;
    border-radius: 16px;
    padding: 32px;
    width: 700px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.inventory-panel h2 {
    font-size: 24px;
    font-weight: 900;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
    text-align: center;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.inventory-item {
    background: var(--bg-card);
    border: 1px solid #2a2a3a;
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.inventory-item:hover { border-color: var(--accent); }
.inventory-item .inv-emoji { font-size: 32px; }
.inventory-item .inv-name { font-size: 12px; font-weight: 700; margin-top: 4px; }
.inventory-item .inv-tier { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }

/* ---- LOADING / CONNECTING ---- */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #2a2a3a;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

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

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
    .base-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .top-bar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 16px;
    }

    .bottom-bar .btn {
        padding: 8px 12px;
        font-size: 11px;
    }

    .egg-selection { flex-direction: column; align-items: center; }
    .egg-card { width: 240px; }

    .server-header { flex-direction: column; gap: 10px; padding: 16px; }

    .admin-panel, .shop-panel, .leaderboard-panel, .events-panel, .inventory-panel, .detail-panel {
        width: 95vw;
        padding: 20px;
    }
}

/* ---- Close button universal ---- */
.overlay-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    color: var(--text-dim);
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font-main);
    z-index: 10;
    transition: color 0.2s;
}
.overlay-close:hover { color: var(--text); }

/* Relative wrapper for overlays with close buttons */
.shop-overlay, .leaderboard-overlay, .events-overlay, .hatch-overlay, .inventory-overlay, .admin-overlay, .detail-overlay {
    position: fixed;
}

/* ---- Branding Footer ---- */
.jh-branding {
    font-size: 11px;
    color: #444;
    font-family: var(--font-mono);
    text-align: center;
    padding: 8px;
    letter-spacing: 1px;
}
