:root {
  color-scheme: dark;
  --ink: #101713;
  --header: #16251f;
  --panel: #20352c;
  --line: #3e5548;
  --text: #f3f1df;
  --muted: #a8b3a7;
  --lime: #b6d56a;
  --amber: #f0b84f;
  --red: #df675d;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
}

body,
button {
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

button svg,
a svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

[hidden] {
  display: none !important;
}

.game-app {
  display: grid;
  width: 100%;
  height: 100dvh;
  grid-template-rows: 66px minmax(0, 1fr);
  background: var(--ink);
  user-select: none;
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 42px minmax(180px, 1fr) minmax(420px, 600px) minmax(98px, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--header);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #e3eadf;
  background: var(--panel);
  cursor: pointer;
  text-decoration: none;
}

.icon-button:hover:not(:disabled) {
  border-color: #70836f;
  background: #2a4136;
}

.icon-button:disabled {
  cursor: default;
  opacity: 0.4;
}

.icon-button .play-icon,
.icon-button.is-paused .pause-icon,
.mute-line {
  display: none;
}

.icon-button.is-paused .play-icon,
.icon-button.is-muted .mute-line {
  display: block;
}

.icon-button.is-muted .sound-wave {
  display: none;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.brand > span:last-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.brand strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small,
.metrics span,
.screen-content > p {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
}

.brand-mark {
  position: relative;
  display: block;
  width: 39px;
  height: 30px;
  flex: 0 0 auto;
}

.brand-mark::before {
  position: absolute;
  bottom: 2px;
  left: 2px;
  width: 35px;
  height: 13px;
  border: 2px solid var(--lime);
  border-radius: 4px;
  background: #243d2f;
  content: "";
}

.brand-mark::after {
  position: absolute;
  top: 8px;
  left: 12px;
  width: 16px;
  height: 10px;
  border: 2px solid #d9e6b5;
  border-radius: 8px 8px 2px 2px;
  background: #375840;
  content: "";
}

.brand-mark i {
  position: absolute;
  z-index: 2;
  top: 4px;
  left: 25px;
  width: 16px;
  height: 3px;
  background: #d9e6b5;
  transform: rotate(-24deg);
  transform-origin: left center;
}

.metrics {
  display: grid;
  height: 100%;
  grid-template-columns: repeat(3, minmax(74px, 1fr)) minmax(110px, 1.35fr);
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.metrics > div {
  display: grid;
  min-width: 0;
  align-content: center;
  gap: 4px;
  padding: 0 14px;
  border-right: 1px solid var(--line);
}

.metrics > div:last-child {
  border-right: 0;
}

.metrics strong {
  overflow: hidden;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

.armor-bar {
  display: block;
  width: 90px;
  height: 11px;
  border: 1px solid #637566;
  background: #2a3c31;
}

.armor-bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--lime);
  transition: width 180ms ease;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.battlefield {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #86bac0;
  isolation: isolate;
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.battle-message {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 7;
  min-width: 190px;
  padding: 9px 15px;
  border: 1px solid #9f7730;
  border-radius: 4px;
  color: #2b210d;
  background: #f0c45f;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  transform: translateX(-50%);
}

.combo {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 6;
  display: grid;
  justify-items: end;
  color: #fff0bd;
  text-shadow: 0 2px 0 rgba(35, 32, 18, 0.4);
}

.combo span {
  font-size: 10px;
}

.combo strong {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 30px;
}

.screen-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(20, 35, 29, 0.72);
}

.screen-layer.is-hidden {
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}

.screen-content {
  display: grid;
  width: min(480px, calc(100% - 32px));
  justify-items: center;
  text-align: center;
}

.screen-content > p {
  margin: 0 0 13px;
  color: #d1e69a;
}

.screen-content h1 {
  margin: 0;
  font-size: clamp(42px, 8vh, 68px);
  line-height: 1;
}

.screen-content > span {
  margin: 15px 0 22px;
  color: #dbe3d9;
  font-size: 14px;
}

.briefing {
  display: grid;
  width: min(390px, 100%);
  margin-bottom: 22px;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid #718176;
  border-bottom: 1px solid #718176;
}

.briefing div {
  display: grid;
  gap: 4px;
  padding: 12px 8px;
}

.briefing div + div {
  border-left: 1px solid #718176;
}

.briefing small {
  color: #b9c3b8;
  font-size: 10px;
}

.briefing strong {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 16px;
}

.primary-button {
  display: flex;
  height: 46px;
  align-items: center;
  gap: 9px;
  padding: 0 23px;
  border: 1px solid #9e742b;
  border-radius: 5px;
  color: #261e0e;
  background: var(--amber);
  font-weight: 800;
  cursor: pointer;
}

.mobile-controls {
  position: absolute;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 16px;
  z-index: 8;
  display: none;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}

.move-controls {
  display: flex;
  gap: 10px;
}

.control-button {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(238, 242, 220, 0.62);
  border-radius: 7px;
  color: #f6f3da;
  background: rgba(27, 44, 34, 0.72);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

.control-button:active,
.control-button.is-active {
  color: #28210e;
  background: var(--amber);
}

.control-button svg {
  width: 27px;
  height: 27px;
}

.fire-button {
  width: 68px;
  height: 68px;
  color: #ffe6a3;
  border-color: rgba(240, 184, 79, 0.85);
}

@media (pointer: coarse), (max-width: 760px) {
  .mobile-controls {
    display: flex;
  }

  #gameCanvas {
    cursor: default;
  }
}

@media (max-width: 880px) {
  .game-app {
    grid-template-rows: 106px minmax(0, 1fr);
  }

  .topbar {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    grid-template-rows: 56px 50px;
    gap: 0 9px;
    padding: 0 12px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .metrics {
    grid-area: 2 / 1 / 3 / 4;
    width: calc(100% + 24px);
    height: 50px;
    margin-left: -12px;
    grid-template-columns: repeat(3, minmax(54px, 1fr)) minmax(88px, 1.25fr);
  }

  .metrics > div {
    gap: 2px;
    padding: 0 9px;
  }

  .metrics strong {
    font-size: 14px;
  }

  .armor-bar {
    width: min(78px, 100%);
  }
}

@media (max-width: 520px) {
  .brand-mark,
  .brand small {
    display: none;
  }

  .brand strong {
    font-size: 14px;
  }

  .metrics span {
    font-size: 8px;
  }

  .metrics strong {
    font-size: 12px;
  }

  .metrics > div {
    padding: 0 7px;
  }

  .screen-content {
    transform: translateY(-18px);
  }

  .screen-content h1 {
    font-size: 40px;
  }

  .screen-content > span {
    margin-bottom: 17px;
  }

  .briefing {
    margin-bottom: 18px;
  }

  .briefing div {
    padding: 9px 5px;
  }

  .briefing strong {
    font-size: 13px;
  }

  .combo {
    top: 14px;
    right: 14px;
  }

  .control-button {
    width: 52px;
    height: 52px;
  }

  .fire-button {
    width: 62px;
    height: 62px;
  }
}
