/* ============================================================
   Tamagotchi Magic World - Super bunte, leuchtende Styles
   ============================================================ */
:root {
    --neon-pink: #FF00E5;
    --neon-cyan: #00F0FF;
    --neon-yellow: #FFE600;
    --neon-green: #00FF94;
    --neon-purple: #B400FF;
    --neon-orange: #FF6B00;
    --bg-grad-1: #1a0033;
    --bg-grad-2: #002a5c;
    --panel-bg: rgba(30, 10, 60, 0.85);
    --panel-border: rgba(255, 255, 255, 0.2);
    --text-glow: 0 0 10px currentColor, 0 0 20px currentColor;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Fredoka', sans-serif;
    background: #000;
    color: #fff;
}

#app {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: linear-gradient(135deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 50%, #4a0080 100%);
}

#game-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#game-container canvas {
    display: block;
}

/* Animated background stars */
#app::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image:
        radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,0.8), transparent),
        radial-gradient(2px 2px at 60% 70%, rgba(255,255,0,0.6), transparent),
        radial-gradient(1px 1px at 50% 50%, rgba(255,255,255,0.9), transparent),
        radial-gradient(2px 2px at 80% 10%, rgba(0,240,255,0.7), transparent),
        radial-gradient(1px 1px at 90% 60%, rgba(255,0,229,0.8), transparent),
        radial-gradient(2px 2px at 33% 80%, rgba(180,0,255,0.7), transparent),
        radial-gradient(1px 1px at 15% 90%, rgba(0,255,148,0.8), transparent);
    background-size: 300px 300px;
    background-repeat: repeat;
    animation: twinkle 4s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes twinkle {
    from { opacity: 0.4; }
    to { opacity: 1; }
}

/* ===== Loading Screen ===== */
#loading-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a0033, #002a5c);
    z-index: 1000;
    transition: opacity 0.6s;
}

.loading-emoji {
    font-size: 80px;
    animation: bounce 1s ease-in-out infinite;
}

.loading-text {
    margin-top: 20px;
    font-size: 28px;
    font-family: 'Baloo 2', sans-serif;
    color: var(--neon-cyan);
    text-shadow: 0 0 20px var(--neon-cyan);
}

.loading-bar {
    margin-top: 30px;
    width: 300px;
    height: 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.3);
}

.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--neon-pink), var(--neon-yellow), var(--neon-cyan));
    animation: loadbar 2s ease-in forwards;
    box-shadow: 0 0 15px var(--neon-pink);
}

@keyframes loadbar {
    to { width: 100%; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.1); }
}

/* ===== UI Overlay (HTML on top of canvas) ===== */
#ui-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
}

.ui-panel {
    pointer-events: auto;
}

/* Top HUD */
.hud-top {
    position: absolute;
    top: 12px; left: 12px; right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    gap: 12px;
    flex-wrap: wrap;
}

.coin-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, rgba(255,230,0,0.25), rgba(255,107,0,0.25));
    border: 2px solid var(--neon-yellow);
    border-radius: 30px;
    padding: 8px 20px;
    font-family: 'Baloo 2', sans-serif;
    font-size: 26px;
    font-weight: 800;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--neon-yellow);
    pointer-events: auto;
    backdrop-filter: blur(10px);
    animation: coin-pulse 2s ease-in-out infinite;
}

@keyframes coin-pulse {
    0%, 100% { box-shadow: 0 0 15px rgba(255,230,0,0.4); }
    50% { box-shadow: 0 0 30px rgba(255,230,0,0.7); }
}

.coin-icon {
    font-size: 32px;
    animation: spin 3s linear infinite;
    display: inline-block;
}

@keyframes spin {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

.title-badge {
    background: linear-gradient(135deg, rgba(255,0,229,0.3), rgba(180,0,255,0.3));
    border: 2px solid var(--neon-pink);
    border-radius: 30px;
    padding: 8px 24px;
    font-family: 'Baloo 2', sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 15px var(--neon-pink);
    backdrop-filter: blur(10px);
}

/* Bottom Toolbar */
.toolbar {
    position: absolute;
    bottom: 12px; left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 24px;
    padding: 8px;
    backdrop-filter: blur(15px);
    pointer-events: auto;
    box-shadow: 0 0 30px rgba(180,0,255,0.3);
    max-width: 95vw;
    flex-wrap: wrap;
    justify-content: center;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 16px;
    padding: 8px 12px;
    color: #fff;
    font-family: 'Fredoka', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 72px;
}

.tool-btn:hover {
    transform: translateY(-4px) scale(1.05);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 20px var(--neon-cyan);
    background: linear-gradient(135deg, rgba(0,240,255,0.2), rgba(180,0,255,0.2));
}

.tool-btn:active {
    transform: scale(0.95);
}

.tool-btn .icon {
    font-size: 28px;
    line-height: 1;
}

.tool-btn .badge {
    position: absolute;
    top: -4px; right: -4px;
    background: var(--neon-orange);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    border-radius: 10px;
    padding: 1px 6px;
    border: 1px solid #fff;
}

.tool-btn {
    position: relative;
}

/* Side Panel */
.side-panel {
    position: absolute;
    top: 70px; right: 12px;
    width: 300px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 20px;
    padding: 14px;
    backdrop-filter: blur(15px);
    pointer-events: auto;
    box-shadow: 0 0 25px rgba(0,240,255,0.2);
}

.side-panel::-webkit-scrollbar { width: 6px; }
.side-panel::-webkit-scrollbar-thumb { background: var(--neon-purple); border-radius: 3px; }

.panel-title {
    font-family: 'Baloo 2', sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan);
    margin-bottom: 10px;
    text-align: center;
}

/* Creature list item */
.creature-card {
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 14px;
    padding: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.creature-card:hover {
    border-color: var(--neon-pink);
    box-shadow: 0 0 15px rgba(255,0,229,0.4);
    transform: translateX(-3px);
}

.creature-card.active {
    border-color: var(--neon-green);
    box-shadow: 0 0 20px var(--neon-green);
    background: rgba(0,255,148,0.1);
}

.creature-avatar {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    flex-shrink: 0;
}

.creature-info {
    flex: 1;
    min-width: 0;
}

.creature-name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.creature-meta {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
}

/* Modal Overlay */
.modal-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(8px);
    pointer-events: auto;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: linear-gradient(135deg, rgba(40,15,80,0.95), rgba(20,5,50,0.95));
    border: 3px solid var(--neon-purple);
    border-radius: 28px;
    padding: 24px;
    max-width: 680px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(180,0,255,0.5);
    animation: modalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-title {
    font-family: 'Baloo 2', sans-serif;
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(90deg, var(--neon-pink), var(--neon-yellow), var(--neon-cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 8px rgba(255,0,229,0.5));
}

.close-btn {
    background: rgba(255,0,100,0.3);
    border: 2px solid var(--neon-pink);
    color: #fff;
    font-size: 20px;
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--neon-pink);
    transform: rotate(90deg) scale(1.1);
}

/* Store Grid */
.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.store-item {
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 18px;
    padding: 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.store-item:hover {
    transform: translateY(-5px) scale(1.03);
    border-color: var(--neon-green);
    box-shadow: 0 0 25px var(--neon-green);
}

.store-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.store-item.disabled:hover {
    transform: none;
    box-shadow: none;
}

.store-item .item-icon {
    font-size: 48px;
    margin-bottom: 8px;
    display: block;
}

.store-item .item-name {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
}

.store-item .item-price {
    color: var(--neon-yellow);
    font-size: 16px;
    font-weight: 800;
    text-shadow: 0 0 8px var(--neon-yellow);
}

.store-item .item-desc {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-top: 4px;
}

/* Stat Bars */
.stat-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.stat-bar-label {
    width: 70px;
    color: rgba(255,255,255,0.7);
}

.stat-bar-track {
    flex: 1;
    height: 14px;
    background: rgba(0,0,0,0.3);
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.2);
    position: relative;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 7px;
    transition: width 0.4s ease;
}

.stat-bar-value {
    width: 32px;
    text-align: right;
    color: #fff;
    font-weight: 600;
}

/* Action Buttons */
.action-btn {
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    font-family: 'Baloo 2', sans-serif;
    font-size: 16px;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(180,0,255,0.4);
}

.action-btn:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 6px 25px rgba(180,0,255,0.7);
}

.action-btn:active { transform: scale(0.96); }

.action-btn.green {
    background: linear-gradient(135deg, var(--neon-green), #00b870);
    box-shadow: 0 4px 15px rgba(0,255,148,0.4);
}

.action-btn.yellow {
    background: linear-gradient(135deg, var(--neon-yellow), var(--neon-orange));
    color: #1a0033;
    box-shadow: 0 4px 15px rgba(255,230,0,0.4);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

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

.inv-slot {
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 14px;
    padding: 10px 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.inv-slot:hover {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 15px var(--neon-cyan);
    transform: translateY(-3px);
}

.inv-slot .qty-badge {
    position: absolute;
    top: -6px; right: -6px;
    background: var(--neon-orange);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    border-radius: 10px;
    padding: 1px 7px;
    border: 1px solid #fff;
}

.inv-slot .inv-icon { font-size: 32px; }
.inv-slot .inv-name { font-size: 11px; margin-top: 4px; color: rgba(255,255,255,0.7); }

/* Notification Toast */
.toast {
    position: absolute;
    top: 70px; left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(0,255,148,0.95), rgba(0,200,130,0.95));
    color: #003a20;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    padding: 12px 28px;
    border-radius: 30px;
    border: 2px solid #fff;
    box-shadow: 0 0 30px rgba(0,255,148,0.6);
    z-index: 200;
    animation: toastIn 0.4s, toastOut 0.4s 2.6s forwards;
    font-size: 18px;
}

.toast.error {
    background: linear-gradient(135deg, rgba(255,50,50,0.95), rgba(200,0,0,0.95));
    color: #fff;
    box-shadow: 0 0 30px rgba(255,50,50,0.6);
}

@keyframes toastIn {
    from { transform: translate(-50%, -60px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes toastOut {
    to { transform: translate(-50%, -60px); opacity: 0; }
}

/* Rarity tags */
.rarity-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    padding: 1px 8px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rarity-common    { background: #607D8B; color: #fff; }
.rarity-uncommon  { background: #4CAF50; color: #fff; }
.rarity-rare      { background: #2196F3; color: #fff; }
.rarity-epic      { background: #9C27B0; color: #fff; }
.rarity-legendary { background: linear-gradient(90deg, #FF9800, #FFC107); color: #3e2700; }
.rarity-mythic    { background: linear-gradient(90deg, #FF1744, #F50057); color: #fff; }

/* Detail card for selected creature */
.detail-card {
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 12px;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.stat-box {
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 6px 10px;
    text-align: center;
}

.stat-box .stat-num {
    font-family: 'Baloo 2', sans-serif;
    font-size: 20px;
    font-weight: 800;
}

.stat-box .stat-label {
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
}

/* Responsive */
@media (max-width: 768px) {
    .side-panel { width: 240px; top: 60px; }
    .tool-btn { min-width: 60px; padding: 6px 8px; }
    .tool-btn .icon { font-size: 24px; }
    .tool-btn span:last-child { font-size: 11px; }
}

@media (max-width: 520px) {
    .side-panel { display: none; }
    .toolbar { bottom: 6px; }
}

/* Egg list */
.egg-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 8px;
}

.egg-icon { font-size: 42px; animation: eggWobble 2s ease-in-out infinite; }

@keyframes eggWobble {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

/* Particles / floating elements */
.float-text {
    position: absolute;
    font-family: 'Baloo 2', sans-serif;
    font-size: 24px;
    font-weight: 800;
    pointer-events: none;
    z-index: 50;
    animation: floatUp 1.5s ease-out forwards;
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    20% { transform: translateY(-20px) scale(1.2); opacity: 1; }
    100% { transform: translateY(-120px) scale(1); opacity: 0; }
}

/* Section divider */
.section-divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--neon-purple), transparent);
    margin: 14px 0;
    border-radius: 1px;
}

.empty-hint {
    text-align: center;
    color: rgba(255,255,255,0.4);
    font-size: 14px;
    padding: 20px;
    font-style: italic;
}

/* ===== Login Screen ===== */
#login-screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1a0033, #002a5c, #4a0080);
    z-index: 5000; animation: fadeIn 0.4s;
}
.login-box {
    background: linear-gradient(135deg, rgba(40,15,80,0.95), rgba(20,5,50,0.95));
    border: 3px solid var(--neon-purple); border-radius: 28px; padding: 36px 32px;
    width: 360px; max-width: 90vw; box-shadow: 0 0 50px rgba(180,0,255,0.5);
    text-align: center; animation: modalPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.login-box h1 {
    font-family: 'Baloo 2', sans-serif; font-size: 32px; font-weight: 800;
    background: linear-gradient(90deg, var(--neon-pink), var(--neon-yellow), var(--neon-cyan));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(255,0,229,0.5)); margin-bottom: 4px;
}
.login-box .login-sub { font-size: 13px; color: rgba(255,255,255,0.5); margin-bottom: 24px; }
.login-box .login-emoji { font-size: 56px; margin-bottom: 8px; animation: bounce 1.5s ease-in-out infinite; }
.login-field {
    width: 100%; padding: 12px 16px; margin-bottom: 12px;
    background: rgba(0,0,0,0.3); border: 2px solid rgba(255,255,255,0.2);
    border-radius: 14px; color: #fff; font-family: 'Fredoka', sans-serif;
    font-size: 16px; outline: none; transition: all 0.2s;
}
.login-field:focus { border-color: var(--neon-cyan); box-shadow: 0 0 15px var(--neon-cyan); }
.login-field::placeholder { color: rgba(255,255,255,0.3); }
.login-error { color: #FF5252; font-size: 13px; margin-bottom: 10px; min-height: 18px; }
.login-btn {
    width: 100%; background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
    border: 2px solid rgba(255,255,255,0.3); color: #fff; font-family: 'Baloo 2', sans-serif;
    font-size: 18px; font-weight: 700; padding: 12px; border-radius: 14px;
    cursor: pointer; transition: all 0.2s; box-shadow: 0 4px 20px rgba(180,0,255,0.4); margin-bottom: 8px;
}
.login-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 6px 30px rgba(180,0,255,0.7); }
.login-btn.green { background: linear-gradient(135deg, var(--neon-green), #00b870); box-shadow: 0 4px 20px rgba(0,255,148,0.4); }
.login-toggle { margin-top: 12px; font-size: 13px; color: rgba(255,255,255,0.5); }
.login-toggle a { color: var(--neon-cyan); cursor: pointer; text-decoration: underline; }
.user-badge {
    display: flex; align-items: center; gap: 6px;
    background: rgba(0,240,255,0.15); border: 2px solid var(--neon-cyan);
    border-radius: 20px; padding: 6px 14px; font-size: 14px; font-weight: 600;
    color: var(--neon-cyan); pointer-events: auto;
}
.logout-btn {
    background: rgba(255,82,82,0.2); border: 1px solid rgba(255,82,82,0.5);
    color: #FF5252; font-size: 12px; padding: 4px 10px; border-radius: 12px;
    cursor: pointer; transition: all 0.2s;
}
.logout-btn:hover { background: rgba(255,82,82,0.4); }
.sound-toggle {
    background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.2);
    border-radius: 12px; padding: 6px 12px; cursor: pointer; font-size: 18px;
    pointer-events: auto; transition: all 0.2s;
}
.sound-toggle:hover { border-color: var(--neon-yellow); }
