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

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

body {
    font-family: 'Share Tech Mono', monospace;
    background: #0a0a0a;
    color: #00ff41;
    overflow-x: hidden;
    height: 100vh;
}

/* CRT Screen Effect */
.crt-screen {
    position: relative;
    width: 100%;
    height: 100vh;
    background: #000;
    overflow: hidden;
}

.crt-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.15),
            rgba(0, 0, 0, 0.15) 1px,
            transparent 1px,
            transparent 2px
        );
    pointer-events: none;
    z-index: 1000;
    animation: scanline 8s linear infinite;
}

.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        transparent 50%,
        rgba(0, 255, 65, 0.03) 50%
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 999;
}

@keyframes scanline {
    0% { transform: translateY(0); }
    100% { transform: translateY(10px); }
}

/* Game Container */
.game-container {
    position: relative;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

/* Header */
.game-header {
    text-align: center;
    margin-bottom: 20px;
    border: 2px solid #00ff41;
    padding: 15px;
    background: rgba(0, 255, 65, 0.05);
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
}

.title {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5em;
    font-weight: 900;
    color: #00ff41;
    text-shadow: 
        0 0 10px #00ff41,
        0 0 20px #00ff41,
        0 0 30px #00ff41;
    letter-spacing: 5px;
    margin-bottom: 15px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.status-bar {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stat-label {
    font-size: 0.9em;
    color: #00ff88;
    letter-spacing: 2px;
}

.stat-bar {
    width: 150px;
    height: 20px;
    border: 2px solid #00ff41;
    background: rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px currentColor;
}

.stat-fill.health {
    background: #ff0040;
    color: #ff0040;
}

.stat-fill.energy {
    background: #00aaff;
    color: #00aaff;
}

.stat-value {
    font-size: 1.2em;
    font-weight: bold;
    color: #00ff41;
}

/* Narrative Panel - TV Display */
.narrative-panel {
    margin-bottom: 20px;
    position: relative;
    padding: 20px;
    background: #1a1a1a;
    border-radius: 15px;
    box-shadow: 
        0 0 0 8px #2a2a2a,
        0 0 0 12px #1a1a1a,
        0 0 0 16px #0a0a0a,
        inset 0 0 30px rgba(0, 0, 0, 0.8),
        0 10px 40px rgba(0, 0, 0, 0.5);
    min-height: 280px;
    max-height: 320px;
    overflow: hidden;
}

.narrative-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.5) 100%),
        repeating-linear-gradient(
            0deg,
            rgba(0, 255, 65, 0.04) 0px,
            transparent 1px,
            transparent 2px
        );
    pointer-events: none;
    z-index: 2;
    border-radius: 15px;
    box-shadow: inset 0 0 60px rgba(0, 255, 136, 0.1);
}

.narrative-panel::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 30px;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.6) 0%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 3;
    border-radius: 15px 15px 0 0;
}

.narrative-text {
    color: #00ff88;
    line-height: 1.9;
    font-size: 1.05em;
    position: relative;
    z-index: 1;
    padding: 15px 20px;
    height: 100%;
    overflow-y: auto;
    scroll-behavior: smooth;
    text-shadow: 
        0 0 5px rgba(0, 255, 136, 0.6),
        0 0 10px rgba(0, 255, 136, 0.4),
        0 0 15px rgba(0, 255, 136, 0.2);
    font-weight: 300;
    letter-spacing: 0.5px;
}

.narrative-text::-webkit-scrollbar {
    width: 8px;
}

.narrative-text::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.narrative-text::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 65, 0.3);
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 65, 0.5);
}

.narrative-text::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 65, 0.5);
}

.narrative-text p {
    margin-bottom: 12px;
    padding-right: 10px;
    animation: fadeInScroll 0.8s ease-in;
    opacity: 0.95;
}

.narrative-text p:last-child {
    margin-bottom: 0;
}

@keyframes fadeInScroll {
    from { 
        opacity: 0;
        transform: translateY(10px);
    }
    to { 
        opacity: 0.95;
        transform: translateY(0);
    }
}

/* Opponent Area */
.opponent-area {
    border: 2px solid #ff0040;
    padding: 15px;
    margin-bottom: 20px;
    background: rgba(255, 0, 64, 0.05);
    box-shadow: 0 0 15px rgba(255, 0, 64, 0.3);
}

.opponent-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.opponent-info h2 {
    font-family: 'Orbitron', sans-serif;
    color: #ff0040;
    text-shadow: 0 0 10px #ff0040;
    font-size: 1.5em;
}

.opponent-stats {
    display: flex;
    gap: 20px;
    color: #ff0040;
    font-weight: bold;
}

.opponent-cards {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 80px;
}

/* Play Area */
.play-area {
    flex: 1;
    border: 2px solid #00aaff;
    padding: 15px;
    margin-bottom: 20px;
    background: rgba(0, 170, 255, 0.05);
    min-height: 180px;
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.3);
    position: relative;
}

.play-area::before {
    content: 'BATTLEFIELD';
    position: absolute;
    top: 5px;
    left: 15px;
    font-size: 0.7em;
    color: #00aaff;
    opacity: 0.5;
    letter-spacing: 2px;
    font-family: 'Orbitron', sans-serif;
}

.battlefield {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    perspective: 900px;
    margin-bottom: 20px;
}

.card-stack {
    width: 150px;
    max-width: 150px;
    border: 2px solid #00aaff;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 6px;
    padding: 10px;
    color: #00aaff;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
}

.stack-fan {
    position: relative;
    height: 70px;
    margin-bottom: 8px;
    border-radius: 6px;
    overflow: visible;
}

.fan-card {
    position: absolute;
    top: 0;
    right: 0; /* stack edge on the right */
    width: 48px;
    height: 70px;
    background: linear-gradient(135deg, rgba(0,0,0,0.95) 0%, rgba(20,20,20,0.95) 100%);
    border: 2px solid #00aaff;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.6);
    transform: translateX(0);
    transition: transform 200ms ease, box-shadow 200ms ease;
    will-change: transform;
    z-index: var(--z, 1);
}

.fan-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(0,255,170,0.06), transparent 60%);
    pointer-events: none;
}

.card-stack:hover .fan-card,
.card-stack.open .fan-card {
    transform: translateX(calc(-1 * var(--i) * 16px)); /* expand left on hover */
    box-shadow: 0 4px 12px rgba(0,170,255,0.5);
}

.fan-label {
    position: absolute;
    right: 0;
    bottom: -18px;
    font-size: 0.75em;
    color: #00ff88;
}

.stack-summary {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
}

.stack-name {
    font-weight: bold;
    font-size: 0.9em;
    text-shadow: 0 0 8px currentColor;
}

.stack-count {
    font-size: 0.85em;
    color: #00ff88;
}

.stack-stats {
    display: flex;
    gap: 10px;
    font-weight: bold;
    font-size: 0.85em;
}

.stack-popover {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    max-height: 240px;
    overflow: auto;
    background: #0a0a0a;
    border: 2px solid #00aaff;
    box-shadow: 0 0 20px rgba(0, 170, 255, 0.5);
    border-radius: 6px;
    padding: 10px;
    z-index: 3000;
}

.card-stack:hover .stack-popover,
.card-stack.open .stack-popover {
    display: block;
}

.stack-item {
    display: flex;
    justify-content: space-between;
    padding: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85em;
}

.stack-item:last-child {
    border-bottom: none;
}

.traps-area {
    border-top: 2px dashed #ffaa00;
    padding-top: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.traps-area::before {
    content: 'TRAPS';
    font-size: 0.7em;
    color: #ffaa00;
    opacity: 0.5;
    letter-spacing: 2px;
    font-family: 'Orbitron', sans-serif;
    margin-right: 10px;
}

.card-back {
    width: 100%;
    height: 100%;
    background: #000;
    border: 2px solid #ffaa00;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    color: #ffaa00;
}

.card-back::before {
    content: '?';
}

/* Hand Area */
.hand-area {
    margin-bottom: 20px;
    position: relative;
    z-index: 1001;
}

.hand-label {
    color: #00ff41;
    font-size: 1.1em;
    margin-bottom: 15px;
    text-align: center;
    letter-spacing: 3px;
    text-shadow: 0 0 10px rgba(0, 255, 65, 0.5);
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
}

.hand {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    min-height: 180px;
    perspective: 900px;
}

/* Cards */
.card {
    width: 10vw;
    height: 14vw;
    max-width: 150px;
    max-height: 210px;
    border: 2px solid;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95) 0%, rgba(20, 20, 20, 0.95) 100%);
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
    z-index: 1001;
    border-radius: 4px;
    transform-style: preserve-3d;
}

.card:hover {
    transform: rotateX(6deg) rotateY(-6deg) translateY(-10px) scale(1.05);
    box-shadow: 0 8px 20px currentColor;
    z-index: 1002;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(0,255,65,0.06), transparent 60%),
                repeating-linear-gradient(90deg, rgba(0,255,65,0.05) 0, rgba(0,255,65,0.05) 1px, transparent 1px, transparent 3px);
    transform: translateZ(18px);
    mix-blend-mode: screen;
}

.card.playable {
    border-color: #00ff41;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.5);
    animation: glow 1.5s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 255, 65, 0.6), 0 4px 12px rgba(0, 0, 0, 0.7); }
    50% { box-shadow: 0 0 30px rgba(0, 255, 65, 0.9), 0 6px 18px rgba(0, 0, 0, 0.8); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.card.enemy {
    border-color: #ff0040;
    color: #ff0040;
}

.card-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    font-size: 0.95em;
    text-align: center;
    margin-bottom: 8px;
    text-transform: uppercase;
    text-shadow: 0 0 8px currentColor;
    letter-spacing: 1px;
}

.card-cost {
    position: absolute;
    top: 8px;
    right: 8px;
    background: currentColor;
    color: #000;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.95em;
    box-shadow: 0 0 10px currentColor, inset 0 2px 4px rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(0, 0, 0, 0.3);
}

.card-description {
    font-size: 0.8em;
    flex: 1;
    display: flex;
    align-items: center;
    text-align: center;
    line-height: 1.4;
    padding: 5px 0;
    opacity: 0.9;
    color: #aaffcc;
}

.card-stats {
    display: flex;
    justify-content: space-around;
    font-size: 0.9em;
    font-weight: bold;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-shadow: 0 0 5px currentColor;
}

.card-modules {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.module {
    font-size: 0.7em;
    text-align: center;
    color: #ffaa00;
}

.card.equipment {
    border-color: #00aaff;
    color: #00aaff;
}

.card.action {
    border-color: #ffaa00;
    color: #ffaa00;
}

.card.raider {
    border-color: #ff6600;
    color: #ff6600;
}


.card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(100%);
}

/* Drag-and-drop states */
.card.dragging {
    opacity: 0.8;
    transform: scale(0.98) rotateX(2deg);
}

.battlefield.drop-ready {
    box-shadow: 0 0 25px rgba(0, 170, 255, 0.5) inset, 0 0 25px rgba(0, 170, 255, 0.3);
    transition: box-shadow 0.2s ease;
}

/* Floating damage/heal text */
.float-text {
    position: absolute;
    transform: translate(-50%, 0);
    pointer-events: none;
    font-weight: bold;
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 8px currentColor, 0 0 16px rgba(0, 0, 0, 0.7);
    z-index: 50;
    animation: floatUp 1s ease-out forwards;
}

.float-text.damage {
    color: #ff0040;
}

.float-text.heal {
    color: #00ff41;
}

.float-text.energy {
    color: #00aaff;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -35px) scale(1.1);
    }
}

/* Inspect panel */
.inspect-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    display: none;
    pointer-events: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.inspect-backdrop.open {
    display: flex;
    pointer-events: auto;
}

.inspect-panel {
    background: #0a0a0a;
    border: 2px solid #00ff41;
    box-shadow: 0 0 30px rgba(0, 255, 65, 0.4), inset 0 0 30px rgba(0, 255, 65, 0.1);
    padding: 20px;
    width: 420px;
    max-width: 90vw;
    border-radius: 10px;
    position: relative;
    color: #00ff88;
}

.inspect-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: transparent;
    border: 2px solid #00ff41;
    color: #00ff41;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
}

.inspect-content h3 {
    font-family: 'Orbitron', sans-serif;
    color: #00ff41;
    margin-bottom: 8px;
}

.inspect-content .meta {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    color: #00ff88;
}

.inspect-content .desc {
    color: #aaffcc;
    line-height: 1.6;
}

.crafting-recipes {
    margin-top: 10px;
}

.crafting-recipe {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #00ff41;
}

.crafting-recipe.craftable {
    border-color: #00ff41;
}

.crafting-requirements {
    display: flex;
    gap: 10px;
}

.perks-list {
    margin-top: 10px;
}

.perk {
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #ccc;
}

.perk.unlocked {
    border-color: #00ff41;
}

.perk-name {
    font-weight: bold;
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 30px;
    border: 2px solid;
    background: rgba(0, 0, 0, 0.7);
    color: inherit;
    font-family: 'Orbitron', sans-serif;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn-primary {
    border-color: #00ff41;
    color: #00ff41;
}

.btn-primary:hover {
    background: rgba(0, 255, 65, 0.1);
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.5);
    transform: scale(1.05);
}

.btn-secondary {
    border-color: #00aaff;
    color: #00aaff;
}

.btn-secondary:hover {
    background: rgba(0, 170, 255, 0.1);
    box-shadow: 0 0 20px rgba(0, 170, 255, 0.5);
    transform: scale(1.05);
}

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

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.5);
}

::-webkit-scrollbar-thumb {
    background: #00ff41;
    border: 1px solid #000;
}

::-webkit-scrollbar-thumb:hover {
    background: #00ff88;
}

/* Responsive */
@media (max-width: 768px) {
    .title {
        font-size: 1.8em;
    }
    
    .card {
        width: 120px;
        height: 170px;
    }
    
    .hand {
        gap: 10px;
    }
}
