:root {
  --ink: #f5eedc;
  --soft: #bac6b4;
  --line: #394a41;
  --gold: #e8c58a;
  --panel: #1c2924;
  --field: #23352c;
  --ease: cubic-bezier(.22, .75, .25, 1);
}
body {
  background: radial-gradient(ellipse at 12% 0%, #27382d 0%, #111c18 39rem);
}
a { color: var(--gold); text-underline-offset: .24em; }
:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
:where(section, h2, h3)[id] { scroll-margin-top: 24px; }
.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  max-width: none;
  padding: 14px max(clamp(16px, 4vw, 56px), calc((100vw - 1512px) / 2));
  background: #121e19;
}
.brand { display: flex; align-items: center; gap: 11px; width: fit-content; text-decoration: none; color: var(--ink); }
.brand h1 { font-size: clamp(1.1rem, 2.2vw, 1.55rem); white-space: nowrap; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border: 1px solid #806c48;
  border-radius: 7px;
  color: var(--gold);
  background: #332e22;
}
.site-nav { display: flex; flex-wrap: wrap; gap: clamp(5px, 2vw, 21px); }
.site-nav a, .player-nav a {
  color: var(--soft);
  text-decoration: none;
  font-size: .875rem;
  padding: 6px 4px;
  transition: color 160ms ease;
}
.site-nav a:hover, .player-nav a:hover { color: var(--gold); }
.player-nav { justify-self: end; }
#signout { min-height: 34px; padding: 3px 8px; font-size: .875rem; margin-inline-start: 4px; }
.hero, main, .status-panels, .guilds {
  max-width: 1600px;
  padding-inline: clamp(14px, 4vw, 56px);
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(230px, .6fr);
  align-items: end;
  gap: 24px;
  padding-block: clamp(23px, 4vw, 52px) clamp(16px, 2vw, 28px);
  animation: panel-in 500ms var(--ease) both;
}
.hero .eyebrow { margin-bottom: 7px; }
.eyebrow { font-weight: 650; }
.hero h2 { font-size: clamp(2.35rem, 5.2vw, 5rem); letter-spacing: -.052em; }
.hero em { color: var(--gold); font-weight: inherit; }
.hero p { margin: 0 0 4px; max-width: 34ch; font-size: .98rem; }
main { grid-template-columns: minmax(0, 1fr) minmax(275px, 320px); gap: clamp(14px, 2vw, 26px); padding-block: 0 28px; }
aside { gap: 12px; }
.card, .atlas { border-radius: 12px; padding: clamp(13px, 1.6vw, 22px); }
.card { background: #1b2822; }
.atlas { background: #1b2823; box-shadow: 0 14px 42px #080f0c42; min-width: 0; }
.atlas-title { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 5px 20px; }
.atlas-title p { margin: 0; font-size: .89rem; }
.map-tools { gap: 6px; margin: 14px 0 10px; }
.map-tools button { padding-inline: 10px; font-size: .875rem; }
.map-tools output { font-size: .85rem; padding-inline: 6px; }
.map-viewport { border-color: #667767; background: #4a6c68; }
.map-viewport .tile { box-shadow: inset -1px -1px #f5e8bf27; }
.map-viewport .tile[data-territory] { box-shadow: inset 0 0 0 1px #ebce7388; }
.map-viewport .tile[data-march-preview="route"] { box-shadow: inset 0 0 0 1px #c9df9f99; }
.map-viewport .tile[data-march-preview="arrival"] { box-shadow: inset 0 0 0 1px #ffe0a3; }
.map-caption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin-top: 10px; }
.legend { gap: 6px 14px; color: var(--soft); font-size: .875rem; }
.map-details { margin-top: 13px; min-height: 106px; }
.map-details p { margin-bottom: 0; }
.map-details .eyebrow { margin-bottom: 4px; }
.tile-contents li { background: #22352b; border-color: #526659; }
button:not(.tile), select, #guild-name, #propose-order textarea {
  background: var(--field);
  border-color: #506657;
  transition: background 165ms ease, border-color 165ms ease, color 165ms ease;
}
button:not(.tile):hover:not(:disabled) { background: #314a3c; border-color: #819582; }
button:not(.tile):disabled { opacity: .5; cursor: default; }
button.primary, .chat-tabs [aria-selected="true"] { background: var(--gold); border-color: var(--gold); color: #252017; }
button.primary:hover:not(:disabled) { background: #f5daa6; border-color: #f5daa6; }
.guild-identity { border-color: var(--line); }
.guild-emblem { background: #322d21; border-color: #7e6d4d; }
.guild-moves { border-color: #445746; }
.chat-tabs { position: relative; isolation: isolate; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; padding: 3px; background: #13211b; border: 1px solid var(--line); border-radius: 9px; }
.chat-tabs::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 3px auto 3px 3px;
  width: calc(50% - 3px);
  background: var(--gold);
  border-radius: 6px;
  transition: transform 300ms var(--ease);
}
.chat-tabs:has(#guild-chat-tab[aria-selected="true"])::before { transform: translateX(100%); }
.chat-tabs button:not(.tile), .chat-tabs button:not(.tile):hover:not(:disabled) { background: transparent; border-color: transparent; }
.chat-channel { background: #17251e; border-color: var(--line); animation: panel-in 260ms var(--ease) both; }
#order-dialog { background: #213129; border-color: #748471; box-shadow: 0 14px 36px #08120dc4; }
#order-dialog:popover-open { animation: order-in 230ms var(--ease) both; }
.role-portrait { background: radial-gradient(ellipse at center, #3b5041, #202f27 72%); }
.status-panels .card { padding: clamp(16px, 2.2vw, 30px); }
.guilds { padding-top: 28px; }
.guild-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
@keyframes panel-in { from { opacity: .45; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes order-in { from { opacity: .45; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (max-width: 850px) {
  main { grid-template-columns: minmax(0, 1fr); }
  aside { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  aside > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 590px) {
  .site-header { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; }
  .site-nav { grid-column: 1 / -1; grid-row: 2; gap: 14px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .hero p { max-width: 45ch; }
  aside { grid-template-columns: minmax(0, 1fr); }
  .map-tools { margin-top: 9px; gap: 4px; }
  .map-tools button { padding-inline: 7px; }
  .map-caption small { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero, .chat-channel, #order-dialog:popover-open { animation: none; }
  .chat-tabs::before, button:not(.tile), select, .site-nav a { transition: none; }
}

.guild-flag { top: 6%; bottom: auto; left: 54%; width: clamp(9px, 58%, 36px); height: auto; aspect-ratio: 4/5; z-index: 4; }
.guild-flag::before, .guild-flag::after { content: none; }
.flag-art, .flag-art::before, .flag-art::after { position: absolute; display: block; }
.flag-art { inset: 0; filter: drop-shadow(0 1px 1px #0e1713); }
.flag-art::before {
  content: ""; inset: 0 auto 0 8%; width: 15%;
  background: #896049; border: max(1px, .09em) solid #201915;
}
.flag-art::after {
  content: ""; inset: 0 0 31% 17%;
  background: var(--flag-color);
  box-shadow: inset -2px -3px #0005, inset 2px 2px #fff4;
  clip-path: polygon(0 15%, 21% 15%, 21% 23%, 40% 23%, 40% 15%, 57% 15%, 57% 7%, 73% 7%, 73% 0, 100% 0, 100% 78%, 84% 78%, 84% 86%, 63% 86%, 63% 94%, 42% 94%, 42% 100%, 21% 100%, 21% 93%, 0 93%);
}
#world-map { --unit-size: max(24px, calc(var(--tile-size, 30px) * .8)); }
.march-party span { width: var(--unit-size); }
.tile[data-troops] { z-index: 3; }
.tile:has(.tile-troops img:hover), .tile[data-troops]:focus-visible { z-index: 5; }
.tile-troops { position: absolute; inset: 0; display: flex; justify-content: center; align-items: center; pointer-events: none; z-index: 2; }
.tile[data-troops] > .guild-flag {
  top: auto;
  bottom: calc(50% + var(--unit-size) / 2 + 4px);
  left: 50%;
  z-index: 1;
}
.tiles > :nth-child(-n+128)[data-troops] > .guild-flag {
  top: calc(50% + var(--unit-size) / 2 + 4px);
  bottom: auto;
}
.tile-troops img { display: block; flex: 0 0 auto; width: var(--unit-size); height: var(--unit-size); image-rendering: pixelated; filter: drop-shadow(0 2px #161612); pointer-events: auto; }
.tile-troops img + img { margin-inline-start: calc(var(--unit-size) * -.48); }
.troop-tooltip { display: none; position: absolute; z-index: 6; bottom: calc(50% + var(--unit-size) * .5 + 3px); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(210px, 62vw); padding: 5px 8px; border: 1px solid #b5a278; border-radius: 5px; background: #1b231d; color: #fff2d6; font-size: .82rem; font-weight: 700; line-height: 1.35; pointer-events: none; }
.tile:has(.tile-troops img:hover) .troop-tooltip, .tile[data-troops]:focus-visible .troop-tooltip { display: block; }

.build-order { min-width: 0; width: 100%; }
.build-cost-preview {
  display: none;
  padding: 9px 11px;
  margin-top: 6px;
  border: 1px solid #60745d;
  border-radius: 7px;
  background: #17251e;
}
.build-order:hover .build-cost-preview,
.build-order:focus-within .build-cost-preview,
.build-order[data-open] .build-cost-preview { display: block; }
.build-cost-preview ul { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0; margin: 4px 0; }
.build-cost-preview li { display: flex; align-items: center; gap: 4px; }
.build-cost-preview img { width: 22px; height: 22px; image-rendering: pixelated; }
.build-cost-preview button { display: flex; margin-top: 8px; }
