@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Inter:wght@400;600;700;900&display=swap');

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

:root {
  --red: #ff3c3c;
  --red-dim: #aa1111;
  --red-glow: rgba(255, 60, 60, 0.4);
  --bg: #110808;
  --surface: rgba(255, 60, 60, 0.06);
  --border: rgba(255, 60, 60, 0.15);
  --text: #fff;
  --text-dim: #999;
  --text-muted: #553333;
  --pixel: #Press Start 2P, monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* === GRID PAGE === */

.grid-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: rgba(0,0,0,0.6);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  flex-shrink: 0;
}

.topbar-brand {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  color: var(--red);
  text-decoration: none;
  letter-spacing: 0.05em;
}

.topbar-stats {
  display: flex;
  gap: 1.5rem;
  font-size: 0.8rem;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat-value {
  font-weight: 700;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
}

.stat-value .highlight { color: var(--red); }

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--red);
  color: white;
  box-shadow: 0 2px 12px var(--red-glow);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px var(--red-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--border);
}

/* Grid canvas area */
.grid-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
}

.grid-area.selecting { cursor: crosshair; }
.grid-area.dragging { cursor: grabbing; }

#gridCanvas {
  position: absolute;
  top: 0;
  left: 0;
  image-rendering: pixelated;
}

/* Selection overlay info */
.selection-info {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.5rem;
  display: none;
  align-items: center;
  gap: 1.5rem;
  z-index: 20;
  font-size: 0.85rem;
}

.selection-info.active { display: flex; }

.selection-detail {
  text-align: center;
}

.selection-detail .label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.2rem;
}

.selection-detail .value {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  font-weight: 700;
}

.selection-detail .value.price { color: var(--red); }

/* Tooltip */
.grid-tooltip {
  position: fixed;
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  pointer-events: none;
  z-index: 30;
  display: none;
  max-width: 200px;
}

.grid-tooltip .tt-name { font-weight: 700; margin-bottom: 0.15rem; }
.grid-tooltip .tt-link { color: var(--text-muted); font-size: 0.65rem; }

/* Purchase modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: #1a0a0a;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  max-width: 420px;
  width: 90%;
}

.modal h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.8rem;
  color: var(--red);
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.form-group input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: white;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  outline: none;
}

.form-group input:focus {
  border-color: var(--red);
}

.modal-summary {
  background: var(--surface);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.8rem;
  line-height: 1.8;
}

.modal-summary strong { color: var(--red); }

.modal-actions {
  display: flex;
  gap: 0.75rem;
}

.modal-actions .btn { flex: 1; padding: 0.75rem; }

/* Zoom controls */
.zoom-controls {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 20;
}

.zoom-btn {
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-btn:hover { border-color: var(--red); }

/* Responsive */
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: 0.5rem; }
  .topbar-stats { gap: 0.75rem; }
  .selection-info { flex-wrap: wrap; justify-content: center; }
}
