:root {
  --desktop-green: #2f6b4f;
  --desktop-grid: rgba(255, 255, 255, 0.045);
  --canvas-border: #1d3327;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 760px;
  min-height: 100%;
  margin: 0;
}

body {
  background-color: var(--desktop-green);
  background-image:
    linear-gradient(var(--desktop-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--desktop-grid) 1px, transparent 1px);
  background-size: 8px 8px;
}

button,
canvas {
  image-rendering: pixelated;
}

.desktop {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.game-window {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 1;
  display: flex;
  width: 598px;
  height: 666px;
  min-width: 598px;
  min-height: 666px;
  flex-direction: column;
  transform: translate(-50%, -50%);
  overflow: hidden;
  resize: both;
}

.menu-bar {
  display: flex;
  gap: 2px;
  padding: 2px 3px 0;
}

.menu-bar button {
  min-width: 0;
  padding: 2px 8px;
  border-color: transparent;
  box-shadow: none;
}

.contextual-actions {
  display: flex;
  gap: 2px;
}

.contextual-actions[hidden] {
  display: none;
}

.contextual-actions button {
  font-weight: 700;
}

.sound-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 2px 5px;
  white-space: nowrap;
}

.speed-controls {
  display: flex;
  gap: 1px;
  margin-left: auto;
}

.speed-controls button[aria-pressed="true"] {
  border-color: #808080 #fff #fff #808080;
  background: #dfdfdf;
  box-shadow: inset 1px 1px #000;
}

.game-layout {
  display: grid;
  grid-template-rows: auto minmax(480px, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
  flex: 1;
  gap: 6px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 4px;
}

.status-strip span {
  padding: 3px 5px;
  border: 1px inset #fff;
  background: #c0c0c0;
}

.canvas-stage {
  position: relative;
  width: 100%;
  min-width: 576px;
  min-height: 480px;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px inset var(--canvas-border);
  background: #6da84d;
  cursor: crosshair;
}

.scene-transition {
  position: absolute;
  z-index: 5;
  inset: 2px;
  display: grid;
  place-items: center;
  background: #17131c;
  color: #fff4cf;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease-in-out;
}

.scene-transition[hidden] {
  display: none;
}

.scene-transition.is-opaque {
  opacity: 1;
}

.scene-transition.is-dimmed {
  opacity: 0.48;
}

.scene-transition span {
  font-family: Georgia, serif;
  font-size: 28px;
}

.scene-transition[data-mode="waiting"] span {
  font-size: 18px;
}

.scene-transition[data-mode="morning"] {
  background: #f6d68a;
  color: #49351f;
}

@media (prefers-reduced-motion: reduce) {
  .scene-transition {
    transition-duration: 0.01ms;
  }
}

.hotbar {
  display: grid;
  grid-template-columns: repeat(10, 52px);
  justify-content: center;
  gap: 3px;
  min-height: 52px;
}

.hotbar button {
  position: relative;
  display: grid;
  min-width: 52px;
  height: 52px;
  place-items: center;
  padding: 4px;
  overflow: hidden;
}

.day-summary-window {
  position: fixed;
  z-index: 40;
  top: 50%;
  left: 50%;
  width: 460px;
  transform: translate(-50%, -50%);
}

.sign-window {
  position: fixed;
  z-index: 25;
  top: 50%;
  left: 50%;
  width: 430px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 32px);
  transform: translate(-50%, -50%);
  overflow: hidden;
}

.sign-window > .title-bar {
  cursor: move;
  touch-action: none;
  user-select: none;
}

.sign-window-body {
  max-height: calc(100vh - 70px);
  overflow: auto;
}

.sign-message-view {
  min-height: 190px;
  padding: 18px 22px;
  border: 3px double #6b4a24;
  outline: 1px solid #31200e;
  background-color: #f5df9c;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 15px, rgba(92, 57, 18, 0.08) 16px),
    linear-gradient(90deg, rgba(112, 72, 24, 0.12), transparent 12%, transparent 88%, rgba(112, 72, 24, 0.12));
  color: #2b1a0c;
  cursor: text;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  line-height: 1.45;
}

.sign-message-view:focus {
  outline: 2px dotted #000;
  outline-offset: -6px;
}

.sign-message-view h1,
.sign-message-view h2,
.sign-message-view h3 {
  margin: 0 0 8px;
  letter-spacing: 0;
  line-height: 1.15;
}

.sign-message-view h1 {
  font-size: 22px;
}

.sign-message-view h2 {
  font-size: 18px;
}

.sign-message-view h3 {
  font-size: 15px;
}

.sign-message-view p,
.sign-message-view ul {
  margin: 7px 0;
}

.sign-message-view code {
  padding: 0 2px;
  background: rgba(255, 255, 255, 0.35);
}

.sign-editor {
  display: grid;
  gap: 7px;
}

.sign-editor[hidden],
.sign-message-view[hidden] {
  display: none;
}

.sign-editor textarea {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.sign-editor-status {
  min-height: 14px;
  margin: 0;
}

.sign-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.webmcp-warning-window {
  position: fixed;
  z-index: 45;
  top: 50%;
  left: 50%;
  width: 470px;
  max-width: calc(100vw - 16px);
  transform: translate(-50%, -50%);
}

.webmcp-warning-window > .title-bar {
  cursor: move;
  touch-action: none;
  user-select: none;
}

.webmcp-warning-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.webmcp-warning-message {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.webmcp-warning-message p {
  margin: 0 0 8px;
  line-height: 1.35;
}

.warning-triangle {
  position: relative;
  display: block;
  width: 0;
  height: 0;
  margin: 2px auto 0;
  border-right: 24px solid transparent;
  border-bottom: 43px solid #000;
  border-left: 24px solid transparent;
}

.warning-triangle::after {
  position: absolute;
  z-index: 0;
  top: 5px;
  left: -19px;
  width: 0;
  height: 0;
  border-right: 19px solid transparent;
  border-bottom: 34px solid #ffd600;
  border-left: 19px solid transparent;
  content: "";
}

.warning-triangle span {
  position: absolute;
  z-index: 1;
  top: 14px;
  left: -3px;
  font-family: Arial, sans-serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.webmcp-warning-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.webmcp-warning-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.webmcp-warning-actions button {
  min-width: 150px;
}

.help-window {
  position: fixed;
  z-index: 30;
  top: 50%;
  left: 50%;
  width: 520px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 32px);
  transform: translate(-50%, -50%);
  overflow: hidden;
}

.help-window > .title-bar {
  cursor: move;
  touch-action: none;
  user-select: none;
}

.help-body {
  display: grid;
  max-height: calc(100vh - 70px);
  gap: 10px;
  overflow: auto;
}

.help-body section {
  padding-bottom: 8px;
  border-bottom: 1px solid #808080;
}

.help-body section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.help-body h2 {
  margin: 0 0 5px;
  font-size: 13px;
  letter-spacing: 0;
}

.help-body p,
.help-body ol {
  margin: 4px 0;
  line-height: 1.35;
}

.webmcp-help-status {
  padding: 6px;
  border: 1px inset #fff;
  background: #fff;
}

.webmcp-help-status[data-state="enabled"] {
  background: #d9f2d0;
}

.webmcp-help-status[data-state="error"] {
  background: #fff0c8;
}

.help-controls {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 3px 8px;
  margin: 6px 0 0;
}

.help-controls dt {
  font-weight: 700;
}

.help-controls dd {
  margin: 0;
}

.sleep-anyway-window {
  position: fixed;
  z-index: 35;
  top: 50%;
  left: 50%;
  width: 360px;
  max-width: calc(100vw - 16px);
  transform: translate(-50%, -50%);
}

.sleep-anyway-body p {
  margin: 4px 0 8px;
}

.sleep-anyway-status {
  min-height: 24px;
  padding: 4px 6px;
  border: 1px inset #fff;
  background: #fff;
}

.sleep-anyway-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.day-summary-body {
  display: grid;
  gap: 10px;
}

.day-summary-actors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.day-summary-actors section {
  padding: 6px;
  border: 1px inset #fff;
}

.day-summary-body h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.day-summary-body dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  margin: 0;
}

.day-summary-body dt,
.day-summary-body dd {
  margin: 0;
}

.day-summary-body dd {
  font-weight: 700;
  text-align: right;
}

#day-summary-continue-button {
  justify-self: end;
  min-width: 130px;
}

.robot-testing button {
  margin-top: 6px;
}

.robot-testing .speed-controls {
  margin: 6px 0;
}

.robot-testing p {
  margin: 6px 0 0;
}

.mcp-description {
  margin: 4px 0 8px;
  padding: 6px;
  border: 1px inset #fff;
}

.storage-context {
  display: flex;
  justify-content: space-between;
  padding: 5px 7px;
  border: 1px inset #fff;
}

.hotbar button[aria-pressed="true"] {
  outline: 2px solid #001f7a;
  outline-offset: -4px;
}

.slot-key {
  position: absolute;
  top: 3px;
  left: 5px;
  font-weight: 700;
}

.slot-item {
  position: absolute;
  right: 4px;
  bottom: 3px;
  font-weight: 700;
  text-shadow: 1px 1px #fff;
}

.slot-icon {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  object-fit: contain;
}

.status-bar {
  margin: 0;
}

.market-window {
  --window-top: clamp(8px, calc((100vh - 560px) / 2), 84px);
  position: fixed;
  top: var(--window-top);
  left: 50%;
  z-index: 10;
  display: flex;
  width: 480px;
  height: min(560px, calc(100vh - 32px));
  min-width: min(420px, calc(100vw - 16px));
  min-height: 360px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - var(--window-top) - 8px);
  flex-direction: column;
  transform: translateX(-50%);
  overflow: hidden;
  resize: both;
}

.market-window[hidden] {
  display: none;
}

.market-body {
  display: grid;
  grid-template-rows: auto minmax(100px, 1fr) minmax(100px, 1fr) auto;
  min-height: 0;
  flex: 1;
  gap: 8px;
  padding-bottom: 14px;
  overflow: hidden;
}

.market-wallet {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px inset #fff;
  background: #fff;
}

.market-items {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 0;
  padding-right: 3px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.market-item-copy small {
  display: block;
}

.market-wallet img {
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
}

.market-wallet strong {
  font-size: 14px;
}

.market-body fieldset {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.market-body fieldset .market-items {
  flex: 1;
}

.market-item-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 54px 58px;
  min-height: 58px;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border: 1px solid #a0a0a0;
  background: #dfdfdf;
  text-align: left;
}

.market-item-copy {
  display: grid;
  gap: 3px;
}

.market-item-copy small {
  color: #404040;
}

.market-trade {
  display: grid;
  justify-items: stretch;
  gap: 3px;
}

.market-price {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}

.market-price img {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
}

.market-command-button {
  width: 58px;
  min-width: 58px;
}

.market-item-row:has(.market-command-button:disabled) .market-item-copy small {
  color: #808080;
}

.storage-window {
  position: fixed;
  top: 84px;
  left: 50%;
  z-index: 10;
  width: 520px;
  max-width: calc(100vw - 16px);
  transform: translateX(-50%);
}

.storage-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.storage-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.storage-body > label,
.storage-body > select,
.storage-body > .status-bar {
  grid-column: 1 / -1;
}

.storage-body select,
.storage-items button {
  width: 100%;
}

.item-action-button {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  min-height: 54px;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  text-align: left;
}

.item-action-icon {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  object-fit: contain;
}

.item-action-copy {
  white-space: pre-line;
  line-height: 1.2;
}

.item-action-quantity {
  position: absolute;
  right: 6px;
  bottom: 4px;
  padding-left: 4px;
  background: #c0c0c0;
}

.item-action-button:disabled .item-action-quantity {
  color: #808080;
}

.market-window > .title-bar,
.storage-window > .title-bar,
.inspector-window > .title-bar,
.action-log-window > .title-bar,
.object-inspector-window > .title-bar,
.sleep-anyway-window > .title-bar {
  cursor: move;
  touch-action: none;
  user-select: none;
}

.inspector-window {
  position: fixed;
  top: 104px;
  left: 50%;
  z-index: 10;
  width: 520px;
  height: 520px;
  min-width: min(420px, calc(100vw - 16px));
  min-height: 280px;
  max-height: calc(100vh - 128px);
  max-width: calc(100vw - 16px);
  transform: translateX(-50%);
  overflow: hidden;
  resize: both;
}

.inspector-body {
  height: calc(100% - 22px);
  overflow: auto;
}

.inspector-body menu {
  display: flex;
  gap: 2px;
  margin: 0 0 8px;
  padding: 0;
}

.inspector-body [role="tab"][aria-selected="true"] {
  border-color: #808080 #fff #fff #808080;
  background: #dfdfdf;
  box-shadow: inset 1px 1px #000;
}

.inspector-body pre,
.inspector-body textarea {
  width: 100%;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  line-height: 1.45;
}

.json-view {
  color: #24292f;
  background: #f6f8fa;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  line-height: 1.45;
}

.json-key {
  color: #0550ae;
}

.json-string {
  color: #0a3069;
}

.json-number {
  color: #953800;
}

.json-boolean,
.json-null {
  color: #8250df;
}

.inspector-body select {
  width: 100%;
}

.inspector-tool-buttons {
  display: flex;
  gap: 6px;
  margin: 6px 0;
}

.robot-overview h3 {
  margin: 10px 0 4px;
  font-size: 12px;
  letter-spacing: 0;
}

.robot-view-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
}

.robot-view-modes {
  display: flex;
}

.robot-view-modes button {
  min-width: 66px;
}

.robot-view-modes button[aria-pressed="true"] {
  border-color: #808080 #fff #fff #808080;
  background: #dfdfdf;
  box-shadow: inset 1px 1px #000;
}

.robot-view-frame {
  display: grid;
  min-height: 196px;
  place-items: center;
  padding: 2px;
  overflow: hidden;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  background: #2b252d;
}

#inspector-robot-camera {
  display: block;
  width: min(336px, 100%);
  height: auto;
  aspect-ratio: 7 / 4;
  image-rendering: pixelated;
}

#inspector-robot-agent-view {
  width: 100%;
  height: 192px;
  max-height: none;
  margin: 0;
  padding: 8px;
  overflow: auto;
  color: #d8f3dc;
  background: #17231b;
  white-space: pre;
  overflow-wrap: normal;
}

.robot-view-frame > [hidden] {
  display: none !important;
}

.robot-view-status {
  margin: 3px 0 0;
  color: #404040;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  text-align: right;
}

.robot-summary {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 10px;
  margin: 0;
}

.robot-summary dt {
  font-weight: 700;
}

.robot-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.robot-inventory {
  display: grid;
  grid-template-columns: repeat(5, minmax(68px, 1fr));
  gap: 4px;
}

.robot-inventory-slot {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 54px;
  place-items: center;
  padding: 15px 4px 4px;
  overflow: hidden;
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
  background: #c0c0c0;
}

.robot-inventory-slot[data-selected="true"] {
  outline: 2px solid #001f7a;
  outline-offset: -4px;
}

.robot-inventory-slot .slot-item {
  right: 3px;
  bottom: 2px;
}

.action-log-window {
  position: fixed;
  top: 104px;
  left: 50%;
  z-index: 10;
  width: 700px;
  height: 500px;
  min-width: min(480px, calc(100vw - 16px));
  min-height: 280px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 128px);
  transform: translateX(-50%);
  overflow: hidden;
  resize: both;
}

.action-log-body {
  height: calc(100% - 22px);
  overflow: auto;
}

.action-log-actors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.action-log-body h3 {
  margin: 4px 0;
  font-size: 12px;
  letter-spacing: 0;
}

.action-log-world {
  margin-top: 8px;
}

.collapsible-log {
  display: grid;
  gap: 4px;
}

.log-entry {
  border: 1px solid #808080;
  background: #fff;
}

.log-entry summary {
  padding: 4px;
  cursor: pointer;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}

.log-entry pre {
  max-height: 240px;
  margin: 0;
  padding: 6px;
  overflow: auto;
  border-top: 1px solid #c0c0c0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.object-inspector-window {
  position: fixed;
  top: 132px;
  left: 50%;
  z-index: 10;
  width: 300px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 148px);
  margin-left: 145px;
}

.object-inspector-body {
  max-height: calc(100vh - 184px);
  overflow: auto;
}

.object-location {
  margin: 0 0 6px;
  color: #404040;
}

#object-inspector-content {
  display: grid;
  gap: 6px;
}

.object-fields {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 3px 8px;
  margin: 0;
}

.object-fields dt {
  font-weight: 700;
}

.object-fields dd {
  margin: 0;
}

#object-inspector-robot-button {
  width: 100%;
  margin-top: 8px;
}

#object-inspector-raw {
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}