:root {
  color-scheme: dark;
  --bg: #0b1009;
  --panel: #17130c;
  --panel-2: #282012;
  --line: #6b5633;
  --text: #f0dfb8;
  --muted: #b8a778;
  --accent: #d6a53f;
  --blue: #496f76;
  --green: #6f8f43;
  --danger: #9e3f32;
  --copper: #a86136;
  --stone: #39352b;
  --black: #050704;
  --ink: #100d08;
  --gold-dim: #886728;
  --pixel-shadow: #040503;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Consolas, "Lucida Console", "Courier New", monospace;
  letter-spacing: 0;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, rgba(124, 78, 37, 0.2), transparent 45%),
    linear-gradient(140deg, rgba(60, 93, 41, 0.18), transparent 58%);
  background-size: 4px 4px, 4px 4px, 100% 100%;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  content: "";
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0.16) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: multiply;
  opacity: 0.42;
}

body.is-menu,
body.is-generator {
  overflow: auto;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #2b2415;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 226, 158, 0.05), 0 2px 0 #0a0806;
}

button,
.button-link,
.stat,
.menu-panel,
.generator-panel,
.auth-box,
.save-entry,
.room-entry,
.join-status,
.info-box,
.need-list,
.roadmap-item,
.notice {
  image-rendering: pixelated;
}

button::first-letter,
.button-link::first-letter {
  color: #ffe29a;
}

a {
  color: inherit;
}

button:hover {
  border-color: #8d7148;
  background: #3a2b1d;
}

button:active {
  transform: translateY(1px);
}

.dev-tools {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(20, 15, 10, 0.96);
  box-shadow: 0 0 0 2px var(--pixel-shadow), 0 8px 0 rgba(0, 0, 0, 0.35);
}

.dev-tools[hidden] {
  display: none;
}

.dev-tools-label {
  padding: 0 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.dev-tools button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

.dev-texture-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  display: grid;
  grid-template-columns: 92px 48px 70px 58px 74px;
  gap: 7px;
  align-items: end;
  min-width: 372px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(20, 15, 10, 0.98);
  box-shadow: 0 0 0 2px var(--pixel-shadow), 0 8px 0 rgba(0, 0, 0, 0.35);
}

.dev-texture-panel[hidden] {
  display: none;
}

.dev-texture-panel label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.dev-texture-panel select {
  min-height: 28px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  background: #090806;
  color: var(--text);
  font-size: 12px;
}

.dev-texture-preview {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  image-rendering: pixelated;
  background: #090806;
}

.dev-file-button {
  min-height: 28px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #2f2a21;
  color: #ffffff;
  text-align: center;
  cursor: pointer;
}

.dev-file-button input {
  display: none;
}

.dev-texture-status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}

button.is-active {
  border-color: var(--accent);
  background: #4a3e25;
  color: #fff4cf;
}

.topbar {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) repeat(4, auto) auto auto auto;
  gap: 10px;
  align-items: center;
  height: 56px;
  padding: 8px 12px;
  border-bottom: 2px solid #0a0805;
  background:
    linear-gradient(90deg, rgba(164, 48, 35, 0.12), transparent 18%, rgba(214, 165, 63, 0.1)),
    linear-gradient(#2a2112, #100d08);
  box-shadow: inset 0 -1px 0 var(--line), 0 3px 0 #050403;
}

.brand {
  color: var(--accent);
  font-weight: 900;
  text-transform: uppercase;
}

body.is-menu .topbar,
body.is-menu .layout,
body.is-generator .topbar,
body.is-generator .layout {
  display: none;
}

.screen {
  min-height: 100vh;
  padding: 28px;
  background:
    linear-gradient(rgba(13, 10, 7, 0.68), rgba(9, 7, 5, 0.92)),
    url("../art_placeholders/sheets/all_placeholders_preview.png") center / 392px 224px;
}

.screen[hidden] {
  display: none;
}

.screen-menu {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: 18px;
  align-content: center;
}

.menu-panel,
.generator-panel {
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 2px;
  background:
    linear-gradient(135deg, rgba(255, 226, 158, 0.035) 25%, transparent 25%) 0 0 / 8px 8px,
    rgba(22, 17, 12, 0.96);
  box-shadow: 0 0 0 2px #070604, 8px 8px 0 rgba(0, 0, 0, 0.46);
}

.menu-panel {
  padding: 18px;
}

.menu-panel-primary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 360px;
}

.account-status,
.server-pill {
  display: inline-flex;
  width: fit-content;
  min-height: 30px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--muted);
  background: rgba(9, 7, 5, 0.72);
  font-size: 13px;
}

.auth-panel,
.dashboard-panel {
  min-width: 0;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.auth-box {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #17120d;
}

.box-title {
  font-weight: 800;
}

.dashboard-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 14px;
}

.dashboard-panel[hidden] {
  display: none;
}

.dashboard-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
}

.dashboard-header h2 {
  margin: 4px 0 0;
  font-size: 28px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.65fr) minmax(300px, 1fr) minmax(320px, 1fr);
  gap: 14px;
  align-items: start;
}

.action-panel {
  display: grid;
  gap: 10px;
}

.menu-kicker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.screen h1 {
  margin: 8px 0 10px;
  font-size: 42px;
  line-height: 1;
  color: #ffe2a0;
  text-transform: uppercase;
}

.menu-lead,
.compact-copy {
  color: var(--muted);
  line-height: 1.45;
}

.menu-actions {
  display: grid;
  gap: 10px;
  max-width: 320px;
  margin-top: 18px;
}

.primary-action {
  border-color: #f0cd62;
  background: #5b3c19;
  color: #fff3c8;
  font-weight: 700;
}

.primary-action:hover {
  border-color: #ffe08a;
  background: #775f28;
}

.button-link {
  display: inline-flex;
  width: fit-content;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #2a2218;
  color: var(--text);
  text-decoration: none;
}

.button-link:hover {
  border-color: #8d7148;
  background: #3a2b1d;
}

.auth-actions,
.auth-switch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.auth-switch {
  margin: 12px 0;
}

.verification-code {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: rgba(228, 189, 88, 0.12);
  color: #fff3c8;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.save-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 96px;
}

.save-list.compact {
  min-height: 0;
  max-height: 150px;
  overflow: auto;
}

.save-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 7px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #17120d;
}

.save-entry-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.save-entry-meta {
  color: var(--muted);
  font-size: 12px;
}

.empty-list {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 2px;
  color: var(--muted);
}

.join-panel {
  display: grid;
  gap: 10px;
}

.join-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
  gap: 8px;
}

.join-status {
  min-height: 34px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  background: rgba(9, 7, 5, 0.72);
}

.room-list {
  display: grid;
  gap: 8px;
  min-height: 96px;
  margin-bottom: 10px;
}

.room-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #17120d;
}

.room-code {
  color: var(--accent);
  font-weight: 800;
}

.room-meta {
  color: var(--muted);
  font-size: 12px;
}

.saves-panel {
  grid-column: 2 / -1;
}

.generator-screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.generator-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.generator-header h1 {
  margin-bottom: 0;
}

.generator-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(320px, 1.1fr) minmax(280px, 0.85fr);
  gap: 16px;
}

.generator-panel {
  padding: 16px;
}

.settings-grid,
.slider-list {
  display: grid;
  gap: 12px;
}

.text-field,
.slider-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.text-field input {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #090806;
  color: var(--text);
  font: inherit;
}

.slider-field span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.slider-field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.slider-field small {
  min-height: 34px;
  color: var(--muted);
  line-height: 1.35;
}

.summary-box {
  display: grid;
  gap: 9px;
}

.summary-item {
  padding: 9px;
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  background: #17120d;
  color: var(--muted);
  line-height: 1.35;
}

input,
select,
textarea {
  border-radius: 2px;
  background: #090806;
  color: var(--text);
  font: inherit;
}

.seed-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.seed-row button {
  min-height: 38px;
  padding: 7px 10px;
}

input:focus,
button:focus-visible,
.button-link:focus-visible {
  outline: 2px solid #d7a945;
  outline-offset: 1px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #090806;
}

::-webkit-scrollbar-thumb {
  border: 1px solid #090806;
  background: #5b4930;
}

.brand {
  font-weight: 700;
  color: var(--accent);
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 94px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #120f0b;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.32);
}

.stat span,
.panel-row span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong,
.panel-row strong {
  font-size: 16px;
}

.map-setting-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 11px 0;
  color: var(--text);
  font-size: 14px;
}

.map-setting-check input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 230px;
  height: calc(100% - 56px);
}

.toolbar,
.sidepanel {
  min-width: 0;
  border-right: 2px solid #070604;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%) 0 0 / 10px 10px,
    linear-gradient(#211b13, #15110d);
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}

.category-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.category-tab {
  min-height: 32px;
  padding: 6px 7px;
  font-size: 13px;
  white-space: nowrap;
  text-transform: uppercase;
}

.category-tab.is-active {
  border-color: var(--copper);
  background: #3c2819;
  color: #ffe1a3;
}

.action-groups {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.action-group {
  display: none;
  flex-direction: column;
  gap: 7px;
}

.action-group.is-active {
  display: flex;
}

.group-title {
  margin: 2px 0 1px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.tool {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 7px 9px;
  text-align: left;
  background:
    linear-gradient(90deg, rgba(215, 169, 69, 0.05), transparent 35%),
    #18130e;
}

.tool span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.tool.is-active {
  border-color: var(--accent);
  background: #4b331c;
  color: #fff4cf;
}

.tool.is-active small {
  color: #fff0bd;
}

.tool.is-planned {
  color: #b8aa91;
  border-style: dashed;
  background: #201a14;
}

.tool.is-planned small {
  color: #7f8995;
}

.tool-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #080705;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  cursor: crosshair;
}

.notice {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: min(520px, calc(100% - 24px));
  padding: 8px 10px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 2px;
  background: rgba(20, 15, 10, 0.9);
  color: var(--text);
  font-size: 14px;
  pointer-events: none;
}

.creature-panel {
  position: absolute;
  top: 15%;
  right: 12px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  width: min(30%, 360px);
  min-width: 250px;
  height: 70%;
  min-height: 420px;
  padding: 12px;
  border: 2px solid #5b4930;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.44);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%) 0 0 / 10px 10px,
    linear-gradient(#221a12, #100d09);
}

.creature-panel[hidden] {
  display: none;
}

.creature-close {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0;
  color: var(--muted);
}

.creature-portrait-wrap {
  display: grid;
  place-items: center;
  min-height: 142px;
  margin: 4px 32px 10px 0;
  border: 1px solid rgba(215, 169, 69, 0.32);
  background:
    radial-gradient(circle at 50% 34%, rgba(215, 169, 69, 0.14), transparent 48%),
    #0b0907;
}

.creature-portrait {
  width: 128px;
  height: 128px;
  object-fit: contain;
  image-rendering: pixelated;
}

.creature-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.creature-kind {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.creature-heading h2 {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 22px;
  line-height: 1.05;
}

.creature-state {
  flex: 0 0 auto;
  padding: 3px 6px;
  border: 1px solid rgba(215, 169, 69, 0.28);
  color: var(--muted);
  font-size: 11px;
}

.creature-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.creature-tab {
  min-height: 30px;
  padding: 5px 4px;
  font-size: 10px;
  text-transform: uppercase;
}

.creature-tab.is-active {
  border-color: var(--accent);
  background: #4b331c;
  color: #fff4cf;
}

.creature-tab-content {
  min-height: 0;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(12, 9, 6, 0.72);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.creature-memory {
  margin: 6px 0;
  padding: 6px 7px;
  border-left: 2px solid rgba(215, 169, 69, 0.48);
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
}

.creature-section-title {
  margin: 8px 0 3px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}

.creature-section-title:first-child {
  margin-top: 0;
}

.sidepanel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-right: 0;
  border-left: 2px solid #070604;
}

.panel-title {
  margin-top: 4px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}

.panel-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(215, 169, 69, 0.14);
}

.layer-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.layer-controls button {
  min-height: 32px;
  font-size: 13px;
}

.info-box,
.need-list {
  min-height: 44px;
  max-height: 148px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(12, 9, 6, 0.72);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

#tile-info {
  max-height: 240px;
}

.roadmap-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 188px;
  overflow: auto;
}

.roadmap-item {
  padding: 6px 7px;
  border: 1px solid rgba(91, 73, 48, 0.78);
  background: rgba(20, 16, 11, 0.72);
  color: var(--muted);
  font-size: 12px;
}

.roadmap-item strong {
  display: block;
  color: var(--text);
  font-size: 12px;
}

.roadmap-item span {
  color: var(--accent);
}

.info-line,
.need-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
}

.tile-info-section {
  padding: 5px 0 7px;
  border-bottom: 1px solid rgba(215, 169, 69, 0.12);
}

.tile-info-section:first-child {
  padding-top: 0;
}

.tile-info-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.tile-info-title {
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.info-line span {
  min-width: 0;
  color: var(--muted);
}

.need-line strong,
.info-line strong {
  min-width: 0;
  color: var(--text);
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.job-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  margin: 0;
  padding-left: 22px;
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
}

.job-list li {
  padding: 3px 0;
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .topbar {
    grid-template-columns: 1fr 1fr;
    height: auto;
  }

  .screen {
    padding: 14px;
  }

  .screen-menu,
  .generator-layout,
  .generator-header,
  .auth-grid,
  .dashboard-header,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .join-panel,
  .saves-panel {
    grid-column: auto;
  }

  .screen h1 {
    font-size: 32px;
  }

  .layout {
    grid-template-columns: 210px minmax(300px, 1fr);
    height: 720px;
  }

  .category-tabs {
    grid-template-columns: 1fr;
  }

  .sidepanel {
    display: none;
  }
}
