* {
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body {
  margin: 0;
  overflow: hidden;
  background: #737e4b;
  color: #eee8cf;
  font-family: Georgia, serif;
}
#world {
  display: block;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
  cursor: var(--god-hand, grab);
  touch-action: none;
  outline: none;
}
#world:active {
  cursor: var(--god-hand, grabbing);
}
header {
  position: fixed;
  top: 26px;
  left: 30px;
  display: flex;
  gap: 14px;
  align-items: center;
  pointer-events: none;
  text-shadow: 0 2px 4px #202918;
}
h1 {
  font-size: 23px;
  letter-spacing: 5px;
  margin: 0;
  font-weight: normal;
}
header p {
  font: 9px Arial;
  letter-spacing: 3.5px;
  margin: 8px 0;
}
.sigil {
  font-size: 44px;
  color: #e0c68b;
}
#place {
  position: fixed;
  top: 32px;
  right: 30px;
  text-align: right;
  pointer-events: none;
  text-shadow: 0 2px 4px #25311d;
}
.eyebrow {
  font: 9px Arial;
  letter-spacing: 2.5px;
  color: #dfc68e;
}
h2 {
  font-size: 21px;
  font-weight: normal;
  margin: 9px 0;
}
#place p {
  font-size: 12px;
  opacity: 0.8;
}
footer {
  position: fixed;
  bottom: 24px;
  left: 30px;
  right: 234px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
footer > span {
  font: 11px Arial;
  text-shadow: 0 1px 3px #000;
}
b {
  font-size: 9px;
  letter-spacing: 1px;
}
i {
  margin: 0 10px;
  opacity: 0.5;
}
.buttons {
  display: flex;
  align-items: center;
  background: #242c24ed;
  border: 1px solid #a49365;
  padding: 4px;
  box-shadow: 0 4px 16px #0003;
}
button {
  background: none;
  color: #eee8cf;
  border: 0;
  cursor: pointer;
  font: 22px Georgia;
  min-width: 34px;
  height: 34px;
}
button:hover {
  background: #d8bd7c22;
}
button:focus-visible {
  outline: 2px solid #e0c68b;
}
button span {
  font: 12px Georgia;
  margin: 0 7px;
}
output {
  font: 10px Arial;
  width: 43px;
  text-align: center;
  color: #d8c99d;
}
#minimap {
  position: fixed;
  right: 30px;
  bottom: 24px;
  border: 3px solid #30382b;
  outline: 1px solid #a49365;
  image-rendering: pixelated;
  cursor: crosshair;
  background: #75804e;
}
#loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #293325;
  font-size: 20px;
  letter-spacing: 2px;
  z-index: 9;
}
.screen {
  position: fixed;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 16px;
  background: #1d251de8;
  color: #e1d3a6;
  text-align: center;
  z-index: 10;
}
.screen[hidden] {
  display: none;
}
.screen h2 {
  font-weight: normal;
  font-size: 34px;
  letter-spacing: 6px;
  margin: 0;
}
.screen p {
  font: 15px/1.6 Georgia;
  color: #c9c9ad;
  margin: 0;
  max-width: 380px;
}
.screen button {
  min-width: 200px;
  min-height: 48px;
  background: #252e25;
  color: #e1d3a6;
  border: 1px solid #a49365;
  font: 14px Georgia;
  letter-spacing: 2px;
  cursor: pointer;
}
.screen button:hover {
  background: #313c31;
}
.modes {
  display: grid;
  gap: 12px;
  width: min(360px, 86vw);
}
.modes button {
  display: grid;
  gap: 6px;
  min-height: 72px;
  padding: 10px 14px;
}
.modes small {
  font: 12px/1.4 Georgia;
  letter-spacing: 0;
  color: #b5b08f;
}
#selection {
  position: fixed;
  bottom: 170px;
  right: 30px;
  width: 265px;
  background: #252e25ed;
  border: 1px solid #a49365;
  padding: 20px;
  box-shadow: 0 8px 24px #0003;
}
#selection h3 {
  font-weight: normal;
  margin: 10px 0;
}
#selection p {
  font: 13px/1.6 Georgia;
  color: #c9c9ad;
  margin-bottom: 0;
}
#inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
#crafting {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
#crafting[hidden] {
  display: none;
}
#crafting p {
  margin: 0;
}
.recipe {
  min-height: 44px;
  padding: 6px 10px;
  background: #1c241c;
  color: #e1d3a6;
  border: 1px solid #5d5a40;
  font: 12px Georgia;
  text-align: left;
  cursor: pointer;
}
#inventory[hidden] {
  display: none;
}
.slot {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 48px;
  padding: 6px 2px 3px;
  background: #1c241c;
  border: 1px solid #5d5a40;
  color: #e1d3a6;
  font: 12px monospace;
  touch-action: none;
  user-select: none;
}
.slot.draggable {
  border-color: #a49365;
  cursor: grab;
}
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  pointer-events: none;
  opacity: 0.9;
}
body.dragging {
  cursor: grabbing;
}
#cancel-site {
  margin-top: 14px;
  min-height: 44px;
  padding: 0 14px;
  background: #252e25;
  color: #f0c0b0;
  border: 1px solid #a49365;
  font: 12px Georgia;
  letter-spacing: 1px;
  cursor: pointer;
}
#cancel-site[hidden] {
  display: none;
}
#close {
  position: absolute;
  top: 3px;
  right: 3px;
}
@media (max-width: 700px) {
  header {
    top: 18px;
    left: 18px;
  }
  h1 {
    font-size: 18px;
  }
  #place {
    display: none;
  }
  footer {
    left: 18px;
    right: 18px;
    bottom: 18px;
  }
  footer > span {
    display: none;
  }
  #minimap {
    right: 18px;
    width: 120px;
    height: 49px;
  }
  #selection {
    top: 220px;
    right: 18px;
    bottom: auto;
    left: 18px;
    width: auto;
  }
  #minimap {
    top: 126px;
    bottom: auto;
  }
}

/* Resource chips: icon cut-outs and numbers in the Numen title colour. */
#resources {
  position: fixed;
  top: 108px;
  left: 30px;
  display: flex;
  gap: 22px;
  pointer-events: none;
  text-shadow: 0 2px 4px #202918;
}
.chip,
.role {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 22px Georgia;
  letter-spacing: 1px;
}
.icon {
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 3px #202918);
}
/* Role cut-outs stack upward from above the Village button. Hidden for now
   (the HUD still keeps the counts); remove the display rule to show them. */
#roles {
  display: none;
  position: fixed;
  left: 34px;
  bottom: 86px;
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  pointer-events: none;
  text-shadow: 0 2px 4px #202918;
}
.role[hidden] {
  display: none;
}

/* Bottom-centre action bar. */
#toolbar {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 24px);
}
#build-hint {
  margin: 0;
  max-width: 460px;
  text-align: center;
  font: 13px/1.5 Georgia;
  color: #eee8cf;
  background: #252e25e8;
  border: 1px solid #a49365;
  padding: 7px 14px;
}
#tool-row,
#categories {
  display: flex;
  justify-content: center;
  background: #242c24ed;
  border: 1px solid #a49365;
  padding: 4px;
  box-shadow: 0 4px 16px #0003;
}
.tools {
  display: flex;
  gap: 4px;
}
.tool[hidden],
.tools[hidden],
#tool-row[hidden],
#build-hint[hidden] {
  display: none;
}
.tool,
.category {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: auto;
  min-width: 84px;
  min-height: 68px;
  padding: 6px 8px;
  border: 1px solid transparent;
}
.category {
  min-width: 96px;
}
.tool span,
.category span {
  font: 14px Georgia;
  margin: 0;
  letter-spacing: 1px;
}
.tool small {
  font: 9px Arial;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #dfc68e;
}
button[aria-pressed="true"] {
  background: #d8bd7c33;
  border-color: #e0c68b;
}
.tool.short {
  opacity: 0.45;
}

@media (pointer: coarse) {
  button {
    min-width: 44px;
    min-height: 44px;
  }
  .buttons {
    gap: 2px;
  }
  body {
    overscroll-behavior: none;
  }
}
#world[data-cast="true"] {
  cursor: var(--god-hand-cast, crosshair);
}

/* Phone layout: declared last so it overrides the base rules above. */
@media (max-width: 700px) {
  #resources {
    top: 78px;
    left: 18px;
    gap: 14px;
  }
  .chip,
  .role {
    font-size: 18px;
  }
  #roles {
    left: 20px;
    bottom: 92px;
  }
  #toolbar {
    bottom: 92px;
  }
  #build-hint {
    max-width: calc(100vw - 36px);
  }
  .tool {
    min-width: 76px;
  }
}

#call-off-hunt {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  min-height: 44px;
  padding: 0 18px;
  background: #252e25ed;
  color: #e1d3a6;
  border: 1px solid #a49365;
  font: 13px Georgia;
  letter-spacing: 1px;
  cursor: pointer;
  z-index: 5;
}
#call-off-hunt[hidden] {
  display: none;
}

#equipment {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
#equipment[hidden] {
  display: none;
}
.slot.equip {
  width: 64px;
  min-height: 56px;
  font: inherit;
  cursor: pointer;
}
.slot.equip.empty {
  border-style: dashed;
  opacity: 0.55;
  cursor: default;
}
.slot.equip small {
  font: 10px monospace;
  letter-spacing: 1px;
}

/* The Miracles button pulses while a miracle is selected and ready to cast. */
#cat-cast.armed {
  animation: armed 1.1s ease-in-out infinite;
}
@keyframes armed {
  0%,
  100% {
    box-shadow: 0 0 0 0 #f2d98a00;
    background: #252e25;
  }
  50% {
    box-shadow: 0 0 14px 3px #f2d98acc;
    background: #3d4630;
  }
}
@media (prefers-reduced-motion: reduce) {
  #cat-cast.armed {
    animation: none;
    box-shadow: 0 0 10px 2px #f2d98acc;
  }
}
