*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #6fa8cc;
  color: #f7fbff;
  font-family: Arial, Helvetica, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game, #c {
  width: 100%;
  height: 100%;
}

#c {
  display: block;
}

#hud {
  position: fixed;
  top: 14px;
  left: 14px;
  display: grid;
  gap: 8px;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
}

.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

#status {
  min-width: 280px;
  max-width: min(460px, calc(100vw - 28px));
  padding: 8px 10px;
  background: rgba(18, 24, 28, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.35;
  backdrop-filter: blur(8px);
}

#hearts {
  display: flex;
  gap: 4px;
  min-height: 18px;
}

.heart {
  width: 18px;
  height: 18px;
  background: #d83b45;
  clip-path: polygon(50% 88%, 8% 45%, 8% 20%, 28% 8%, 50% 22%, 72% 8%, 92% 20%, 92% 45%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

.heart.empty {
  background: rgba(255, 255, 255, 0.22);
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

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

#crosshair::before {
  left: 8px;
  top: 0;
  width: 2px;
  height: 18px;
}

#crosshair::after {
  left: 0;
  top: 8px;
  width: 18px;
  height: 2px;
}

#inventory {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(6, 48px);
  gap: 6px;
  padding: 7px;
  background: rgba(18, 24, 28, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  backdrop-filter: blur(8px);
}

.slot {
  position: relative;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
}

.slot.active {
  border-color: #ffd95a;
  box-shadow: 0 0 0 2px rgba(255, 217, 90, 0.24);
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), 0 2px 5px rgba(0, 0, 0, 0.32);
}

.key {
  position: absolute;
  left: 5px;
  top: 3px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 11px;
  font-weight: 700;
}

#message {
  position: fixed;
  left: 50%;
  top: 78px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 28px));
  padding: 9px 12px;
  border-radius: 6px;
  background: rgba(20, 24, 27, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-align: center;
  font-size: 14px;
  line-height: 1.35;
  opacity: 0;
  transition: opacity 160ms ease;
  pointer-events: none;
}

#message.show {
  opacity: 1;
}


#orientation {
  position: fixed;
  top: 12px;
  right: 12px;
  display: none;
  max-width: 230px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(18, 24, 28, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 13px;
  line-height: 1.3;
  pointer-events: none;
  z-index: 8;
}

#mobileControls {
  position: fixed;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 6;
}

.stick {
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: rgba(18, 24, 28, 0.34);
  border: 2px solid rgba(255, 255, 255, 0.24);
  pointer-events: auto;
  touch-action: none;
}

.stickKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.52);
  border: 2px solid rgba(255, 255, 255, 0.68);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

#lookPad {
  position: fixed;
  right: 0;
  top: 0;
  width: 54vw;
  height: 100vh;
  pointer-events: auto;
  touch-action: none;
}

#mobileActions {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(2, 68px);
  grid-template-rows: repeat(2, 68px);
  gap: 10px;
  pointer-events: auto;
}

.roundBtn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(18, 24, 28, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(8px);
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.25);
  touch-action: none;
}

.roundBtn.active {
  background: rgba(255, 217, 90, 0.78);
  color: #1c1b10;
}

#start {
  position: fixed;
  z-index: 12;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(rgba(24, 35, 39, 0.2), rgba(10, 13, 16, 0.55));
}

#start.hidden,
#loader.hidden {
  display: none;
}

.panel {
  width: min(460px, 100%);
  padding: 24px;
  background: rgba(12, 18, 22, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(14px);
}

h1 {
  margin: 0 0 8px;
  font-size: 42px;
  line-height: 1;
}

p {
  margin: 0 0 18px;
  color: #dbe8ee;
  line-height: 1.45;
}

button {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 6px;
  background: #ffd95a;
  color: #20200f;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
}

.help {
  margin-top: 14px;
  color: #bfd0d8;
  font-size: 13px;
  line-height: 1.45;
}

#loader {
  position: fixed;
  z-index: 9;
  right: 14px;
  bottom: 14px;
  padding: 8px 10px;
  background: rgba(18, 24, 28, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  font-size: 13px;
}

@media (hover: none), (pointer: coarse) {
  #mobileControls {
    display: block;
  }

  #crosshair {
    opacity: 0.72;
  }

  #hud {
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
  }

  #status {
    min-width: 0;
    max-width: min(360px, calc(100vw - 20px));
    font-size: 12px;
  }

  #inventory {
    bottom: max(10px, env(safe-area-inset-bottom));
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
  #orientation {
    display: block;
  }

  #inventory {
    left: auto;
    right: 10px;
    bottom: 102px;
    transform: none;
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  #inventory {
    bottom: max(12px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 520px) {
  #inventory {
    grid-template-columns: repeat(6, 38px);
    gap: 4px;
    bottom: 10px;
  }

  .slot {
    width: 38px;
    height: 38px;
  }

  .swatch {
    width: 24px;
    height: 24px;
  }

  h1 {
    font-size: 34px;
  }
}

@media (max-height: 430px) and (orientation: landscape) {
  #hud {
    gap: 5px;
  }

  #status {
    padding: 6px 8px;
  }

  .stick {
    width: 112px;
    height: 112px;
  }

  .stickKnob {
    width: 50px;
    height: 50px;
  }

  #mobileActions {
    grid-template-columns: repeat(2, 58px);
    grid-template-rows: repeat(2, 58px);
    gap: 8px;
  }

  .roundBtn {
    width: 58px;
    height: 58px;
    font-size: 11px;
  }
}
