header {
  background: linear-gradient(180deg, #202a35, #121b25);
  box-shadow: inset 0 1px #eef3ff12;
}

#controlPreset {
  background: #18242a;
  color: #d1dbd7;
  border: 1px solid #52646b;
  border-radius: 4px;
  padding: 7px 10px;
  cursor: pointer;
  white-space: nowrap;
}
#controlPreset:hover, #controlPreset:focus-visible { border-color: #c4e97c; }
#controlPreset[aria-pressed="true"] { background: #293827; color: #d1f590; border-color: #8ab353; }
#lockHint { color: #eac478; }
#lockHint:empty { display: none; }
.facility-status { margin: 0 8px 6px; color: #eac478; font-size: .7rem; }
.facility-status:empty { display: none; }

#joinForm .join-row + label { margin-top: 14px; }
#joinForm .join-row input:focus-visible, #joinButton:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}
.overlay { overflow-y: auto; padding-block: 16px; }

.stage > canvas {
  background: #263821;
}

.stage aside {
  background: linear-gradient(145deg, #202a32, #101820 70%);
  display: flex;
  flex-direction: column;
}

.panel {
  background: linear-gradient(165deg, #1a2731, #101820);
  border-color: #485761;
  box-shadow: inset 0 1px #e4eaff11, 0 2px 5px #0004;
}

.map-panel canvas {
  width: calc(100% - 14px);
  margin: 0 7px 7px;
  border: 1px solid #52656d;
}

.stats b { font-variant-numeric: tabular-nums; }
.stats > div { padding-block: 7px; }
.stats > .timber-shortage {
  animation: timber-shortage .4s ease-out 3;
}
@keyframes timber-shortage {
  from { background-color: #9a242b; box-shadow: inset 0 0 0 1px #ff6565; }
  to { background-color: transparent; box-shadow: inset 0 0 0 1px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .stats > .timber-shortage { animation-duration: 1s; animation-iteration-count: 1; }
}
.stage aside .map-panel, .stage aside .stats, .broadcast-form { flex: 0 0 auto; }
.stage aside .feed {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 48px;
  overflow: hidden;
}
.stage aside #feed { overflow-y: auto; }
#fuelGauge { accent-color: #e9bd64; }
#baseWorkTool:disabled, #dismantleTool:disabled { opacity: .5; cursor: default; }
.broadcast-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
  margin: 0 0 8px;
}
.broadcast-form input, .broadcast-form button {
  min-width: 0;
  font-size: .7rem;
  border: 1px solid #485761;
  border-radius: 3px;
  color: #edf2e7;
}
.broadcast-form input { background: #101820; padding: 7px 5px; }
.broadcast-form button { background: #283a2f; padding: 7px 5px; cursor: pointer; }
.broadcast-form button:disabled { opacity: .55; }
.broadcast-form p {
  grid-column: 1 / -1;
  font-size: .7rem;
  color: #ffd091;
  margin: 0;
}
.broadcast-form p:empty { display: none; }
#feed .broadcast-entry { border-color: #dfbc65; color: #f6dc97; overflow-wrap: anywhere; }
#matchCommands { padding: 0; background: none; border: 0; cursor: pointer; line-height: 1; }
#matchCommands:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }
#matchStatus.paused { border-color: var(--gold); color: var(--gold); }
#matchCommandDialog {
  width: min(390px, 90vw);
  padding: 22px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid #566b71;
  border-radius: 7px;
}
#matchCommandDialog::backdrop { background: #050a0cbd; }
#matchCommandDialog h2 { font-size: 1.15rem; margin: 0; }
#matchCommandDialog p { color: #bac9c7; font-size: .84rem; }
#matchCommandStatus { min-height: 1.2em; }
#matchCommandInput {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #566b71;
  background: #081014;
  color: var(--ink);
  font-family: monospace;
}
.match-command-buttons { display: flex; justify-content: flex-end; gap: 8px; }
.match-command-buttons button {
  padding: 7px 13px;
  border: 1px solid #566b71;
  background: #1a2a32;
  color: var(--ink);
  cursor: pointer;
}
#runMatchCommand { border-color: var(--gold); color: var(--gold); }
#game { grid-template-rows: 54px minmax(0, 1fr) 58px 26px; }
.engineer-dock {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  min-width: 0;
  background: linear-gradient(#1d2627, #101719);
  border-top: 1px solid #495150;
  box-shadow: inset 0 1px #ffffff15, 0 -5px 20px #08101370;
}
.dock-title {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  min-width: 96px;
  color: #e4ded0;
  font-size: .72rem;
  font-weight: 800;
}
.dock-title span { grid-row: span 2; align-self: center; color: #b5cb54; font-size: 1.05rem; }
#dockStatus { color: #bdcf65; font-weight: 600; }
#dockStatus[data-phase]:not([data-phase=""]) { color: #ffbf57; }
#toolbar {
  flex: 0 1 auto;
  gap: 5px;
  min-width: 0;
  overflow-x: auto;
  padding: 2px;
  background: transparent;
  border: 0;
  scrollbar-width: thin;
}
#toolbar button {
  display: grid;
  grid-template-columns: 28px auto auto;
  align-items: center;
  column-gap: 4px;
  flex: 0 0 auto;
  min-height: 39px;
  max-width: none;
  min-width: 86px;
  padding: 3px 8px 6px;
  border-radius: 5px;
  border-color: #495353;
  background: linear-gradient(#273031, #171e20);
  color: #e5dfcf;
  box-shadow: inset 0 1px #ffffff24, 0 2px 2px #050809aa;
  font-size: .71rem;
  letter-spacing: 0;
}
#toolbar button:not(:disabled):hover, #toolbar button.active {
  background: linear-gradient(#26372e, #15221c);
  border-color: #aac55d;
}
#toolbar button:focus-visible { outline: 2px solid #bbdc71; outline-offset: -2px; }
#toolbar button:disabled { opacity: .48; cursor: default; }
#toolbar button .tool-icon { display: grid; place-items: center; }
#toolbar canvas { width: 29px; height: 20px; filter: grayscale(.84) sepia(.32); }
#toolbar kbd { justify-self: end; color: #a4ad9e; font: 600 .60rem ui-monospace, monospace; }
#toolbar button .tool-timer { display: none; color: #ffcf74; font-size: .67rem; font-variant-numeric: tabular-nums; }
#toolbar button .tool-progress {
  position: absolute;
  inset: auto 6px 3px;
  height: 3px;
  border-radius: 3px;
  background: #574329;
  display: none;
  overflow: hidden;
}
#toolbar button[data-phase]:not([data-phase=""]) {
  opacity: 1;
  border-color: #efac41;
  background: linear-gradient(#49351e, #282017);
  color: #fff0ce;
  box-shadow: inset 0 0 9px #ffbf4033, 0 0 7px #ffab2b44;
}
#toolbar button[data-phase]:not([data-phase=""]) .tool-progress { display: block; }
#toolbar button[data-phase="working"] .tool-timer { display: inline; }
#toolbar button[data-phase="working"] kbd { display: none; }
#toolbar .tool-progress::before {
  content: "";
  display: block;
  width: var(--job-progress, 0%);
  height: 100%;
  background: repeating-linear-gradient(100deg, #ed9b2c 0 8px, #ffcf6e 9px 11px, #ed9b2c 18px);
  background-size: 54px 100%;
  transition: width .10s linear;
  animation: engineer-sweep .8s linear infinite;
}
#toolbar [data-phase="outbound"] .tool-progress::before,
#toolbar [data-phase="returning"] .tool-progress::before {
  width: 36%;
  animation: engineer-travel 1.3s ease-in-out infinite alternate;
}
@keyframes engineer-sweep { to { background-position: 54px 0; } }
@keyframes engineer-travel { to { transform: translateX(178%); } }
@media (prefers-reduced-motion: reduce) {
  #toolbar button .tool-progress::before { animation: none; transition: none; }
}
@media (max-width: 800px) {
  .status #players { display: none; }
  .stage aside { top: 48px; }
  #game { grid-template-rows: 48px minmax(0, 1fr) 58px; }
  .engineer-dock { justify-content: flex-start; padding-inline: 5px; gap: 6px; }
  .dock-title { min-width: 58px; grid-template-columns: 1fr; gap: 2px; }
  .dock-title span { display: none; }
  #toolbar button { min-width: 76px; padding-inline: 4px; grid-template-columns: 23px auto auto; }
  #toolbar canvas { width: 23px; height: 16px; }
}
