/* --- RESET & VARS --- */
:root {
    --bg-dark: #050505;
    --gold: #f0c420; /* Brighter Gold */
    --gold-dim: #6e5a12;
    --red: #ff2a2a; /* Brighter Red */
    --red-glow: rgba(255, 42, 42, 0.6);
    --green: #00ffaa; /* Brighter Green */
    --green-glow: rgba(0, 255, 170, 0.6);
    --border: rgba(255, 255, 255, 0.15);
    
    --font-head: 'Cinzel', serif;
    --font-tech: 'Rajdhani', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

body {
    background-color: var(--bg-dark);
    color: #fff;
    font-family: var(--font-tech);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- LAYER ORDER FIX --- */

/* 1. Background Layer (Behind Everything) */
.fx-layer {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
}

/* 2. UI Layer (On Top - Crisp) */
.ui-wrapper {
    position: relative; z-index: 10;
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    padding: 20px;
    background: radial-gradient(circle at 50% 10%, #1a1a1e 0%, #000 80%);
}

/* --- ATMOSPHERE --- */
.scanlines {
    position: absolute; inset: 0; opacity: 0.15; /* Reduced opacity */
    background: linear-gradient(rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.5) 50%);
    background-size: 100% 4px;
}
.noise {
    position: absolute; inset: 0; opacity: 0.03; /* Very faint noise */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}
.vignette {
    position: absolute; inset: 0;
    background: radial-gradient(circle, transparent 50%, #000 130%);
}

/* --- HEADER --- */
.hud-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.logo-text { font-family: var(--font-head); font-size: 2rem; letter-spacing: 2px; color: #fff; }
.logo-sub { font-size: 0.8rem; letter-spacing: 6px; color: var(--gold); text-transform: uppercase; }

.status-badge {
    font-size: 0.7rem; color: var(--red); 
    border: 1px solid var(--red); padding: 2px 8px; margin-top: 5px; 
    display: inline-block; font-weight: 700;
    box-shadow: 0 0 10px var(--red-glow);
}
.blink { animation: blinker 1s linear infinite; }
@keyframes blinker { 50% { opacity: 0; } }

/* COUNTER */
.hud-center { text-align: center; }
.counter-box { display: flex; align-items: baseline; justify-content: center; gap: 5px; }
.counter-display {
    font-size: 3rem; font-weight: 700; color: var(--gold);
    text-shadow: 0 0 15px var(--gold-dim);
}
.counter-total { font-size: 1.5rem; color: #666; font-weight: 500; }
.label-tiny { font-size: 0.7rem; letter-spacing: 3px; color: #888; margin-top: 2px; }

/* BUTTONS */
.hud-group.right { display: flex; align-items: center; gap: 15px; }

.btn-icon {
    width: 44px; height: 44px; border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.05); transition: 0.2s;
}
.btn-icon:hover { border-color: #fff; background: rgba(255,255,255,0.15); }
.btn-icon svg { width: 22px; fill: #ddd; }

.cyber-button {
    background: transparent; border: 1px solid var(--gold);
    color: var(--gold); padding: 0 25px; height: 44px;
    font-family: var(--font-tech); font-weight: 700; font-size: 1rem;
    letter-spacing: 1px; cursor: pointer; 
    transition: all 0.2s ease;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.cyber-button:hover { 
    background: var(--gold); color: #000; 
    box-shadow: 0 0 20px var(--gold-dim);
}

/* --- STAGE LAYOUT --- */
.stage {
    flex: 1; display: flex; gap: 30px; position: relative;
    perspective: 1000px;
}

/* LEFT PANEL */
.data-panel {
    width: 280px;
    background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
    border-top: 2px solid var(--border);
    padding: 20px;
    display: flex; flex-direction: column; gap: 20px;
}

.panel-header { display: flex; flex-direction: column; gap: 5px; }
.panel-header h3 { color: #888; letter-spacing: 2px; font-weight: 600; font-size: 1rem; }
.dec-line { width: 40px; height: 3px; background: var(--red); }

.rule-block { display: flex; gap: 12px; font-size: 0.95rem; line-height: 1.3; color: #ccc; }
.idx { color: var(--gold); font-weight: 800; font-family: var(--font-head); font-size: 1.1rem; }
.highlight { color: #fff; font-weight: 700; border-bottom: 1px solid #555; }
.danger { color: var(--red); font-weight: 700; text-shadow: 0 0 8px var(--red-glow); }

.terminal-log {
    margin-top: auto; font-family: 'Courier New', monospace; font-size: 0.75rem; color: var(--green);
    height: 120px; overflow: hidden;
    border-top: 1px solid #333; padding-top: 10px;
    display: flex; flex-direction: column; justify-content: flex-end;
}
.log-entry { margin-bottom: 4px; opacity: 0.8; }
.system { color: #555; }

/* --- 3D ARENA --- */
.arena-viewport {
    flex: 1; display: flex; justify-content: center; align-items: center; position: relative;
}

.grid-frame {
    /* Subtle tilt for game board feel */
    transform: rotateX(30deg);
    transform-style: preserve-3d;
    background: rgba(0,0,0,0.4);
    padding: 15px;
    border: 1px solid #333;
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
    border-radius: 4px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(10, 50px);
    grid-template-rows: repeat(10, 50px);
    gap: 6px;
}

/* SEATS */
.seat {
    background: rgba(255,255,255,0.02);
    border: 1px solid #222;
    border-radius: 2px;
    position: relative;
    transition: all 0.2s ease-out;
    display: flex; justify-content: center; align-items: center;
    font-size: 0.55rem; color: transparent;
    cursor: default;
}

/* OCCUPIED (Enemy) */
.seat.occupied {
    background: rgba(60, 10, 10, 1);
    border: 1px solid var(--red);
    box-shadow: 0 0 15px var(--red-glow);
    z-index: 2;
    transform: scale(1.05) translateZ(5px);
    color: #fff; font-weight: bold;
    text-shadow: 0 0 2px #000;
}

/* OCCUPIED (User) */
.seat.user-owned {
    background: rgba(0, 60, 30, 1) !important;
    border-color: var(--green) !important;
    box-shadow: 0 0 25px var(--green-glow) !important;
    transform: scale(1.15) translateZ(10px) !important;
    color: #fff !important;
    z-index: 5;
}

/* Floor Reflection */
.floor-glow {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotateX(60deg);
    width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.03) 0%, transparent 60%);
    pointer-events: none;
    z-index: -1;
}

/* --- MODAL --- */
.cyber-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 200;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: 0.3s;
}
.cyber-modal.active { opacity: 1; pointer-events: all; }

.modal-box {
    border: 1px solid var(--red); padding: 3rem 4rem; text-align: center;
    background: #050000;
    box-shadow: 0 0 60px rgba(255, 0, 0, 0.2);
    position: relative;
    min-width: 400px;
}

/* Brackets for Modal */
.modal-box::before {
    content: ''; position: absolute; top: -1px; left: -1px; width: 20px; height: 20px;
    border-top: 3px solid var(--red); border-left: 3px solid var(--red);
}
.modal-box::after {
    content: ''; position: absolute; bottom: -1px; right: -1px; width: 20px; height: 20px;
    border-bottom: 3px solid var(--red); border-right: 3px solid var(--red);
}

.glitch-text {
    font-family: var(--font-head); font-size: 3.5rem; color: var(--red);
    text-shadow: 0 0 10px var(--red-glow); margin-bottom: 10px;
}
.modal-line { width: 100%; height: 1px; background: #333; margin: 20px 0; }
.sub { color: var(--gold); letter-spacing: 3px; font-size: 0.9rem; }

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
    .ui-wrapper { overflow-y: scroll; display: block; height: auto; padding: 10px; }
    .hud-header { flex-wrap: wrap; gap: 15px; justify-content: center; text-align: center; }
    .stage { flex-direction: column-reverse; margin-top: 20px; padding-bottom: 50px; }
    .data-panel { width: 100%; border-top: 1px solid #333; }
    .grid { grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr); gap: 3px; }
    .grid-frame { transform: none; width: 100%; aspect-ratio: 1; padding: 5px; }
    .seat { font-size: 0.35rem; }
    .seat.occupied { transform: none; }
}