/* Tokenheim viewer — game-client chrome with readable type */

/* Press Start K (Codeman38) — dafont.com/press-start.font K variant — native 8px */
@font-face {
  font-family: "Press Start K";
  src: url("/fonts/PressStartK.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* 04b03 (04) — dafont.com/04b-03.font — native 8px
   Family name avoids a leading digit (some engines mishandle that). */
@font-face {
  font-family: "ZeroFourB03";
  src: url("/fonts/04B_03.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --void: #16110d;
  --stone: #5a4a36;
  --stone-mid: #7a6548;
  --stone-light: #a08860;
  --stone-dark: #2e2418;
  --copper: #c4924a;
  --copper-dark: #8a6230;
  --copper-light: #e8c482;
  --wood: #3a2c20;
  --wood-mid: #4e3c2a;
  --wood-light: #6a5238;
  --wood-dark: #241810;
  --beige: #d2bc8a;
  --beige-light: #e8d6a8;
  --beige-dark: #a89058;
  --ink: #1a1208;
  --text: #f2e6c8;
  --mute: #c4b090;
  --yellow: #ffe566;
  --orange: #ff9a3c;
  --live: #3fbf8a;
  --offline: #c44a3a;
  --connecting: #e8c040;
  --world: #0c0a08;
  --font: "Press Start K", "Courier New", monospace;
  --display: "Press Start K", "Courier New", monospace;
  /* Three sizes (Press Start K native grid = 8px) */
  --font-body: 8px;
  --font-sub: 16px;
  --font-head: 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; }

html:has(body.viewer),
body.viewer {
  overflow: hidden;
  overscroll-behavior: none;
}

body.viewer {
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--font-body);
  line-height: 1.35;
  letter-spacing: 0;
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(196, 146, 74, 0.14), transparent 55%),
    linear-gradient(180deg, #1c1510, var(--void));
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
  font-smooth: never;
  text-rendering: optimizeSpeed;
  font-synthesis: none;
}

body.desk-open { overflow: hidden; }

button, input, select {
  font: inherit;
  -webkit-font-smoothing: none;
  font-smooth: never;
}

.app {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  overflow: hidden;
}

/* —— Top bar —— */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  min-height: 32px;
}

.logo {
  display: inline-flex;
  align-items: center;
  height: 32px;
  text-decoration: none;
  color: inherit;
}

.logo__word {
  height: 32px;
  width: auto;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
  display: block;
  flex: 0 0 auto;
}

.auth-actions { display: flex; gap: 6px; align-items: center; }

.btn {
  appearance: none;
  border-style: solid;
  border-width: 2px;
  border-color: var(--stone-light) var(--stone-dark) var(--stone-dark) var(--stone-light);
  background:
    linear-gradient(180deg, var(--wood-light), var(--wood) 55%, var(--wood-dark));
  color: var(--yellow);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.85);
  height: 24px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  box-shadow:
    inset 0 0 0 1px rgba(232, 196, 130, 0.12),
    2px 2px 0 rgba(0, 0, 0, 0.35);
}

a.btn {
  text-decoration: none;
  box-sizing: border-box;
}

.btn:hover { filter: brightness(1.1); }

.btn--accent,
.btn.is-active {
  background: linear-gradient(180deg, var(--copper-light), var(--copper) 50%, var(--copper-dark));
  color: var(--ink);
  text-shadow: none;
  border-color: #e0c078 #5a3c18 #5a3c18 #e0c078;
}

/* —— Panel chrome: stacked moldings + large true-pixel corner flourishes —— */

.frame {
  position: relative;
  height: 100%;
  min-height: 0;
  padding: 8px;
  background: #2a1c12;
  border: 3px solid #120c08;
  box-shadow:
    0 0 0 1px #6a4a28,
    3px 3px 0 rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px #e8c482,
    inset 0 0 0 2px #b88848,
    inset 0 0 0 4px #6a4828,
    inset 0 0 0 5px #1a120c,
    inset 0 0 0 7px #3a2818;
  overflow: hidden;
}

.frame__corner {
  position: absolute;
  width: 32px;
  height: 32px;
  background: url("/art/frame-corner-16.png") 0 0 / 32px 32px no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: 4;
  pointer-events: none;
}

.frame__corner--tl { top: 2px; left: 2px; }
.frame__corner--tr { top: 2px; right: 2px; transform: scaleX(-1); }
.frame__corner--bl { bottom: 2px; left: 2px; transform: scaleY(-1); }
.frame__corner--br { bottom: 2px; right: 2px; transform: scale(-1); }

.frame__well {
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 4px;
  padding: 5px;
  background:
    repeating-linear-gradient(
      90deg,
      var(--wood-dark) 0 2px,
      var(--wood) 2px 5px,
      var(--wood-mid) 5px 7px,
      var(--wood) 7px 11px
    );
  border: 2px solid #120c08;
  box-shadow:
    inset 2px 2px 0 rgba(0, 0, 0, 0.45),
    inset -1px -1px 0 rgba(232, 196, 130, 0.1);
  overflow: hidden;
}

.frame__well--stack {
  grid-template-rows: auto minmax(0, 1fr);
}

.frame__well--map {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  padding: 0;
  gap: 0;
  border: 0;
  box-shadow: none;
}

.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  background:
    linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  border-style: solid;
  border-width: 1px;
  border-color: var(--stone-dark) var(--stone-light) var(--stone-light) var(--stone-dark);
  box-shadow: inset 1px 1px 0 rgba(255, 220, 160, 0.1);
  color: var(--mute);
}

.status h2 {
  margin: 0;
  font-size: var(--font-body);
  font-weight: 400;
  color: var(--yellow);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.85);
}

.icon-btn {
  appearance: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-style: solid;
  border-width: 2px;
  border-color: var(--stone-light) var(--stone-dark) var(--stone-dark) var(--stone-light);
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  color: var(--yellow);
  cursor: pointer;
  padding: 0;
}

.icon-btn:hover { filter: brightness(1.12); }
.icon-btn svg { width: 12px; height: 12px; display: block; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
}

.live i {
  width: 8px;
  height: 8px;
  background: var(--live);
  box-shadow: 1px 1px 0 #000;
  flex: 0 0 auto;
}

.live[data-live="live"] i {
  background: var(--live);
  animation: live-pulse 1.4s ease-in-out infinite;
}

.live[data-live="connecting"] {
  color: var(--yellow);
}

.live[data-live="connecting"] i {
  background: var(--connecting);
  animation: live-pulse 0.9s ease-in-out infinite;
}

.live[data-live="offline"] {
  color: #d08070;
}

.live[data-live="offline"] i {
  background: var(--offline);
  animation: none;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .live[data-live="live"] i,
  .live[data-live="connecting"] i {
    animation: none;
  }
}

/* Stage */

.stage {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(250px, 26vw, 330px);
  gap: 8px;
  overflow: hidden;
}

.world, .minimap, .ledger, .side {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.world__canvas,
.minimap__view {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--world);
  border-style: solid;
  border-width: 2px;
  border-color: var(--stone-dark) var(--copper-dark) var(--copper-dark) var(--stone-dark);
  box-shadow:
    inset 2px 2px 0 rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(196, 146, 74, 0.15);
}

/* World view: avoid a heavy inset that reads as a permanent vignette. */
.world__canvas {
  box-shadow: inset 0 0 0 1px rgba(196, 146, 74, 0.15);
}

.map-expand {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  box-shadow:
    inset 1px 1px 0 rgba(255, 220, 160, 0.18),
    2px 2px 0 rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.map-expand img {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

.map-expand:hover {
  filter: brightness(1.12);
}

/* Live world canvas (RCT v7 WebGL isometric) */
.world__rct {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #70baf6;
}

.world__view,
.world__view--rct {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: auto;
  cursor: grab;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.world__canvas.is-panning .world__view,
.world__rct.dragging .world__view--rct {
  cursor: grabbing;
}

.world__rct.molding .world__view--rct {
  cursor: cell;
}

.world__rct.molding.molding--raise .world__view--rct {
  cursor: crosshair;
}

.world__rct.molding.molding--lower .world__view--rct {
  cursor: crosshair;
}

.world__rct.molding.dragging .world__view--rct {
  cursor: grabbing;
}

.world__rct-loading,
.world__rct-error {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  transform: translate(-50%, -50%);
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 14px;
  border: 1px solid rgba(232, 194, 104, 0.35);
  background: rgba(12, 16, 20, 0.88);
  color: #f2efe6;
  font: 600 12px/1.4 "IBM Plex Sans", "Segoe UI", sans-serif;
  text-align: center;
  pointer-events: none;
}

.world__rct-error {
  border-color: rgba(220, 90, 70, 0.55);
  color: #ffd0c8;
  white-space: pre-wrap;
  text-align: left;
  pointer-events: auto;
  max-height: 40%;
  overflow: auto;
}

.world__placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 4px;
  text-align: center;
  z-index: 1;
  pointer-events: none;
}

.world__placeholder--hud {
  place-content: start stretch;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(8, 6, 12, 0.72), transparent 56%);
}

.world__label {
  margin: 0;
  font-size: var(--font-sub);
  color: var(--yellow);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.85);
}

.world__sub {
  margin: 0;
  font-size: var(--font-body);
  color: var(--mute);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.85);
}

.side {
  display: grid;
  grid-template-rows: clamp(150px, 27%, 200px) minmax(0, 1fr);
  gap: 8px;
}

.map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background:
    linear-gradient(135deg, #1c1810 25%, #0a0806 25% 50%, #242018 50% 75%, #0a0806 75%);
  background-size: 32px 32px;
}

.map-canvas--expanded {
  cursor: grab;
  touch-action: none;
}

.minimap__view.is-map-panning .map-canvas--expanded,
.win__body--map.is-map-panning .map-canvas--expanded {
  cursor: grabbing;
}

.map-cursor {
  display: none;
}

/* Icon tabs */

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  padding: 4px;
  background:
    linear-gradient(180deg, #2a1e14, var(--wood-dark));
  border-bottom: 1px solid var(--stone-dark);
  box-shadow: inset 0 -1px 0 rgba(232, 196, 130, 0.1);
}

.tab {
  appearance: none;
  min-height: 48px;
  display: grid;
  place-items: center;
  border-style: solid;
  border-width: 2px;
  border-color: var(--stone-light) var(--stone-dark) var(--stone-dark) var(--stone-light);
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  cursor: pointer;
  padding: 0;
}

.tab__icon {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  opacity: 0.85;
}

.tab:hover {
  filter: brightness(1.08);
}

.tab:hover .tab__icon {
  opacity: 1;
}

.tab.is-active {
  background: linear-gradient(180deg, var(--copper-light), var(--copper) 55%, var(--copper-dark));
  border-color: #e0c078 #5a3c18 #5a3c18 #e0c078;
  box-shadow: inset 1px 1px 0 rgba(255, 245, 200, 0.35);
}

.tab.is-active .tab__icon {
  opacity: 1;
}

.panel {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(80, 55, 25, 0.05) 0 2px, transparent 2px 4px),
    linear-gradient(180deg, var(--beige-light), var(--beige));
  border-style: solid;
  border-width: 2px;
  border-color: var(--beige-dark) var(--beige-light) var(--beige-light) var(--beige-dark);
  box-shadow: inset 0 0 0 1px rgba(255, 245, 210, 0.35);
}

.panel__pane h2 {
  margin: 0 0 4px;
  font-size: var(--font-sub);
  font-weight: 400;
  color: #4a3010;
}

.panel__lede {
  margin: 0 0 10px;
  color: #5a4020;
  font-size: var(--font-body);
}

.panel__empty {
  padding: 8px 10px;
  border-style: solid;
  border-width: 1px;
  border-color: var(--beige-dark) var(--beige-light) var(--beige-light) var(--beige-dark);
  background: rgba(168, 144, 88, 0.35);
  color: #3a2810;
  box-shadow: inset 1px 1px 0 rgba(255, 245, 210, 0.35);
}

.panel__check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  color: var(--ink);
}

.panel__check input { accent-color: var(--copper-dark); }

.panel__check--spaced {
  margin-top: 12px;
}

.panel__field {
  display: grid;
  gap: 4px;
  margin: 12px 0 0;
  color: var(--ink);
}

.panel__fieldset {
  margin: 0 0 12px;
  padding: 10px 10px 6px;
  border: 2px solid #3a2a18;
  background: #fff8e8;
  color: var(--ink);
}

.panel__fieldset legend {
  padding: 0 6px;
  font-weight: 700;
}

.panel__hint {
  margin: 0 0 8px;
  font-size: 0.85em;
  line-height: 1.35;
  color: var(--copper-dark);
}

.panel__segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.panel__segment {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 2px solid #3a2a18;
  background: #f3e6c4;
  cursor: pointer;
  user-select: none;
}

.panel__segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.panel__segment:has(input:checked) {
  background: var(--copper);
  color: #fffaf0;
}

.panel__segment:has(input:focus-visible) {
  outline: 2px solid var(--copper-dark);
  outline-offset: 1px;
}

.panel__seed {
  width: 100%;
  padding: 6px 8px;
  border: 2px solid #3a2a18;
  background: #fffaf0;
  color: var(--ink);
  font: inherit;
}

.panel__seed:focus {
  outline: 2px solid var(--copper);
  outline-offset: 1px;
}

.panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
}

.panel__field select {
  width: 100%;
  border: 2px solid var(--beige-dark);
  background: #f3e6c4;
  color: var(--ink);
  padding: 6px 8px;
  outline: none;
}

.panel__field select:focus {
  border-color: var(--copper-dark);
}

.panel__field .btn {
  width: 100%;
  justify-self: stretch;
}

.panel__field em {
  font-style: normal;
  color: var(--copper-dark);
}

.panel__range {
  width: 100%;
  accent-color: var(--copper-dark);
  cursor: pointer;
}

/* Full day/night loop track: night → dawn → noon → dusk → night */
.panel__range--day {
  -webkit-appearance: none;
  appearance: none;
  accent-color: transparent;
  height: 12px;
  border-radius: 0;
  border: 1px solid var(--ink);
  background: linear-gradient(
    90deg,
    #1a2438 0%,
    #c48a6a 18%,
    #f0e2a8 36%,
    #ffe27a 50%,
    #f0e2a8 64%,
    #c48a6a 82%,
    #1a2438 100%
  );
}

.panel__range--day::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  height: 12px;
  border: 0;
  background: linear-gradient(
    90deg,
    #1a2438 0%,
    #c48a6a 18%,
    #f0e2a8 36%,
    #ffe27a 50%,
    #f0e2a8 64%,
    #c48a6a 82%,
    #1a2438 100%
  );
}

.panel__range--day::-moz-range-track {
  height: 12px;
  border: 0;
  background: linear-gradient(
    90deg,
    #1a2438 0%,
    #c48a6a 18%,
    #f0e2a8 36%,
    #ffe27a 50%,
    #f0e2a8 64%,
    #c48a6a 82%,
    #1a2438 100%
  );
}

.panel__range--day::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 16px;
  margin-top: -3px;
  border: 1px solid var(--ink);
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.35);
}

.panel__range--day::-moz-range-thumb {
  width: 14px;
  height: 16px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.35);
}

.panel__day-hint {
  display: block;
  margin-top: 2px;
  color: #6a4a28;
  font-size: 10px;
  letter-spacing: 0.02em;
  opacity: 0.85;
}

.panel__hint {
  margin: 4px 0 0;
  color: #5a4020;
  font-size: var(--font-body);
}

/* Windows */

.desk[hidden] { display: none !important; }
.desk { position: fixed; inset: 0; z-index: 50; }

.desk__dim {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(8, 5, 3, 0.7);
}

.win[hidden] { display: none !important; }

.win {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 300px;
  max-width: min(920px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: #2a1c12;
  border: 3px solid #120c08;
  box-shadow:
    0 0 0 1px #6a4a28,
    4px 4px 0 rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px #e8c482,
    inset 0 0 0 2px #b88848,
    inset 0 0 0 4px #6a4828,
    inset 0 0 0 5px #1a120c,
    inset 0 0 0 7px #3a2818;
  z-index: 2;
  overflow: hidden;
}

#win-map {
  width: min(860px, calc(100vw - 24px));
  height: min(620px, calc(100dvh - 24px));
}

#win-auth { width: min(400px, calc(100vw - 24px)); }

.win__bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 4px 10px;
  margin-bottom: 4px;
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  border-style: solid;
  border-width: 1px;
  border-color: var(--stone-dark) var(--stone-light) var(--stone-light) var(--stone-dark);
  cursor: default;
  user-select: none;
}

.win__title {
  font-size: var(--font-sub);
  color: var(--yellow);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win__bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.map-zoom {
  display: flex;
  gap: 2px;
}

.map-zoom__btn {
  appearance: none;
  width: 26px;
  height: 22px;
  padding: 0;
  border-style: solid;
  border-width: 1px;
  border-color: var(--stone-light) var(--stone-dark) var(--stone-dark) var(--stone-light);
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  color: var(--yellow);
  font: inherit;
  font-size: var(--font-sub);
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 1px 1px 0 rgba(255, 220, 160, 0.12);
}

.map-zoom__btn:hover {
  filter: brightness(1.12);
}

.map-zoom__btn:disabled {
  opacity: 0.35;
  cursor: default;
  filter: none;
}

.win__close {
  appearance: none;
  width: 26px;
  height: 22px;
  border-style: solid;
  border-width: 2px;
  border-color: var(--stone-light) var(--stone-dark) var(--stone-dark) var(--stone-light);
  background: linear-gradient(180deg, #8a5a40, #4a2818);
  color: var(--yellow);
  font-size: var(--font-body);
  line-height: 1;
  cursor: pointer;
  padding: 0;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.85);
}

.win__close:hover {
  background: linear-gradient(180deg, #c45a40, #8a3020);
}

.win__body {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--wood);
  border-style: solid;
  border-width: 2px;
  border-color: var(--stone-dark) var(--stone-light) var(--stone-light) var(--stone-dark);
}

.win__body--map {
  position: relative;
  overflow: hidden;
  background: var(--world);
}

.win__foot {
  margin-top: 4px;
  padding: 4px 8px;
  background: linear-gradient(180deg, var(--wood-mid), var(--wood-dark));
  border-style: solid;
  border-width: 1px;
  border-color: var(--stone-dark) var(--stone-light) var(--stone-light) var(--stone-dark);
  color: var(--mute);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
}

.win__body--form {
  padding: 14px;
  display: grid;
  gap: 8px;
  align-content: start;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(80, 55, 25, 0.05) 0 2px, transparent 2px 4px),
    linear-gradient(180deg, var(--beige-light), var(--beige));
}

.win__body--form h2 {
  margin: 0;
  font-size: var(--font-head);
  font-weight: 400;
  color: #4a3010;
}

.auth__sub { margin: 0; color: #5a4020; }
.auth__modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.auth__form { display: grid; gap: 8px; }
.auth__form[hidden] { display: none !important; }

.auth__form label {
  display: grid;
  gap: 2px;
  color: #5a4020;
}

.auth__form input {
  width: 100%;
  border-style: solid;
  border-width: 2px;
  border-color: var(--beige-dark) var(--beige-light) var(--beige-light) var(--beige-dark);
  background: #f3e6c4;
  color: var(--ink);
  padding: 6px 8px;
  outline: none;
}

.auth__form input:focus {
  border-color: var(--copper-dark);
  background: #fff6d8;
}

.win__actions { display: flex; justify-content: flex-end; gap: 8px; }
.auth__note { margin: 0; color: #5a4020; }

body.admin {
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--font-body);
  background: var(--void);
  -webkit-font-smoothing: none;
  font-smooth: never;
  font-synthesis: none;
}

body.admin .shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2rem, 6vw, 4rem);
  max-width: 42rem;
}

body.admin .brand {
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  height: 32px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 0;
  color: transparent;
  text-shadow: none;
}

body.admin .brand::before {
  content: none;
}

body.admin .brand::after {
  content: "";
  width: 254px;
  height: 32px;
  background: url("/wordmark-6bb4bf02.png?v=16") left center / auto 32px no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

body.admin h1 {
  margin: 0 0 0.5rem;
  font-size: var(--font-sub);
  font-weight: 400;
  color: var(--yellow);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.85);
}

body.admin .lede {
  margin: 0;
  color: var(--mute);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
}

body.admin .meta { margin: 2rem 0 0; color: var(--mute); }
body.admin .meta a {
  color: var(--orange);
  text-decoration: none;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
}

@media (max-width: 820px) {
  .stage {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr);
  }
  .side {
    grid-template-columns: minmax(0, 40%) minmax(0, 1fr);
    grid-template-rows: 1fr;
  }
  #win-map {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
  }
}


/* Tab icon picker */

.win--icons {
  width: min(520px, calc(100vw - 24px));
}

.win__body--icons {
  padding: 12px;
  overflow: auto;
  max-height: min(70vh, 560px);
  background: linear-gradient(180deg, var(--beige-light), var(--beige));
  color: var(--ink);
}

.win--terrain {
  width: min(720px, calc(100vw - 24px));
}

.win__body--terrain {
  padding: 12px;
  overflow: auto;
  max-height: min(78vh, 720px);
  background: linear-gradient(180deg, var(--beige-light), var(--beige));
  color: var(--ink);
}

.terrain-gallery__lede {
  margin: 0 0 12px;
  color: #5a4020;
  font-size: var(--font-body);
}

.terrain-seed {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
}

.terrain-seed__label {
  color: #5a4020;
  font-size: var(--font-body);
}

.terrain-seed__row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.terrain-seed__input {
  flex: 1 1 140px;
  min-width: 0;
  padding: 6px 8px;
  border: 2px solid #3a2a18;
  background: #fffaf0;
  color: var(--ink);
  font: inherit;
}

.terrain-seed__input:focus {
  outline: 2px solid var(--copper);
  outline-offset: 1px;
}

.terrain-seed__status {
  margin: 0;
  min-height: 1.2em;
  color: #7a5830;
  font-size: var(--font-body);
}

.terrain-gallery__featured {
  margin: 0 0 14px;
  padding: 8px;
  background: rgba(20, 14, 10, 0.88);
  border-style: solid;
  border-width: 2px;
  border-color: #120c08 #3a2a18 #3a2a18 #120c08;
  box-shadow: inset 0 0 0 1px rgba(255, 220, 160, 0.08);
}

.terrain-gallery__featured img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 220px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #141018;
}

.terrain-gallery__featured figcaption {
  margin: 8px 2px 0;
  color: #e8d8b0;
  font-size: var(--font-body);
}

.terrain-gallery {
  display: grid;
  gap: 14px;
}

.terrain-gallery__item.is-active {
  outline: 2px solid var(--copper);
  outline-offset: 1px;
}

.terrain-gallery__item {
  margin: 0;
  padding: 8px;
  background: rgba(20, 14, 10, 0.88);
  border-style: solid;
  border-width: 2px;
  border-color: #120c08 #3a2a18 #3a2a18 #120c08;
  box-shadow: inset 0 0 0 1px rgba(255, 220, 160, 0.08);
}

.terrain-gallery__item img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 180px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #141018;
}

.terrain-gallery__item figcaption {
  margin: 8px 2px 0;
  color: #e8d8b0;
  font-size: var(--font-body);
}

.icon-picker {
  display: grid;
  gap: 14px;
}

.icon-picker__section {
  display: grid;
  gap: 6px;
}

.icon-picker__heading {
  margin: 0;
  font-size: var(--font-body);
  font-weight: inherit;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.75;
}

.icon-picker__row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.icon-picker__opt {
  appearance: none;
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 8px 2px 6px;
  border: 2px solid var(--beige-dark);
  background: #f3e6c4;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-body);
}

.icon-picker__opt img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  background: #0c0a08;
}

.icon-picker__opt span {
  text-align: center;
  line-height: 1.15;
}

.icon-picker__opt:hover {
  filter: brightness(1.05);
}

.icon-picker__opt.is-selected {
  border-color: var(--copper-dark);
  background: linear-gradient(180deg, var(--copper-light), var(--copper));
  box-shadow: inset 1px 1px 0 rgba(255, 245, 200, 0.35);
}

@media (max-width: 420px) {
  .icon-picker__row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
