/*
MIT License

Copyright (c) 2026 mr-highball

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

:root {
  font-family: Inter, 'Segoe UI', sans-serif;
  color: #233b3b;
  background: #cbc6aa;
  font-synthesis: none;
  --ink: #233b3b;
  --paper: #f5f0de;
  --orange: #c75a2d;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  overflow: hidden;
}
button,
input,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  color: var(--ink);
  border: 1px solid #233b3b25;
  border-radius: 9px;
  background: #f4efdf;
  min-height: 44px;
  padding: 10px 15px;
}
button:hover {
  filter: brightness(1.04);
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
button:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid #268b8b;
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
a {
  color: inherit;
}
#game {
  height: 100dvh;
  min-height: 430px;
  position: relative;
  isolation: isolate;
}
#world {
  position: absolute;
  border: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: #ccc5a8;
}
.topbar {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(12px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px
    max(18px, env(safe-area-inset-left));
  background: linear-gradient(#f4efdf, #f4efdfcc, transparent);
}
.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  gap: 10px;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: -1.5px;
}
.brand > span {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 1px;
}
.resources {
  display: flex;
  gap: 16px;
  margin-left: auto;
  font-size: 17px;
}
.resources > span {
  background: #f5f0dedb;
  border: 1px solid #233b3b15;
  padding: 7px 12px;
  border-radius: 20px;
}
.resources > span:last-child {
  color: #a06b1a;
}
.icon {
  width: 44px;
  padding: 0;
  font-size: 23px;
}
.dispatch {
  position: absolute;
  left: 22px;
  top: 88px;
  width: 270px;
  padding: 16px 18px;
  background: #f6f1dfe8;
  border-radius: 3px 14px 14px 14px;
  box-shadow: 0 4px 20px #27392d0b;
  border-left: 4px solid var(--orange);
  pointer-events: none;
}
.dispatch-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 9px;
  letter-spacing: 1.2px;
  font-weight: 800;
  text-transform: uppercase;
  color: #677363;
}
.dispatch h1 {
  font-size: 21px;
  line-height: 1.15;
  margin: 9px 0 16px;
  letter-spacing: -0.6px;
}
.order-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}
.order-line b {
  white-space: nowrap;
}
.progress {
  height: 5px;
  background: #263e3b18;
  border-radius: 8px;
  margin-top: 10px;
  overflow: hidden;
}
.progress i {
  display: block;
  background: var(--orange);
  height: 100%;
  width: 0;
  transition: width 0.35s;
}
.camera-controls {
  position: absolute;
  right: 20px;
  top: 45%;
  display: grid;
  gap: 5px;
}
.camera-controls button {
  width: 44px;
  font-size: 20px;
  padding: 0;
  background: #f5f0ded9;
}
.dock {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 36px));
  border: 1px solid #fff8;
  background: #f7f2e3f5;
  border-radius: 16px;
  padding: 12px 16px 16px;
  box-shadow: 0 8px 40px #263e3b22;
  backdrop-filter: blur(10px);
}
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
}
.status > span {
  font-size: 9px;
  letter-spacing: 1.5px;
  font-weight: 800;
  color: #678477;
  flex: 1;
}
.status button {
  min-height: 30px;
  padding: 3px 8px;
  font-size: 12px;
  border: 0;
  background: transparent;
}
#status-text {
  font-size: 13px;
  line-height: 1.4;
  min-height: 36px;
  margin: 6px 0 9px;
}
.tools {
  display: flex;
  gap: 5px;
  margin-bottom: 9px;
}
.tools button {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 12px;
  padding: 7px 5px;
  white-space: nowrap;
}
.tools button > span {
  font-size: 21px;
  vertical-align: middle;
  margin-right: 4px;
}
.tools small {
  font-size: 9px;
  opacity: 0.7;
}
body[data-tool='inspect'] #inspect-tool,
body[data-tool='clear'] #clear-tool,
body[data-tool='route'] #route-button,
body[data-tool='move'] #move-tool {
  background: #dce5d2;
  box-shadow: inset 0 0 0 1px #abc1a5;
}
.primary {
  display: block;
  width: 100%;
  border: 0;
  background: var(--orange);
  color: #fff9e9;
  min-height: 52px;
  box-shadow: 0 3px 0 #994a28;
  font-size: 15px;
  letter-spacing: 0.1px;
}
.secondary {
  width: 100%;
  background: #dce5d2;
  min-height: 48px;
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #172e2d60;
  backdrop-filter: blur(5px);
  z-index: 10;
}
.dialog,
.start-card {
  width: min(420px, 100%);
  border-radius: 18px;
  padding: 28px;
  background: var(--paper);
  box-shadow: 0 20px 100px #172e2d44;
  max-height: calc(100dvh - 40px);
  overflow: auto;
}
.dialog h2 {
  font-size: 29px;
  letter-spacing: -1px;
  margin: 10px 0;
}
.dialog p {
  font-size: 14px;
  line-height: 1.6;
  color: #617065;
}
.dialog small,
.start-card > small {
  display: block;
  color: #718074;
  font-size: 11px;
  line-height: 1.5;
  margin-top: 16px;
}
.start {
  background: #233b3b33;
  backdrop-filter: blur(3px);
}
.start-card {
  text-align: center;
  padding: 30px 32px;
}
.eyebrow {
  font-size: 8px;
  letter-spacing: 1.8px;
  font-weight: 800;
}
.road-mark {
  width: 68px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 22px auto 15px;
  background: var(--ink);
  color: var(--paper);
  font-size: 35px;
  letter-spacing: -4px;
  font-weight: 900;
  border-radius: 12px 12px 3px 3px;
  box-shadow:
    -11px 8px 0 -5px #aebaa5,
    11px 8px 0 -5px #aebaa5;
}
.start-card h2 {
  font-size: 48px;
  line-height: 0.97;
  letter-spacing: -2.5px;
  margin: 24px 0 18px;
  font-weight: 800;
}
.start-card h2 em {
  font-family: Georgia, serif;
  color: var(--orange);
  font-weight: 400;
  letter-spacing: -2px;
}
.start-card p {
  font-size: 15px;
  line-height: 1.5;
  margin: 12px auto;
  color: #637364;
  max-width: 260px;
}
.start-steps {
  display: grid;
  gap: 9px;
  margin: 25px 0;
  text-align: left;
  font-size: 13px;
}
.start-steps b {
  display: inline-block;
  width: 30px;
  font-size: 10px;
  color: var(--orange);
}
.sound-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 12px;
  margin-bottom: 18px;
  min-height: 36px;
  cursor: pointer;
}
input[type='checkbox'] {
  accent-color: var(--ink);
  width: 18px;
  height: 18px;
}
.compact {
  text-align: center;
}
.spinner {
  display: inline-block;
  width: 25px;
  height: 25px;
  border: 3px solid #b8c4ad;
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.world-loading {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: 12px;
  background: var(--paper);
  padding: 16px;
  font-size: 12px;
  white-space: nowrap;
}
.reward {
  text-align: center;
}
.win-stars {
  font-size: 36px;
  color: #c68f34;
  letter-spacing: 6px;
}
.reward button {
  margin-top: 12px;
}
.road {
  font-size: 36px;
  color: #c68f34;
  letter-spacing: 8px;
}
.menu-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.menu-title h2 {
  font-size: 25px;
}
.menu > button {
  width: 100%;
  margin-top: 9px;
}
.menu .radio {
  display: grid;
  gap: 12px;
  grid-template-columns: auto 1fr;
  padding: 15px 0 20px;
  border-bottom: 1px solid #233b3b20;
}
.radio button,
.radio small {
  grid-column: 1/-1;
}
.radio small {
  margin: 0;
}
.radio label {
  font-size: 13px;
}
.radio input {
  width: 100%;
  accent-color: #33776e;
}
.menu details {
  font-size: 12px;
  margin-top: 20px;
}
.menu summary {
  cursor: pointer;
  min-height: 35px;
  padding-top: 8px;
  font-weight: 650;
}
.menu details p {
  font-size: 12px;
}
.text-button {
  border: 0;
  background: transparent;
  color: #a65b3c;
}
.floating-card {
  position: absolute;
  bottom: 270px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 13px 50px 13px 18px;
  border-radius: 12px;
  min-width: 250px;
  max-width: calc(100% - 36px);
  font-size: 13px;
}
.floating-card span {
  display: block;
  font-size: 11px;
  margin-top: 5px;
  color: #c1cdb9;
}
.floating-card .icon {
  position: absolute;
  right: 5px;
  top: 5px;
  background: transparent;
  border: 0;
  color: var(--paper);
}
.floating-card button:not(.icon) {
  margin-top: 12px;
}
.storm {
  position: absolute;
  top: 225px;
  left: 22px;
  background: #c75a2d;
  color: white;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
}
@media (min-width: 1000px) {
  .dock {
    left: 22px;
    transform: none;
    width: 320px;
  }
  .dispatch {
    width: 320px;
  }
  .floating-card {
    left: 22px;
    transform: none;
  }
  .camera-controls {
    right: 25px;
  }
  .topbar {
    padding-left: 25px;
    padding-right: 25px;
  }
}
@media (max-width: 600px) {
  .topbar {
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    gap: 8px;
  }
  .brand > span {
    font-size: 10px;
    letter-spacing: 0.6px;
  }
  .brand {
    font-size: 25px;
    gap: 7px;
  }
  .resources {
    gap: 6px;
    font-size: 13px;
  }
  .resources > span {
    padding: 6px 9px;
  }
  .dispatch {
    top: calc(68px + env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    width: auto;
    padding: 11px 14px;
  }
  .dispatch h1 {
    font-size: 19px;
    margin: 6px 0 10px;
  }
  .dispatch-top {
    font-size: 8px;
  }
  .dock {
    bottom: max(8px, env(safe-area-inset-bottom));
    width: calc(100% - 16px);
    padding: 9px 12px 12px;
    border-radius: 14px;
  }
  .camera-controls {
    right: 12px;
    top: 38%;
    gap: 4px;
  }
  .camera-controls button {
    width: 44px;
    min-height: 44px;
  }
  .floating-card {
    bottom: 245px;
  }
  .storm {
    top: 205px;
    left: 12px;
  }
  .start-card {
    padding: 25px;
  }
  .start-card h2 {
    font-size: 44px;
  }
  .start-card .road-mark {
    margin-top: 18px;
  }
  .overlay {
    padding: 14px;
  }
  .dialog {
    padding: 24px;
  }
  .tools button {
    font-size: 11px;
  }
  #status-text {
    font-size: 12px;
  }
  .primary {
    min-height: 49px;
  }
}
@media (max-height: 550px) and (orientation: landscape) {
  .dispatch {
    top: 65px;
    left: 12px;
    width: 230px;
    padding: 10px;
  }
  .dispatch h1 {
    font-size: 17px;
    margin: 6px 0;
  }
  .dock {
    left: auto;
    right: 12px;
    transform: none;
    width: 260px;
    bottom: 12px;
    padding: 8px 10px 10px;
  }
  .dock .status {
    min-height: 20px;
  }
  #status-text {
    margin: 4px 0;
    min-height: 32px;
    font-size: 11px;
  }
  .tools {
    margin-bottom: 5px;
  }
  .tools button {
    min-height: 44px;
    font-size: 10px;
  }
  .primary {
    min-height: 44px;
  }
  .camera-controls {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: auto;
    display: flex;
  }
  .floating-card {
    left: 12px;
    transform: none;
    bottom: 65px;
  }
  .start-card {
    width: 560px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 25px;
    padding: 20px 28px;
    text-align: left;
  }
  .start-card .eyebrow {
    grid-column: 1/-1;
  }
  .start-card .road-mark {
    display: none;
  }
  .start-card h2 {
    grid-column: 1;
    grid-row: 2/4;
    font-size: 44px;
    margin: 20px 0;
  }
  .start-card p {
    grid-column: 2;
    grid-row: 2;
    margin: 12px 0;
    font-size: 13px;
  }
  .start-steps {
    grid-column: 2;
    grid-row: 3;
    margin: 6px 0 12px;
  }
  .sound-choice {
    grid-column: 1;
    grid-row: 4;
    margin: 0;
    justify-content: flex-start;
  }
  .start-card .primary {
    grid-column: 2;
    grid-row: 4;
  }
  .start-card > small {
    grid-column: 1/-1;
    margin-top: 14px;
  }
  .storm {
    top: 185px;
  }
  .world-loading {
    top: 52%;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation-duration: 0.001ms !important;
    transition: none !important;
  }
}
#tile-hint {
  position: absolute;
  transform: translate(-50%, -140%);
  background: #f6c15d;
  color: #463c28;
  border: 2px solid #fff0c8;
  border-radius: 20px;
  min-height: 44px;
  font-size: 12px;
  box-shadow: 0 4px 15px #453b2433;
  z-index: 2;
}
#tile-hint:after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: calc(50% - 8px);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid #f6c15d;
}
@media (max-height: 550px) {
  #game {
    min-height: 0;
  }
}
.quick-radio {
  opacity: 0.55;
}
.quick-radio[aria-pressed='true'] {
  opacity: 1;
  background: #dce5d2;
  color: #27786c;
}
@media (max-width: 360px) {
  .brand > span {
    display: none;
  }
  .resources {
    gap: 4px;
  }
  .resources > span {
    padding: 6px 8px;
  }
}
@media (max-width: 600px) {
  .brand > span {
    display: none;
  }
  .topbar .icon {
    flex-shrink: 0;
  }
}
.trial-progress {
  font-size: 11px;
  font-weight: 800;
  margin-top: 10px;
  color: #b6603d;
}
.next-step {
  font-size: 11px;
  line-height: 1.4;
  margin: 7px 0;
}
.flow-chain {
  font-size: 8px;
  letter-spacing: 1px;
  color: #6c7d71;
}
.challenge {
  width: 100%;
  min-height: 38px;
  margin-bottom: 6px;
  background: #e5bf73;
  color: #574224;
  border: 0;
  font-size: 12px;
}
.conflict-card,
.preview-card {
  position: absolute;
  left: 365px;
  top: 88px;
  max-width: 360px;
  background: #fff4e7f0;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 12px;
  border-left: 4px solid #d26444;
  box-shadow: 0 4px 20px #253c3320;
}
.conflict-card span,
.preview-card span {
  display: block;
  margin-top: 7px;
  line-height: 1.4;
}
.preview-card {
  border-color: #49a982;
}
.preview-card button {
  margin-top: 8px;
  min-height: 38px;
}
.key {
  display: inline-block;
  width: 16px;
  height: 4px;
  vertical-align: middle;
  margin-left: 8px;
}
.key.old {
  background: #ee694b;
}
.key.new {
  background: #54d8aa;
}
body[data-tool='jam'] #jam-tool {
  background: #f0c9a8;
  box-shadow: inset 0 0 0 1px #c58163;
}
.tools button {
  white-space: normal;
  font-size: 11px;
}
.tools button > span {
  display: block;
  margin: 0;
  line-height: 20px;
}
.tools small {
  display: none;
}
@media (max-width: 999px) {
  .conflict-card,
  .preview-card {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 295px;
    max-width: none;
    font-size: 11px;
    padding: 10px 13px;
  }
  .dispatch {
    width: 300px;
  }
  .dock {
    padding-top: 8px;
  }
  .floating-card {
    bottom: 295px;
  }
}
@media (max-width: 600px) {
  .dispatch {
    width: auto;
  }
  .next-step {
    font-size: 10px;
  }
  .trial-progress {
    font-size: 10px;
  }
  .flow-chain {
    font-size: 7px;
  }
  .dispatch h1 {
    font-size: 17px;
    margin-bottom: 6px;
  }
  .conflict-card,
  .preview-card {
    bottom: 275px;
  }
  .tools button {
    padding: 4px 2px;
    min-height: 44px;
  }
  .challenge {
    min-height: 36px;
  }
  #status-text {
    min-height: 30px;
    font-size: 11px;
  }
  .dock {
    padding: 7px 10px 10px;
  }
  .camera-controls {
    top: 43%;
  }
}
@media (max-height: 550px) and (orientation: landscape) {
  .dispatch {
    width: 220px;
  }
  .next-step {
    display: none;
  }
  .conflict-card,
  .preview-card {
    left: 12px;
    right: auto;
    top: 235px;
    bottom: auto;
    width: 220px;
    max-height: 140px;
    overflow: auto;
    font-size: 10px;
  }
  .dock {
    width: 265px;
  }
  .flow-chain {
    display: none;
  }
  .tools button > span {
    display: inline;
    font-size: 16px;
  }
  .trial-progress {
    font-size: 9px;
  }
  .challenge {
    min-height: 32px;
  }
}
body[data-preview='true'] #tile-hint {
  display: none;
}
.challenge,
.preview-card button {
  min-height: 44px;
}
body[data-needs-build='true'] .next-step {
  display: none;
}
@media (max-width: 999px) {
  body[data-needs-build='true'] .conflict-card,
  body[data-preview='true'] .preview-card {
    bottom: 225px;
  }
}
@media (max-height: 550px) and (orientation: landscape) {
  body[data-needs-build='true'] .conflict-card,
  body[data-preview='true'] .preview-card {
    top: 205px;
    bottom: auto;
  }
}
.conflict-card button {
  min-height: 44px;
  margin-top: 8px;
  font-size: 11px;
  padding: 7px 12px;
  background: #efddba;
  border-color: #d6be92;
}
