:root {
  --ash: #12100d;
  --sand: #6b4e33;
  --rust: #c25b22;
  --burnt: #e57a2f;
  --metal: #7d7a74;
  --chrome: #b8b2a7;
  --smoke: #2b2723;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Bahnschrift", "Franklin Gothic Medium", "Arial Narrow", sans-serif;
  color: #f6e6cc;
  background:
    radial-gradient(circle at 20% 20%, #4f3825 0, #1d1712 45%, #0e0c0a 100%),
    linear-gradient(135deg, #190f0b 0%, #2f2218 50%, #0f0d0b 100%);
}

.app-shell {
  position: relative;
  width: min(95vw, 1500px);
  height: min(95vh, 860px);
  margin: auto;
  top: 50%;
  transform: translateY(-50%);
  border: 2px solid rgba(255, 177, 91, 0.3);
  box-shadow:
    0 20px 80px rgba(0, 0, 0, 0.65),
    inset 0 0 120px rgba(229, 122, 47, 0.12);
  overflow: hidden;
  background: linear-gradient(180deg, rgba(33, 24, 18, 0.65), rgba(10, 9, 7, 0.9));
  touch-action: none;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-content: center;
  gap: 0.8rem;
  text-align: center;
  padding: 1.5rem;
  background:
    linear-gradient(180deg, rgba(17, 12, 9, 0.18), rgba(10, 7, 5, 0.78)),
    radial-gradient(circle at 50% 20%, rgba(255, 149, 71, 0.3), transparent 60%);
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  margin: 0;
  font-family: "Impact", "Haettenschweiler", "Arial Black", sans-serif;
  letter-spacing: 0.08em;
  color: #ffd9ac;
  text-shadow:
    0 0 20px rgba(255, 149, 71, 0.4),
    0 0 40px rgba(255, 75, 0, 0.22);
}

.overlay p {
  margin: 0;
  color: #f0cf9f;
}

.enemy-select {
  margin: 0 auto;
  display: grid;
  gap: 0.45rem;
  justify-items: center;
  background: rgba(25, 20, 15, 0.62);
  border: 1px solid rgba(255, 177, 91, 0.3);
  padding: 0.65rem 0.9rem;
}

.enemy-select-label {
  color: #f6d6a7;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.enemy-select-controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.enemy-select-btn {
  border: 1px solid rgba(255, 191, 122, 0.8);
  background: linear-gradient(180deg, rgba(214, 120, 58, 0.95), rgba(92, 44, 21, 0.96));
  color: #fff3de;
  font-family: "Impact", "Haettenschweiler", "Arial Black", sans-serif;
  font-size: 1.05rem;
  width: 2rem;
  height: 2rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.enemy-count-value {
  min-width: 2.2rem;
  text-align: center;
  color: #ffd9ac;
  font-family: "Impact", "Haettenschweiler", "Arial Black", sans-serif;
  font-size: 1.1rem;
}

.overlay ul {
  margin: 0 auto;
  text-align: left;
  line-height: 1.35;
  max-width: 720px;
  background: rgba(25, 20, 15, 0.58);
  border: 1px solid rgba(255, 177, 91, 0.2);
  padding: 0.9rem 1.1rem;
}

.overlay li {
  margin: 0.2rem 0;
}

#start-btn {
  justify-self: center;
  border: 1px solid rgba(255, 191, 122, 0.8);
  background:
    linear-gradient(180deg, #d67930 0%, #9d461f 100%);
  color: #fff6e5;
  font-family: "Impact", "Haettenschweiler", "Arial Black", sans-serif;
  letter-spacing: 0.06em;
  font-size: 1rem;
  text-transform: uppercase;
  padding: 0.65rem 1.6rem;
  cursor: pointer;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.35);
}

#start-btn:hover {
  filter: brightness(1.08);
}


.touch-controls {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  display: none;
}

.touch-enabled .touch-controls {
  display: block;
}

.touch-pad {
  position: absolute;
  left: 24px;
  bottom: 22px;
  width: 178px;
  height: 178px;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
}

.touch-pad-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 214, 164, 0.62);
  background:
    radial-gradient(circle at 35% 35%, rgba(255, 170, 98, 0.25), rgba(42, 30, 24, 0.45) 64%),
    linear-gradient(180deg, rgba(92, 58, 35, 0.45), rgba(22, 16, 13, 0.58));
  box-shadow:
    0 0 24px rgba(255, 140, 66, 0.25),
    inset 0 0 35px rgba(255, 150, 77, 0.2);
}

.touch-pad-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72px;
  height: 72px;
  margin-left: -36px;
  margin-top: -36px;
  border-radius: 50%;
  border: 2px solid rgba(255, 225, 188, 0.7);
  background:
    radial-gradient(circle at 36% 36%, rgba(255, 214, 155, 0.78), rgba(212, 106, 45, 0.78) 52%, rgba(62, 36, 22, 0.9) 100%);
  box-shadow:
    0 3px 20px rgba(0, 0, 0, 0.45),
    inset 0 0 24px rgba(255, 171, 90, 0.35);
  transition: transform 0.06s linear;
}

.touch-buttons {
  position: absolute;
  right: 24px;
  bottom: 28px;
  display: grid;
  gap: 10px;
  pointer-events: auto;
}

.touch-btn {
  border: 1px solid rgba(255, 206, 152, 0.75);
  background:
    linear-gradient(180deg, rgba(214, 120, 58, 0.95), rgba(92, 44, 21, 0.96));
  color: #ffe7c9;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: "Impact", "Haettenschweiler", "Arial Black", sans-serif;
  font-size: 0.88rem;
  padding: 0.58rem 0.92rem;
  min-width: 124px;
  touch-action: manipulation;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.45),
    inset 0 0 12px rgba(255, 170, 96, 0.22);
}

.touch-btn:active {
  filter: brightness(1.1);
  transform: translateY(1px);
}

.touch-btn[disabled],
.touch-btn[aria-disabled="true"] {
  opacity: 0.45;
  filter: saturate(0.55);
  cursor: default;
  transform: none;
}

:fullscreen .touch-pad {
  bottom: 26px;
}

:fullscreen .touch-buttons {
  bottom: 30px;
}

@media (max-width: 860px) {
  .app-shell {
    width: 100vw;
    height: 100vh;
    border: none;
    top: 0;
    transform: none;
  }

  .overlay {
    place-content: start center;
    align-content: start;
    padding: 0.9rem 0.8rem 1.1rem;
    gap: 0.65rem;
    overflow-y: auto;
  }

  .overlay h1 {
    font-size: clamp(1.15rem, 5.8vw, 1.65rem);
    line-height: 1.1;
  }

  .overlay p {
    font-size: 0.9rem;
    max-width: 38ch;
    margin: 0 auto;
  }

  .overlay ul {
    max-width: min(95vw, 580px);
    font-size: 0.85rem;
    line-height: 1.28;
    padding: 0.7rem 0.85rem;
  }

  .overlay li {
    margin: 0.12rem 0;
  }

  #start-btn {
    width: min(86vw, 320px);
    padding: 0.65rem 1rem;
  }

  .touch-pad {
    width: 156px;
    height: 156px;
    left: 14px;
    bottom: 14px;
  }

  .touch-pad-knob {
    width: 64px;
    height: 64px;
    margin-left: -32px;
    margin-top: -32px;
  }

  .touch-buttons {
    right: 14px;
    bottom: 16px;
  }

  .touch-btn {
    min-width: 110px;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }
}

@media (max-width: 420px) {
  .overlay {
    padding-top: 0.75rem;
    gap: 0.55rem;
  }

  .overlay ul {
    font-size: 0.8rem;
  }
}

:fullscreen .app-shell {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border: none;
  top: 0;
  transform: none;
}
