:root {
  color-scheme: dark;
  --panel: rgba(18, 22, 24, 0.84);
  --panel-strong: rgba(9, 12, 14, 0.94);
  --line: rgba(255, 255, 255, 0.16);
  --accent: #f4c84f;
  --danger: #c91e36;
  --ink: #f5f1e7;
  --muted: #a9b5b5;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #111518;
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

button {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(180deg, #f6cf59, #b7771d);
  color: #16120a;
  font: 800 15px/1 "Segoe UI", Arial, sans-serif;
  min-height: 42px;
  padding: 0 18px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

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

#gameShell,
#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#gameCanvas {
  touch-action: none;
  cursor: grab;
}

#gameCanvas.grabbing {
  cursor: grabbing;
}

.hud {
  position: fixed;
  z-index: 4;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.hudLeft {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(460px, 46vw);
}

.job,
.controlsLegend,
.meters {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.job {
  min-width: 230px;
  padding: 10px 14px;
}

.job span,
.meters span,
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.job strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.controlsLegend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 10px;
  padding: 9px 11px;
  color: #d8dfdd;
  font-size: 12px;
  font-weight: 700;
}

.controlsLegend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

kbd {
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.09);
  color: #fff7d7;
  padding: 0 5px;
  font: 800 10px/1 "Segoe UI", Arial, sans-serif;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.24);
}

.meters {
  display: grid;
  grid-template-columns: repeat(4, minmax(74px, 1fr));
}

.meters div {
  min-width: 82px;
  padding: 10px 14px;
  border-left: 1px solid var(--line);
}

.meters div:first-child {
  border-left: 0;
}

.meters strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.mobileControls {
  position: fixed;
  z-index: 5;
  left: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: none;
  gap: 10px;
}

.mobileControls button {
  width: 62px;
  height: 54px;
  padding: 0;
  font-size: 22px;
}

.bossModal,
.roundModal,
.loadingWarning {
  position: fixed;
  z-index: 10;
  display: none;
}

.bossModal.active,
.roundModal.active,
.loadingWarning.active {
  display: flex;
}

.bossModal {
  inset: 0;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.74), rgba(0, 0, 0, 0.36)),
    radial-gradient(circle at 70% 20%, rgba(244, 200, 79, 0.18), transparent 36%);
}

.bossPortrait {
  width: 154px;
  height: 188px;
  image-rendering: pixelated;
  position: relative;
  filter: drop-shadow(0 26px 22px rgba(0, 0, 0, 0.36));
}

.bossPortrait span {
  position: absolute;
  display: block;
}

.bossPortrait span:nth-child(1) {
  left: 38px;
  top: 6px;
  width: 82px;
  height: 26px;
  background: #e1a52e;
  box-shadow: -14px 18px #9f6720, 14px 18px #9f6720;
}

.bossPortrait span:nth-child(2) {
  left: 30px;
  top: 32px;
  width: 94px;
  height: 72px;
  background: #c98b62;
  box-shadow: inset 18px 20px #efb487, inset -18px 20px #8f5638;
}

.bossPortrait span:nth-child(3) {
  left: 18px;
  top: 102px;
  width: 118px;
  height: 76px;
  background: #2d5565;
  box-shadow: inset 0 18px #f0bd36, inset 0 26px #1d303a;
}

.bossPortrait span:nth-child(4) {
  left: 56px;
  top: 58px;
  width: 12px;
  height: 12px;
  background: #1c1814;
  box-shadow: 34px 0 #1c1814, 16px 24px #59311f, 20px 44px #f3d2b7;
}

.bossCopy,
.roundModal {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  background: var(--panel-strong);
  padding: 24px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.bossCopy h1,
.roundModal h2 {
  margin: 4px 0 12px;
  font-size: clamp(34px, 7vw, 70px);
  line-height: 0.92;
  letter-spacing: 0;
}

.bossCopy p,
.roundModal p {
  color: #d7dedc;
  font-size: 16px;
  line-height: 1.52;
}

.roundModal {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  flex-direction: column;
}

.loadingWarning {
  right: 16px;
  bottom: 16px;
  max-width: 320px;
  flex-direction: column;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(20, 20, 20, 0.88);
  padding: 12px 14px;
  color: #fff;
}

.loadingWarning span {
  color: #cdd5d2;
  font-size: 13px;
}

@media (max-width: 760px) {
  .hud {
    align-items: flex-start;
  }

  .job {
    min-width: 150px;
    max-width: 42vw;
  }

  .hudLeft {
    max-width: 46vw;
  }

  .job strong {
    font-size: 15px;
  }

  .meters {
    grid-template-columns: repeat(4, minmax(50px, 1fr));
  }

  .meters div {
    min-width: 58px;
    padding: 8px 9px;
  }

  .meters strong {
    font-size: 17px;
  }

  .controlsLegend {
    gap: 5px;
    padding: 7px;
    font-size: 10px;
  }

  .controlsLegend span {
    gap: 3px;
  }

  kbd {
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    font-size: 9px;
  }

  .mobileControls {
    display: flex;
  }

  .bossModal {
    align-items: flex-end;
    gap: 12px;
  }

  .bossPortrait {
    width: 92px;
    height: 114px;
    flex: 0 0 auto;
  }

  .bossPortrait span {
    transform: scale(0.6);
    transform-origin: left top;
  }

  .bossCopy {
    padding: 18px;
  }
}
