* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #171d19;
  color: #e4dbc2;
  font-family: Georgia, serif;
}
#game {
  position: absolute;
  width: 1920px;
  height: 1080px;
  transform-origin: 0 0;
  overflow: hidden;
  box-shadow: 0 0 100px #000;
}
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: default;
}
/* Painted 2172×724 source: the frame occupies y≈256–466.
   Coordinates below are in the fixed 1920×1080 game space. */
.command-frame {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 1920px;
  height: 188px;
  transform: translateX(-50%) scale(0.8);
  transform-origin: top center;
  isolation: isolate;
  background: transparent url("../assets/ui/hud/top-frame-v1.png")
    center -226px / 1920px 640px no-repeat;
}
.resources {
  font-family: Georgia, serif;
}
.resource-readout {
  position: absolute;
  top: 74px;
  height: 44px;
  display: flex;
  align-items: center;
  font-size: 28px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #f5e7bf;
  text-shadow: 0 2px 3px #000;
  white-space: nowrap;
}
.resource-wood {
  left: 146px;
  width: 108px;
}
.resource-gold {
  left: 370px;
  width: 108px;
}
.resource-population {
  left: 590px;
  width: 110px;
}
.brand-crest {
  position: absolute;
  left: 50%;
  top: 32px;
  transform: translateX(-50%);
  width: 310px;
  height: 110px;
  display: grid;
  place-items: center;
}
.brand-logo {
  display: block;
  width: 310px;
  height: 110px;
  object-fit: contain;
  filter: drop-shadow(0 3px 4px #0008);
}
.header-controls {
  position: absolute;
  left: 1240px;
  right: 64px;
  /* Match the painted inner well (source y330–401), then center controls. */
  top: 66px;
  height: 62px;
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 18px;
  align-items: center;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
/* Original fantasy controls: antique brass frame around an inset garnet face. */
button {
  --button-face-top: #733b31;
  --button-face-bottom: #381c19;
  position: relative;
  isolation: isolate;
  border: 3px solid transparent;
  border-radius: 4px;
  background:
    linear-gradient(
        180deg,
        var(--button-face-top),
        #52261f 48%,
        var(--button-face-bottom)
      )
      padding-box,
    linear-gradient(
        145deg,
        #d1b477,
        #79613a 26%,
        #49371f 51%,
        #ae8b51 78%,
        #dec38a
      )
      border-box;
  color: #f1dfb2;
  padding: 13px 24px;
  font:
    15px Georgia,
    serif;
  letter-spacing: 0.3px;
  text-shadow: 0 2px 2px #160d0b;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 #f5c08c30,
    inset 0 -3px 5px #190b0bc4,
    0 2px 0 #16140f,
    0 4px 8px #0005;
  transition:
    filter 0.14s ease,
    box-shadow 0.14s ease;
}
button::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid #d5ab665c;
  border-top-color: #f2cf8b85;
  border-bottom-color: #241309;
  border-radius: 1px;
  pointer-events: none;
}
button::after {
  content: "";
  position: absolute;
  inset: -2px;
  pointer-events: none;
  background:
    linear-gradient(#ead09a, #8d6838) left top / 8px 2px no-repeat,
    linear-gradient(#ead09a, #8d6838) right top / 8px 2px no-repeat,
    linear-gradient(#8d6838, #b6975f) left bottom / 8px 2px no-repeat,
    linear-gradient(#8d6838, #b6975f) right bottom / 8px 2px no-repeat;
}
button:hover:not(:disabled) {
  filter: brightness(1.18);
  box-shadow:
    inset 0 1px #f5cf9166,
    inset 0 -3px 5px #190b0b99,
    0 2px #16140f,
    0 0 12px #c69a3938;
}
button:active:not(:disabled) {
  filter: brightness(0.9);
  box-shadow:
    inset 0 3px 8px #170b0be6,
    0 1px #ad8b4c55;
}
button:disabled {
  opacity: 0.5;
  filter: saturate(0.25);
  cursor: not-allowed;
}
button:focus-visible {
  outline: 2px solid #f1d796;
  outline-offset: 4px;
}
.header-controls button {
  margin: 0;
  min-width: 112px;
  height: 46px;
  padding: 0 22px;
}
.objective {
  position: absolute;
  top: 175px;
  left: 38px;
  background: #202b20c4;
  border-left: 3px solid #baad7a;
  padding: 20px 24px;
  pointer-events: none;
}
.objective span,
.eyebrow {
  font: 11px Arial;
  letter-spacing: 3px;
  color: #b7a777;
}
.objective h2 {
  font-size: 24px;
  font-weight: normal;
  margin: 10px 0;
}
.objective p {
  font: 15px/1.6 Arial;
  color: #c7cbb7;
  margin-bottom: 14px;
}
#warning {
  font: 12px Arial;
  color: #d2ba83;
}
footer {
  position: absolute;
  inset: auto 0 0;
  height: 170px;
  background: linear-gradient(#34372bef, #24291ff5);
  border-top: 3px solid #8b805e;
  display: flex;
  align-items: center;
  padding: 24px 40px;
  gap: 40px;
}
.selection {
  width: 350px;
  border-right: 1px solid #8b805e66;
}
.selection h2 {
  margin: 12px 0;
  font-size: 28px;
  font-weight: normal;
}
.selection p {
  font: 14px Arial;
  color: #bcbda6;
}
.orders {
  flex: 1;
}
#actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
  min-height: 48px;
}
.help {
  width: 450px;
}
.help b {
  font-weight: normal;
  font-size: 22px;
  color: #d7c697;
}
.help p {
  font: 13px/1.8 Arial;
  color: #aeb29d;
}
#notice {
  position: absolute;
  bottom: 195px;
  left: 50%;
  transform: translateX(-50%);
  font: 16px Arial;
  background: #20291fe8;
  padding: 12px 24px;
  border: 1px solid #a2905d;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
#outcome {
  position: absolute;
  inset: 0;
  background: #111b16cc;
  display: grid;
  place-items: center;
}
#outcome[hidden] {
  display: none;
}
#outcome > div {
  text-align: center;
  padding: 65px;
  background: #30372a;
  border: 1px solid #9f9063;
  box-shadow: 0 20px 100px #0008;
}
#outcome h1 {
  font-size: 60px;
  font-weight: normal;
  margin: 20px;
}
#outcome p {
  font: 18px Arial;
  margin-bottom: 35px;
}

/* Present from the first HTML paint, before modules or images finish loading. */
#splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 37%, #58604438, transparent 53%),
    radial-gradient(ellipse at 50% 90%, #9e663c18, transparent 55%),
    linear-gradient(145deg, #18251e, #111b17 55%, #20271c);
  color: #dacba8;
  transition: opacity 0.45s ease;
}
#splash[hidden] {
  display: none;
}
#splash.is-leaving {
  opacity: 0;
  pointer-events: none;
}
#splash:before,
#splash:after {
  content: "";
  position: absolute;
  inset: -25%;
  pointer-events: none;
  background: repeating-linear-gradient(
    122deg,
    transparent 0 100px,
    #c5bd8c03 101px 103px,
    transparent 104px 240px
  );
  transform: rotate(-8deg);
}
#splash:after {
  background: radial-gradient(
    ellipse at center,
    transparent 25%,
    #060d0bb3 75%
  );
  transform: none;
}
.splash-frame {
  position: absolute;
  inset: 28px;
  border: 1px solid #c7af702e;
  z-index: 1;
  pointer-events: none;
}
.splash-frame:before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid #c7af7010;
}
.splash-content {
  position: relative;
  z-index: 2;
  width: min(850px, 85vw);
  text-align: center;
  padding: 55px 0;
}
.splash-kicker {
  font:
    11px Arial,
    sans-serif;
  letter-spacing: 6px;
  color: #a2aa88;
  margin: 0 0 25px;
}
.splash-logo {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 20px 25px #0006);
}
.splash-divider {
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 330px;
  margin: 25px auto 20px;
  color: #b49b62;
  font-size: 17px;
}
.splash-divider:before,
.splash-divider:after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, #c3aa6155);
}
.splash-divider:after {
  transform: rotate(180deg);
}
.splash-tagline {
  font:
    italic clamp(16px, 2vw, 23px) Georgia,
    serif;
  color: #c9c4ac;
  margin: 0 0 42px;
}
.splash-loading {
  max-width: 340px;
  margin: auto;
}
.splash-loading-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  font:
    12px Arial,
    sans-serif;
  color: #b5b89d;
  margin-bottom: 12px;
}
#loading-count {
  color: #d6bd7d;
  font-variant-numeric: tabular-nums;
}
#loading-progress {
  display: block;
  appearance: none;
  width: 100%;
  height: 5px;
  border: 0;
  background: #070f0b;
  border-radius: 3px;
  overflow: hidden;
}
#loading-progress::-webkit-progress-bar {
  background: #070f0b;
}
#loading-progress::-webkit-progress-value {
  background: linear-gradient(90deg, #716b41, #d1b77a);
  transition: width 0.2s;
}
#loading-progress::-moz-progress-bar {
  background: #c3aa71;
}
#loading-detail {
  font: 11px/1.6 Arial;
  color: #89927d;
  margin-top: 15px;
}
#loading-retry {
  margin-top: 12px;
}
#loading-retry[hidden] {
  display: none;
}
.splash-footnote {
  position: absolute;
  bottom: 44px;
  z-index: 2;
  font: 9px Arial;
  letter-spacing: 4px;
  color: #798570;
}
#splash noscript {
  position: absolute;
  bottom: 70px;
  z-index: 3;
}
@media (max-height: 600px) {
  .splash-content {
    width: min(580px, 72vw);
    padding: 20px 0;
  }
  .splash-kicker {
    margin-bottom: 10px;
  }
  .splash-divider {
    margin: 10px auto;
  }
  .splash-tagline {
    margin-bottom: 22px;
  }
  .splash-footnote {
    bottom: 20px;
  }
  .splash-frame {
    inset: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #splash,
  #loading-progress::-webkit-progress-value {
    transition: none;
  }
}

/* A fixed-aspect illustrated prologue, inside the same viewport as the match. */
#main-menu {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: #121e18;
  text-align: center;
  overflow: hidden;
}
#main-menu[hidden] {
  display: none;
}
.menu-landscape {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(#122019ef, #14231ad9 45%, #152018ae),
    url("../assets/terrain/grass-v1.png") center / cover;
}
.menu-landscape::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 42%, transparent 18%, #0a141660 78%),
    linear-gradient(transparent 60%, #0b1615cc);
}
.menu-wynd {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.menu-wynd path {
  fill: none;
  stroke: #a48a5f;
  stroke-width: 36;
  opacity: 0.17;
}
.menu-hall {
  position: absolute;
  width: 420px;
  bottom: 130px;
  opacity: 0.53;
  filter: drop-shadow(-24px -10px 12px #0008);
}
.menu-hall-player {
  left: 40px;
}
.menu-hall-enemy {
  right: 40px;
}
.menu-frame {
  position: absolute;
  inset: 32px;
  border: 1px solid #b59b6040;
  pointer-events: none;
}
.menu-frame::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid #b59b601c;
}
.menu-content {
  position: relative;
  width: 860px;
  margin: 65px auto 0;
}
.menu-kicker {
  font:
    12px Arial,
    sans-serif;
  letter-spacing: 6px;
  color: #b4b59a;
  margin: 0 0 18px;
}
.menu-logo {
  display: block;
  width: 640px;
  height: 220px;
  object-fit: contain;
  margin: auto;
  filter: drop-shadow(0 10px 20px #0009);
}
.menu-content .splash-divider {
  margin: 12px auto 20px;
}
#menu-title {
  font:
    normal 44px Georgia,
    serif;
  color: #e1d2ac;
  margin: 0 0 24px;
}
.menu-story {
  max-width: 740px;
  margin: auto;
  font:
    21px/1.65 Georgia,
    serif;
  color: #c2c7b3;
}
.menu-story p {
  margin: 0 0 18px;
}
.menu-begin {
  --button-face-top: #824536;
  --button-face-bottom: #422019;
  margin: 18px auto 0;
  min-width: 330px;
  padding: 20px 32px;
  font-size: 22px;
}
.menu-begin span {
  margin-left: 24px;
  color: #cfb77d;
}
.menu-mode {
  font:
    10px Arial,
    sans-serif;
  letter-spacing: 3px;
  color: #969e85;
  margin: 20px 0;
}
.menu-controls {
  font:
    16px/1.7 Arial,
    sans-serif;
  color: #bfc4ae;
}
.menu-controls summary {
  cursor: pointer;
  color: #d3bf89;
  width: fit-content;
  margin: auto;
}
.menu-controls p {
  font-size: 15px;
  margin-top: 12px;
}
.menu-footnote {
  position: absolute;
  bottom: 35px;
  width: 100%;
  color: #90977d;
  letter-spacing: 5px;
  font:
    10px Arial,
    sans-serif;
}

@media (prefers-reduced-motion: reduce) {
  button {
    transition: none;
  }
}

/* The painted frame already has alpha; let the battlefield show around its silhouette. */
#game-menu-button {
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  filter: none;
  border-radius: 16px;
}
#game-menu-button::before,
#game-menu-button::after {
  display: none;
}
#game-menu-button .brand-logo {
  transition: filter 220ms ease;
}
#game-menu-button:hover .brand-logo,
#game-menu-button:focus-visible .brand-logo {
  filter: brightness(1.12) drop-shadow(0 0 8px #efbb58aa)
    drop-shadow(0 0 20px #d78d3455);
}
#game-menu-button:active .brand-logo {
  filter: brightness(1.04) drop-shadow(0 0 6px #efbb5888);
}
#pause-menu {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #080f0bc9;
  backdrop-filter: blur(3px);
}
#pause-menu[hidden] {
  display: none;
}
.pause-menu-panel {
  position: relative;
  width: 620px;
  text-align: center;
  padding: 45px 68px 32px;
  border: 2px solid #a88950;
  border-radius: 8px;
  background: linear-gradient(145deg, #303a29, #142019);
  box-shadow:
    inset 0 0 0 6px #121a13,
    inset 0 0 0 7px #88713f70,
    0 24px 80px #000a;
}
.pause-menu-logo {
  width: 300px;
  height: 135px;
  object-fit: contain;
}
.pause-menu-panel h1 {
  font-size: 38px;
  color: #f1dfb2;
  margin: 20px 0 16px;
}
.pause-menu-panel p {
  color: #bdc2ac;
  line-height: 1.6;
  font-size: 18px;
}
.pause-menu-panel .eyebrow {
  font-size: 11px;
  letter-spacing: 3px;
  color: #c8ab6f;
}
.pause-menu-actions {
  display: grid;
  gap: 14px;
  margin: 30px 0 24px;
}
.pause-menu-actions button {
  min-height: 58px;
  font-size: 19px;
}
.pause-menu-panel .pause-menu-hint {
  font-size: 13px;
  color: #a2a68d;
}
.pause-menu-close {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 27px;
}
@media (prefers-reduced-motion: reduce) {
  #game-menu-button .brand-logo {
    transition: none;
  }
}

.counter-change {
  position: absolute;
  left: 50%;
  top: 100%;
  pointer-events: none;
  font:
    bold 23px Georgia,
    serif;
  text-shadow: 0 2px 4px #000;
  animation: counter-rise 1.4s ease-out forwards;
}
.counter-change.gain {
  color: #d9edaf;
}
.counter-change.loss {
  color: #ffb7a3;
  animation-name: counter-fall;
}
@keyframes counter-rise {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -32px);
  }
}
@keyframes counter-fall {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, 32px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .counter-change {
    animation-name: counter-fade;
  }
}
@keyframes counter-fade {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

#actions button {
  padding: 9px 12px;
}
