:root {
  --panel-bg: rgba(8, 12, 13, 0.86);
  --panel-edge: #1d2627;
  --panel-hi: #8d9695;
  --text: #e7e2d6;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #101714;
  color: var(--text);
  font-family: "Courier New", ui-monospace, monospace;
  letter-spacing: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #6fa0dd;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  text-shadow: 2px 2px 0 #111;
}

.panel {
  position: absolute;
  background: var(--panel-bg);
  border: 4px solid #050808;
  box-shadow:
    inset 0 0 0 3px var(--panel-edge),
    inset 0 0 0 5px var(--panel-hi),
    0 2px 0 #000;
}

.lemon-count {
  top: 28px;
  right: 28px;
  min-width: 250px;
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  gap: 28px;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1;
}

.lemon-count strong {
  font-weight: 700;
}

.game-stats {
  top: 118px;
  right: 28px;
  min-width: 250px;
  padding: 16px 18px;
  display: grid;
  gap: 10px;
  font-size: clamp(16px, 2.2vw, 24px);
  line-height: 1;
}

.game-stats div {
  display: flex;
  justify-content: space-between;
  gap: 22px;
}

.game-stats strong {
  color: #f5d84e;
}

.base-panel {
  left: 28px;
  bottom: 28px;
  min-width: 220px;
  padding: 14px 16px;
  display: grid;
  gap: 8px;
  font-size: 18px;
  line-height: 1;
}

.base-panel strong {
  color: #f5d84e;
}

.objective-panel {
  left: 28px;
  bottom: 104px;
  min-width: 260px;
  padding: 14px 16px;
  display: grid;
  gap: 8px;
  font-size: 18px;
  line-height: 1;
}

.objective-panel strong {
  color: #e64d37;
}

.minimap-wrap {
  right: 28px;
  bottom: 28px;
  width: 172px;
  height: 172px;
  padding: 12px;
}

.settings-button {
  left: 28px;
  top: 28px;
  min-width: 160px;
  height: 62px;
  padding: 0 18px;
  color: var(--text);
  font: 700 22px/1 "Courier New", ui-monospace, monospace;
  pointer-events: auto;
  cursor: pointer;
}

.book-button {
  left: 202px;
  top: 28px;
  min-width: 112px;
  height: 62px;
  padding: 0 18px;
  color: var(--text);
  font: 700 22px/1 "Courier New", ui-monospace, monospace;
  pointer-events: auto;
  cursor: pointer;
}

.settings-menu {
  left: 28px;
  top: 102px;
  width: min(280px, calc(100vw - 56px));
  padding: 18px;
  display: grid;
  gap: 14px;
  pointer-events: auto;
}

.book-menu {
  left: 28px;
  top: 178px;
  width: min(380px, calc(100vw - 56px));
  padding: 18px;
  display: grid;
  gap: 14px;
  pointer-events: auto;
}

.settings-menu.hidden {
  display: none;
}

.book-menu.hidden {
  display: none;
}

.book-menu h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1;
}

.book-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  font-size: 16px;
}

.book-grid div,
.book-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.book-grid strong,
.book-list strong {
  color: #f5d84e;
}

.book-list {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 2px solid rgba(231, 226, 214, 0.22);
  font-size: 16px;
}

.volume-control {
  display: grid;
  gap: 8px;
  font-size: 18px;
  line-height: 1;
}

.volume-control input {
  width: 100%;
  accent-color: #d9d1bd;
  cursor: pointer;
}

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

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(231, 226, 214, 0.88);
  box-shadow: 1px 1px 0 #111;
}

.crosshair::before {
  width: 22px;
  height: 3px;
  transform: translate(-50%, -50%);
}

.crosshair::after {
  width: 3px;
  height: 22px;
  transform: translate(-50%, -50%);
}

.scope-reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(72vmin, 620px);
  height: min(72vmin, 620px);
  transform: translate(-50%, -50%);
  border: 5px solid rgba(8, 10, 10, 0.92);
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 2px rgba(231, 226, 214, 0.55),
    inset 0 0 70px rgba(0, 0, 0, 0.45),
    0 0 0 9999px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.scope-reticle::before,
.scope-reticle::after,
.scope-reticle span::before,
.scope-reticle span::after {
  content: "";
  position: absolute;
  background: rgba(8, 10, 10, 0.9);
}

.scope-reticle::before {
  left: 50%;
  top: 6%;
  width: 3px;
  height: 88%;
  transform: translateX(-50%);
}

.scope-reticle::after {
  left: 6%;
  top: 50%;
  width: 88%;
  height: 3px;
  transform: translateY(-50%);
}

.scope-reticle span::before {
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(8, 10, 10, 0.92);
  border-radius: 50%;
  background: transparent;
  transform: translate(-50%, -50%);
}

.scope-reticle span::after {
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

#minimap {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background: #355431;
}

.prompt {
  position: absolute;
  left: 50%;
  bottom: 118px;
  transform: translateX(-50%);
  padding: 12px 18px;
  background: rgba(4, 7, 7, 0.82);
  border: 3px solid #d9d1bd;
  font-size: clamp(16px, 3vw, 24px);
  white-space: nowrap;
}

.float-text {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  padding: 10px 14px;
  color: #f5d84e;
  font-size: clamp(22px, 4vw, 40px);
  font-weight: 700;
  pointer-events: none;
}

.death-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 48%, rgba(70, 0, 0, 0.1), rgba(0, 0, 0, 0.78) 62%),
    rgba(0, 0, 0, 0.42);
  pointer-events: none;
  opacity: 0;
  animation: deathfade 4.8s ease-out forwards;
}

.death-overlay span {
  color: #8f1010;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(56px, 12vw, 150px);
  font-weight: 400;
  letter-spacing: 0;
  text-shadow:
    0 0 18px rgba(120, 0, 0, 0.65),
    0 3px 0 rgba(0, 0, 0, 0.8);
  transform: scale(1.08);
  opacity: 0;
  animation: deathtext 4.8s ease-out forwards;
}

.death-overlay small {
  position: absolute;
  left: 50%;
  top: calc(50% + min(13vmin, 120px));
  transform: translateX(-50%);
  color: rgba(231, 226, 214, 0.78);
  font-size: clamp(14px, 2.2vw, 22px);
  opacity: 0;
  animation: deathtext 4.8s ease-out 1.1s forwards;
  white-space: nowrap;
}

@keyframes deathfade {
  0% { opacity: 0; }
  28% { opacity: 0.35; }
  100% { opacity: 1; }
}

@keyframes deathtext {
  0% {
    opacity: 0;
    transform: scale(1.22);
  }
  34% {
    opacity: 0;
    transform: scale(1.16);
  }
  58% {
    opacity: 0.92;
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.hud.hit-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 245, 150, 0.16);
  pointer-events: none;
  animation: hitflash 160ms ease-out;
}

@keyframes hitflash {
  from { opacity: 1; }
  to { opacity: 0; }
}

.hidden {
  display: none;
}

.touch-controls {
  position: absolute;
  inset: auto 18px 18px 18px;
  display: none;
  justify-content: space-between;
  align-items: end;
  pointer-events: none;
}

.stick {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: rgba(5, 8, 8, 0.55);
  border: 3px solid rgba(231, 226, 214, 0.55);
  pointer-events: auto;
  position: relative;
}

.stick i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border-radius: 50%;
  background: rgba(231, 226, 214, 0.75);
}

.action {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid rgba(231, 226, 214, 0.75);
  background: rgba(5, 8, 8, 0.72);
  color: var(--text);
  font: 700 20px "Courier New", ui-monospace, monospace;
  pointer-events: auto;
}

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

}

@media (max-width: 720px) {
  .lemon-count {
    top: 12px;
    right: 12px;
    min-width: 180px;
    padding: 14px 16px;
  }

  .minimap-wrap {
    right: 12px;
    bottom: 126px;
    width: 126px;
    height: 126px;
    padding: 9px;
  }

  .game-stats {
    top: 74px;
    right: 12px;
    min-width: 180px;
    padding: 12px 14px;
  }

  .settings-button {
    left: 12px;
    top: 12px;
    min-width: 124px;
    height: 48px;
    padding: 0 12px;
    font-size: 16px;
  }

  .book-button {
    left: 148px;
    top: 12px;
    min-width: 82px;
    height: 48px;
    padding: 0 10px;
    font-size: 16px;
  }

  .settings-menu {
    left: 12px;
    top: 72px;
    width: min(240px, calc(100vw - 24px));
  }

  .book-menu {
    left: 12px;
    top: 132px;
    width: min(320px, calc(100vw - 24px));
  }

  .base-panel {
    left: 12px;
    bottom: 126px;
    min-width: 160px;
    padding: 10px 12px;
    font-size: 14px;
  }

  .objective-panel {
    left: 12px;
    bottom: 186px;
    min-width: 160px;
    max-width: 240px;
    padding: 10px 12px;
    font-size: 14px;
  }
}
