:root {
  --hud-metal-dark: rgba(7, 12, 14, 0.98);
  --hud-metal-mid: rgba(28, 42, 44, 0.96);
  --hud-metal-edge: rgba(166, 188, 176, 0.62);
  --hud-glow-cyan: rgba(104, 221, 217, 0.46);
  --hud-glow-amber: rgba(255, 143, 54, 0.72);
  --hud-red: #ff5f35;
  color-scheme: dark;
  font-family:
    "Arial Narrow", "Roboto Condensed", ui-sans-serif, system-ui, sans-serif;
  background: #05070a;
  color: #e9f6ff;
  touch-action: none;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at 30% 20%, rgba(80, 128, 140, 0.14), transparent 32rem),
    #05070a;
}

#app {
  position: relative;
}

#game {
  display: block;
  width: 100vw;
  height: 100dvh;
  cursor: crosshair;
  background: #0a1014;
  touch-action: none;
  user-select: none;
}

#hud {
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0;
}

.hud-row {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  border-color: var(--hud-metal-edge);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.1), transparent 12%, transparent 88%, rgba(255, 255, 255, 0.08)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px 18px),
    linear-gradient(180deg, rgba(48, 62, 62, 0.98), var(--hud-metal-dark) 52%, rgba(2, 5, 7, 0.98));
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.2),
    inset 0 -2px rgba(0, 0, 0, 0.7),
    0 9px 30px rgba(0, 0, 0, 0.42);
}

.hud-row::before {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(204, 222, 210, 0.18);
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.55),
    0 0 14px rgba(0, 0, 0, 0.32);
}

.hud-top {
  min-height: 58px;
  justify-content: space-between;
  border-bottom: 2px solid rgba(151, 177, 171, 0.42);
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 6px
    max(8px, env(safe-area-inset-left));
}

.hud-bottom {
  min-height: 82px;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  border-top: 2px solid rgba(151, 177, 171, 0.42);
  padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
}

.panel,
.queue-panel {
  position: relative;
  z-index: 1;
  min-height: 38px;
  border: 1px solid rgba(143, 169, 165, 0.5);
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(15, 29, 34, 0.96), rgba(3, 7, 10, 0.92)),
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.13),
    inset 0 -2px rgba(0, 0, 0, 0.58),
    0 0 0 1px rgba(0, 0, 0, 0.42);
}

.panel {
  min-width: 104px;
  padding: 5px 8px;
}

.objective-panel {
  min-width: 148px;
}

.timer-panel {
  min-width: 132px;
  border-color: rgba(255, 129, 63, 0.72);
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 90, 43, 0.2), transparent 68%),
    linear-gradient(180deg, rgba(31, 23, 17, 0.98), rgba(7, 8, 8, 0.94));
  box-shadow:
    inset 0 1px rgba(255, 221, 186, 0.18),
    inset 0 -2px rgba(0, 0, 0, 0.62),
    0 0 14px rgba(255, 78, 42, 0.14);
}

.timer-panel .label {
  color: #ffb17a;
}

#timer {
  display: block;
  color: #fff4dc;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0;
  text-shadow:
    0 0 8px rgba(255, 86, 41, 0.52),
    0 2px 0 #000;
}

.queue-panel {
  pointer-events: auto;
  width: min(47vw, 410px);
  padding: 5px 7px;
}

.label {
  display: block;
  margin-bottom: 3px;
  color: #8eb7b5;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0;
}

strong {
  color: #f5fff9;
  font-size: 17px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 8px rgba(117, 236, 218, 0.24);
}

.bar {
  width: 118px;
  height: 11px;
  overflow: hidden;
  border: 1px solid rgba(232, 255, 255, 0.28);
  border-radius: 3px;
  background: rgba(10, 12, 14, 0.86);
}

.bar span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d33d46, #ff794f);
}

.queue {
  display: grid;
  grid-template-columns: repeat(4, minmax(38px, 1fr));
  gap: 6px;
  min-height: 48px;
}

.queue[data-queue="clips"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.slot {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 46px;
  min-width: 0;
  place-items: center;
  border: 1px solid rgba(151, 183, 177, 0.38);
  border-radius: 4px;
  padding: 3px 3px 5px;
  background:
    radial-gradient(circle at 50% 18%, rgba(112, 231, 218, 0.16), transparent 42%),
    rgba(5, 13, 16, 0.9);
  color: #eefcff;
  font-size: 9px;
  font-weight: 850;
  text-align: center;
  user-select: none;
  touch-action: none;
  overflow: hidden;
}

.slot.active {
  border-color: var(--hud-glow-amber);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 143, 54, 0.34), transparent 46%),
    linear-gradient(180deg, rgba(72, 40, 16, 0.92), rgba(15, 11, 8, 0.92));
  box-shadow: inset 0 0 10px rgba(255, 106, 49, 0.16);
}

.slot.dragging {
  opacity: 0.58;
}

.slot.empty {
  color: rgba(205, 230, 230, 0.38);
}

.slot-icon {
  display: block;
  width: min(34px, 78%);
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7));
}

.slot-label {
  display: block;
  max-width: 100%;
  color: #c7e6e0;
  line-height: 1;
  text-shadow: 0 1px 0 #000;
}

.slot small {
  position: absolute;
  right: 5px;
  top: 4px;
  color: #ffe7a1;
  font-size: 10px;
}

.usage {
  position: absolute;
  right: 5px;
  bottom: 5px;
  left: 5px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(230, 246, 246, 0.14);
}

.usage span {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #77f0c0, #ffe277);
}

.usage.danger span {
  background: linear-gradient(90deg, #ff4e56, #ffb347);
}

.slot.full-denied {
  animation: denied-pulse 420ms ease;
  border-color: rgba(255, 83, 83, 0.9);
}

@keyframes denied-pulse {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}

.result-overlay {
  pointer-events: auto;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(1, 5, 8, 0.62);
  backdrop-filter: blur(5px);
}

.result-overlay[hidden] {
  display: none;
}

.result-card {
  width: min(420px, 100%);
  border: 1px solid rgba(160, 205, 205, 0.4);
  border-radius: 8px;
  padding: 22px;
  background: linear-gradient(180deg, rgba(12, 24, 31, 0.95), rgba(3, 8, 12, 0.96));
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.48);
  text-align: center;
}

.result-card h1 {
  margin: 6px 0 8px;
  font-size: 28px;
  letter-spacing: 0;
}

.result-card p {
  margin: 0 0 18px;
  color: #b7cfd0;
}

.result-card button {
  border: 1px solid rgba(148, 220, 205, 0.65);
  border-radius: 6px;
  padding: 10px 14px;
  background: #123035;
  color: #eaffff;
  font: inherit;
  font-weight: 800;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: calc(118px + env(safe-area-inset-bottom));
  min-width: 160px;
  max-width: min(440px, calc(100vw - 24px));
  transform: translateX(-50%);
  border: 1px solid rgba(148, 201, 188, 0.42);
  border-radius: 6px;
  padding: 8px 12px;
  background: rgba(4, 10, 13, 0.78);
  color: #c9fff0;
  font-size: 13px;
  text-align: center;
  opacity: 0;
  transition: opacity 160ms ease;
}

#toast.show {
  opacity: 1;
}

#help {
  pointer-events: none;
  position: absolute;
  top: 84px;
  right: 12px;
  display: grid;
  gap: 3px;
  width: min(260px, calc(100vw - 24px));
  border: 1px solid rgba(140, 175, 178, 0.24);
  border-radius: 6px;
  padding: 10px;
  background: rgba(3, 8, 11, 0.64);
  color: #abc6c7;
  font-size: 12px;
}

#help strong {
  color: #eefcff;
  font-size: 13px;
}

@media (max-width: 760px) {
  .hud-top {
    min-height: 82px;
    display: grid;
    grid-template-columns: 1.1fr 0.82fr 0.9fr;
    align-items: stretch;
    gap: 5px;
  }

  .panel {
    min-width: 0;
    min-height: 37px;
    padding: 5px 6px;
  }

  .objective-panel {
    grid-column: 1 / 3;
    max-width: none;
  }

  .bar {
    width: 100%;
  }

  strong {
    font-size: 14px;
  }

  .timer-panel {
    min-width: 0;
  }

  #timer {
    font-size: 23px;
  }

  .hud-bottom {
    min-height: 96px;
    gap: 8px;
    align-items: stretch;
  }

  .queue-panel {
    width: calc(50vw - 12px);
    padding: 6px;
  }

  .queue,
  .queue[data-queue="clips"] {
    gap: 5px;
  }

  .slot {
    min-height: 44px;
    font-size: 10px;
  }

  .slot-icon {
    width: min(30px, 86%);
    height: 25px;
  }

  #help {
    display: none;
  }
}

@media (orientation: portrait) and (max-width: 760px) {
  .hud-top {
    min-height: 96px;
  }

  .hud-bottom {
    min-height: 112px;
  }

  .label {
    font-size: 8px;
  }

  .queue {
    gap: 4px;
  }

  .slot {
    min-height: 52px;
    padding-inline: 2px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .hud-top {
    display: flex;
    min-height: 48px;
    gap: 5px;
    padding-top: max(4px, env(safe-area-inset-top));
    padding-bottom: 4px;
  }

  .hud-bottom {
    min-height: 70px;
    padding-top: 4px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }

  .panel {
    min-height: 34px;
    min-width: 86px;
    padding: 4px 6px;
  }

  .objective-panel {
    min-width: 120px;
  }

  .label {
    margin-bottom: 2px;
    font-size: 8px;
  }

  strong {
    font-size: 13px;
  }

  #timer {
    font-size: 20px;
  }

  .bar {
    height: 9px;
    width: 90px;
  }

  .queue-panel {
    width: min(45vw, 330px);
    padding: 4px 6px;
  }

  .queue {
    min-height: 40px;
    gap: 4px;
  }

  .slot {
    min-height: 38px;
    padding: 2px 2px 4px;
    font-size: 8px;
  }

  .slot-icon {
    width: min(26px, 82%);
    height: 22px;
  }
}
