:root {
  --bg-primary: #090d16;
  --bg-card: rgba(18, 26, 43, 0.75);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(10, 15, 26, 0.8);
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
}

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

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.12) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  backdrop-filter: blur(16px);
  padding: 16px 24px;
  border-radius: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}

.brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Cards & Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  flex: 1;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  backdrop-filter: blur(16px);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Buttons */
button, a.btn-link {
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:hover:not(:disabled) {
  background: linear-gradient(135deg, #047857, #059669);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--bg-card-border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

/* Inputs */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

input {
  font-family: inherit;
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  border-radius: 10px;
  color: var(--text-main);
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Badges & Status */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--bg-card-border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
  box-shadow: 0 0 8px var(--accent-red);
}

.status-badge.connected .status-dot {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.status-badge.connecting .status-dot {
  background: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
  animation: pulse 1s infinite;
}

.admin-badge {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

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

/* Progress Stats */
.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--bg-card-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-cyan);
}

.progress-bar-bg {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
  transition: width 0.4s ease;
}

/* Grid Visualizer */
.grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.grid-canvas-container {
  background: rgba(10, 15, 26, 0.9);
  border: 1px solid var(--bg-card-border);
  border-radius: 12px;
  padding: 14px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.blocks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.block-tile {
  aspect-ratio: 1;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.block-tile:hover {
  transform: scale(1.1);
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border-color: #fff;
}

.block-tile.claimed {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.block-tile.selected {
  outline: 2px solid var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
}

.grid-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-box {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-box.free {
  background: rgba(16, 185, 129, 0.4);
  border: 1px solid #10b981;
}

.legend-box.claimed {
  background: rgba(239, 68, 68, 0.4);
  border: 1px solid #ef4444;
}

/* Admin Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.admin-table th, .admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

/* Console Log */
.log-container {
  background: #050811;
  border: 1px solid var(--bg-card-border);
  border-radius: 12px;
  height: 240px;
  overflow-y: auto;
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-line {
  display: flex;
  gap: 10px;
  line-height: 1.4;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  padding-bottom: 4px;
}

.log-time {
  color: var(--text-dim);
  flex-shrink: 0;
}

.log-tag {
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  flex-shrink: 0;
}

.log-tag.out { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.log-tag.in { background: rgba(16, 185, 129, 0.2); color: #86efac; }
.log-tag.err { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.log-tag.info { background: rgba(139, 92, 246, 0.2); color: #d8b4fe; }
.log-tag.admin { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }

.log-content {
  color: var(--text-main);
  word-break: break-all;
  flex: 1;
}

.log-dur {
  color: var(--accent-amber);
  font-size: 11px;
  flex-shrink: 0;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Science-fiction Tab Buttons */
.tab-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(18, 26, 43, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 10px 20px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
  background: rgba(18, 26, 43, 0.8);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  border: none;
  color: #fff;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.2);
}

/* Subterranean Vault Radar Styles */
.vault-badge {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  border: 1px solid #fff;
  box-sizing: border-box;
}

.vault-badge.standard {
  width: 7px;
  height: 7px;
  background-color: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
  left: 3px;
  top: 3px;
}

.vault-badge.echo {
  width: 7px;
  height: 7px;
  background-color: var(--accent-amber);
  box-shadow: 0 0 6px var(--accent-amber);
  right: 3px;
  top: 3px;
}

.vault-badge.star {
  width: 8px;
  height: 8px;
  background-color: var(--accent-purple);
  box-shadow: 0 0 8px var(--accent-purple);
  right: 3px;
  bottom: 3px;
  animation: radar-pulse 1.2s infinite ease-in-out;
}

/* Breathing Neon shadows for cells containing high-stakes vaults */
.glow-pulse-cyan {
  box-shadow: inset 0 0 8px rgba(6, 182, 212, 0.6);
  border-color: rgba(6, 182, 212, 0.8) !important;
}

.glow-pulse-amber {
  box-shadow: inset 0 0 8px rgba(245, 158, 11, 0.6);
  border-color: rgba(245, 158, 11, 0.8) !important;
  animation: cell-glow-amber 1.8s infinite ease-in-out;
}

.glow-pulse-purple {
  box-shadow: inset 0 0 10px rgba(139, 92, 246, 0.8);
  border-color: rgba(139, 92, 246, 1.0) !important;
  animation: cell-glow-purple 1.5s infinite ease-in-out;
}

@keyframes radar-pulse {
  0%, 100% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
}

@keyframes cell-glow-amber {
  0%, 100% { box-shadow: inset 0 0 4px rgba(245, 158, 11, 0.4); }
  50% { box-shadow: inset 0 0 12px rgba(245, 158, 11, 0.8), 0 0 8px rgba(245, 158, 11, 0.3); }
}

@keyframes cell-glow-purple {
  0%, 100% { box-shadow: inset 0 0 4px rgba(139, 92, 246, 0.4); }
  50% { box-shadow: inset 0 0 14px rgba(139, 92, 246, 0.9), 0 0 10px rgba(139, 92, 246, 0.4); }
}
