@import url('https://fonts.googleapis.com/css2?family=Fira+Sans+Condensed:wght@400;600;700;800&family=Nosifer&display=swap');

:root {
  color-scheme: dark;
  --ink: #f4efd9;
  --muted: #a9afbd;
  --night: #080b19;
  --panel: #101426;
  --panel-raised: #171c31;
  --line: #343a52;
  --acid: #b8ff45;
  --acid-dark: #47740f;
  --danger: #ff665e;
  --radius-small: 6px;
  --radius-large: 14px;
  --font-body: 'Fira Sans Condensed', 'Arial Narrow', sans-serif;
  --font-display: 'Nosifer', Impact, fantasy;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--font-body);
}

body {
  min-height: 100vh;
  overflow: hidden;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--acid);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(290px, 360px) 1fr;
  width: 100vw;
  height: 100vh;
}

.control-panel {
  position: relative;
  z-index: 5;
  height: 100vh;
  padding: 22px;
  overflow-y: auto;
  background: var(--panel);
  border-right: 2px solid var(--line);
  box-shadow: 12px 0 30px rgb(0 0 0 / 35%);
  scrollbar-color: var(--line) var(--panel);
}

.brand {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.brand-kicker,
.dialog-kicker {
  color: var(--acid);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 8px 0 4px;
  color: var(--acid);
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.brand p {
  max-width: 28ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.4;
}

.idea-entry,
.tool-section,
.survivor-section {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.idea-entry h2,
.section-heading h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.idea-entry label,
.burial-dialog label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.idea-entry textarea,
.burial-dialog input {
  width: 100%;
  padding: 10px 12px;
  background: #090c18;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  color: var(--ink);
  line-height: 1.35;
  resize: vertical;
}

.idea-entry textarea::placeholder,
.burial-dialog input::placeholder {
  color: #747b90;
}

.idea-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 8px;
  margin-top: 10px;
}

.raise-button,
.bury-button {
  width: 100%;
  padding: 11px 16px;
  background: var(--acid);
  border: 2px solid #d9ff9d;
  border-radius: var(--radius-small);
  box-shadow: 0 3px 0 var(--acid-dark);
  color: #10170a;
  font-weight: 800;
  cursor: pointer;
  transition: transform 100ms ease-out, box-shadow 100ms ease-out;
}

.random-idea-button {
  padding: 11px 10px;
  background: var(--panel-raised);
  border: 1px solid #626b89;
  border-radius: var(--radius-small);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.random-idea-button:hover {
  border-color: var(--acid);
}

.raise-button:active,
.bury-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--acid-dark);
}

.entry-error,
.dialog-error {
  min-height: 1.15em;
  margin: 7px 0 0;
  color: #ffaaa5;
  font-size: 0.8rem;
}

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

.section-heading > span {
  color: var(--acid);
  font-size: 0.72rem;
  font-weight: 700;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tool-button {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  min-height: 60px;
  padding: 8px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  text-align: left;
  cursor: pointer;
}

.tool-button:hover {
  border-color: #626b89;
}

.tool-button.is-active {
  background: #27311e;
  border-color: var(--acid);
  box-shadow: inset 0 0 0 1px var(--acid-dark);
}

.tool-button > span:nth-child(2) {
  font-size: 0.9rem;
  font-weight: 800;
}

.tool-button small {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.68rem;
}

.tool-icon {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
}

.tool-icon::before,
.tool-icon::after {
  position: absolute;
  display: block;
  content: '';
}

.tool-icon-weapon::before {
  top: 8px;
  left: 1px;
  width: 17px;
  height: 5px;
  background: #c9cdd6;
  border: 1px solid #080b19;
  transform: rotate(-20deg);
}

.tool-icon-weapon::after {
  top: 11px;
  left: 5px;
  width: 6px;
  height: 8px;
  background: #8a5a3b;
  transform: rotate(18deg);
}

.tool-icon-shovel::before,
.tool-icon-hammer::before {
  top: 1px;
  left: 9px;
  width: 4px;
  height: 18px;
  background: #a86e42;
  transform: rotate(35deg);
}

.tool-icon-shovel::after {
  right: 0;
  bottom: 0;
  width: 10px;
  height: 8px;
  background: #c9cdd6;
  border-radius: 2px 2px 5px 5px;
  transform: rotate(35deg);
}

.tool-icon-hammer::after {
  top: 1px;
  left: 5px;
  width: 15px;
  height: 7px;
  background: #c9cdd6;
  transform: rotate(35deg);
}

.tool-icon-reagent::before {
  top: 1px;
  left: 8px;
  width: 7px;
  height: 17px;
  background: var(--acid);
  border: 1px solid #eaffcb;
  box-shadow: 0 0 7px var(--acid);
  transform: rotate(35deg);
}

.tool-icon-reagent::after {
  top: 0;
  left: 4px;
  width: 15px;
  height: 2px;
  background: #d9dce3;
  transform: rotate(35deg);
}

.survivor-count {
  min-width: 24px;
  padding: 2px 7px;
  background: var(--acid);
  border-radius: 999px;
  color: #10170a !important;
  text-align: center;
}

.survivor-list {
  display: grid;
  gap: 6px;
  max-height: 128px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.survivor-list li {
  padding: 7px 9px;
  background: #202a1b;
  border-left: 3px solid var(--acid);
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
  font-size: 0.84rem;
}

.survivor-list .empty-survivors {
  padding: 4px 0;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-style: italic;
}

.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 16px;
}

.export-actions button,
.dialog-actions button,
.epitaph-chips button {
  padding: 8px 10px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.export-actions button:hover,
.dialog-actions button:hover,
.epitaph-chips button:hover,
.epitaph-chips button.is-selected {
  border-color: var(--acid);
  color: var(--ink);
}

.cemetery-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--night);
}

#cemetery {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.stage-topbar {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  background: rgb(8 11 25 / 78%);
  border: 1px solid rgb(123 132 163 / 40%);
  border-radius: var(--radius-small);
  box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
  color: var(--muted);
  font-size: 0.78rem;
  transform: translateX(-50%);
  pointer-events: none;
}

.stage-topbar p {
  margin: 0;
  white-space: nowrap;
}

.stage-topbar strong {
  color: var(--ink);
}

.world-meter {
  width: 80px;
  height: 4px;
  overflow: hidden;
  background: #343a52;
  border-radius: 999px;
}

.world-meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--acid);
  transition: width 100ms linear;
}

.stage-hint {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 3;
  max-width: 300px;
  padding: 8px 12px;
  background: rgb(8 11 25 / 86%);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  color: var(--muted);
  font-size: 0.8rem;
  pointer-events: none;
}

.burial-dialog {
  width: min(430px, calc(100vw - 32px));
  padding: 0;
  background: var(--panel);
  border: 2px solid #68708d;
  border-radius: var(--radius-large);
  box-shadow: 0 22px 70px rgb(0 0 0 / 60%);
  color: var(--ink);
}

.burial-dialog::backdrop {
  background: rgb(4 6 14 / 78%);
}

.burial-dialog form {
  padding: 24px;
}

.burial-dialog h2 {
  margin: 5px 0 0;
  font-size: 1.45rem;
}

.burial-idea {
  margin: 10px 0 16px;
  color: var(--muted);
  font-style: italic;
}

.epitaph-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.dialog-actions .bury-button {
  margin: 0;
  border-color: #d9ff9d;
  color: #10170a;
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 62vh;
    width: 100%;
    height: auto;
    min-height: 100vh;
  }

  .control-panel {
    width: 100%;
    height: auto;
    padding: 18px;
    overflow: visible;
    border-right: 0;
    border-bottom: 2px solid var(--line);
  }

  .brand h1 {
    font-size: 1.7rem;
  }

  .cemetery-stage {
    min-height: 420px;
  }

  .stage-topbar {
    top: 10px;
  }

  .stage-topbar p {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
