:root {
  color-scheme: dark;
  --ink: #f6f8f0;
  --muted: #c3c9bd;
  --panel: rgba(13, 18, 15, 0.72);
  --line: rgba(255, 255, 255, 0.2);
  --gold: #f4c84a;
  --green: #6fcb58;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: #101714;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
}

.game-shell {
  position: fixed;
  inset: 0 0 32px;
  background: #77b8e8;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  image-rendering: crisp-edges;
  touch-action: none;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.statusbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.brand,
.message,
.hud-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(8px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  font-weight: 800;
}

.brand-mark {
  width: 20px;
  height: 20px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18) 50%, transparent 0),
    linear-gradient(#70ca56 0 48%, #8b5a36 49%);
  background-size: 10px 10px, 100% 100%;
  border: 2px solid rgba(255, 255, 255, 0.28);
}

.message {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-button {
  pointer-events: auto;
  padding: 0 14px;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.hud-button:focus-visible,
.hotbar button:focus-visible,
.action:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.crosshair::before {
  left: 11px;
  top: 2px;
  width: 2px;
  height: 20px;
}

.crosshair::after {
  left: 2px;
  top: 11px;
  width: 20px;
  height: 2px;
}

.bottom-hud {
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: min(640px, calc(100% - 28px));
  transform: translateX(-50%);
}

.vitals,
.hotbar {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.vitals {
  margin-bottom: 8px;
}

.vitals span {
  width: 18px;
  height: 18px;
  background: #e64d4f;
  clip-path: polygon(50% 91%, 8% 50%, 8% 22%, 26% 8%, 50% 22%, 74% 8%, 92% 22%, 92% 50%);
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.45));
}

.hotbar {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 9, 0.7);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.34);
  pointer-events: auto;
}

.hotbar button {
  position: relative;
  width: 56px;
  height: 56px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 5px;
  background: rgba(42, 45, 40, 0.96);
  cursor: pointer;
}

.hotbar button.active {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 2px rgba(244, 200, 74, 0.28), 0 0 18px rgba(244, 200, 74, 0.22);
}

.cube-swatch {
  position: absolute;
  inset: 11px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset -10px -10px rgba(0, 0, 0, 0.2), inset 9px 8px rgba(255, 255, 255, 0.12);
}

.hotbar kbd {
  position: absolute;
  right: 4px;
  bottom: 2px;
  color: rgba(255, 255, 255, 0.82);
  font: 700 0.72rem ui-monospace, SFMono-Regular, Menlo, monospace;
}

.grass { background: #65b84e; }
.dirt { background: #8b5a36; }
.stone { background: #8f9695; }
.wood { background: #b97438; }
.leaf { background: #3f9a45; }
.sand { background: #dfcb7b; }
.glass { background: rgba(160, 224, 231, 0.62); }

.mobile-stick,
.mobile-look,
.action-buttons {
  display: none;
}

footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b0f0c;
  color: #aeb8aa;
  font-size: 0.82rem;
}

@media (max-width: 760px), (pointer: coarse) {
  .game-shell {
    inset-bottom: 32px;
  }

  .statusbar {
    top: 10px;
    left: 10px;
    right: 10px;
    grid-template-columns: 1fr auto;
  }

  .brand {
    display: none;
  }

  .message {
    justify-content: flex-start;
    font-size: 0.82rem;
  }

  .hud-button {
    min-width: 78px;
    padding: 0 10px;
  }

  .bottom-hud {
    bottom: 12px;
    width: min(430px, calc(100% - 16px));
  }

  .hotbar {
    gap: 3px;
    padding: 5px;
  }

  .hotbar button {
    width: 45px;
    height: 45px;
  }

  .cube-swatch {
    inset: 9px;
  }

  .vitals {
    display: none;
  }

  .mobile-look {
    display: block;
    position: absolute;
    inset: 74px 0 112px 43%;
    pointer-events: auto;
  }

  .mobile-stick {
    display: block;
    position: absolute;
    left: 18px;
    bottom: 120px;
    width: 118px;
    height: 118px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(7, 10, 8, 0.36);
    box-shadow: inset 0 0 28px rgba(255, 255, 255, 0.08);
    pointer-events: auto;
  }

  .mobile-stick span {
    position: absolute;
    left: 39px;
    top: 39px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.74);
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.35);
  }

  .action-buttons {
    display: grid;
    position: absolute;
    right: 16px;
    bottom: 122px;
    gap: 10px;
    pointer-events: auto;
  }

  .action {
    width: 74px;
    height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    font-weight: 900;
    background: rgba(13, 18, 15, 0.72);
  }

  .action.place {
    border-color: rgba(111, 203, 88, 0.7);
  }

  .action.mine {
    border-color: rgba(244, 200, 74, 0.7);
  }
}
