html,
body {
  margin: 0;
  height: 100%;
  font:
    13px/1.4 system-ui,
    sans-serif;
}
#map {
  position: absolute;
  inset: 0;
}
#panel {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 300px;
  max-width: calc(100vw - 44px);
  max-height: calc(100vh - 44px);
  overflow-y: auto;
  background: #fffe;
  border-radius: 8px;
  box-shadow: 0 2px 10px #0003;
  padding: 10px 12px;
}
#panel h1 {
  font-size: 15px;
  margin: 0 0 6px;
}
#panel label {
  display: block;
  margin: 6px 0;
}
#panel select,
#panel input[type="range"] {
  width: 100%;
}
#panel button {
  margin: 6px 4px 0 0;
}
#shareControls {
  flex-basis: 100%;
  max-width: 300px;
}
#debugLink {
  box-sizing: border-box;
  width: 100%;
  margin-top: 6px;
}
#status {
  font-weight: 700;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  margin: 6px 0;
}
.s-Normal {
  background: #d6f5d6;
}
.s-Grace {
  background: #ffe9b3;
}
.s-Arrived {
  background: #cde3ff;
}
.s-FollowRoute {
  background: #ffd2a6;
}
.s-Exited,
.s-Unreachable,
.s-NoStart,
.s-NoDestination {
  background: #ffd0d0;
}
.s-NoTrip {
  background: #eee;
}
#walkingTime {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
#walkingTrend {
  font-size: 12px;
  margin-top: 2px;
  min-height: 1.4em;
}
#walkingEstimate.decreasing {
  color: #15803d;
}
#walkingEstimate.increasing {
  color: #b91c1c;
}
table {
  width: 100%;
  border-collapse: collapse;
}
td {
  padding: 1px 0;
}
td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.hint {
  color: #666;
  font-size: 12px;
}
#hint:empty {
  display: none;
}
[hidden] {
  display: none !important;
}
button {
  font: inherit;
  cursor: pointer;
}
button:disabled {
  cursor: default;
}
button:focus-visible,
summary:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 3px;
}
#simulationControls {
  display: flex;
  align-items: center;
  gap: 6px;
  position: sticky;
  top: -10px;
  z-index: 1;
  background: #fff;
  padding: 8px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid #ddd;
}
#simulationControls strong {
  margin-right: auto;
}
#simulationControls button {
  margin: 0;
  width: 36px;
  height: 36px;
  font-size: 18px;
}
#mapControls {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 40px);
  background: #fffe;
  border-radius: 8px;
  box-shadow: 0 2px 10px #0003;
  padding: 6px 10px;
}
#mapControls[hidden] {
  display: none;
}
#mapControls button {
  width: 36px;
  height: 36px;
  font-size: 18px;
}
.detour-text {
  display: flex;
  flex-direction: column;
  margin-left: 4px;
}
#detourHint {
  font-weight: 600;
}
#detourNote {
  color: #555;
}
#tripDiagnostics {
  border-top: 1px solid #ddd;
  margin-top: 12px;
  padding-top: 8px;
}
#tripDiagnostics table {
  font-size: 12px;
  margin-top: 8px;
}
#tripBudget {
  margin-top: 12px;
  padding: 10px 0;
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
}
#tripBudget h2 {
  font-size: 13px;
  margin: 0 0 6px;
}
#budgetExplanation {
  background: #fff0d4;
  color: #754716;
  padding: 8px;
  border-radius: 4px;
  margin: 8px 0 0;
}
.map-key {
  display: inline-block;
  width: 18px;
  height: 10px;
  vertical-align: middle;
  margin-right: 4px;
}
.original-key {
  border: 1px dashed #c9ba81;
  box-sizing: border-box;
}
.current-key {
  background: #14b8a64d;
}
.lost-key {
  background: repeating-linear-gradient(
    135deg,
    transparent 0 3px,
    #94a3b8 3px 4px
  );
}
#areaStatus {
  min-height: 1.4em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.budget-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 10px;
}
#budgetBar {
  position: relative;
  display: flex;
  height: 16px;
  border-radius: 3px;
  overflow: hidden;
  background: #e2e8f0;
}
#budgetUsed,
.used-key {
  background: #94a3b8;
}
#budgetNeeded,
.needed-key {
  background: #2563eb;
}
#budgetFree {
  background: #14b8a6;
}
#budgetOver {
  background: #dc2626;
}
#budgetLimit {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #111827;
}
.budget-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.budget-values > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.budget-values strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.budget-values span {
  font-size: 12px;
}
.budget-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
}
#allowanceLabel::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  background: #14b8a6;
}
.over-budget #allowanceLabel::before {
  background: #dc2626;
}
.over-budget strong {
  color: #b91c1c;
}
#budgetAdjustment {
  margin-top: 8px;
}
#initialBudget {
  font-variant-numeric: tabular-nums;
}
.route-key {
  height: 0;
  border-top: 3px dashed #6d28d9;
}
.trace-key {
  height: 0;
  border-top: 2px solid #64748b;
  opacity: 0.7;
}
.area-key {
  background: rgba(245, 158, 11, 0.25);
  border: 1.5px solid #f59e0b;
}
.leg-key {
  height: 0;
  border-top: 3px dotted #6d28d9;
}
#legend {
  margin: 6px 0 10px;
}
#legend.inactive {
  opacity: 0.4;
}

.legend-bar {
  height: 8px;
  margin-top: 4px;
  border-radius: 4px;
  background: linear-gradient(to right, #2563eb 0%, #14b8a6 25%, #f59e0b 100%);
}

.legend-labels {
  position: relative;
  height: 18px;
}

.legend-labels span {
  position: absolute;
}

.legend-labels span:nth-child(2) {
  left: 25%;
  transform: translateX(-50%);
}

.legend-labels span:last-child {
  right: 0;
}

.unavailable-key {
  background: #ffe08a;
}
