:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0e1116;
  color: #f4f7fb;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  grid-template-rows: 1fr auto;
  touch-action: none;
  user-select: none;
}

#game {
  position: relative;
  min-height: 0;
  background: #86b8ef;
}

#world {
  display: block;
  width: 100%;
  height: 100%;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.75));
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.42);
}

#crosshair::before {
  left: 10px;
  top: 0;
  width: 4px;
  height: 24px;
}

#crosshair::after {
  left: 0;
  top: 10px;
  width: 24px;
  height: 4px;
}

.panel {
  position: absolute;
  left: 50%;
  top: 44%;
  width: min(460px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(13, 18, 25, 0.78);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  text-align: center;
}

.panel.hidden {
  display: none;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

p {
  margin: 12px 0 18px;
  color: #dbe7f8;
}

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

.keys span {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.86rem;
  color: #edf4ff;
}

#hud {
  position: absolute;
  inset: auto 0 14px;
  display: grid;
  justify-items: center;
  gap: 10px;
  pointer-events: none;
}

#combat-hud {
  display: grid;
  grid-template-columns: 148px 220px;
  gap: 8px;
  align-items: center;
}

.meter {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 5px 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(7, 10, 14, 0.72);
}

.meter span {
  color: #edf4ff;
  font-size: 0.76rem;
  font-weight: 800;
}

.meter b {
  display: block;
  width: 100%;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, #e74646 var(--value, 100%), rgba(255, 255, 255, 0.16) var(--value, 100%));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.meter.boss b {
  background: linear-gradient(90deg, #8f5cff var(--value, 100%), rgba(255, 255, 255, 0.16) var(--value, 100%));
}

#mobile-controls {
  position: absolute;
  inset: auto 14px 82px;
  display: none;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}

.move-pad {
  display: grid;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(3, 54px);
  gap: 8px;
  pointer-events: auto;
}

.control-btn {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  background: rgba(9, 12, 17, 0.68);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  color: #f8fbff;
  font: 800 1rem/1 Inter, ui-sans-serif, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.control-btn:active,
.control-btn.pressed {
  background: rgba(255, 255, 255, 0.24);
  transform: translateY(1px);
}

.control-btn.up {
  grid-column: 2;
  grid-row: 1;
}

.control-btn.left {
  grid-column: 1;
  grid-row: 2;
}

.control-btn.down {
  grid-column: 2;
  grid-row: 3;
}

.control-btn.right {
  grid-column: 3;
  grid-row: 2;
}

.control-btn.jump {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  pointer-events: auto;
}

#status {
  min-height: 28px;
  padding: 5px 11px;
  border-radius: 6px;
  background: rgba(9, 12, 17, 0.7);
  color: #eef5ff;
  font-size: 0.88rem;
}

#hotbar {
  display: grid;
  grid-template-columns: repeat(10, 48px);
  gap: 5px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(7, 10, 14, 0.72);
}

.slot {
  position: relative;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: #28313c;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.28);
}

.slot.selected {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 218, 84, 0.9), inset 0 0 18px rgba(0, 0, 0, 0.25);
}

.slot::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 4px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.14), inset 0 -10px 16px rgba(0, 0, 0, 0.18);
}

.slot::after {
  content: attr(data-key);
  position: absolute;
  left: 5px;
  top: 2px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.72rem;
  font-weight: 700;
}

footer {
  display: grid;
  place-items: center;
  min-height: 28px;
  padding: 5px 8px;
  background: #10151c;
  color: #b9c7d8;
  font-size: 0.78rem;
}

@media (max-width: 620px) {
  #mobile-controls {
    display: flex;
  }

  #hud {
    inset: auto 0 8px;
    gap: 6px;
  }

  #status {
    display: none;
  }

  #combat-hud {
    width: calc(100vw - 16px);
    grid-template-columns: 1fr 1fr;
  }

  #hotbar {
    grid-template-columns: repeat(10, minmax(28px, 1fr));
    width: calc(100vw - 16px);
    gap: 3px;
  }

  .slot {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

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

@media (hover: none), (pointer: coarse) {
  #mobile-controls {
    display: flex;
  }
}
