:root {
  --night:   #05070f;      /* space */
  --dusk:    #12202b;
  --paper:   #fdf6e9;      /* floating cards */
  --cream:   #f6ead6;
  --butter:  #ffd98a;
  --peach:   #ff9f86;
  --berry:   #ff6f9c;
  --mint:    #7fd8b4;
  --sky:     #8fc3ff;
  --grape:   #a8dee8;
  --ink:     #22333d;
  --faint:   #8aa0ad;
  --edge:    #22333d;
  --pop: 0 3px 0 var(--edge);
  --display: "Baloo 2", ui-rounded, system-ui, sans-serif;
  --body: "Quicksand", ui-rounded, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--body);
  font-weight: 600;
  font-size: 14px;
  background: var(--night);
  -webkit-font-smoothing: antialiased;
}

/* ---------- globe behind everything ---------- */
.globe {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- framed map ---------- */
main {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 272px;
  gap: clamp(16px, 2.5vw, 32px);
  padding: 0 clamp(12px, 2.5vw, 24px) 28px;
  align-items: start;
}

.frame { position: relative; display: flex; flex-direction: column; align-items: center; }

.viewport {
  position: relative;
  height: min(72vh, 720px);
  aspect-ratio: 1 / 1;
  max-width: 100%;
  overflow: hidden;
  border: 3px solid var(--edge);
  border-radius: 22px;
  background-color: rgba(10, 20, 28, 0.78);
  box-shadow: 0 5px 0 var(--edge), 0 0 0 6px rgba(168, 222, 232, 0.14);
  cursor: grab;
  touch-action: none;
}

.expand { position: absolute; right: 12px; top: 12px; z-index: 6; }

/* full screen swallows the page */
body.is-full { overflow: hidden; }
body.is-full .viewport {
  position: fixed;
  inset: 0;
  z-index: 20;
  height: auto;
  aspect-ratio: auto;
  max-width: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
body.is-full .expand { position: fixed; right: 16px; top: 16px; z-index: 22; }
body.is-full .tray { position: fixed; left: 16px; bottom: 16px; z-index: 22; }
body.is-full .bar, body.is-full .brief { display: none; }
.viewport.is-dragging { cursor: grabbing; }

.stage { position: absolute; z-index: 1; top: 0; left: 0; width: 100%; aspect-ratio: 1 / 1; transform-origin: 0 0; }
#world { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

.graticule {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(168, 222, 232, 0.14) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(168, 222, 232, 0.14) 1px, transparent 1px);
  background-size: 40px 40px;
  transition: opacity 0.2s;
}

.claim, .cursor, .chosen { position: absolute; z-index: 2; width: 6%; height: 6%; pointer-events: none; }
.claim { pointer-events: none; }
.claim .ring {
  position: absolute;
  outline: 3px solid var(--berry);
  outline-offset: -1px;
  border-radius: 2px;
}
.cursor { outline: 2px dashed var(--grape); outline-offset: -1px; }
.chosen {
  z-index: 3;
  outline: 3px solid var(--butter);
  outline-offset: 2px;
  border-radius: 3px;
  box-shadow: 0 0 0 2px rgba(34, 51, 61, 0.9), 0 0 18px rgba(255, 217, 138, 0.55);
}

/* username stickers, drawn over the map so they stay readable */
.tags { position: absolute; z-index: 3; inset: 0; pointer-events: none; overflow: hidden; }
.tag {
  position: absolute;
  transform: translate(-100%, -100%);
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(253, 250, 240, 0.58);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag.is-mine { background: rgba(255, 111, 156, 0.7); color: var(--paper); }

/* ---------- floating chrome ---------- */
.bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px clamp(12px, 2.5vw, 24px);
  pointer-events: none;
}
.bar > * { pointer-events: auto; }

/* hand lettered wordmark: every letter its own colour and tilt */
.logo-name {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(26px, 3.4vw, 38px);
  line-height: 0.9;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.logo-name span {
  display: inline-block;
  text-shadow: 2px 3px 0 var(--edge);
  transition: transform 0.18s ease;
}
.logo-name em { font-style: normal; margin-left: 0.22em; }
.logo-name em span { text-shadow: 2px 3px 0 var(--edge), 0 0 18px rgba(255, 214, 138, 0.35); }

.logo-name .w1  { color: #ff8fb4; transform: rotate(-7deg)  translateY(1px); }
.logo-name .w2  { color: #ffc978; transform: rotate(4deg)   translateY(-2px); }
.logo-name .w3  { color: #9fe0c2; transform: rotate(-3deg); }
.logo-name .w4  { color: #8fd3ea; transform: rotate(6deg)   translateY(-1px); }
.logo-name .w5  { color: #c9a6f0; transform: rotate(-5deg)  translateY(2px); }
.logo-name .w6  { color: #ffd98a; transform: rotate(5deg)   translateY(-2px); }
.logo-name .w7  { color: #ff9e6b; transform: rotate(-6deg)  translateY(1px); }
.logo-name .w8  { color: #7bd86b; transform: rotate(3deg); }
.logo-name .w9  { color: #6bc6f5; transform: rotate(-4deg)  translateY(-2px); }
.logo-name .w10 { color: #ff6f9c; transform: rotate(7deg)   translateY(1px); }

.logo-name:hover span { transform: rotate(0deg) translateY(-2px); }

.logo-tag { display: block; font-size: 11px; color: var(--grape); margin-top: 5px; letter-spacing: 0.02em; }

.bar-side { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.badge {
  background: var(--mint);
  border: 2px solid var(--edge);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  box-shadow: var(--pop);
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--body);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--edge);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  box-shadow: var(--pop);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s;
}
.btn:hover { background: var(--butter); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--edge); }
.btn:focus-visible { outline: 3px solid var(--berry); outline-offset: 2px; }
.btn-pop { background: var(--berry); color: var(--paper); }
.btn-pop:hover { background: #ff8db1; }
.btn-mini { padding: 6px 12px; font-size: 12px; box-shadow: 0 2px 0 var(--edge); }
.btn-x { padding: 4px 10px; font-size: 15px; line-height: 1; }
.btn-wide { width: 100%; padding: 12px; font-size: 15px; }
.btn[disabled] { opacity: 0.55; cursor: default; }

/* ---------- search ---------- */
.finder { position: relative; flex: 0 1 240px; }

.finder input {
  width: 100%;
  font-family: var(--body);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--edge);
  border-radius: 999px;
  padding: 9px 16px;
  box-shadow: var(--pop);
}
.finder input::placeholder { color: var(--faint); }
.finder input:focus { outline: none; background: #fffdf5; }

.suggests {
  position: absolute;
  z-index: 12;
  top: calc(100% + 8px);
  left: 0; right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--paper);
  border: 2px solid var(--edge);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--edge);
  max-height: 260px;
  overflow: auto;
}
.suggests li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.suggests li:hover, .suggests li.is-on { background: var(--butter); }
.suggests small { color: var(--faint); font-weight: 600; }
.suggests .empty { color: var(--faint); cursor: default; }
.suggests .empty:hover { background: transparent; }

/* ---------- floating intro card ---------- */
.brief {
  position: sticky;
  z-index: 8;
  top: 14px;
  background: var(--paper);
  border: 3px solid var(--edge);
  border-radius: 22px;
  box-shadow: 0 5px 0 var(--edge);
  padding: 18px;
}
.brief.is-away { display: none; }

.brief-close {
  position: absolute;
  top: 8px; right: 10px;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--edge);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.brief-close:hover { background: var(--peach); }

.card-lead { font-family: var(--display); font-weight: 600; font-size: 17px; line-height: 1.35; margin: 0 22px 14px 0; }

.steps { list-style: none; counter-reset: step; margin: 0 0 14px; padding: 0; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 7px 0 7px 30px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--faint);
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 6px;
  width: 20px; height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sky);
  border: 2px solid var(--edge);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}
.steps span { color: var(--ink); }

.tally-where { background: var(--mint); }

.field select {
  width: 100%;
  font-family: var(--body);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--edge);
  border-radius: 14px;
  padding: 11px 13px;
  cursor: pointer;
}
.field select:focus { outline: none; background: #fffdf5; }

.perk {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 2px dashed var(--edge);
  border-radius: 16px;
  background: #fffaf0;
}
.perk-head {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
}
.perk-body { margin: 0 0 8px; font-size: 12px; line-height: 1.5; color: var(--faint); }
.perk-body:last-of-type { margin-bottom: 0; }
.perk-mine {
  margin: 10px 0 0;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--mint);
  font-size: 12px;
  text-align: center;
}

.ref-note { display: block; margin-top: 5px; font-size: 11px; min-height: 14px; }
.ref-note.is-good { color: #2f9e6b; }
.ref-note.is-bad { color: #d9556f; }
.field span small { color: var(--faint); font-weight: 600; }

/* shape picker */
.shapes {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 384px;
  margin: 0 auto 12px;
}
.shape-label { font-size: 11px; color: var(--faint); margin-right: 2px; }
.shape-hint { font-size: 11px; color: var(--faint); line-height: 1.4; }
.shape {
  font-family: var(--body);
  font-weight: 700;
  font-size: 12px;
  padding: 7px 12px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--edge);
  border-radius: 999px;
  cursor: pointer;
}
.shape:hover { background: var(--butter); }
.shape.is-on { background: var(--sky); }

.tally { margin: 0 0 8px; padding: 8px 12px; border-radius: 12px; background: var(--butter); font-size: 13px; text-align: center; }

/* ---------- bottom tray ---------- */
.tray {
  position: relative;
  z-index: 9;
  margin-top: 12px;
  align-self: stretch;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  max-width: calc(100vw - 40px);
}

.peek {
  display: flex;
  gap: 8px;
  align-items: baseline;
  background: rgba(16, 28, 36, 0.78);
  border: 2px solid rgba(168, 222, 232, 0.35);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 13px;
  color: var(--grape);
}
.peek-coord { color: var(--berry); font-weight: 700; }
.peek-owner { color: var(--paper); }

.pending {
  background: var(--butter);
  border: 2px solid var(--edge);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 13px;
  box-shadow: var(--pop);
}

.picked {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--paper);
  border: 2px solid var(--edge);
  border-radius: 999px;
  padding: 6px 8px 6px 16px;
  box-shadow: var(--pop);
}
.picked-who { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }
.picked-who small { color: var(--faint); font-size: 11px; }

/* ---------- sheets ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 20, 28, 0.72);
  overflow: auto;
}

.sheet-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  background: var(--paper);
  border: 3px solid var(--edge);
  border-radius: 24px;
  box-shadow: 0 6px 0 var(--edge);
  padding: 24px 22px 22px;
}
.sheet-wide { max-width: 560px; }

.sheet-close {
  position: absolute;
  top: 10px; right: 12px;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--edge);
  background: var(--paper);
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.sheet-close:hover { background: var(--peach); }

.sheet-title { font-family: var(--display); font-weight: 800; font-size: 24px; color: var(--ink); margin: 0 0 14px; }
.coord { font-family: var(--body); font-size: 13px; font-weight: 600; color: var(--faint); }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1;
  font-family: var(--body);
  font-weight: 700;
  font-size: 13px;
  padding: 8px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--edge);
  border-radius: 999px;
  cursor: pointer;
}
.tab.is-on { background: var(--sky); }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: var(--faint); margin-bottom: 5px; padding-left: 4px; }
.field input {
  width: 100%;
  font-family: var(--body);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--edge);
  border-radius: 14px;
  padding: 11px 13px;
}
.field input:focus { outline: none; background: #fffdf5; }

.note { font-size: 12px; line-height: 1.5; color: var(--faint); margin: 0 0 14px; }

.alert {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--peach);
  border: 2px solid var(--edge);
  font-size: 13px;
  line-height: 1.4;
}

/* ---------- editor ---------- */
.easel {
  position: relative;
  width: 100%;
  max-width: 384px;
  margin: 0 auto 16px;
  aspect-ratio: 1 / 1;      /* replaced at runtime to match the block */
  border: 3px solid var(--edge);
  border-radius: 16px;
  overflow: hidden;
  background: repeating-conic-gradient(#e8ebe4 0% 25%, #fdf6e9 0% 50%) 0 0 / 24px 24px;
}
#pad { display: block; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; cursor: crosshair; }
.pad-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(34, 51, 61, 0.1) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(34, 51, 61, 0.1) 1px, transparent 1px);
  background-size: 6.25% 6.25%;
}
.pad-tag {
  position: absolute;
  right: 8px; bottom: 8px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(253, 246, 233, 0.55);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; max-width: 384px; margin: 0 auto 14px; }
.swatches .swatch { min-height: 34px; }
.swatch { aspect-ratio: 1 / 1; border: 2px solid var(--edge); border-radius: 8px; cursor: pointer; padding: 0; }
.swatch.is-on { outline: 3px solid var(--berry); outline-offset: 2px; }

/* the colour wheel sits with the presets and opens the system picker */
.swatch.wheel {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    conic-gradient(#ff6b8b, #ffc978, #c9e86b, #4fd1b0, #6bc6f5, #8c8ce8, #e5559b, #ff6b8b);
  cursor: pointer;
}
/* the middle shows whatever colour the wheel currently holds */
.swatch.wheel::after {
  content: "";
  width: 46%;
  height: 46%;
  border-radius: 50%;
  background: var(--mixed, var(--paper));
  border: 2px solid var(--edge);
}
.swatch.wheel input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.tools { display: flex; flex-wrap: wrap; gap: 6px; max-width: 384px; margin: 0 auto 14px; }
.tool {
  flex: 1 0 auto;
  font-family: var(--body);
  font-weight: 700;
  font-size: 12px;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--edge);
  border-radius: 999px;
  cursor: pointer;
}
.tool:hover { background: var(--butter); }
.tool.is-on { background: var(--mint); }

.sheet-wide .btn-wide, .sheet-wide .alert { max-width: 384px; margin-left: auto; margin-right: auto; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 40;
  background: var(--mint);
  border: 2px solid var(--edge);
  border-radius: 999px;
  box-shadow: var(--pop);
  padding: 9px 18px;
  font-weight: 700;
  font-size: 13px;
}

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
  .sheet-card { max-height: 92vh; overflow-y: auto; }
  .swatch { border-radius: 10px; }
  .swatches { grid-template-columns: repeat(8, 1fr); gap: 8px; }
  .tool, .shape { padding: 11px 14px; font-size: 13px; }
  .easel { max-width: 100%; }
  .brief { position: static; }
  .viewport { height: min(62vh, 520px); }
  .logo-tag { display: none; }
  .finder { flex-basis: 100%; order: 3; }
  .bar-side { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
