html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #10100f;
  color: #e9e3d6;
  font: 13px/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#view {
  display: block;
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 0;
  width: min(100vw, 133.333vh);
  height: min(75vw, 100vh);
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.damage-overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(160, 0, 0, 0) 0 26%, rgba(175, 0, 0, 0.16) 58%, rgba(185, 0, 0, 0.44) 100%);
}

.damage-overlay.is-active {
  opacity: 1;
}

.damage-shard {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 48, 38, 0.12), rgba(210, 0, 0, 0.76));
  mix-blend-mode: screen;
}

.crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: 22px;
  height: 22px;
  box-sizing: border-box;
  border: 2px solid rgba(236, 230, 204, 0.86);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(22, 17, 12, 0.65), inset 0 0 0 1px rgba(22, 17, 12, 0.65);
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(236, 230, 204, 0.86);
  transform: translate(-50%, -50%);
}

.crosshair::after {
  width: 36px;
  height: 1px;
  border-radius: 0;
  background: linear-gradient(90deg, transparent 0 36%, rgba(236, 230, 204, 0.72) 36% 44%, transparent 44% 56%, rgba(236, 230, 204, 0.72) 56% 64%, transparent 64%);
}

.quiver-hud,
.health-hud {
  position: fixed;
  right: calc((100vw - min(100vw, 133.333vh)) * 0.5 + 18px);
  z-index: 4;
  width: 188px;
  overflow: hidden;
  border: 1px solid rgba(255, 224, 178, 0.34);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42), inset 0 0 0 1px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.quiver-hud {
  bottom: 54px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  height: 26px;
  padding: 0 9px;
  background: rgba(19, 17, 13, 0.86);
}

.quiver-icon {
  width: 42px;
  height: 7px;
  border-radius: 999px 1px 1px 999px;
  background: linear-gradient(90deg, #806137 0 18%, #d8c28c 18% 86%, #f2e4b8 86%);
  box-shadow: 0 0 0 1px rgba(31, 21, 12, 0.76), 0 0 8px rgba(242, 214, 148, 0.18);
  transform: rotate(-12deg);
}

.quiver-text {
  color: #f1ddb2;
  font-family: Papyrus, "Lucida Blackletter", Georgia, fantasy;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 0 #1e1308, 0 0 5px rgba(0, 0, 0, 0.82);
  font-variant-numeric: tabular-nums;
}

.health-hud {
  bottom: 18px;
  height: 28px;
  background: rgba(26, 10, 8, 0.82);
}

.health-fill {
  width: 100%;
  height: 100%;
  background: rgb(150, 20, 16);
  box-shadow: inset 0 0 12px rgba(255, 120, 92, 0.38);
  transform-origin: left center;
}

.health-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ffe8c2;
  font-family: Papyrus, "Lucida Blackletter", Georgia, fantasy;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 0 #220b08, 0 0 5px rgba(0, 0, 0, 0.88);
  font-variant-numeric: tabular-nums;
}

.game-menu-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  box-sizing: border-box;
  color: #f3eee2;
  background: #000;
  opacity: 1;
  transition: opacity 900ms ease;
}

.game-menu-layer.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.game-menu {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: hidden;
}

.game-menu [hidden] {
  display: none;
}

.game-menu-header {
  margin-bottom: 22px;
}

.game-menu h1,
.game-menu h2,
.game-menu p {
  margin: 0;
}

.game-menu h1 {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.05;
}

.game-menu-header p {
  margin-top: 8px;
  color: #b8b0a3;
  font-size: 14px;
}

.game-menu-nav {
  display: grid;
  gap: 9px;
}

.game-menu-nav button {
  min-height: 40px;
  padding: 0 14px;
  text-align: left;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #10100f;
}

.game-menu-nav button:hover,
.game-menu-nav button.is-active {
  background: #26231f;
}

.game-menu-page {
  display: grid;
  gap: 9px;
  max-height: calc(100vh - 48px);
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-color: #6f201f #151413;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.game-menu-page::-webkit-scrollbar {
  width: 10px;
}

.game-menu-page::-webkit-scrollbar-track {
  border-radius: 999px;
  background: #151413;
}

.game-menu-page::-webkit-scrollbar-thumb {
  border: 2px solid #151413;
  border-radius: 999px;
  background: linear-gradient(180deg, #8b2826, #451615);
}

.game-menu-page::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #a93431, #5b1c1b);
}

.game-menu-page-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
  padding-bottom: 6px;
  background: rgba(24, 22, 20, 0.96);
}

.game-menu-page-header button {
  min-width: 78px;
}

.game-menu-page h2 {
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
}

.menu-select-row {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: #d5ccbe;
}

.menu-select-row select {
  width: 100%;
  padding: 8px 10px;
}

#menuAboutText {
  color: #d5ccbe;
  white-space: pre-wrap;
}

.menu-loading {
  margin-top: 0;
  color: #f6d58d;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.loading-menu-screen {
  display: grid;
  min-height: 120px;
  place-items: center;
  text-align: center;
}

.resolution-layer {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(18, 18, 16, 0.88);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
}

.resolution-layer label {
  color: #cfc6b6;
  white-space: nowrap;
}

.resolution-layer select {
  padding: 5px 28px 5px 7px;
}

.panel {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 2;
  width: min(390px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(18, 18, 16, 0.88);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
}

.panel-head,
.row,
.control,
.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-menu-page .row,
.game-menu-page .control {
  min-width: 0;
}

.game-menu-page .buttons {
  flex-wrap: wrap;
}

.panel-head {
  position: sticky;
  top: 0;
  justify-content: space-between;
  padding: 9px 10px;
  background: rgba(24, 24, 21, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1;
}

#panelBody {
  padding: 10px;
}

button,
select,
input,
textarea {
  color: #f4efe5;
  background: #2b2b27;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
}

button {
  min-height: 28px;
  padding: 0 9px;
  cursor: pointer;
}

button:hover {
  background: #3a3a34;
}

.buttons button {
  flex: 1;
}

.controls {
  display: grid;
  gap: 5px;
  margin: 6px 0;
  overflow: hidden;
}

.control label {
  width: 128px;
  color: #cfc6b6;
  font-size: 12px;
}

.control input[type="range"] {
  flex: 1;
  min-width: 0;
}

.control input[type="number"] {
  width: 68px;
  padding: 4px 5px;
}

.control input[type="color"] {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 2px;
}

.control select {
  flex: 1;
  padding: 5px;
}

.value {
  width: 44px;
  text-align: right;
  color: #f6d58d;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.check {
  margin: 6px 0;
}

#settingsJson {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 56px;
  margin-top: 4px;
  padding: 7px;
  resize: vertical;
  font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.game-menu-page #settingsJson {
  resize: none;
}

#stats {
  white-space: pre-wrap;
  color: #d8d0c2;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 9px;
  margin: 9px 0 0;
}

#map {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  width: 256px;
  height: 256px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vw - 24px);
  image-rendering: pixelated;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #050505;
}

.debug-ui-off .resolution-layer,
.debug-ui-off .panel,
.debug-ui-off #map {
  display: none;
}

body:not(.game-running) .damage-overlay,
body:not(.game-running) .crosshair,
body:not(.game-running) .quiver-hud,
body:not(.game-running) .health-hud {
  display: none;
}

.collapsed #panelBody {
  display: none;
}

@media (max-width: 760px) {
  .resolution-layer {
    top: auto;
    bottom: 54px;
    left: 12px;
    transform: none;
  }
}
