.board .has-list {
  aspect-ratio: auto;
}
.board > .visual,
.board > .detail {
  min-width: 0;
  width: 100%;
  aspect-ratio: auto;
}
.board > .visual:not(.has-list) { min-height: 0; }
.visual .map {
  position: relative;
  aspect-ratio: 1.54;
  min-height: 225px;
}
.hero-slots { padding-left: 16px; color: var(--muted); font-size: .9rem; }
.guild-event fieldset { min-width: 0; margin: 8px 0; border: 1px solid var(--line); }
.region-neighbors { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 8px; }
.region-neighbors button { padding: 3px 8px; background: #192f39; border: 1px solid var(--line); border-radius: 5px; }
.visual .report-area { position: relative; min-width: 0; min-height: 100%; }
.visual > .village:not(.city-scene) { position: relative; aspect-ratio: 2.2; }
.building-list button > span { overflow-wrap: anywhere; min-width: 0; }
.starter-guide { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 12px; }
#connection-warning { color: #fff0cc; padding: 10px 14px; border: 1px solid var(--line); background: #573d29; }
.has-list .village {
  position: relative;
  aspect-ratio: 2.2;
}
.has-list img {
  object-fit: cover;
}
.building-list button, .recruit-box button, .report-area .secondary {
  text-align: left;
  background: #192f39;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 9px;
}
.building-list button[aria-pressed=true], .building-list button:hover {
  border-color: var(--gold);
}
.building-list small {
  display: block;
  color: var(--muted);
}
.recruit-box {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.recruit-box h3 {
  font-size: 13px;
  margin: 0 0 7px;
}
.detail .primary {
  margin-top: 8px;
}
.detail select {
  width: 100%;
  padding: 7px;
  margin: 0 0 8px;
  color: var(--cream);
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #192f39;
}
.quantity input {
  width: 72px;
}
.cost span {
  white-space: nowrap;
}
.march-token {
  position: absolute;
  z-index: 3;
  left: calc(50% + (var(--marker-x) - 50%) * var(--zoom));
  top: calc(50% + (var(--marker-y) - 50%) * var(--zoom));
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  height: 23px;
  width: 28px;
  background: #f4da96;
  border: 1px solid #7d542b;
  border-radius: 5px;
  box-shadow: 0 2px 5px #1e3039aa;
  color: #503819;
  pointer-events: none;
}
.march-token[hidden] {
  display: none;
}
.march-token svg {
  width: 22px;
  height: 20px;
}
.hero-card {
  margin: 18px 0;
}
.hero-card img {
  display: block;
  max-width: 210px;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.hero-card .eyebrow {
  margin-top: 8px;
}
@media (max-width: 700px) {
  .visual.has-list {
    min-height: auto;
  }
  .tabs button {
    padding-inline: 8px;
  }
}

.google-login {
  display: flex;
  justify-content: center;
  gap: 9px;
  text-decoration: none;
}
.google-login span {
  background: #fff;
  color: #4285f4;
  padding: 0 5px;
  border-radius: 50%;
}

.march-token {
  background: transparent;
  border: 0;
  box-shadow: none;
  width: 48px;
  height: 34px;
}
.march-token img { max-width: 100%; max-height: 100%; }

.guild-event, .guild-chat {
  border-top: 1px solid var(--line);
  padding-top: 9px;
  margin-top: 12px;
}
.guild-view label, .detail label {
  display: block;
}
.guild-view input, .guild-view select, .detail input {
  max-width: 100%;
}
.guild-event progress { width: 100%; accent-color: var(--gold); }
.guild-chat { list-style: none; padding-left: 0; overflow-wrap: anywhere; }
.guild-chat strong { color: var(--gold); }
.detail code { overflow-wrap: anywhere; }
#queues { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.building-list .building-thumb { width: 45px; height: 42px; object-fit: contain; flex: none; }
.building-list .building-thumb.unbuilt { filter: saturate(.25); opacity: .66; }
.building-list button { display: flex; align-items: center; gap: .5rem; text-align: left; }

.guild-march { opacity: .78; filter: drop-shadow(0 1px 2px #69c9bb); }

.hero-picker { display: flex; flex-wrap: wrap; gap: .5rem; }
.hero-picker button { border: 1px solid var(--line); padding: .35rem .65rem; border-radius: .35rem; }
.hero-picker button[aria-pressed=true] { background: #ead5ae; color: #321e12; }
.hero-card img { margin-inline: auto; border: 0; max-height: 260px; object-fit: contain; }

.inventory-item img { float: right; width: 56px; height: 56px; margin: 0 0 .4rem .5rem; border-radius: 6px; }
.inventory-item::after { content: ""; display: block; clear: both; }

@media (max-width: 560px) {
  .tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
  }
  .tabs button { min-width: 0; padding-inline: 5px; }
}

.city-switch { padding: .7rem 1rem; }
.city-switch select { margin-inline-start: .4rem; }

nav.tabs[hidden], .heading[hidden], .activity[hidden], .info > [hidden] { display: none; }
.board .primary:disabled { color: var(--muted); background: #334d58; opacity: 1; border-color: var(--line); }
.board .secondary, .map-list button {
  color: var(--cream);
  background: #192f39;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 12px;
}
.board .secondary:hover, .map-list button:hover { border-color: var(--gold); }
.board label { display: block; }
.board input:not([data-troop]), .board select {
  min-height: 36px;
  padding: 6px 8px;
  margin: 3px 0 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #192f39;
  color: var(--cream);
}
.guild-view label:not(:has(input[type="number"])), .event-list fieldset { max-width: 40rem; }
.guild-view label > input:not([type="number"]), .guild-view select { width: 100%; }
.event-list { margin-top: 24px; }
.event-list details { padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.event-list summary, .map-list summary, .report-area summary { cursor: pointer; font-weight: 650; }
.event-list progress { max-width: 40rem; }
.event-list input[type="number"], .guild-view input[type="number"] { width: 5.25rem; }
.map-list { padding: 10px 16px; }
.map-list button { margin: 5px 5px 0 0; }
.goal-tasks { padding-left: 1.2rem; }
.heading #troops { max-width: min(70%, 46rem); }
.march-token.shipment-token { filter: sepia(1) brightness(1.2); }
@media (max-width: 390px) {
  .heading { align-items: start; flex-direction: column; gap: 6px; }
  .heading #troops { max-width: 100%; margin: 0; text-align: left; }
}

/* Storage stays readable at a glance, including outside the Polis tab. */
.resources { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: min(55%, 480px); }
.storage-balance {
  min-width: 0;
  padding: 7px 9px 8px;
  border: 1px solid #ffffff16;
  border-radius: 7px;
  background: #142832;
  --storage-tint: #caaa6c;
}
.storage-stone { --storage-tint: #d8bcaa; }
.storage-iron { --storage-tint: #9fc7d3; }
.storage-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 3px; flex-wrap: wrap; }
.storage-heading span { color: var(--storage-tint); font-weight: 650; font-size: 12px; }
.storage-heading small, .storage-amount small { color: var(--muted); font-size: 11px; }
.storage-amount { font-variant-numeric: tabular-nums; }
.storage-amount strong { font-size: clamp(14px, 1.6vw, 18px); line-height: 1.2; }
.storage-balance progress { width: 100%; height: 5px; display: block; margin-top: 4px; accent-color: var(--storage-tint); }
.storage-balance progress::-webkit-progress-bar { background: #304a53; border-radius: 9px; }
.storage-balance progress::-webkit-progress-value { background: var(--storage-tint); border-radius: 9px; }

.city-scene { margin: 0; }
.has-list .city-scene { aspect-ratio: 1.82; min-height: 150px; }
.has-list .city-backdrop { object-position: center 54%; }
.city-scene .visual-caption { font: 17px/1.2 var(--serif); padding: 7px 12px; }
.city-plan { background: var(--panel); padding: clamp(13px, 2.5vw, 26px); }
.city-plan h2 { font: 30px/1.08 var(--serif); margin: 0; font-weight: 400; }
.building-group { margin-top: 16px; }
.building-group h3 { color: var(--green); font-size: 12px; letter-spacing: .045em; margin: 0 0 7px; }
.building-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.building-list button {
  min-width: 0;
  min-height: 59px;
  background: linear-gradient(150deg, #253e47, #192f39);
}
.building-list button[aria-pressed=true] { background: #344b50; }
.building-list .working { color: #f0c884; }
@media (min-width: 701px) {
  .board:has(.city-plan) > .detail { align-self: start; position: sticky; top: 12px; }
}

/* Markers are sized in viewport pixels. Labels live outside their hit targets. */
.map-world .atlas-marker {
  left: calc(50% + (var(--marker-x, 50%) - 50%) * var(--zoom));
  top: calc(50% + (var(--marker-y, 50%) - 50%) * var(--zoom));
  width: var(--atlas-size, 20px);
  height: var(--atlas-size, 20px);
  padding: 1px;
  display: grid;
  place-items: center;
  border: 1px solid #9d7951;
  background: #f1dcb0;
  box-shadow: 0 1px 4px #20313b8c;
  border-radius: 6px;
}
.map-world .atlas-marker[hidden] { display: none; }
.map-world .atlas-marker.harbor-marker { background: #d0e3dc; border-color: #5b8c87; }
.map-world .atlas-marker.event-marker { background: #8d5939; border-color: #f2dca7; }
.map-world .atlas-marker.home { background: #28606d; border-color: #eef0bd; }
.map-world .atlas-marker.foreign-marker { background: #edbaad; border: 1px dashed #6c4035; }
.map-world .atlas-dot { padding: 0; border: 1px solid #716646; border-radius: 50%; background: #e8dcb7; opacity: .75; }
.map-world .atlas-marker img { width: 100%; height: 100%; min-width: 0; object-fit: contain; }
.map-world .atlas-compact { border-radius: 50%; }
.map-world .atlas-compact img { display: none; }
.map-world .atlas-marker[aria-pressed=true], .map-world .atlas-marker:focus-visible, .map-world .atlas-marker:hover {
  border-color: #fff2c9;
  box-shadow: 0 0 0 2px #344f53, 0 2px 7px #223637aa;
  opacity: 1;
  z-index: 6;
}
.atlas-label {
  display: none;
  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 140px;
  padding: 3px 7px;
  border: 1px solid #b0905f;
  border-radius: 5px;
  background: #192f39;
  color: #fff0cc;
  font-size: 11px;
  line-height: 1.25;
  white-space: normal;
  pointer-events: none;
}
.map-world .atlas-marker[data-label-edge=start] .atlas-label { left: 0; transform: none; }
.map-world .atlas-marker[data-label-edge=end] .atlas-label { left: auto; right: 0; transform: none; }
.atlas-marker[aria-pressed=true] .atlas-label,
.atlas-marker:is(:hover, :focus-visible) .atlas-label { display: block; }
.map-world:has(.atlas-marker:is(:hover, :focus-visible)) .atlas-marker[aria-pressed=true]:not(:hover, :focus-visible) .atlas-label { display: none; }
.atlas-key {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 12px;
  padding: 8px 13px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #172e38;
  font-size: 11px;
}
.atlas-key span { display: inline-flex; align-items: center; gap: 4px; }
.atlas-key i { width: 9px; height: 9px; border: 1px solid #f2dfae; border-radius: 3px; background: #28606d; }
.atlas-key span:nth-child(2) i { background: #f1dcb0; border-color: #9d7951; }
.atlas-key span:nth-child(3) i { background: #edbaad; border-color: #6c4035; }
.atlas-key span:last-child i { border-radius: 50%; background: #e8dcb7; border-color: #716646; }
.map-list { background: var(--panel); }
.atlas-list-group h3 { margin: 12px 0 4px; color: var(--green); font-size: 12px; }
.atlas-list-group > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(144px, 100%), 1fr)); gap: 5px; }
.atlas-list-group button { text-align: left; margin: 0; overflow-wrap: anywhere; }
.atlas-list-group button[aria-pressed=true] { border-color: var(--gold); }
.atlas-list-group button small { display: block; color: var(--muted); }

/* Guild and goals use the same materials and hierarchy as the Polis. */
.guild-view, .goals-view { display: grid; gap: 16px; align-content: start; }
.guild-stats { display: flex; flex-wrap: wrap; gap: 6px 15px; margin: 6px 0 0; }
.guild-stats > div { display: flex; align-items: center; gap: 6px; }
.guild-stats dt { color: var(--muted); }
.guild-stats dd { margin: 0; color: var(--gold); font-weight: 700; }
.guild-unlocks { display: block; margin-top: 4px; color: var(--gold); }
.guild-start, .goal-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.guild-panel, .event-list details, .goal-card {
  min-width: 0;
  padding: 13px;
  border: 1px solid #ffffff20;
  border-radius: 8px;
  background: #1b333d;
}
.guild-panel h3, .event-list h3, .goals-section > h3, .guild-side h3, .goal-card h3 {
  font: 19px/1.18 var(--serif);
  color: var(--cream);
  margin: 0 0 8px;
}
.guild-panel label, .guild-side label { color: var(--muted); font-size: 13px; }
.guild-panel input, .guild-side input { width: 100%; }
.guild-chat { display: grid; gap: 5px; margin: 0; border: 0; padding-top: 0; max-height: 240px; overflow: auto; }
.guild-chat li { min-width: 0; padding: 7px 9px; border-radius: 5px; background: #152b35; }
.guild-chat p { margin: 2px 0; }
.guild-chat time { color: var(--muted); font-size: 11px; margin-left: .4em; }
.guild-composer { display: grid; gap: 5px; margin-top: 10px; }
.guild-composer textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 9px;
  background: #152b35;
  color: var(--cream);
  font: inherit;
}
.guild-side { margin-top: 10px; padding-top: 11px; border-top: 1px solid var(--line); }
.guild-side code { display: block; margin: 0 0 7px; color: var(--gold); }
.guild-side summary { cursor: pointer; }
.guild-side .primary { margin-top: 7px; }
.event-list { margin: 0; }
.event-list details { margin-top: 7px; padding: 0; }
.event-list .event-card summary {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto 8px;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
}
.event-list .event-card summary::after { content: '›'; color: var(--gold); font-size: 17px; }
.event-list .event-card[open] summary::after { transform: rotate(90deg); }
.event-list .event-card summary img { object-fit: contain; }
.event-list summary small { color: var(--muted); display: block; }
.event-list summary em { font: inherit; color: var(--gold); white-space: nowrap; }
.event-list .event-body { padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.event-list .event-body p { margin: 7px 0 4px; }
.event-list .event-body progress { max-width: none; }
.goal-card { display: flex; flex-direction: column; gap: 6px; }
.goal-card h3 { margin-bottom: 3px; }
.goal-card header p, .goal-card small { margin: 0; color: var(--muted); font-size: 12px; }
.goal-card.goal-ready { border-color: #e3bd76; box-shadow: inset 3px 0 #e3bd76; }
.goal-card.goal-weekly { background: linear-gradient(150deg, #2a454c, #1b333d); }
.goal-progress { display: flex; align-items: center; gap: 7px; }
.goal-progress progress { flex: 1; min-width: 0; height: 7px; accent-color: #b1cab1; }
.goal-progress small { white-space: nowrap; }
.goal-reward { margin: auto 0 0; }
.goal-reward .cost { margin-bottom: 3px; }
.goal-card button { margin: 0; align-self: start; }
.goal-tasks { list-style: none; padding: 0; margin: 3px 0; }
.goal-tasks li { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 4px 0; border-top: 1px solid var(--line); }
.goal-tasks strong { flex: none; color: var(--gold); font-size: 12px; }
.completed-goals .goal-list { margin: 8px 0 0; }

@media (max-width: 700px) {
  .top-inner { display: grid; grid-template-columns: 1fr; gap: 8px; padding-block: 10px; }
  .resources { width: 100%; gap: 5px; }
  .resources:empty { display: none; }
  .storage-balance { padding: 5px 7px; }
  .storage-amount small, .storage-heading small { font-size: 10px; }
  .building-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .guild-start, .goal-list { grid-template-columns: 1fr; }
}
@media (max-width: 359px) {
  .building-list { grid-template-columns: 1fr; }
}
