:root {
  --wood-dark: #2a1a0f;
  --wood: #4a2e1a;
  --ork-green: #5f8a2a;
  --ork-green-light: #7ab03a;
  --ale: #d9a441;
  --bone: #e8dcc0;
  --blood: #9e2a1f;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--wood-dark);
  color: var(--bone);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.screen {
  display: none;
  height: 100%;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 1rem;
}

.screen.active {
  display: flex;
}

.game-title {
  font-family: "Metal Mania", Impact, "Arial Black", sans-serif;
  font-weight: 400;
  font-size: clamp(2.6rem, 9vw, 5.5rem);
  line-height: 1;
  color: var(--ork-green-light);
  text-shadow: 3px 3px 0 var(--wood-dark), 5px 5px 0 #000;
  text-align: center;
}

.tagline {
  font-size: 1.1rem;
  color: var(--ale);
}

.load-bar {
  width: min(360px, 80vw);
  height: 14px;
  border: 2px solid var(--bone);
  border-radius: 7px;
  overflow: hidden;
}

.load-fill {
  height: 100%;
  width: 0;
  background: var(--ork-green-light);
  transition: width 0.2s;
}

.load-text {
  font-size: 0.95rem;
}

.menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
}

.menu-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.menu-label {
  font-size: 1rem;
  color: var(--ale);
}

.menu-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--bone);
  background: var(--wood);
  border: 3px solid var(--bone);
  border-radius: 6px;
  padding: 0.7rem 1.4rem;
  min-height: 48px;
  min-width: 48px;
  cursor: pointer;
  box-shadow: 0 4px 0 #000;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #000;
}

.btn:focus-visible {
  outline: 3px solid var(--ale);
  outline-offset: 3px;
}

.btn-main {
  font-family: "Metal Mania", Impact, "Arial Black", sans-serif;
  font-weight: 400;
  font-size: 1.8rem;
  background: var(--ork-green);
  padding: 0.8rem 2.4rem;
}

.btn-small {
  font-size: 0.95rem;
  padding: 0.4rem 0.9rem;
  min-height: 44px;
}

.asset-report {
  font-size: 0.85rem;
  color: var(--bone);
  opacity: 0.8;
  max-width: 60ch;
  text-align: center;
}

.build-label {
  font-size: 0.8rem;
  opacity: 0.6;
}

.asset-report ul {
  list-style: none;
  margin-top: 0.3rem;
}

#screen-game {
  justify-content: flex-start;
  gap: 0;
  padding: 0;
}

.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  background: var(--wood);
  border-bottom: 3px solid #000;
  flex: 0 0 auto;
}

.status-text {
  flex: 1;
  text-align: center;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-wrap {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
}

#board {
  display: block;
  touch-action: none;
  box-shadow: 0 6px 20px #000;
}

#screen-game {
  position: relative;
}

.hidden {
  display: none !important;
}

.editor-bar {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: var(--wood-dark);
  border-bottom: 3px solid #000;
  flex: 0 0 auto;
}

.editor-gap {
  flex: 1;
}

.tool.selected {
  background: var(--ork-green);
  border-color: var(--ale);
}

.tool-object { border-left: 8px solid var(--ale); }
.tool-balcony { border-left: 8px solid #2f6fb5; }
.tool-stairs { border-left: 8px solid #7a3fa0; }
.tool-blocked { border-left: 8px solid var(--blood); }
.tool-wall { border-left: 8px solid #ff3b2f; }

.dialog {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10;
}

.dialog-box {
  background: var(--wood);
  border: 3px solid var(--bone);
  border-radius: 8px;
  padding: 1rem;
  width: min(640px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.dialog-box textarea {
  width: 100%;
  height: 16rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  background: var(--wood-dark);
  color: var(--bone);
  border: 2px solid #000;
  padding: 0.5rem;
  -webkit-user-select: text;
  user-select: text;
}

.tool-rail { border-left: 8px dashed #ffd23f; }

.screen.scroll {
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: 1.5rem;
  padding-bottom: 2rem;
}

.screen-heading {
  font-family: "Metal Mania", Impact, "Arial Black", sans-serif;
  font-weight: 400;
  font-size: clamp(2rem, 6vw, 3.2rem);
  color: var(--ork-green-light);
  text-shadow: 3px 3px 0 #000;
}

.count-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.btn.selected {
  background: var(--ork-green);
  border-color: var(--ale);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-go {
  background: var(--ork-green);
}

.seat-list,
.roster-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(640px, 100%);
}

.seat,
.roster-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--wood);
  border: 2px solid #000;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
}

.swatch {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid #000;
}

.seat input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.1rem;
  color: var(--bone);
  background: var(--wood-dark);
  border: 2px solid #000;
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  -webkit-user-select: text;
  user-select: text;
}

.roster-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.roster-name {
  font-weight: 700;
  font-size: 1.15rem;
}

.roster-detail {
  font-size: 0.9rem;
  opacity: 0.9;
}

.roster-wounds {
  font-family: "Metal Mania", Impact, "Arial Black", sans-serif;
  font-size: 2rem;
  color: var(--ale);
  text-align: center;
  line-height: 1;
}

.roster-wounds small {
  display: block;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.7rem;
  color: var(--bone);
}

.roster-first {
  font-size: 1.1rem;
  color: var(--ale);
  text-align: center;
}

.roster-bar {
  width: 100%;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.4rem 0.6rem;
  background: var(--wood);
  border-top: 3px solid #000;
  flex: 0 0 auto;
}

.chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  background: var(--wood-dark);
  border: 2px solid #000;
  border-radius: 20px;
  padding: 0.25rem 0.7rem 0.25rem 0.3rem;
  font-size: 0.9rem;
}

.chip .swatch {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

.chip.current {
  border-color: var(--bone);
  background: var(--ork-green);
}

.board-wrap {
  position: relative;
}

.toast {
  position: absolute;
  top: 0.8rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90%;
  background: rgba(26, 18, 12, 0.92);
  color: var(--bone);
  border: 2px solid var(--ale);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  z-index: 5;
}

.btn-fight {
  border-color: #ff9a8f;
}

.btn-test {
  border-style: dashed;
  opacity: 0.8;
}

.handoff-box {
  align-items: center;
  text-align: center;
  width: min(420px, 100%);
}

.handoff-swatch {
  width: 64px;
  height: 64px;
  border-width: 4px;
}

.chip.down {
  opacity: 0.6;
}

.skill-buttons {
  display: contents;
}

.btn-skill {
  border-color: #8fd0ff;
}

.win-swatch {
  width: 88px;
  height: 88px;
  border-width: 5px;
}

.log-list {
  list-style: none;
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
  -webkit-user-select: text;
  user-select: text;
}

.log-list li {
  background: var(--wood-dark);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
}

.log-round {
  color: var(--ale);
  font-weight: 700;
}

body > .dialog {
  position: fixed;
}

.howto-box {
  width: min(720px, 100%);
}

.howto-text {
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  line-height: 1.45;
  max-width: 70ch;
}

@media (prefers-reduced-motion: reduce) {
  .load-fill {
    transition: none;
  }
}
