:root {
  color-scheme: dark;
  --hw-bg: #101b25;
  --hw-panel: #172630;
  --hw-panel2: #1c2e3a;
  --hw-border: #304450;
  --hw-text: #e5eceb;
  --hw-muted: #9cb1b9;
  --hw-cyan: #76d5e7;
  --hw-gold: #edc27c;
  --hw-red: #f09e88;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 16px
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  background: var(--hw-bg);
  color: var(--hw-text)
}

[hidden] {
  display: none !important
}

button,
input,
select {
  font: inherit;
  color: inherit
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent
}

button,
a {
  touch-action: manipulation
}

button {
  border: 1px solid var(--hw-border);
  border-radius: 6px;
  background: #213440;
  padding: .55rem .75rem;
  cursor: pointer;
  font-size: .875rem;
  transition: background .15s, border-color .15s
}

button:hover {
  background: #2c4552;
  border-color: #607b87
}

button:disabled {
  opacity: .4;
  cursor: not-allowed
}

button.active {
  color: var(--hw-cyan);
  background: #254653;
  border-color: #47717d
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--hw-cyan);
  outline-offset: 3px
}

a {
  color: inherit;
  text-decoration: none
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid #415663;
  background: #152630;
  border-radius: 6px;
  padding: .7rem .75rem;
  font-size: .875rem
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #9cb1b9 50%), linear-gradient(135deg, #9cb1b9 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 12px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  padding-right: 1.8rem
}

label {
  display: grid;
  gap: .5rem;
  color: #c4d2d5;
  font-size: .875rem
}

h1,
h2,
h3,
p {
  margin: 0
}

small {
  font-size: .75rem
}

.hw-primary {
  background: var(--hw-gold);
  color: #19232a;
  border-color: var(--hw-gold);
  font-weight: 600
}

.hw-primary:hover {
  background: #f8d69f;
  color: #15212a
}

.hw-header {
  height: 78px;
  display: flex;
  align-items: center;
  padding: 0 1.2rem;
  gap: 1.4rem;
  border-bottom: 1px solid var(--hw-border);
  background: #14232d
}

.hw-brand {
  display: flex;
  align-items: baseline;
  gap: .65rem;
  padding-right: 1.3rem;
  border-right: 1px solid var(--hw-border)
}

.hw-brand>span {
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  font-size: 1.8rem;
  letter-spacing: .1em;
  color: var(--hw-gold)
}

.hw-brand small {
  letter-spacing: .16em;
  color: var(--hw-muted);
  font-size: .65rem
}

.hw-world-name {
  display: grid;
  gap: .35rem;
  min-width: 150px
}

.hw-world-name strong {
  font-size: .9rem;
  font-weight: 500;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.hw-world-name span {
  color: var(--hw-muted);
  font-size: .75rem
}

.hw-resources {
  display: flex;
  gap: 2rem;
  margin: auto
}

.hw-resources>div {
  display: grid;
  grid-template-columns: auto auto;
  gap: .15rem .4rem;
  align-items: baseline
}

.hw-resources small {
  grid-column: 1/-1;
  color: var(--hw-muted)
}

.hw-resources strong {
  font-size: 1.2rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums
}

.hw-resources span {
  color: var(--hw-muted);
  font-size: .75rem
}

.hw-iconbutton {
  width: 35px;
  height: 35px;
  padding: 0;
  border-radius: 50%
}

.hw-body {
  display: flex;
  height: calc(100dvh - 140px);
  min-height: 420px
}

.hw-layers {
  width: 78px;
  flex: none;
  background: #14232d;
  border-right: 1px solid var(--hw-border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: .8rem .45rem;
  gap: .25rem
}

.hw-layers>span {
  font-size: .65rem;
  letter-spacing: .16em;
  color: var(--hw-muted);
  text-align: center;
  margin-bottom: .5rem
}

.hw-layers>button {
  display: grid;
  justify-items: center;
  gap: .2rem;
  border: 0;
  background: transparent;
  font-size: .75rem;
  padding: .6rem 0
}

.hw-layers>button b {
  font-size: 1.4rem;
  font-weight: 400
}

.hw-layers>button.active {
  background: #254653
}

.hw-layer-bottom {
  display: grid;
  gap: .35rem;
  margin-top: auto
}

.hw-layer-bottom button {
  font-size: .75rem;
  padding: .35rem
}

.hw-mapstage {
  position: relative;
  flex: 1;
  min-width: 200px;
  overflow: hidden;
  background: #101e29
}

.hw-mapstage>canvas#hw-map {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: crosshair
}

.hw-mapstage.dragging>canvas#hw-map {
  cursor: grabbing
}

.hw-map-top {
  position: absolute;
  left: 1rem;
  top: 1rem;
  display: flex;
  gap: .8rem;
  align-items: center;
  pointer-events: none;
  color: #b7cbd0;
  font-size: .75rem
}

.hw-map-badge {
  background: #142733e8;
  border: 1px solid #44606d;
  padding: .4rem .6rem;
  border-radius: 4px;
  color: #e4eeee
}

.hw-map-actions {
  position: absolute;
  left: 1rem;
  top: 3.7rem;
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  right: .8rem;
  pointer-events: none
}

.hw-map-actions button {
  pointer-events: auto;
  background: #192d39ed;
  font-size: .75rem;
  padding: .45rem .65rem;
  box-shadow: 0 2px 10px #0002
}

.hw-map-actions button.active {
  background: #35545f;
  color: #adf4ff
}

.hw-map-bottom {
  position: absolute;
  bottom: .8rem;
  left: 1rem;
  display: flex;
  gap: 1.2rem;
  color: #b4c8d0;
  font-size: .75rem;
  pointer-events: none;
  text-shadow: 0 1px 3px #000
}

.hw-map-bottom span {
  background: #122630bd;
  padding: .3rem .5rem;
  border-radius: 3px
}

.hw-map-bottom span:last-child {
  max-width: 240px
}

#hw-minimap {
  position: absolute;
  bottom: 2.8rem;
  right: 1rem;
  width: 176px;
  height: 128px;
  border: 1px solid #5d7782;
  border-radius: 5px;
  box-shadow: 0 8px 24px #0004;
  cursor: pointer
}

.hw-route-preview {
  position: absolute;
  top: 6.8rem;
  left: 1rem;
  max-width: 440px;
  border: 1px solid #617679;
  background: #1b3039f5;
  padding: .7rem 1rem;
  border-radius: 6px;
  font-size: .875rem;
  color: #dce8e8
}

#hw-toast {
  position: absolute;
  left: 50%;
  bottom: 3.5rem;
  transform: translateX(-50%);
  max-width: 75%;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
  background: #243e4af5;
  border: 1px solid #74909a;
  border-radius: 6px;
  padding: .75rem 1rem;
  font-size: .875rem;
  box-shadow: 0 4px 20px #0004
}

#hw-toast.show {
  opacity: 1
}

#hw-toast.error {
  border-color: #ce9279;
  color: #ffd3ba
}

.hw-panel {
  width: 314px;
  flex: none;
  background: var(--hw-panel);
  border-left: 1px solid var(--hw-border);
  display: flex;
  flex-direction: column
}

.hw-panel-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--hw-border);
  padding: .6rem .45rem;
  gap: .2rem
}

.hw-panel-tabs button {
  background: transparent;
  border: 0;
  padding: .55rem .2rem
}

.hw-panel-tabs button.active {
  background: #294450
}

.hw-panel-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.15rem;
  scrollbar-width: thin;
  scrollbar-color: #45606b transparent
}

.hw-panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  border-top: 1px solid var(--hw-border);
  font-size: .75rem;
  color: var(--hw-muted)
}

.hw-panel-foot button {
  padding: .3rem .6rem;
  font-size: .75rem
}

.hw-panel-kicker {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--hw-cyan);
  margin-bottom: .65rem
}

.hw-panel-title {
  font-family: "Noto Serif SC", SimSun, serif;
  font-size: 1.7rem;
  font-weight: 500;
  line-height: 1.4
}

.hw-owner {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  color: #adbec4;
  margin-top: .6rem
}

.hw-owner i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: block
}

.hw-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem .75rem;
  margin: 1.3rem 0
}

.hw-stat-grid div {
  display: grid;
  gap: .3rem
}

.hw-stat-grid small {
  color: var(--hw-muted)
}

.hw-stat-grid strong {
  font-size: 1.25rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums
}

.hw-section {
  border-top: 1px solid var(--hw-border);
  padding-top: 1rem;
  margin-top: 1rem;
  display: grid;
  gap: .65rem
}

.hw-section h3 {
  font-size: .875rem;
  font-weight: 500;
  color: #d9e2e3
}

.hw-section p,
.hw-subtle {
  font-size: .8rem;
  line-height: 1.75;
  color: var(--hw-muted)
}

.hw-section label {
  font-size: .75rem
}

.hw-section input,
.hw-section select {
  padding: .5rem;
  font-size: .8rem
}

.hw-button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem
}

.hw-button-grid button {
  font-size: .75rem;
  padding: .6rem .35rem
}

.hw-build-button {
  display: grid;
  gap: .35rem;
  justify-items: start
}

.hw-build-button small {
  font-size: .65rem;
  color: var(--hw-muted)
}

.hw-pill {
  display: inline-block;
  border-radius: 3px;
  padding: .2rem .4rem;
  background: #2a424d;
  color: #c7e4e7;
  font-size: .7rem
}

.hw-warning {
  color: #e3ba83;
  font-size: .8rem;
  line-height: 1.6
}

.hw-city-row,
.hw-report {
  border-bottom: 1px solid #2b404b;
  padding: .9rem 0
}

.hw-city-row button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #e5eceb;
  font-size: 1rem
}

.hw-city-row p {
  font-size: .75rem;
  line-height: 1.7;
  color: var(--hw-muted);
  margin-top: .35rem
}

.hw-city-row strong {
  font-weight: 500
}

.hw-diplomat {
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--hw-border);
  padding-bottom: 1rem
}

.hw-diplomat h3 {
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  gap: .5rem;
  align-items: center
}

.hw-diplomat h3 i {
  width: 10px;
  height: 10px;
  border-radius: 50%
}

.hw-diplomat p {
  font-size: .75rem;
  line-height: 1.7;
  color: var(--hw-muted);
  margin: .4rem 0 .65rem
}

.hw-diplomat .hw-button-grid {
  gap: .35rem
}

.hw-diplomat button {
  font-size: .7rem;
  padding: .5rem .3rem
}

.hw-report small {
  color: var(--hw-cyan);
  font-size: .65rem
}

.hw-report p {
  font-size: .8rem;
  line-height: 1.7;
  color: #cad7da;
  margin-top: .3rem
}

.hw-report button {
  font-size: .7rem;
  padding: .25rem .45rem;
  margin-top: .4rem
}

.hw-clock {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: .6rem 1rem;
  border-top: 1px solid var(--hw-border);
  background: #14232d
}

.hw-clock-actions {
  display: flex;
  gap: .5rem;
  align-items: center
}

.hw-clock-actions select {
  width: 75px;
  padding: .5rem .7rem
}

.hw-tick {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  margin-left: .6rem;
  white-space: nowrap
}

.hw-tick small {
  color: var(--hw-muted)
}

.hw-tick strong {
  font-size: 1.2rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums
}

.hw-tick>span {
  font-size: .75rem;
  color: var(--hw-muted)
}

#hw-last-event {
  font-size: .8rem;
  color: #a7bdc4;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis
}

.hw-dialog {
  border: 1px solid #536c77;
  border-radius: 12px;
  background: #152731;
  color: var(--hw-text);
  padding: 0;
  box-shadow: 0 28px 110px #0009;
  max-height: 90dvh;
  overflow-y: auto
}

.hw-dialog::backdrop {
  background: #07121bb8;
  backdrop-filter: blur(7px)
}

.hw-setup {
  width: min(890px, 90vw)
}

.hw-dialog-heading {
  padding: 2rem 2.3rem 1.2rem
}

.hw-eyebrow {
  display: block;
  color: var(--hw-gold);
  font-size: .65rem;
  letter-spacing: .2em;
  margin-bottom: .9rem
}

.hw-dialog-heading h1 {
  font-family: "Noto Serif SC", SimSun, serif;
  font-size: 2.75rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: .06em
}

.hw-dialog-heading h2 {
  font-size: 1.6rem;
  font-weight: 500
}

.hw-dialog-heading p {
  font-size: .875rem;
  color: #adc0c7;
  line-height: 1.8;
  margin-top: .75rem
}

.hw-setup-grid {
  padding: .5rem 2.3rem 2rem;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 2.5rem
}

.hw-config {
  display: grid;
  gap: 1rem
}

.hw-form-row {
  display: flex;
  gap: .8rem
}

.hw-form-row>label {
  flex: 1;
  min-width: 0
}

.hw-checkbox {
  display: flex;
  align-items: center;
  gap: .6rem
}

.hw-checkbox input {
  width: 16px;
  accent-color: var(--hw-gold)
}

.hw-briefing {
  display: grid;
  gap: 1.4rem;
  padding: 1.2rem 0 .5rem;
  border-left: 1px solid #3b5360;
  padding-left: 1.5rem
}

.hw-briefing>div {
  display: grid;
  grid-template-columns: 25px 1fr;
  gap: .35rem .65rem;
  align-content: start
}

.hw-briefing span {
  color: #7d9ba7;
  font-size: .75rem;
  padding-top: .2rem
}

.hw-briefing strong {
  font-weight: 500;
  font-size: .95rem;
  color: #dfebe9
}

.hw-briefing p {
  grid-column: 2;
  line-height: 1.8;
  color: #9bb3bd;
  font-size: .8rem
}

.hw-dialog-footer {
  border-top: 1px solid #304753;
  display: flex;
  justify-content: flex-end;
  gap: .65rem;
  padding: 1rem 2.3rem;
  background: #11232c
}

.hw-small-dialog {
  width: 440px
}

.hw-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .7rem;
  padding: .5rem 2rem 1.5rem
}

.hw-menu-grid a {
  font-size: .875rem;
  padding: .6rem;
  text-align: center;
  border: 1px solid var(--hw-border);
  border-radius: 6px
}

.hw-small-dialog>.hw-subtle {
  padding: 0 2rem 1rem
}

.hw-dialog-close {
  display: block;
  margin: 1rem 2rem 1.5rem auto
}

.hw-help-dialog {
  width: 840px
}

.hw-help-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: .5rem 2rem 1rem
}

.hw-help-columns h3 {
  font-size: .95rem;
  font-weight: 500;
  color: var(--hw-gold);
  margin: .75rem 0
}

.hw-help-columns p {
  font-size: .85rem;
  line-height: 1.9;
  color: #b4c8cf;
  margin: .6rem 0
}

#hex-mobile {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
  text-align: center
}

#hex-mobile h1 {
  font-size: 1.3rem;
  font-weight: 500
}

#hex-mobile a {
  color: var(--hw-cyan);
  padding: .8rem 1.2rem;
  border: 1px solid var(--hw-border);
  border-radius: 6px
}

.hw-monogram {
  font-family: SimSun, serif;
  font-size: 3rem;
  color: var(--hw-gold);
  letter-spacing: .2em
}

.hw-empty {
  padding-top: 1rem;
  line-height: 1.9;
  font-size: .9rem;
  color: var(--hw-muted)
}

.hw-stability {
  height: 5px;
  background: #30454d;
  margin: .65rem 0 0;
  border-radius: 3px;
  overflow: hidden
}

.hw-stability span {
  display: block;
  height: 100%;
  background: #7bc3b5
}

.hw-network-note {
  font-size: .75rem;
  color: var(--hw-gold);
  line-height: 1.7
}

dialog {
  scrollbar-width: thin
}

body:has(#hex-app:not([hidden])) {
  overflow: hidden
}

@media(max-width:1150px) {
  .hw-resources {
    gap: 1rem
  }

  .hw-header {
    gap: .75rem
  }

  .hw-world-name {
    display: none
  }

  .hw-panel {
    width: 285px
  }

  .hw-map-actions {
    right: .5rem
  }

  .hw-map-bottom span:last-child {
    display: none
  }

  .hw-resources>div:nth-child(4) {
    display: none
  }
}

@media(max-height:740px) {
  .hw-dialog-heading h1 {
    font-size: 2.1rem
  }

  .hw-dialog-heading {
    padding-top: 1.3rem
  }

  .hw-setup-grid {
    padding-bottom: 1.2rem;
    gap: 1.7rem
  }

  .hw-config {
    gap: .7rem
  }

  .hw-briefing {
    gap: .9rem
  }

  .hw-layers>button {
    padding: .35rem 0
  }

  .hw-body {
    min-height: 300px
  }
}

@media(prefers-reduced-motion:reduce) {
  * {
    transition: none !important
  }
}
