:root {
  --ink: #1b1a1f;
  --paper: #f4efe4;
  --panel: #26242c;
  --line: #3a3742;
  --muted: #b9b4c4;
  --muted-dark: #57525f;
  --accent: #ffd23f;
  --danger: #c1121f;
  --ok: #2b9348;
  --foe: #ff6b6b;
  --calm: #8ecae6;
  --ally: #95d5b2;
  --stone: #8a7f69;
  --stone-line: #7a705e;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--paper); font-family: 'Space Grotesk', system-ui, sans-serif; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
.display { font-family: 'Bowlby One', sans-serif; line-height: 1.1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.label { font-size: 12px; font-weight: 700; color: var(--muted-dark); letter-spacing: 0.02em; }
.dark .label { color: var(--muted); }

/* Buttons */
.btn { min-height: 44px; padding: 0 14px; border-radius: 12px; border: 2px solid var(--ink); background: transparent; color: var(--ink); font-weight: 700; font-size: 14px; }
.btn.solid { background: var(--ink); color: var(--paper); }
.btn.accent { background: var(--accent); border-color: var(--ink); color: var(--ink); }
.btn.big { min-height: 52px; font-size: 15px; }
.btn.full { width: 100%; }
.btn.light { border-color: var(--paper); color: var(--paper); }
.btn.light.accent { border-color: var(--accent); color: var(--ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.dashed { border-style: dashed; }
.btn.on { background: var(--ink); color: var(--paper); }
.light-on.on { background: var(--paper); color: var(--ink); }
.icon-btn { width: 44px; height: 44px; flex: none; border-radius: 22px; border: 2px solid currentColor; background: transparent; color: inherit; display: flex; align-items: center; justify-content: center; padding: 0; }

.card { border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.grid6 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.chip { display: inline-block; padding: 7px 12px; border-radius: 20px; background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 700; }
.badge { padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }

input[type=text], input[type=number], select, textarea {
  min-height: 44px; border-radius: 10px; border: 2px solid var(--ink); background: #fff; color: var(--ink); padding: 0 10px; font-size: 16px; width: 100%;
}
textarea { padding: 10px; min-height: 70px; resize: vertical; }
.dark input[type=text], .dark input[type=number], .dark select, .dark textarea { background: var(--ink); color: var(--paper); border-color: #4a4656; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

/* Map */
.map { position: relative; width: 100%; aspect-ratio: 390 / 520; }
.mosaic { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(15, 1fr); grid-template-rows: repeat(20, 1fr); }
.room { position: absolute; border: 3px solid var(--ink); border-radius: 6px; background-color: var(--stone);
  background-image: linear-gradient(var(--stone-line) 1px, transparent 1px), linear-gradient(90deg, var(--stone-line) 1px, transparent 1px);
  background-size: 13px 13px; padding: 5px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; text-align: left; color: var(--ink); overflow: hidden; }
.room.hidden { background-color: #4a4538; background-image: repeating-linear-gradient(45deg, #3a352c 0, #3a352c 6px, transparent 6px, transparent 12px); }
.room-name { padding: 2px 6px; border-radius: 6px; background: var(--paper); color: var(--ink); font-family: 'Bowlby One', sans-serif; font-size: 11px; line-height: 1.2; max-width: 100%; }
.tokens { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tok { width: 26px; height: 26px; border-radius: 13px; border: 3px solid var(--ink); color: var(--ink); font-weight: 700; font-size: 10px; display: flex; align-items: center; justify-content: center; flex: none; }
.tok.foe { border-style: dashed; }
.tok.me { box-shadow: 0 0 0 2px #fff; }
.tok.ally { box-shadow: 0 0 0 2px var(--ok); }
.explore { position: absolute; border-radius: 12px; border: 2px dashed var(--paper); background: var(--ink); color: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; padding: 2px; }
.explore.locked { border: 2px solid var(--danger); }
.explore .q { font-family: 'Bowlby One', sans-serif; font-size: 16px; line-height: 1; }

/* Toast + overlays */
.toast { position: fixed; left: 12px; right: 12px; top: 64px; z-index: 50; padding: 12px 14px; border-radius: 12px; background: var(--paper); color: var(--ink); font-size: 14px; font-weight: 500; box-shadow: 0 6px 20px rgba(0,0,0,0.45); max-width: 560px; margin: 0 auto; }
.toast.error { border: 3px solid var(--danger); }
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(10,9,12,0.65); display: flex; align-items: flex-end; justify-content: center; }
.scrim.center { align-items: center; padding: 20px; }
.sheet { width: 100%; max-width: 560px; background: var(--paper); color: var(--ink); border-radius: 22px 22px 0 0; padding: 16px 14px 24px; display: flex; flex-direction: column; gap: 10px; max-height: 90vh; overflow-y: auto; }
.scrim.center .sheet { border-radius: 20px; }
.conn { position: fixed; bottom: 8px; right: 8px; z-index: 70; padding: 6px 10px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; }
