:root {
    --bg-color: #070214;
    --magenta: #ff00de;
    --cyan: #00ffff;
    --terminal-green: #39ff14;
    
    --grade-common: #ffffff;
    --grade-rare: #00ffff;
    --grade-epic: #ff00de;
    --grade-legendary: #ffaa00;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--terminal-green);
    font-family: 'VT323', monospace;
    overflow: hidden;
    image-rendering: pixelated;
}

/* CRT Overlay Effect */
.crt-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 2px, 3px 100%;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.8;
}

.screen {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    padding: 20px;
    padding-bottom: 80px; /* Space for nav */
    overflow-y: auto;
}

.hidden { display: none !important; }

/* Text Styles */
.neon-magenta {
    color: var(--magenta);
    text-shadow: 0 0 5px var(--magenta), 0 0 10px var(--magenta);
}

.neon-cyan {
    color: var(--cyan);
    text-shadow: 0 0 5px var(--cyan), 0 0 10px var(--cyan);
}

.screen-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    text-align: center;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* --- BOOT SCREEN --- */
#boot-screen {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    font-size: 18px;
    text-shadow: 0 0 5px var(--terminal-green);
}

/* --- MAIN HUB --- */
.main-hub {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.hub-background {
    position: absolute;
    top: 0; left: 0; right: 0; height: 200px;
    background: repeating-linear-gradient(0deg, #11082f, #11082f 2px, #070214 2px, #070214 4px);
    z-index: -1;
    opacity: 0.5;
    border-bottom: 2px solid var(--magenta);
}

.hub-header {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(0,0,0,0.8);
    padding: 15px;
    border: 2px solid var(--cyan);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

.pixel-avatar {
    font-size: 40px;
    border: 2px solid var(--magenta);
    padding: 5px;
    background: #000;
}

.user-stats { flex-grow: 1; font-size: 18px; }

.exp-bar-container {
    width: 100%;
    height: 10px;
    background: #000;
    border: 1px solid var(--terminal-green);
    margin: 5px 0;
}

.exp-bar {
    height: 100%;
    background: var(--terminal-green);
    width: 0%;
    transition: width 0.3s ease;
}

/* --- INVENTORY (3D Cards) --- */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.card {
    perspective: 1000px;
    width: 100%;
    aspect-ratio: 2.5 / 3.5;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: #111;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-shadow: inset 0 0 15px rgba(0,0,0,1);
}

.card-front {
    border: 2px solid var(--border-color);
    box-shadow: 0 0 10px var(--border-color);
}

.card-back {
    transform: rotateY(180deg);
    border: 2px dashed var(--magenta);
    justify-content: center;
    font-size: 14px;
}

.card-img-placeholder {
    flex-grow: 1;
    background: repeating-linear-gradient(45deg, #222, #222 5px, #111 5px, #111 10px);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
}

.card-stats {
    display: flex;
    justify-content: space-between;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
}

/* --- CRAFTING --- */
.craft-station {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.craft-slot {
    width: 80px;
    aspect-ratio: 2.5 / 3.5;
    border: 2px dashed var(--cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 14px;
    background: rgba(0, 255, 255, 0.1);
}

.craft-slot.filled {
    border-style: solid;
    background: rgba(0, 255, 255, 0.3);
}

.fodder-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    margin-bottom: 20px;
}

.fodder-mini {
    aspect-ratio: 1;
    border: 1px solid #555;
    background: #222;
}

.fodder-mini.filled { background: var(--cyan); }

.glitch-btn {
    width: 100%;
    padding: 15px;
    background: var(--magenta);
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    border: none;
    box-shadow: 4px 4px 0 var(--cyan);
    text-transform: uppercase;
    cursor: pointer;
}

.glitch-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--cyan);
    animation: glitch 0.2s linear infinite;
}

@keyframes glitch {
    0% { transform: translate(0) }
    20% { transform: translate(-2px, 1px) }
    40% { transform: translate(-1px, -2px) }
    60% { transform: translate(2px, 1px) }
    80% { transform: translate(1px, -1px) }
    100% { transform: translate(0) }
}

/* --- NAVIGATION --- */
.app-navigation {
    position: fixed;
    bottom: 0; left: 0; width: 100%;
    display: flex;
    justify-content: center;
    padding: 10px;
    background: linear-gradient(to top, rgba(0,0,0,1) 50%, rgba(0,0,0,0));
    z-index: 100;
}

.nav-radial-menu {
    display: flex; gap: 10px; background: rgba(20, 10, 35, 0.9);
    padding: 10px 20px; border-radius: 30px; border: 2px solid var(--magenta);
}
.nav-item {
    width: 45px; height: 45px; border-radius: 50%; background: #110524;
    border: 2px solid var(--cyan); color: #fff; cursor: pointer; font-size: 20px;
    display: flex; justify-content: center; align-items: center;
}
.nav-item.active { background: var(--magenta); box-shadow: 0 0 10px var(--magenta); }

/* --- MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(7, 2, 20, 0.9);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    width: 90%;
    max-width: 400px;
    height: 80%;
    background: #000;
    border: 2px solid var(--magenta);
    box-shadow: 0 0 20px var(--magenta);
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.modal-card-grid {
    flex-grow: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.modal-card {
    aspect-ratio: 2.5 / 3.5;
    border: 2px solid #555;
    background: #222;
    cursor: pointer;
    padding: 5px;
    display: flex;
    flex-direction: column;
}

.modal-card.selected {
    border-color: var(--cyan);
    box-shadow: 0 0 10px var(--cyan);
}

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

/* --- REPAIR OVERLAY --- */
.card-repair-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(45deg, rgba(0,0,0,0.95), rgba(0,0,0,0.95) 10px, rgba(255,68,68,0.2) 10px, rgba(255,68,68,0.2) 20px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 2px solid #ff4444;
}

.repair-text {
    color: #ff4444;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    margin-bottom: 15px;
    text-align: center;
    text-shadow: 0 0 5px #000, 0 0 10px #ff4444;
    line-height: 1.5;
}

.repair-btn {
    background: #000;
    border: 2px solid var(--terminal-green);
    color: var(--terminal-green);
    font-family: 'VT323', monospace;
    font-size: 14px;
    padding: 5px;
    cursor: pointer;
    box-shadow: 0 0 5px var(--terminal-green);
}

.repair-btn:active {
    background: var(--terminal-green);
    color: #000;
}

/* --- SHOP & PACK ANIMATIONS --- */
.shop-item {
    background: #111; border: 2px solid var(--cyan); padding: 20px;
    text-align: center; border-radius: 10px; margin-top: 20px;
}
.pack-sprite { font-size: 60px; margin-bottom: 10px; text-shadow: 0 0 20px var(--magenta); }

.pack-animation-container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; }
.pack-box { font-size: 120px; transition: transform 0.1s; text-shadow: 0 0 50px var(--cyan); }

.shake-anim { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both infinite; }
@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0) scale(1.1); }
  20%, 80% { transform: translate3d(4px, 0, 0) scale(1.1); }
  30%, 50%, 70% { transform: translate3d(-8px, 0, 0) scale(1.1); }
  40%, 60% { transform: translate3d(8px, 0, 0) scale(1.1); }
}

.flash-anim { animation: flash 1s ease-out forwards; }
@keyframes flash {
    0% { background-color: transparent; }
    50% { background-color: #fff; box-shadow: 0 0 100px 100px #fff; }
    100% { background-color: transparent; }
}

/* --- RAID UI --- */
.raid-container {
    background: rgba(0,0,0,0.8); border: 1px solid #333;
    padding: 15px; border-radius: 8px; margin-top: 20px;
}
.raid-log {
    height: 200px; overflow-y: auto; background: #000; border: 1px solid var(--terminal-green);
    padding: 10px; font-family: 'VT323', monospace; font-size: 14px; margin: 15px 0;
    display: flex; flex-direction: column; gap: 5px;
}
.raid-log p { margin: 0; color: #aaa; }
.raid-log p.hit { color: #ff4444; }
.raid-log p.win { color: var(--terminal-green); }
.raid-actions { display: flex; gap: 10px; }