:root {
  --ink: #f4f7f2;
  --shadow: #1b1b1b;
  --grass: #5ea83a;
  --grass-dark: #3d7a24;
  --panel: rgba(8, 10, 14, 0.55);
  --slot: rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #07090d;
  font-family: "DejaVu Sans", sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
  z-index: 0;
}

#ui { position: fixed; inset: 0; z-index: 2; pointer-events: none; }

button, input { font-family: inherit; pointer-events: auto; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.overlay.hidden, .hidden { display: none !important; }

#loading {
  background:
    radial-gradient(ellipse at 50% 40%, rgba(20, 28, 18, 0.2), rgba(0, 0, 0, 0.72));
  flex-direction: column;
  gap: 18px;
  text-align: center;
}

.blocks {
  width: 92px;
  height: 46px;
  position: relative;
}

.blocks span {
  position: absolute;
  bottom: 0;
  width: 22px;
  height: 22px;
  background: linear-gradient(#79c84a, #3e8a28);
  border: 2px solid #14210e;
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.25), inset 3px 3px 0 rgba(255, 255, 255, 0.25);
  animation: bounce 0.7s infinite ease-in-out;
}

.blocks span:nth-child(1) { left: 4px; animation-delay: 0s; }
.blocks span:nth-child(2) { left: 34px; background: linear-gradient(#c4a574, #8a6840); animation-delay: 0.12s; }
.blocks span:nth-child(3) { left: 64px; background: linear-gradient(#b9b9b9, #6e6e6e); animation-delay: 0.24s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}

#load-text { font-size: 20px; letter-spacing: 0.5px; text-shadow: 2px 2px 0 #000; }
#load-bar {
  width: min(420px, 70vw);
  height: 14px;
  border: 3px solid #111;
  background: #1a1a1a;
  box-shadow: inset 0 0 0 2px #3a3a3a;
}
#load-bar > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(#8ed45a, #4f9a30);
}

#menu, #pause {
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.62) 100%);
}

.panel {
  width: min(760px, 94vw);
  max-height: 92vh;
  overflow: auto;
  padding: 28px 32px 22px;
  text-align: center;
  background: var(--panel);
  border: 4px solid #111;
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.18),
    inset 0 0 0 6px rgba(0, 0, 0, 0.35),
    0 18px 50px rgba(0, 0, 0, 0.45);
}

.brand-row {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
}

#logo-tile {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  background: rgba(0, 0, 0, 0.25);
  border: 3px solid #111;
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.2), 4px 4px 0 #000;
}

h1 {
  margin: 0;
  font-size: clamp(40px, 7vw, 76px);
  line-height: 0.9;
  letter-spacing: 1px;
  color: #7dcc45;
  text-shadow:
    0 3px 0 #3c7a22,
    0 6px 0 #244a14,
    4px 9px 0 #111,
    0 0 24px rgba(0, 0, 0, 0.45);
}

.splash {
  margin: 8px 0 0;
  color: #ffe14a;
  font-weight: 700;
  font-size: 18px;
  transform: rotate(-8deg);
  text-shadow: 2px 2px 0 #3a3408;
  animation: pulse 0.7s infinite alternate;
}

@keyframes pulse { from { transform: rotate(-8deg) scale(1); } to { transform: rotate(-8deg) scale(1.06); } }

.sub {
  margin: 8px 0 16px;
  color: #d7e2cf;
  text-shadow: 2px 2px 0 #000;
}

.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }

button.mc {
  background: linear-gradient(#8d8d8d, #5c5c5c);
  color: white;
  border: 3px solid #1a1a1a;
  box-shadow: inset 3px 3px 0 #bdbdbd, inset -3px -3px 0 #3a3a3a;
  padding: 10px 18px;
  font-size: 18px;
  font-weight: 700;
  text-shadow: 2px 2px 0 #222;
  cursor: pointer;
}

button.mc:hover, button.mc:focus-visible {
  background: linear-gradient(#9ccc65, #5a9a32);
  outline: none;
}

button.mc.primary { min-width: 180px; }

.seed-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin: 6px 0 12px;
  text-shadow: 1px 1px 0 #000;
}

.seed-row input {
  width: 140px;
  background: #111;
  color: #fff;
  border: 3px solid #2a2a2a;
  padding: 6px 8px;
  font-size: 16px;
}

.times { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.times button { font-size: 14px; padding: 6px 10px; }

.help {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 22px;
  text-align: left;
  margin: 12px auto 0;
  max-width: 640px;
  color: #e7eee4;
  font-size: 14px;
  text-shadow: 1px 1px 0 #000;
}

.help b { color: #fff; }

.foot {
  margin-top: 12px;
  font-size: 12px;
  color: #c5d0c0;
  text-shadow: 1px 1px 0 #000;
}

#hud { position: absolute; inset: 0; }

#vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.38) 100%);
  pointer-events: none;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(#fff, #fff) center / 2px 18px no-repeat,
    linear-gradient(#fff, #fff) center / 18px 2px no-repeat;
  filter: drop-shadow(1px 1px 0 #000) drop-shadow(-1px 0 0 #000);
  pointer-events: none;
}

#topbar {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
  text-shadow: 2px 2px 0 #000;
  font-size: 14px;
}

#brand { font-weight: 700; letter-spacing: 0.5px; }
#brand span {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.25);
  font-weight: 400;
  font-size: 12px;
}

#compass { font-weight: 700; font-size: 16px; letter-spacing: 1px; }
#clock { text-align: right; }

#debug {
  position: absolute;
  top: 48px;
  left: 12px;
  font-family: "DejaVu Sans Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 10px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  text-shadow: 1px 1px 0 #000;
  white-space: pre;
}

#toast, #hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
}

#toast {
  bottom: 128px;
  font-size: 18px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.4s;
}

#toast.show { opacity: 1; }

#hint {
  top: 22%;
  max-width: 80vw;
  color: #fff;
  font-size: 16px;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

#hotbar-wrap {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#target-name, #hotbar-label {
  min-height: 18px;
  font-weight: 700;
  text-shadow: 2px 2px 0 #000;
}

#hotbar { display: flex; gap: 4px; }

.slot {
  position: relative;
  width: 58px;
  height: 58px;
  background: var(--slot);
  border: 3px solid #1c1c1c;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.28), inset -2px -2px 0 rgba(0, 0, 0, 0.45);
  image-rendering: pixelated;
}

.slot canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
}

.slot em {
  position: absolute;
  top: 1px;
  left: 3px;
  font-style: normal;
  font-size: 12px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}

.slot.selected {
  transform: translateY(-6px);
  border-color: #fff;
  box-shadow: 0 0 0 2px #fff, inset 2px 2px 0 rgba(255, 255, 255, 0.4);
  z-index: 1;
}

#inventory {
  background: rgba(0, 0, 0, 0.45);
}

.inv-panel { width: min(760px, 96vw); }

.inv-grid {
  display: grid;
  grid-template-columns: repeat(9, 58px);
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
}

.inv-grid .slot { cursor: pointer; pointer-events: auto; }
.inv-grid .slot:hover { border-color: #d0d0d0; }

#inv-name { min-height: 22px; font-weight: 700; text-shadow: 2px 2px 0 #000; }

#fatal {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: #4a1010;
  color: #fff;
  border: 3px solid #ffb4b4;
  padding: 12px 14px;
  z-index: 5;
  pointer-events: auto;
  white-space: pre-wrap;
}

@media (max-width: 760px) {
  .help { grid-template-columns: 1fr; }
  .slot, .inv-grid { }
  .inv-grid { grid-template-columns: repeat(6, 46px); }
  .slot { width: 46px; height: 46px; }
  h1 { font-size: 40px; }
}
