/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
  --bg:           #080808;
  --surface:      #111;
  --border:       rgba(255, 255, 255, 0.07);
  --muted:        #555;
  --text:         #e8e8e8;
  --accent:       #00ff88;
  --gold:         #B6A39E;
  --blue:         #3b82f6;
  --tile-bg:      #141414;
  --tile-border:  #1e1e1e;
}


/* ============================================================
   RESET & BASE
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Syne', sans-serif;
  background: var(--bg);
  color: var(--text);
}


/* ============================================================
   TOPBAR
   ============================================================ */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  background: rgba(8, 8, 8, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

.topbar h1 {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
animation: titleFlicker 6s ease-in-out infinite alternate;
  background: linear-gradient(90deg, #00ff88, #3b82f6, #a855f7, #00ff88);
  background-size: 300% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar .subtitle {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: #eeeeee;
  letter-spacing: 0.04em;
  text-align: center;
}

@keyframes titleFlicker {
  0%   { background-position: 0% center; }
  100% { background-position: 100% center; }
}


/* ============================================================
   HUD PANELS
   ============================================================ */

.hud {
  position: fixed;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  padding: 8px 12px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  z-index: 30;
}

#stats {
  top: 68px;
  left: 16px;
  color: #aaa;
}

#badge {
  top: 68px;
  right: 16px;
  color: #aaa;
}

.top-link-hint {
  margin-top: 18px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: #cccccc;
  text-align: center;
  letter-spacing: 0.06em;
}


/* ============================================================
   TOP LINK BAR
   ============================================================ */

#topLink {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 14px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  z-index: 40;
  white-space: nowrap;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#topLink:hover {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(0, 255, 136, 0.25);
}

.top-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#topLink a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

#topLink a:hover { text-decoration: underline; }


/* ============================================================
   VIEWPORT & GRID
   ============================================================ */

.viewport {
  position: absolute;
  top: 56px; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  cursor: grab;
}

.viewport.dragging { cursor: grabbing; }

.grid {
  display: grid;
  grid-template-columns: repeat(50, 40px);
  grid-auto-rows: 40px;
  gap: 2px;
  transform-origin: 0 0;
  will-change: transform;
}


/* ============================================================
   TILES — BASE
   ============================================================ */

.tile {
  width: 40px;
  height: 40px;
  background: var(--tile-bg);
  border: 1px solid var(--tile-border);
  position: relative;
  overflow: hidden;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.tile img { width: 100%; height: auto; object-fit: cover; display: block; }

.tile a { position: absolute; inset: 0; z-index: 2; }

.tile.sold::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  pointer-events: none;
}


/* ============================================================
   TILES — HOVER
   ============================================================ */

.tile.unsold:hover {
  border-color: #444;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.tile.sold:hover {
  z-index: 5;
  transform: scale(1.08);
  border-color: #555;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}


/* ============================================================
   TILES — LABELS
   ============================================================ */

.tile-label {
  position: absolute;
  font-size: 8px;
  background: rgba(0, 0, 0, 0.65);
  padding: 1px 3px;
  color: rgba(255, 255, 255, 1);
  border-radius: 1px;
  pointer-events: none;
  z-index: 3;
  max-width: 75%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-label.owner  { bottom: 2px; left: 2px; }
.tile-label.price  { bottom: 2px; right: 2px; }


.tile-flag {
  position: absolute;
  bottom: 12px;
  left: 2px;
  width: 12px;
  height: 9px;
  z-index: 4;
  pointer-events: none;
}


/* ============================================================
   TILES — STATES
   ============================================================ */

/* Brief flash on new purchase */
.tile.flash { animation: flashTile 0.8s ease forwards; }

/* Premium centre tiles (unsold) */
.tile.tier-premium {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(255, 208, 0, 0.3);
}

/* High view-count glow */
.tile.hot {
  border-color: var(--accent);
  animation: hotPulse 1.2s ease infinite;
}

/* #1 by total clicks — green */
.tile.top-clicks {
  border-color: #00ff88;
  box-shadow: 0 0 14px rgba(0, 255, 136, 0.9);
  animation: pulseGlow 1.2s ease infinite;
}

/* #1 by unique visitors — purple */
.tile.top-unique {
  border-color: #a855f7;
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.9);
  animation: pulseGlow 1.2s ease infinite;
}

/* #1 in both — blue */
.tile.top-both {
  border-color: #3b82f6;
  box-shadow: 0 0 18px rgba(59, 130, 246, 0.9);
  animation: pulseGlow 1.2s ease infinite;
}


/* ============================================================
   HOVER PREVIEW CARD
   ============================================================ */

#preview {
  position: fixed;
  width: 220px;
  pointer-events: none;
  z-index: 100;
  display: none;
  background: #0c0c0c;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.preview-img {
  width: 100%;
  height: auto;
  object-fit: cover;
  background: #000;
  overflow: hidden;
}

.preview-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.preview-meta {
  padding: 10px;
  background: rgba(0, 0, 0, 0.85);
  border-top: 1px solid var(--border);
  font-family: 'Space Mono', monospace;
}

.preview-name {
  font-size: 12px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-link,
.preview-tagline,
.preview-stats {
  font-size: 10px;
  color: #777;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-stats { color: #999; margin-top: 6px; }


/* ============================================================
   ACTIVITY FEED
   ============================================================ */

#feed {
  position: fixed;
  bottom: 16px;
  left: 16px;
  width: 250px;
  z-index: 110;
}

.feed-item {
  margin-top: 6px;
  font-size: 11px;
  font-family: 'Space Mono', monospace;
  color: #ddd;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border);
  padding: 7px 10px;
  backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateY(8px);
  animation: fadeUp 0.3s forwards;
}


/* ============================================================
   LEADERBOARD
   ============================================================ */

#leaderboard {
  position: fixed;
  top: 68px;
  right: 16px;
  width: 420px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  padding: 10px 12px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  z-index: 30;
}

#leaderboard h4 {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

#leaderboardList {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.lb-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lb-col::before {
  content: attr(data-label);
  font-size: 11px;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.leaderboard-item {
  color: #ccc;
  cursor: pointer;
  transition: color 0.15s;
}

.leaderboard-item:hover { color: var(--accent); }

/* Top entry in each column glows with its category color */
.lb-col:first-child .leaderboard-item:first-child {
  color: #00ff88;
  text-shadow: 0 0 8px rgba(0, 255, 136, 0.7);
}

.lb-col:last-child .leaderboard-item:first-child {
  color: #a855f7;
  text-shadow: 0 0 8px rgba(168, 85, 247, 0.7);
}


/* ============================================================
   MODAL
   ============================================================ */

#modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  backdrop-filter: blur(4px);
}

#modal.open { display: flex; }

.modal-card {
  width: 100%;
  max-width: 400px;
  background: #0e0e0e;
  border: 1px solid #2a2a2a;
  padding: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.modal-card h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 4px;
}

.modal-price {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 16px;
}

.modal-card input {
  display: block;
  width: 100%;
  padding: 11px 12px;
  margin-top: 8px;
  background: #000;
  border: 1px solid #2a2a2a;
  color: var(--text);
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}

.modal-card input:focus        { border-color: #555; }
.modal-card input::placeholder { color: #3a3a3a; }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}


/* ============================================================
   CONFIRMATION POPUP
   ============================================================ */

#confirmOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  backdrop-filter: blur(4px);
}

.confirm-card {
  width: 100%;
  max-width: 380px;
  background: #0e0e0e;
  border: 1px solid #333;
  padding: 28px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}

.confirm-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.05em;
  margin-bottom: 20px;
  color: var(--text);
}

.confirm-list {
  list-style: none;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.confirm-list li {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: #aaa;
  padding-left: 16px;
  position: relative;
}

.confirm-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent);
}

.confirm-footer {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: #dddddd;
  margin-bottom: 24px;
  border-top: 1px solid #1e1e1e;
  padding-top: 16px;
}

.confirm-actions {
  display: flex;
  gap: 8px;
}


.confirm-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 48px 28px;
}

.confirm-spinner {
  width: 36px;
  height: 36px;
  border: 2px solid #222;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.confirm-loading-text {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: #555;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  flex: 1;
  padding: 12px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.05em;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}

.btn:hover       { opacity: 0.85; }
.btn-primary     { background: var(--text); color: #000; }
.btn-secondary   { background: #1e1e1e; color: var(--text); border: 1px solid #333; }


/* ============================================================
   MICRO-ANIMATIONS
   ============================================================ */

.view-float {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--accent);
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  pointer-events: none;
  animation: floatUp 0.8s ease forwards;
  z-index: 10;
}


.tile-label.num { top: 2px; left: 2px; color: #ffffff; }


/* ============================================================
   SHARE OVERLAY
   ============================================================ */

#shareOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  backdrop-filter: blur(4px);
}

.share-card {
  width: 100%;
  max-width: 380px;
  background: #0e0e0e;
  border: 1px solid #333;
  padding: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  margin: 16px;
}

.share-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--text);
}

.share-url {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  background: #000;
  border: 1px solid #2a2a2a;
  padding: 10px 12px;
  margin-bottom: 16px;
  word-break: break-all;
}

.share-actions {
  display: flex;
  gap: 8px;
}

.preview-share-btn {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  background: transparent;
  border: 1px solid #333;
  color: #aaa;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.preview-share-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
/* ============================================================
   KEYFRAMES
   ============================================================ */

@keyframes hotPulse {
  0%, 100% { box-shadow: 0 0 0    rgba(0, 255, 136, 0.3); }
  50%       { box-shadow: 0 0 14px rgba(0, 255, 136, 0.9); }
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1);    }
  50%       { transform: scale(1.05); }
}

@keyframes flashTile {
  0%   { box-shadow: none; transform: scale(1);    }
  30%  { box-shadow: 0 0 18px rgba(255, 255, 255, 0.7); transform: scale(1.15); }
  100% { box-shadow: none; transform: scale(1);    }
}

@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes floatUp {
  0%   { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -80%); }
}







/* ============================================================
   MOBILE PREVIEW & RESPONSIVE
   ============================================================ */

#preview.mobile-pinned {
  pointer-events: all;
  cursor: pointer;
  transform: translate(-50%, -50%);
  width: 280px;
}

.preview-tap-hint {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--accent);
  margin-top: 8px;
  text-align: right;
}

@media (max-width: 768px) {
  .topbar h1 { font-size: 16px; }
  .topbar .subtitle { display: none; }

  #badge { display: none; }

  #topLink {
  top: 84px;
}

#stats {
  position: fixed;
  top: 0;
  bottom: auto;
  left: 0;
  right: 0;
  width: 100%;
  border-left: none;
  border-right: none;
  border-top: none;
  border-radius: 0;
  font-size: 10px;
  padding: 4px 0;
  color: #aaa;
  overflow: hidden;
  z-index: 60;
}

.marquee-track {
  display: flex;
  white-space: nowrap;
  width: max-content;
  animation: marquee 18s linear infinite;
}

.marquee-track > * {
  flex-shrink: 0;
}
@keyframes marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.topbar {
  top: 28px;
}

.viewport {
  top: 84px;
}

  #stats::-webkit-scrollbar { display: none; }

#leaderboard {
  top: auto;
  bottom: 0;
  right: 0;
  left: 0;
  width: 100%;
  border-left: none;
  border-right: none;
  border-bottom: none;
  padding: 6px 12px 8px;
  overflow: hidden;
}
  #leaderboardList {
    grid-template-columns: 1fr 1fr;
  }

  #leaderboard h4 { margin-bottom: 4px; }

  .leaderboard-item { font-size: 10px; }

  #feed { display: none; }

  #selectionInfo { display: none; }

  #preview {
    pointer-events: all;
    width: 280px;
  }

  .modal-card { padding: 16px; }
  .modal-card h3 { font-size: 15px; }
  .confirm-card { padding: 20px; margin: 16px; }
}