:root {
  color-scheme: light;
  font-family: "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #d8e8c8;
  color: #14210f;
  height: 100vh;
  overflow: hidden;
}

.app {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 10px;
  border: 4px solid #2d4a2a;
  background: #edf6df;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 10px;
}

.play-area {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 6px;
  position: relative;
}

.control-area {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

h1 {
  margin: 0 0 10px;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
}

.hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 6px 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 3px solid #40683c;
  background: #dcecca;
}

.hud p {
  margin: 0;
  min-width: 0;
}

.hud p.wide {
  grid-column: 1 / -1;
}

#healthBar {
  color: #a82020;
  letter-spacing: 0.04em;
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

#armorBar {
  color: #4f5966;
  letter-spacing: 0.03em;
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

#temperatureText.cold {
  color: #1f4e9d;
}

#statusText {
  font-weight: 700;
}

.game-canvas {
  width: 100%;
  max-width: none;
  max-height: 100%;
  height: 100%;
  display: block;
  border: 4px solid #2d4a2a;
  background: #7daf67;
  image-rendering: pixelated;
  object-fit: contain;
}

.inventory-panel {
  position: absolute;
  inset: 12px;
  border: 3px solid #2d4a2a;
  background: rgba(237, 246, 223, 0.97);
  padding: 10px;
  z-index: 10;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
}

.inventory-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

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

.inventory-slot {
  min-height: 48px;
  padding: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  font-size: 0.8rem;
  background: #d9d9d9;
  line-height: 1;
}

.inventory-slot.active {
  border-color: #be6a18;
  background: #f7e3cc;
}

.inventory-slot.empty {
  color: #d7d7d7;
}

.inventory-icon {
  font-size: 0.95rem;
}

.pixel-art {
  width: 24px;
  height: 24px;
  display: grid;
  grid-template-columns: repeat(8, 3px);
  grid-template-rows: repeat(8, 3px);
  image-rendering: pixelated;
}

.pixel-art .px {
  width: 3px;
  height: 3px;
}

.inventory-count {
  font-size: 0.84rem;
  font-weight: 700;
  color: #1f3318;
  margin-top: -1px;
  text-shadow: 0 1px 0 #ffffff;
}

.inventory-empty {
  font-size: 0.78rem;
}

.inventory-hint {
  margin: 0;
  font-size: 0.82rem;
}

.hotbar {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
}

.hotbar-slot {
  min-height: 54px;
  padding: 2px;
  border: 2px solid #2d4a2a;
  background: #f2f8ea;
  display: grid;
  grid-template-rows: auto 1fr auto;
  place-items: center;
}

.hotbar-key {
  font-size: 0.62rem;
  color: #516b49;
}

.hotbar-icon {
  min-height: 26px;
  display: grid;
  place-items: center;
}

.hotbar-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1f3318;
  text-shadow: 0 1px 0 #ffffff;
}

.hotbar-slot.active {
  border-color: #be6a18;
  background: #f7e3cc;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.controls {
  display: grid;
  gap: 8px;
  width: max-content;
}

.controls .row {
  display: flex;
  gap: 8px;
}

button {
  padding: 8px 12px;
  border: 2px solid #2d4a2a;
  border-radius: 0;
  background: #f2f8ea;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

#pauseBtn {
  font-weight: 700;
}

#newGameBtn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
}

.help {
  margin-top: 10px;
  color: #2d4a2a;
  font-size: 0.92rem;
}

.hidden {
  display: none;
}

.craft-panel {
  padding: 10px;
  border: 3px solid #40683c;
  background: #dcecca;
  max-width: none;
}

.craft-panel h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.craft-hint,
.craft-result {
  margin: 6px 0;
  font-size: 0.88rem;
}

.craft-items,
.craft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.craft-items button {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  min-height: 64px;
}

.craft-item-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1f3318;
}

.craft-grid {
  display: grid;
  grid-template-columns: repeat(3, 74px);
  gap: 6px;
  margin: 8px 0;
}

.craft-slot {
  width: 74px;
  height: 74px;
  padding: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
}

.craft-slot-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1f3318;
  text-shadow: 0 1px 0 #ffffff;
}

.craft-items button.active {
  background: #c8e0af;
}

@media (max-width: 520px) {
  body {
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .play-area {
    grid-template-rows: auto auto auto;
  }

  .control-area {
    overflow: visible;
  }

  .game-canvas {
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .hud {
    grid-template-columns: 1fr;
  }
}
