:root {
  color-scheme: dark;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #111614;
  color: #f3f4ec;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  background:
    radial-gradient(circle at 18% 20%, rgba(91, 124, 93, 0.24), transparent 28%),
    radial-gradient(circle at 82% 78%, rgba(179, 73, 48, 0.18), transparent 30%),
    #111614;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 480px;
  overflow: hidden;
  background: #151915;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.hud {
  position: absolute;
  inset: 12px 12px auto;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1.2fr) minmax(120px, 1fr);
  gap: 10px;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
}

.hud-left,
.hud-center,
.hud-right {
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid rgba(238, 232, 201, 0.14);
  background: rgba(14, 16, 13, 0.68);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.hud-left {
  border-radius: 8px 3px 3px 8px;
}

.hud-center {
  display: grid;
  place-items: center;
  text-align: center;
  border-radius: 3px;
}

.hud-right {
  display: grid;
  justify-items: end;
  align-content: center;
  gap: 6px;
  border-radius: 3px 8px 8px 3px;
}

.bars {
  display: grid;
  gap: 7px;
}

.bars label {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #cfd3bf;
}

meter {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
}

meter::-webkit-meter-bar {
  border: 0;
  background: rgba(0, 0, 0, 0.45);
}

#hpMeter::-webkit-meter-optimum-value {
  background: linear-gradient(90deg, #b73d36, #f07f55);
}

#armorMeter::-webkit-meter-optimum-value {
  background: linear-gradient(90deg, #3d7d9f, #78d0be);
}

meter::-moz-meter-bar {
  background: #d66;
}

.status-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: #f2e3b0;
  font-size: 13px;
}

.hud-center strong {
  font-size: clamp(24px, 4vw, 40px);
  line-height: 1;
  color: #fff6cc;
}

.hud-center span {
  max-width: 100%;
  min-height: 18px;
  margin-top: 5px;
  overflow: hidden;
  color: #cfd3bf;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-right span:first-child {
  color: #ffe08a;
  font-weight: 800;
  font-size: 18px;
}

.hud-right span:last-child {
  color: #b9c6b2;
  font-size: 13px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 16px;
  padding: 28px;
  text-align: center;
  background:
    linear-gradient(rgba(8, 10, 8, 0.55), rgba(8, 10, 8, 0.78)),
    radial-gradient(circle at 50% 42%, rgba(227, 176, 82, 0.2), transparent 28%);
  z-index: 5;
}

.overlay.hidden {
  display: none;
}

.title-mark {
  justify-self: center;
  width: fit-content;
  padding: 7px 12px;
  border: 1px solid rgba(255, 224, 138, 0.35);
  border-radius: 4px;
  color: #ffe08a;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.overlay h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(34px, 8vw, 78px);
  line-height: 0.98;
}

.overlay p {
  max-width: 620px;
  margin: 0 auto;
  color: #d7dac9;
  font-size: clamp(15px, 2.4vw, 18px);
  line-height: 1.7;
}

.overlay button {
  justify-self: center;
  width: min(260px, 78vw);
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: #f0bc55;
  color: #171408;
  font-weight: 900;
  box-shadow: 0 16px 40px rgba(240, 188, 85, 0.28);
  cursor: pointer;
}

.overlay button:active {
  transform: translateY(1px);
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(620px, 92vw);
  margin-top: 8px;
}

.help-grid span {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  color: #cfd3bf;
  font-size: 13px;
}

.interaction {
  position: absolute;
  left: 50%;
  bottom: 118px;
  width: min(360px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 10px 12px;
  border: 1px solid rgba(255, 224, 138, 0.35);
  border-radius: 6px;
  background: rgba(11, 13, 10, 0.78);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.interaction.hidden {
  display: none;
}

.interaction span {
  display: block;
  margin-bottom: 7px;
  color: #ffe08a;
  font-size: 13px;
  font-weight: 800;
}

.interaction div {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.interaction i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #e36b4f, #ffe08a);
}

.touch-ui {
  position: absolute;
  inset: auto 0 0;
  display: none;
  justify-content: space-between;
  align-items: end;
  padding: 0 20px 24px;
  pointer-events: none;
}

.pad {
  position: relative;
  width: 126px;
  height: 126px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: rgba(14, 16, 13, 0.46);
  box-shadow: inset 0 0 0 20px rgba(255, 255, 255, 0.02);
  pointer-events: auto;
  touch-action: none;
}

.pad i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #d5ddc7;
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.touch-actions {
  display: grid;
  grid-template-columns: repeat(2, 64px);
  gap: 10px;
  pointer-events: auto;
}

.touch-actions button {
  width: 64px;
  height: 64px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: rgba(15, 18, 14, 0.62);
  color: #f5f1d9;
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
  touch-action: none;
}

.touch-actions button:last-child {
  grid-row: span 2;
  align-self: center;
  width: 74px;
  height: 74px;
  background: rgba(202, 65, 46, 0.78);
}

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

  #gameCanvas {
    cursor: default;
  }
}

@media (max-width: 720px) {
  .game-shell {
    min-height: 100dvh;
  }

  .hud {
    inset: 8px 8px auto;
    grid-template-columns: 1fr 1fr;
  }

  .hud-center {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 56px;
    padding: 8px 10px;
  }

  .hud-left,
  .hud-right {
    min-height: 58px;
    padding: 8px 9px;
  }

  .bars label {
    grid-template-columns: 34px 1fr;
    font-size: 11px;
  }

  .hud-center strong {
    font-size: 28px;
  }

  .hud-right span:first-child {
    font-size: 15px;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }

  .overlay {
    padding: 18px;
  }
}
