/* ── base ──────────────────────────────────────────────────────────────────── */
:root {
  --bg:           #030808;
  --bg2:          #050d0d;
  --border:       #0a2a2a;
  --accent:       #00ffcc;
  --text:         #8aa0a0;
  --text-dim:     #4a6060;
  --text-dimmer:  #2a4040;
  --text-bright:  #fff;
  --red:          #ff4444;
  --max-w:        1140px;
}

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

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  line-height: 1.5;
}

/* ── header ────────────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
}

.brand {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-bright);
  letter-spacing: .05em;
}

.brand-accent { color: var(--accent); }

.header-meta {
  font-size: .75rem;
  color: var(--text-dim);
}

/* ── intro ─────────────────────────────────────────────────────────────────── */
#intro {
  max-width: var(--max-w);
  margin: 32px auto 0;
  padding: 0 20px;
  display: flex;
  gap: 10px;
  flex-direction: column;
}

#intro p {
  font-size: .8rem;
  color: var(--text-dim);
  max-width: 640px;
  line-height: 1.7;
}

.intro-dim { color: var(--text-dimmer) !important; font-size: .72rem !important; }

/* ── grid ──────────────────────────────────────────────────────────────────── */
main {
  max-width: var(--max-w);
  margin: 28px auto 60px;
  padding: 0 20px;
  overflow-x: auto;
}

#wall-grid {
  display: grid;
  grid-template-columns: repeat(20, 52px);
  grid-template-rows: repeat(20, 52px);
  gap: 3px;
  width: fit-content;
}

/* ── tile ──────────────────────────────────────────────────────────────────── */
.tile {
  width: 52px;
  height: 52px;
  background: var(--bg2);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: border-color .15s, background .15s;
  overflow: hidden;
}

.tile:hover {
  border-color: var(--accent);
  z-index: 2;
}

.tile.empty:hover { background: #051212; }

.tile.owned { border-color: var(--accent); }
.tile.owned::after {
  content: '';
  position: absolute;
  bottom: 3px; right: 3px;
  width: 4px; height: 4px;
  background: var(--accent);
  border-radius: 50%;
}

/* type dot */
.tile-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tile[data-type="js"]      .tile-dot { background: #00ff44; }
.tile[data-type="text"]    .tile-dot { background: #8888ff; }
.tile[data-type="photo"]   .tile-dot { background: #ff8800; }
.tile[data-type="drawing"] .tile-dot { background: var(--accent); }

.tile-sign {
  font-size: 7px;
  color: var(--text-dimmer);
  text-align: center;
  max-width: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: .02em;
}

.tile.empty .tile-sign {
  font-size: 14px;
  color: var(--text-dimmer);
  font-weight: 300;
}

/* ── modal ─────────────────────────────────────────────────────────────────── */
#modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
#modal.hidden { display: none; }

#modal-bg {
  position: absolute;
  inset: 0;
  background: rgba(3,8,8,.85);
  backdrop-filter: blur(4px);
}

#modal-box {
  position: relative;
  z-index: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  max-height: 92vh;
  overflow-y: auto;
  width: 580px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
}

#modal-close {
  position: absolute;
  top: 12px; right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  z-index: 2;
}

#modal-close:hover { color: var(--text-bright); }

#modal-content { padding: 24px; }

/* ── modal sections ────────────────────────────────────────────────────────── */
.m-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: .06em;
  margin-bottom: 6px;
}

.m-sub {
  font-size: .75rem;
  color: var(--text-dim);
  margin-bottom: 20px;
  line-height: 1.6;
}

.m-label {
  font-size: .7rem;
  color: var(--text-dim);
  letter-spacing: .06em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 6px;
}

/* type chooser */
.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}

/* Span last item full-width when it sits alone on a row */
.type-grid > button:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.type-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: .75rem;
  padding: 14px 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, color .15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.type-btn:hover, .type-btn.selected {
  border-color: var(--accent);
  color: var(--text-bright);
}

.type-btn .tb-label {
  font-size: .85rem;
  color: var(--text-bright);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  letter-spacing: .05em;
}

.type-btn .tb-desc {
  font-size: .67rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* inputs */
.m-input, .m-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-bright);
  font-family: 'Share Tech Mono', monospace;
  font-size: .8rem;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s;
  resize: vertical;
}

.m-input:focus, .m-textarea:focus { border-color: var(--accent); }

.m-textarea { min-height: 180px; }

.m-callsign { margin-top: 14px; }
.m-callsign .m-input { resize: none; }

/* buttons */
.m-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: 'Share Tech Mono', monospace;
  font-size: .8rem;
  padding: 10px 20px;
  cursor: pointer;
  letter-spacing: .05em;
  transition: background .15s, color .15s;
}

.m-btn:hover { background: var(--accent); color: var(--bg); }
.m-btn:disabled { opacity: .4; cursor: not-allowed; }
.m-btn:disabled:hover { background: none; color: var(--accent); }

.m-btn.secondary {
  border-color: var(--border);
  color: var(--text-dim);
}
.m-btn.secondary:hover { border-color: var(--text-dim); background: none; color: var(--text); }

.m-btn.danger { border-color: var(--red); color: var(--red); }
.m-btn.danger:hover { background: var(--red); color: #fff; }

.m-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* file drop zone */
.drop-zone {
  border: 1px dashed var(--border);
  background: var(--bg);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s;
  margin-bottom: 4px;
}

.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); }

.drop-zone p { font-size: .75rem; color: var(--text-dim); }
.drop-zone .drop-hint { font-size: .68rem; color: var(--text-dimmer); margin-top: 4px; }

.drop-preview {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
  border: 1px solid var(--border);
  margin-top: 8px;
  background: var(--bg);
}

/* drawing canvas */
.draw-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.draw-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.draw-canvas-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 100%;
  border: 1px solid var(--border);
  overflow: hidden;
}

.draw-canvas-wrap canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  display: block;
  touch-action: none;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.swatch {
  width: 20px; height: 20px;
  border: 1px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.swatch.active, .swatch:hover { border-color: var(--text-bright); }

.tool-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: .7rem;
  padding: 4px 10px;
  cursor: pointer;
}

.tool-btn.active, .tool-btn:hover { border-color: var(--accent); color: var(--accent); }

.size-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .7rem;
  color: var(--text-dim);
}

.size-wrap input[type=range] { width: 80px; accent-color: var(--accent); }

/* parcel viewer */
.parcel-view { display: flex; flex-direction: column; gap: 14px; }

.parcel-frame-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.parcel-frame-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.parcel-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .72rem;
  color: var(--text-dim);
}

.parcel-meta .pm-sign { font-size: .85rem; color: var(--text-bright); font-family: 'Rajdhani', sans-serif; font-weight: 700; }
.pm-type { color: var(--accent); }

/* source viewer */
.source-box {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 14px;
  font-size: .72rem;
  line-height: 1.6;
  overflow: auto;
  max-height: 300px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}

/* token reveal */
.token-box {
  background: var(--bg);
  border: 1px solid var(--accent);
  padding: 14px;
  font-size: .75rem;
  word-break: break-all;
  color: var(--accent);
  letter-spacing: .05em;
  margin: 10px 0;
  cursor: text;
  user-select: all;
}

.token-warn {
  font-size: .7rem;
  color: var(--red);
  line-height: 1.5;
  margin-bottom: 6px;
}

/* error / status */
.m-error {
  font-size: .75rem;
  color: var(--red);
  margin-top: 8px;
  line-height: 1.5;
}

.m-status {
  font-size: .75rem;
  color: var(--accent);
  margin-top: 8px;
}

/* ── responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  #wall-grid { grid-template-columns: repeat(20, 40px); grid-template-rows: repeat(20, 40px); }
  .tile { width: 40px; height: 40px; }
  .tile-sign { display: none; }
  #modal-box { width: 100vw; max-width: 100vw; min-height: 50vh; }
}
