@font-face {
  font-family: "PressStart";
  src: local("Courier New");
}

:root {
  --ui-bg: rgba(0, 0, 0, 0.45);
  --ui-border: rgba(255, 255, 255, 0.45);
  --ui-text: #e9eef4;
  --slot-size: 56px;
}

* {
  box-sizing: border-box;
  image-rendering: pixelated;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--ui-text);
  font-family: PressStart, "Trebuchet MS", sans-serif;
}

#game-root,
canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  background: radial-gradient(circle at 50% 40%, rgba(22, 38, 64, 0.35), rgba(5, 8, 15, 0.8));
  z-index: 30;
}

.overlay.visible {
  display: flex;
}

.panel {
  width: min(680px, 90vw);
  background: linear-gradient(180deg, rgba(30, 35, 43, 0.92), rgba(12, 14, 18, 0.9));
  border: 2px solid var(--ui-border);
  border-radius: 12px;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.45);
  padding: 30px;
  text-align: center;
}

.panel h1 {
  margin: 0 0 12px;
  font-size: clamp(26px, 4vw, 44px);
  letter-spacing: 0.05em;
}

.panel p {
  margin: 10px 0;
  font-size: clamp(14px, 2vw, 19px);
}

.panel .small {
  opacity: 0.82;
  line-height: 1.6;
}

#crosshair {
  position: fixed;
  width: 28px;
  height: 28px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 25;
  mix-blend-mode: screen;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.hud-card {
  position: absolute;
  right: 12px;
  top: 12px;
  min-width: 256px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 1px rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(8, 11, 15, 0.58), rgba(5, 8, 10, 0.36));
  transition: opacity 180ms ease, transform 180ms ease;
}

.hud-card.hidden {
  opacity: 0;
  transform: translateX(8px);
}

.hud-card .title {
  font-size: 13px;
  margin-bottom: 4px;
  color: #fff2c1;
}

.hud-card .muted {
  margin-top: 5px;
  opacity: 0.8;
}

kbd {
  display: inline-block;
  min-width: 2em;
  margin-inline: 2px;
  padding: 0 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  font-size: 10px;
  color: #fff;
}

#debug {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 1px rgba(0, 0, 0, 0.7);
  background: linear-gradient(180deg, rgba(8, 11, 15, 0.54), rgba(5, 8, 10, 0.35));
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 220px;
}

#action-ui {
  position: absolute;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#item-label {
  min-height: 20px;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.72);
  color: #f6edcd;
}

#break-meter {
  width: min(280px, 60vw);
  height: 13px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 120ms ease, transform 120ms ease;
}

#break-meter.visible {
  opacity: 1;
  transform: translateY(0);
}

#break-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #f7b863, #ffd78e);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.36);
  transition: width 60ms linear;
}

#hotbar {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: auto;
  padding: 8px;
  background: linear-gradient(180deg, rgba(5, 7, 9, 0.68), rgba(0, 0, 0, 0.58));
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.hotbar-slot {
  width: var(--slot-size);
  height: var(--slot-size);
  border: 2px solid rgba(180, 180, 180, 0.38);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(40, 45, 52, 0.6), rgba(17, 19, 23, 0.6));
  position: relative;
  display: grid;
  place-items: center;
}

.hotbar-slot.selected {
  border-color: rgba(255, 240, 156, 0.96);
  box-shadow: 0 0 0 2px rgba(255, 220, 80, 0.35), 0 6px 16px rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
}

.hotbar-slot img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  pointer-events: none;
}

.slot-index {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 10px;
  opacity: 0.82;
  text-shadow: 0 2px 1px rgba(0, 0, 0, 0.72);
}

@media (max-width: 720px) {
  :root {
    --slot-size: 44px;
  }

  #debug {
    font-size: 10px;
    min-width: 180px;
  }

  #hotbar {
    bottom: 14px;
    gap: 6px;
    padding: 6px;
  }

  #crosshair {
    width: 24px;
    height: 24px;
  }

  .hud-card {
    min-width: 190px;
    font-size: 10px;
    padding: 8px 9px;
  }

  .hud-card .title {
    font-size: 11px;
  }

  #action-ui {
    bottom: 76px;
    gap: 7px;
  }

  #item-label {
    font-size: 11px;
  }

  #break-meter {
    height: 10px;
  }
}
