:root {
  --ink: #f8f0d4;
  --ink-soft: #dbcda9;
  --panel-border: #2b1f16;
  --panel: rgba(28, 21, 15, 0.8);
  --panel-strong: rgba(19, 14, 10, 0.92);
  --accent: #ffd16f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Press Start 2P', cursive;
  color: var(--ink);
  background:
    radial-gradient(120% 100% at 10% 20%, #bee4ff 0%, #89bde9 45%, #466988 100%),
    linear-gradient(180deg, #8ec8ff, #2a4d6b);
}

#game-root {
  position: fixed;
  inset: 0;
}

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

#overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  z-index: 30;
  padding: 28px;
  color: #fff8df;
  background:
    radial-gradient(circle at 16% 24%, rgba(255, 219, 145, 0.2), transparent 45%),
    radial-gradient(circle at 84% 75%, rgba(102, 172, 255, 0.2), transparent 45%),
    rgba(12, 18, 28, 0.76);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

#overlay.visible {
  display: flex;
}

#overlay h1 {
  margin: 0 0 18px;
  font-size: clamp(22px, 5vw, 44px);
  letter-spacing: 1px;
  animation: title-float 2.8s ease-in-out infinite alternate;
}

#overlay p {
  margin: 0;
  font-size: clamp(8px, 1.55vw, 12px);
  line-height: 1.7;
  max-width: 900px;
}

@keyframes title-float {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-3px);
  }
}

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

#hud::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 52%, rgba(6, 8, 13, 0.18) 100%);
}

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

#crosshair::before,
#crosshair::after {
  content: '';
  position: absolute;
  background: rgba(12, 9, 7, 0.88);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
}

#crosshair::before {
  top: 12px;
  left: 0;
  width: 26px;
  height: 2px;
}

#crosshair::after {
  left: 12px;
  top: 0;
  width: 2px;
  height: 26px;
}

#stats {
  position: absolute;
  top: 16px;
  left: 16px;
  min-width: 300px;
  padding: 12px 14px;
  font-size: 9px;
  line-height: 1.72;
  color: #fff3ce;
  background: linear-gradient(160deg, rgba(37, 29, 21, 0.88), rgba(19, 14, 10, 0.78));
  border: 3px solid var(--panel-border);
  border-radius: 5px;
  white-space: pre-line;
  box-shadow:
    inset 0 0 0 2px rgba(255, 236, 170, 0.12),
    0 12px 24px rgba(0, 0, 0, 0.3);
}

#hotbar {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.slot {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 132px;
  height: 64px;
  padding: 6px 10px 8px;
  border-radius: 4px;
  border: 3px solid #20170f;
  background: linear-gradient(180deg, rgba(40, 31, 23, 0.92), rgba(20, 15, 11, 0.88));
  color: #ffe9be;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.05),
    0 8px 14px rgba(0, 0, 0, 0.28);
}

.slot::before {
  content: '';
  width: 100%;
  height: 9px;
  border-radius: 2px;
  background: var(--slot-color, rgba(255, 255, 255, 0.08));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.slot-number {
  font-size: 8px;
  opacity: 0.78;
}

.slot-name {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.slot-count {
  position: absolute;
  right: 8px;
  bottom: 7px;
  font-size: 10px;
  color: #fffadf;
}

.slot.selected {
  transform: translateY(-4px);
  border-color: var(--accent);
  color: #fff4cf;
  box-shadow:
    inset 0 0 0 2px rgba(255, 226, 140, 0.28),
    0 10px 20px rgba(0, 0, 0, 0.42);
}

#inventory-panel {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 206, 122, 0.16), transparent 38%),
    radial-gradient(circle at 84% 76%, rgba(110, 173, 255, 0.2), transparent 38%),
    rgba(9, 14, 22, 0.78);
  backdrop-filter: blur(3px);
}

#inventory-panel.visible {
  display: flex;
}

#inventory-window {
  width: min(880px, calc(100vw - 24px));
  border: 4px solid #241a11;
  border-radius: 8px;
  padding: 18px;
  background:
    linear-gradient(160deg, rgba(38, 30, 22, 0.95), rgba(18, 14, 10, 0.94)),
    repeating-linear-gradient(
      -45deg,
      rgba(255, 255, 255, 0.025) 0,
      rgba(255, 255, 255, 0.025) 7px,
      transparent 7px,
      transparent 14px
    );
  box-shadow:
    inset 0 0 0 2px rgba(255, 239, 178, 0.12),
    0 24px 40px rgba(0, 0, 0, 0.45);
}

#inventory-window h2 {
  margin: 0;
  font-size: clamp(14px, 2.4vw, 20px);
  color: #fff1c6;
}

#inventory-window p {
  margin: 10px 0 14px;
  font-size: 9px;
  line-height: 1.7;
  color: var(--ink-soft);
}

.inventory-label {
  margin: 14px 0 8px;
  font-size: 10px;
  color: #ffeab2;
}

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

.inv-slot {
  position: relative;
  min-height: 66px;
  border: 2px solid #2f2217;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(42, 31, 22, 0.95), rgba(22, 16, 11, 0.86));
  color: #ffe9be;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: transform 0.08s ease, border-color 0.08s ease;
}

.inv-slot::before {
  content: '';
  width: 100%;
  height: 8px;
  border-radius: 2px;
  background: var(--slot-color, rgba(255, 255, 255, 0.08));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.36);
}

.inv-slot:hover {
  border-color: #9a7b54;
  transform: translateY(-1px);
}

.inv-slot.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 224, 130, 0.35);
}

.inv-key {
  font-size: 8px;
  opacity: 0.76;
}

.inv-name {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.inv-count {
  position: absolute;
  right: 6px;
  bottom: 5px;
  font-size: 10px;
}

#inventory-carry {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  display: none;
  pointer-events: none;
  max-width: 210px;
  padding: 9px 11px;
  border-radius: 4px;
  border: 2px solid #2f2217;
  background: linear-gradient(180deg, rgba(45, 32, 23, 0.96), rgba(20, 15, 10, 0.9));
  color: #ffefc5;
  font-size: 9px;
  line-height: 1.4;
  box-shadow: 0 12px 18px rgba(0, 0, 0, 0.32);
}

#inventory-carry.visible {
  display: block;
}

#inventory-carry::before {
  content: '';
  display: block;
  width: 100%;
  height: 8px;
  margin-bottom: 7px;
  border-radius: 2px;
  background: var(--slot-color, rgba(255, 255, 255, 0.1));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.34);
}

@media (max-width: 900px) {
  #stats {
    min-width: 0;
    width: calc(100vw - 32px);
    font-size: 8px;
  }

  #hotbar {
    width: calc(100vw - 16px);
    justify-content: center;
    gap: 4px;
    bottom: 14px;
  }

  .slot {
    width: 72px;
    height: 60px;
    padding: 5px 6px;
  }

  .slot-name {
    display: none;
  }

  .slot-count {
    right: 5px;
    bottom: 4px;
    font-size: 9px;
  }

  #inventory-window {
    padding: 12px;
  }

  .inventory-grid {
    gap: 4px;
  }

  .inv-slot {
    min-height: 56px;
    padding: 4px;
  }

  .inv-name {
    font-size: 8px;
  }
}