:root {
  color-scheme: dark;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  --player-status-bar-width: 180px;
  --ui-panel-border: #11181a;
  --ui-panel-edge: #7b8584;
  --ui-panel-texture: url("./sprites/shop_back.png");
  --ui-button-green: url("./sprites/shop_buy_btn.png");
  --ui-tab-active: url("./sprites/shop_tab_active.png");
  --ui-tab-inactive: url("./sprites/shop_tab_inactive.png");
  --ui-tile: url("./sprites/bordered_panel.png");
  --ui-round: url("./sprites/round_button.png");
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #09131b;
  color: #eef6fb;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

@media (hover: none) and (pointer: coarse) {
  html,
  body {
    min-height: -webkit-fill-available;
    height: 100dvh;
    touch-action: none;
  }

  body {
    position: fixed;
    inset: 0;
    width: 100vw;
  }

  #viewport {
    width: 100vw;
    height: 100dvh;
    min-height: -webkit-fill-available;
    touch-action: none;
  }
}

body.menu-camera-active {
  background: #9fd8ff;
}

body * {
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea,
select,
[contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}

img,
canvas,
button {
  -webkit-user-drag: none;
  user-drag: none;
}

#viewport {
  width: 100%;
  height: 100%;
  display: block;
}

body.desktop-aim-active.desktop-aim-cursor-hidden #viewport {
  cursor: none;
}

body.desktop-aim-active:not(.desktop-aim-cursor-hidden) #viewport,
body.desktop-aim-active.desktop-aim-ui-hover #viewport {
  cursor: default;
}

/* ── Debug toggle button (top-right) ── */

.debug-toggle-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 12;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  pointer-events: auto;
  transition: transform 0.15s;
}

.debug-toggle-btn:hover {
  transform: scale(1.08);
}

.debug-toggle-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

body.shop-hud-open .debug-toggle-btn,
body.shop-hud-open .top-icon-btn {
  display: none;
}

.top-icon-btn {
  position: fixed;
  top: 16px;
  right: 76px;
  z-index: 12;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 2px solid rgba(10, 12, 16, 0.9);
  background: rgba(230, 239, 245, 0.88);
  color: #17222c;
  font: 900 0.9rem/1 "Open Sans", sans-serif;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

.game-menu-btn {
  z-index: 12;
}

/* ── Debug HUD (left side, hidden by default) ── */

.hud {
  position: fixed;
  top: 16px;
  left: 16px;
  bottom: 60px;
  display: grid;
  gap: 12px;
  width: min(360px, calc(100vw - 32px));
  z-index: 11;
  align-content: start;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.hud.is-hidden {
  display: none;
}

.card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 18, 27, 0.88);
  backdrop-filter: blur(10px);
}

.card h1,
.card p,
.card strong {
  margin: 0;
}

.controls-card label {
  display: grid;
  gap: 6px;
}

.controls-card select,
.controls-card input,
.controls-card button {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  font: inherit;
  padding: 10px 12px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.compact {
  gap: 4px;
}

.network-card {
  gap: 8px;
}

.network-meta {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.network-meta p,
.network-meta strong {
  margin: 0;
  font-size: 0.78rem;
}

/* ============================================================
   MENU FLOW — overlays, panels, main menu, character select,
   multiplayer, weapon upgrade, in-match menu, match result.
   Uses flat metallic dark slate with subtle teal accent.
   ============================================================ */

.screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(40, 100, 110, 0.35), transparent 70%),
    linear-gradient(180deg, rgba(2, 6, 10, 0.62), rgba(2, 6, 10, 0.82));
  backdrop-filter: blur(6px);
  pointer-events: auto;
  animation: screen-overlay-in 0.18s ease-out;
}

.screen-overlay.is-hidden {
  display: none;
}

@keyframes screen-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

body.menu-flow-active .combat-ui > :not(.screen-overlay) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.menu-flow-active > #btn-debug-toggle,
body.menu-flow-active > #btn-menu-toggle,
body.menu-flow-active > #debug-hud {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ── shared panel chrome ── */
.screen-panel {
  position: relative;
  isolation: isolate;
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 26px;
  border-radius: 16px;
  border: 1px solid rgba(102, 138, 146, 0.32);
  background:
    linear-gradient(180deg, rgba(38, 58, 66, 0.94), rgba(14, 22, 28, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    0 22px 48px rgba(0, 0, 0, 0.55),
    0 2px 0 rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
  animation: screen-panel-in 0.22s ease-out both;
}

.screen-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 130% 60% at 50% 0%, rgba(127, 215, 200, 0.07), transparent 60%);
  pointer-events: none;
}

.screen-panel h1,
.screen-panel p,
.screen-panel strong,
.screen-panel span,
.screen-panel label {
  margin: 0;
}

.screen-panel h1 {
  font: 800 1.55rem/1.15 "Open Sans", sans-serif;
  color: #f1faff;
  letter-spacing: 0.02em;
}

.screen-kicker,
.screen-note {
  font: 800 0.7rem/1 "Open Sans", sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #6fc7a8;
}

@keyframes screen-panel-in {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* shared header row (Back | Title | extra) */
.screen-panel-head,
.character-select-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.screen-panel-head strong,
.character-select-head strong {
  text-align: center;
  font: 800 1.05rem/1 "Open Sans", sans-serif;
  color: #eaf6ff;
  letter-spacing: 0.02em;
}

/* ── shared base buttons / inputs inside panels ── */
.screen-panel button,
.screen-panel input,
.chat-input-shell button,
.chat-input-shell input,
.lobby-chat-form button,
.lobby-chat-form input {
  border: 1px solid rgba(0, 0, 0, 0.55);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, #3b4a4d, #1d2a2d);
  color: #eef6fb;
  font: 700 0.92rem/1 "Open Sans", sans-serif;
  padding: 11px 14px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 1px 0 rgba(0, 0, 0, 0.4);
  min-height: 42px;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease,
    filter 0.12s ease;
}

.screen-panel input,
.chat-input-shell input,
.lobby-chat-form input {
  font-weight: 600;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.28));
  border-color: rgba(0, 0, 0, 0.6);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  cursor: text;
}

.screen-panel input::placeholder,
.chat-input-shell input::placeholder,
.lobby-chat-form input::placeholder {
  color: rgba(238, 246, 251, 0.4);
}

.screen-panel input:focus,
.chat-input-shell input:focus,
.lobby-chat-form input:focus {
  outline: none;
  border-color: rgba(118, 220, 173, 0.6);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.45),
    0 0 0 2px rgba(118, 220, 173, 0.22);
}

.screen-panel button:not(:disabled) {
  cursor: pointer;
}

.screen-panel button:not(:disabled):hover {
  transform: translateY(-1px);
  border-color: rgba(118, 220, 173, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 4px 12px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(118, 220, 173, 0.28);
}

.screen-panel button:not(:disabled):active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.screen-panel button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.screen-primary {
  background:
    linear-gradient(180deg, #95eaa9 0%, #4eb771 55%, #2c8a4e 100%) !important;
  color: #082a16 !important;
  border-color: #1f4927 !important;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  font-weight: 800 !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -2px 0 rgba(0, 0, 0, 0.25),
    0 2px 0 rgba(20, 60, 32, 0.5),
    0 6px 14px rgba(46, 138, 78, 0.32) !important;
}

.screen-primary:not(:disabled):hover {
  filter: brightness(1.08);
  border-color: #1f4927 !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -2px 0 rgba(0, 0, 0, 0.25),
    0 4px 0 rgba(20, 60, 32, 0.5),
    0 8px 18px rgba(46, 138, 78, 0.42) !important;
}

.screen-secondary {
  color: #c9e8f5 !important;
}

/* ──────────────── MAIN MENU ──────────────── */

.main-flow-overlay {
  background:
    radial-gradient(ellipse 70% 50% at 50% 30%, rgba(50, 110, 130, 0.4), transparent 70%),
    linear-gradient(180deg, rgba(2, 8, 14, 0.42), rgba(2, 8, 14, 0.7));
  backdrop-filter: blur(2px);
}

.main-menu-stack {
  display: grid;
  gap: 18px;
  justify-items: center;
  align-content: center;
  width: min(440px, calc(100vw - 28px));
  max-height: calc(100vh - 16px);
  padding: 8px 0;
}

.main-menu-logo {
  width: auto;
  height: auto;
  max-width: min(70vw, 440px);
  max-height: min(22vh, 200px);
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.7));
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.main-menu-profile {
  display: grid;
  gap: 8px;
  justify-items: center;
  min-height: 46px;
  width: 100%;
}

.player-name-button {
  min-width: 200px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.55);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, rgba(48, 64, 70, 0.85), rgba(18, 28, 32, 0.9));
  color: #eaf6ff;
  font: 700 0.92rem/1 "Open Sans", sans-serif;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 2px 0 rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.player-name-button:hover {
  transform: translateY(-1px);
  border-color: rgba(118, 220, 173, 0.5);
}

.player-name-editor {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  width: min(320px, 100%);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.55);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, rgba(48, 64, 70, 0.9), rgba(18, 28, 32, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 2px 0 rgba(0, 0, 0, 0.45);
}

.player-name-editor.is-hidden {
  display: none;
}

.player-name-editor span {
  color: #76dbb1;
  font: 800 0.68rem/1 "Open Sans", sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.player-name-editor input {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #eaf6ff;
  font: 700 0.92rem/1 "Open Sans", sans-serif;
  padding: 8px 0 !important;
  min-height: auto !important;
}

.main-diamond-balance {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 19;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.main-diamond-balance img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7));
}

.main-diamond-balance strong {
  font: 900 1.25rem/1 "Open Sans", "Arial Black", sans-serif;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, #ffffff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter:
    drop-shadow(1px 0 0 #000)
    drop-shadow(-1px 0 0 #000)
    drop-shadow(0 1px 0 #000)
    drop-shadow(0 -1px 0 #000);
}

.main-menu-actions {
  display: grid;
  gap: 12px;
  width: 100%;
}

.main-menu-cta {
  display: grid;
  gap: 4px;
  justify-items: center;
  width: 100%;
  padding: 16px 22px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.55);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, #3e525a, #1c2930);
  color: #eaf6ff;
  cursor: pointer;
  text-align: center;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 4px 0 rgba(0, 0, 0, 0.45),
    0 8px 20px rgba(0, 0, 0, 0.4);
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    filter 0.15s ease;
}

.main-menu-cta-label {
  font: 800 1.05rem/1 "Open Sans", sans-serif;
  letter-spacing: 0.04em;
}

.main-menu-cta-sub {
  font: 700 0.72rem/1 "Open Sans", sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.65;
}

.main-menu-cta:hover {
  transform: translateY(-2px);
  border-color: rgba(118, 220, 173, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 6px 0 rgba(0, 0, 0, 0.45),
    0 12px 26px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(118, 220, 173, 0.28);
}

.main-menu-cta:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.main-menu-cta.is-primary {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, #95eaa9 0%, #4eb771 55%, #2c8a4e 100%);
  color: #082a16;
  border-color: #1f4927;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 0 rgba(0, 0, 0, 0.22),
    0 4px 0 rgba(20, 60, 32, 0.55),
    0 10px 22px rgba(46, 138, 78, 0.42);
}

.main-menu-cta.is-primary .main-menu-cta-sub {
  opacity: 0.78;
}

.main-menu-cta.is-primary:hover {
  filter: brightness(1.08);
  border-color: #1f4927;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 0 rgba(0, 0, 0, 0.22),
    0 6px 0 rgba(20, 60, 32, 0.55),
    0 14px 28px rgba(46, 138, 78, 0.48);
}

/* ──────────────── CHARACTER SELECT ──────────────── */

.character-select-panel {
  width: min(540px, calc(100vw - 28px));
  text-align: center;
  gap: 16px;
}

.character-stage {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background:
    radial-gradient(ellipse 60% 70% at 50% 70%, rgba(40, 110, 95, 0.32), transparent 70%),
    linear-gradient(180deg, rgba(8, 18, 24, 0.9), rgba(4, 10, 14, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

#character-preview-canvas {
  width: 100%;
  height: auto;
  min-height: 240px;
  max-height: 360px;
  display: block;
  background: transparent;
}

.round-nav {
  width: 50px !important;
  height: 84px !important;
  padding: 0 !important;
  font: 800 2.2rem/1 "Open Sans", sans-serif !important;
  color: #cce8f5 !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, rgba(50, 66, 70, 0.85), rgba(18, 28, 32, 0.92)) !important;
  min-height: 0 !important;
}

.character-preview-name {
  font: 800 1.2rem/1 "Open Sans", sans-serif;
  color: #eaf6ff;
  letter-spacing: 0.04em;
}

/* ──────────────── MULTIPLAYER ──────────────── */

.multiplayer-panel {
  width: min(880px, calc(100vw - 28px));
}

.multiplayer-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: start;
}

.multiplayer-actions,
.upgrade-stat-list {
  display: grid;
  gap: 10px;
}

.join-code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.join-code-row input {
  letter-spacing: 0.1em;
  text-align: center;
  font-weight: 700;
}

.room-code-chip {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, rgba(48, 64, 70, 0.92), rgba(18, 28, 32, 0.94));
  border: 1px solid rgba(0, 0, 0, 0.55);
  color: #c9e8f5;
  font: 800 0.78rem/1 "Open Sans", sans-serif;
  letter-spacing: 0.08em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 2px 0 rgba(0, 0, 0, 0.4);
}

.inline-resource-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

.server-list,
.lobby-player-list,
.menu-player-list {
  display: grid;
  gap: 8px;
  align-content: start;
}

.server-list {
  min-height: 120px;
  max-height: 280px;
  overflow: auto;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.55);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.25));
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
  color: rgba(238, 246, 251, 0.55);
  font: 600 0.85rem/1.4 "Open Sans", sans-serif;
  text-align: center;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.server-list:has(> .server-card) {
  text-align: left;
}

.server-card,
.lobby-player-card,
.menu-player-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.45);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, rgba(44, 60, 64, 0.85), rgba(20, 30, 34, 0.9));
  color: #eaf6ff;
  font: 600 0.88rem/1.2 "Open Sans", sans-serif;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.server-card button {
  padding: 8px 12px;
  min-height: 36px;
}

#multiplayer-overlay.is-lobby-mode .multiplayer-grid {
  grid-template-columns: 1fr;
}

#multiplayer-overlay.is-lobby-mode .multiplayer-actions {
  display: none;
}

#multiplayer-overlay.is-lobby-mode .lobby-panel {
  min-height: 380px;
}

.lobby-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.45);
  background: linear-gradient(180deg, rgba(20, 30, 34, 0.55), rgba(10, 18, 22, 0.7));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.lobby-panel.is-hidden {
  display: none;
}

.lobby-panel > strong {
  font: 800 0.95rem/1 "Open Sans", sans-serif;
  color: #eaf6ff;
}

.lobby-panel #lobby-room-summary {
  font: 600 0.82rem/1.3 "Open Sans", sans-serif;
  color: rgba(238, 246, 251, 0.7);
}

.lobby-chat-history {
  display: grid;
  gap: 4px;
  align-content: end;
  min-height: 130px;
  max-height: 180px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.55);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.3));
  color: rgba(238, 246, 251, 0.78);
  font: 600 0.82rem/1.4 "Open Sans", sans-serif;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.lobby-chat-line {
  display: flex;
  gap: 6px;
  align-items: baseline;
  min-width: 0;
}

.lobby-chat-line strong {
  flex: 0 0 auto;
  font: 700 0.82rem/1 "Open Sans", sans-serif;
  color: #76dbb1;
}

.lobby-chat-line strong::after {
  content: ":";
}

.lobby-chat-line span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #eaf6ff;
}

.lobby-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

/* ──────────────── IN-MATCH MENU ──────────────── */

.game-menu-panel {
  width: min(740px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(240px, 1.2fr) minmax(150px, 1fr);
  align-items: start;
  gap: 16px;
}

.game-menu-side,
.game-menu-center {
  display: grid;
  gap: 10px;
  align-content: start;
}

.game-menu-side {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  background: linear-gradient(180deg, rgba(20, 30, 34, 0.55), rgba(10, 18, 22, 0.65));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.game-menu-side > strong,
.game-menu-center > strong {
  font: 800 0.72rem/1 "Open Sans", sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #76dbb1;
}

.game-menu-side p,
.menu-player-list {
  font: 600 0.84rem/1.3 "Open Sans", sans-serif;
  color: rgba(238, 246, 251, 0.78);
}

/* ──────────────── WEAPON UPGRADE ──────────────── */

.upgrade-panel {
  width: min(900px, calc(100vw - 28px));
  max-height: min(720px, calc(100vh - 34px));
}

.upgrade-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(300px, 1.2fr);
  gap: 18px;
  align-items: start;
}

#weapon-preview-canvas {
  display: block;
  width: 100%;
  height: clamp(220px, 30vh, 320px);
  min-height: 0;
  max-height: 340px;
  align-self: start;
  border-radius: 12px;
  background:
    radial-gradient(ellipse 70% 60% at 50% 50%, rgba(40, 110, 95, 0.3), transparent 70%),
    linear-gradient(180deg, rgba(10, 18, 22, 0.9), rgba(4, 10, 14, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.upgrade-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.upgrade-tabs button {
  padding: 8px 14px !important;
  min-height: 40px;
  font: 700 0.82rem/1 "Open Sans", sans-serif !important;
}

.upgrade-tabs button.is-active {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, rgba(120, 200, 170, 0.5), rgba(40, 80, 70, 0.65)) !important;
  border-color: rgba(118, 220, 173, 0.55) !important;
  color: #eafff5 !important;
}

.upgrade-tabs button:not(.is-active) {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, rgba(48, 64, 68, 0.7), rgba(20, 30, 34, 0.8)) !important;
}

.upgrade-stat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, rgba(40, 56, 60, 0.85), rgba(18, 28, 32, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.upgrade-stat-meta {
  display: grid;
  gap: 6px;
  text-align: left;
  min-width: 0;
}

.upgrade-stat-meta strong {
  font: 700 0.88rem/1.1 "Open Sans", sans-serif;
  color: #eaf6ff;
}

.upgrade-level-track {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 160px;
}

.upgrade-dot {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.35);
}

.upgrade-dot.is-filled {
  background: linear-gradient(180deg, #95eaa9, #4eb771);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 0 6px rgba(118, 220, 173, 0.4);
}

.diamond-cost-button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 86px;
  padding: 9px 12px !important;
  font-weight: 800 !important;
}

.upgrade-dps-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(180, 130, 40, 0.5);
  background:
    linear-gradient(180deg, rgba(255, 200, 80, 0.18), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, rgba(70, 56, 28, 0.78), rgba(34, 26, 14, 0.86));
  color: #ffd784;
  font: 800 0.95rem/1 "Open Sans", sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 130, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4);
}

.upgrade-dps-row strong {
  font: 800 1.1rem/1 "Open Sans", sans-serif;
  color: #ffe8a8;
  letter-spacing: 0;
  text-transform: none;
}

.upgrade-effect {
  pointer-events: none;
  height: 4px;
  border-radius: 999px;
  margin-top: 10px;
  background: transparent;
}

.upgrade-effect.is-active {
  animation: upgrade-flash 0.75s ease-out;
}

@keyframes upgrade-flash {
  0% { box-shadow: 0 0 0 rgba(131, 233, 185, 0); background: #83e9b9; }
  40% { box-shadow: 0 0 28px rgba(131, 233, 185, 0.95); background: #fff0a8; }
  100% { box-shadow: 0 0 0 rgba(131, 233, 185, 0); background: transparent; }
}

/* ──────────────── MATCH RESULT ──────────────── */

.match-result-panel {
  width: min(440px, calc(100vw - 28px));
  text-align: center;
  gap: 16px;
}

.result-diamonds {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-items: stretch;
}

.result-diamonds > div {
  display: grid;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.45);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, rgba(40, 56, 60, 0.85), rgba(18, 28, 32, 0.9));
}

.result-diamonds > div span {
  font: 700 0.7rem/1 "Open Sans", sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(238, 246, 251, 0.6);
}

.result-diamonds > div strong {
  font: 800 1.15rem/1 "Open Sans", sans-serif;
  color: #eaf6ff;
}

/* ──────────────── RESPONSIVE ──────────────── */

@media (max-width: 720px) {
  .screen-overlay {
    padding: 14px;
  }

  .screen-panel {
    padding: 18px 18px;
    border-radius: 14px;
    gap: 14px;
  }

  .screen-panel h1 {
    font-size: 1.3rem;
  }

  .main-menu-stack {
    gap: 14px;
    padding: 4px 0;
  }

  .main-menu-logo {
    max-width: min(80vw, 360px);
    max-height: min(20vh, 160px);
  }

  .main-menu-cta {
    padding: 12px 18px;
    gap: 2px;
  }

  .main-menu-cta-label {
    font-size: 1rem;
  }

  .main-menu-cta-sub {
    font-size: 0.68rem;
  }

  .main-diamond-balance {
    top: 10px;
    right: 12px;
    gap: 6px;
  }

  .main-diamond-balance img {
    width: 30px;
    height: 30px;
  }

  .main-diamond-balance strong {
    font-size: 1.05rem;
  }

  .multiplayer-grid,
  .upgrade-layout {
    grid-template-columns: 1fr;
  }

  .game-menu-panel {
    grid-template-columns: 1fr;
  }

  .game-menu-side {
    padding: 10px 12px;
  }

  .character-stage {
    grid-template-columns: 44px 1fr 44px;
    padding: 10px;
    gap: 8px;
  }

  .round-nav {
    width: 44px !important;
    height: 64px !important;
    font-size: 1.8rem !important;
  }

  .upgrade-tabs button {
    padding: 8px 10px !important;
    font-size: 0.78rem;
  }

  #weapon-preview-canvas {
    height: clamp(180px, 28vh, 240px);
  }

  .upgrade-stat-meta strong {
    font-size: 0.82rem;
  }

  .result-diamonds {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .player-name-button,
  .player-name-editor {
    min-width: 0;
    width: 100%;
  }

  .upgrade-stat-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .upgrade-stat-row .diamond-cost-button {
    justify-self: stretch;
  }

  .join-code-row {
    grid-template-columns: 1fr;
  }
}

/* short / landscape phones — keep main menu fitting in viewport */
@media (max-height: 560px) {
  .main-menu-stack {
    gap: 10px;
    padding: 0;
  }

  .main-menu-logo {
    max-height: min(28vh, 110px);
    max-width: min(50vw, 320px);
  }

  .main-menu-profile {
    min-height: 0;
  }

  .player-name-button {
    padding: 7px 16px;
    font-size: 0.85rem;
  }

  .main-menu-actions {
    gap: 8px;
  }

  .main-menu-cta {
    padding: 9px 16px;
  }

  .main-menu-cta-label {
    font-size: 0.95rem;
  }

  .main-menu-cta-sub {
    font-size: 0.64rem;
    letter-spacing: 0.08em;
  }

  .main-diamond-balance {
    top: 8px;
    right: 12px;
  }

  .main-diamond-balance img {
    width: 26px;
    height: 26px;
  }

  .main-diamond-balance strong {
    font-size: 0.95rem;
  }
}

.chat-history {
  position: fixed;
  left: 50%;
  bottom: 156px;
  transform: translateX(-50%);
  z-index: 14;
  width: min(520px, calc(100vw - 24px));
  display: grid;
  gap: 5px;
  pointer-events: none;
}

.chat-history.is-hidden {
  display: none;
}

.chat-line {
  justify-self: center;
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 11px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0) 46%),
    linear-gradient(180deg, rgba(27, 42, 45, 0.9), rgba(8, 16, 20, 0.92));
  border: 2px solid rgba(5, 8, 9, 0.88);
  color: #effaff;
  font: 800 0.82rem/1.25 "Open Sans", sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.11),
    0 3px 0 rgba(0, 0, 0, 0.4);
}

.chat-input-shell {
  position: fixed;
  left: 50%;
  bottom: 128px;
  transform: translateX(-50%);
  z-index: 20;
  width: min(520px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(47, 61, 62, 0.92), rgba(13, 22, 25, 0.95));
  border: 3px solid rgba(7, 10, 11, 0.86);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    0 4px 0 rgba(0, 0, 0, 0.5);
}

.chat-input-shell.is-hidden {
  display: none;
}

.side-btn-chat {
  position: relative;
  width: 70px;
  height: 70px;
  margin-bottom: 10px;
  background: var(--ui-round) center / 100% 100% no-repeat;
}

.side-btn-chat-icon {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 1.8rem;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.8));
}

.side-btn-chat-key {
  position: absolute;
  left: 50%;
  bottom: -19px;
  transform: translateX(-50%);
  font: 900 13px/1 "Open Sans", "Arial Black", "Impact", sans-serif;
  background: linear-gradient(180deg, #ffffff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter:
    drop-shadow(1px 0 0 #000)
    drop-shadow(-1px 0 0 #000)
    drop-shadow(0 1px 0 #000)
    drop-shadow(0 -1px 0 #000);
  pointer-events: none;
}

/* ── Global HUD text: black outline + white-to-gray gradient ── */

.combat-ui strong,
.combat-ui .player-weapon-ammo,
.combat-ui .kill-counter-hud strong,
.combat-ui .resource-chip strong,
.shop-frame-title,
.shop-item-card strong,
.shop-detail-name,
.shop-tab-btn span,
.shop-detail-buy-label {
  font-family: "Open Sans", "Arial Black", "Impact", "Segoe UI Black", sans-serif;
  font-weight: 900;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, #ffffff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter:
    drop-shadow(1px 0 0 #000)
    drop-shadow(-1px 0 0 #000)
    drop-shadow(0 1px 0 #000)
    drop-shadow(0 -1px 0 #000);
}

/* ── Combat UI overlay ── */

.combat-ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

/* ── Player Vitals (top-left) ── */

.player-vitals {
  position: fixed;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.player-vitals-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.player-vitals-avatar {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  background: url('./sprites/bordered_panel.png') center / 100% 100% no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}


.portrait-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.player-vitals-icon {
  width: 44px;
  height: 44px;
  opacity: 0.85;
}

/* ── Weapon Slot (below portrait) ── */

.player-weapon-slot {
  position: relative;
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
}

.player-weapon-slot-icon {
  width: 72px;
  height: 72px;
  background: url('./sprites/bordered_panel.png') center / 100% 100% no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
}

.player-weapon-slot-icon img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

.weapon-slot-placeholder {
  width: 36px;
  height: 36px;
  opacity: 0.5;
}

.player-weapon-ammo {
  font-family: "Open Sans", "Arial Black", "Impact", "Segoe UI Black", sans-serif;
  font-weight: 900;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, #ffffff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter:
    drop-shadow(1px 0 0 #000)
    drop-shadow(-1px 0 0 #000)
    drop-shadow(0 1px 0 #000)
    drop-shadow(0 -1px 0 #000);
  font-size: 1.1rem;
  white-space: nowrap;
  text-align: center;
}

.weapon-ammo-buy {
  position: absolute;
  left: calc(100% + 8px);
  top: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.6);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, rgba(58, 108, 76, 0.96), rgba(26, 60, 40, 0.98));
  color: #ffffff;
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 3px 0 rgba(0, 0, 0, 0.55),
    0 6px 14px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}

.weapon-ammo-buy.is-hidden {
  display: none;
}

.weapon-ammo-buy:not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.26),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 4px 0 rgba(0, 0, 0, 0.55),
    0 8px 18px rgba(0, 0, 0, 0.5);
}

.weapon-ammo-buy:not(:disabled):active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(0, 0, 0, 0.5);
}

.weapon-ammo-buy:disabled {
  cursor: not-allowed;
  filter: grayscale(0.55) brightness(0.7);
}

.weapon-ammo-buy-plus {
  font: 900 22px/1 "Open Sans", "Arial Black", sans-serif;
  color: #ffffff;
  text-shadow:
    1px 0 0 rgba(0, 0, 0, 0.7),
    -1px 0 0 rgba(0, 0, 0, 0.7),
    0 1px 0 rgba(0, 0, 0, 0.7),
    0 -1px 0 rgba(0, 0, 0, 0.7),
    0 2px 0 rgba(0, 0, 0, 0.45);
  margin-top: -2px;
}

.weapon-ammo-buy-cost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font: 900 14px/1 "Open Sans", "Arial Black", sans-serif;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, #ffffff 0%, #c9c9c9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter:
    drop-shadow(1px 0 0 #000)
    drop-shadow(-1px 0 0 #000)
    drop-shadow(0 1px 0 #000)
    drop-shadow(0 -1px 0 #000);
}

.weapon-ammo-buy-cost img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

.weapon-ammo-buy-key {
  position: absolute;
  left: 50%;
  bottom: -18px;
  transform: translateX(-50%);
  font: 900 13px/1 "Open Sans", "Arial Black", "Impact", sans-serif;
  background: linear-gradient(180deg, #ffffff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter:
    drop-shadow(1px 0 0 #000)
    drop-shadow(-1px 0 0 #000)
    drop-shadow(0 1px 0 #000)
    drop-shadow(0 -1px 0 #000);
  pointer-events: none;
}

@media (hover: none) and (pointer: coarse) {
  .weapon-ammo-buy-key {
    display: none;
  }
}

.player-vitals-bars {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding-top: 4px;
}

.player-vitals-bar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-bar-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  object-fit: contain;
  image-rendering: auto;
}

.player-vitals-bar-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  min-width: 58px;
  text-align: right;
}

.player-health-bar,
.player-mana-bar {
  position: relative;
  overflow: hidden;
  width: var(--player-status-bar-width);
  height: 22px;
  border-radius: 4px;
  background: #343e40;
  border: 2px solid #000;
}

.player-health-fill,
.player-health-glow,
.player-mana-fill,
.player-mana-glow {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: inherit;
  transform-origin: left center;
}

.player-health-fill {
  background: linear-gradient(180deg, #d34d32 0%, #d34d32 50%, #a83a28 50%, #a83a28 100%);
}

.player-health-bar.is-critical .player-health-fill {
  animation: healthBlink 0.6s ease-in-out infinite;
}

@keyframes healthBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.player-health-glow {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, transparent 50%);
  mix-blend-mode: screen;
  opacity: 0.5;
}

.player-mana-fill {
  background: linear-gradient(180deg, #dbae21 0%, #dbae21 50%, #c2871f 50%, #c2871f 100%);
}

.player-mana-glow {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, transparent 50%);
  mix-blend-mode: screen;
  opacity: 0.4;
}

.player-vitals-head {
  display: none;
}

.player-ammo-status {
  display: none;
  margin: 0;
}

/* ── Resources (top, no background) ── */

.resource-hud {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 12;
  pointer-events: auto;
}

.resource-chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  min-width: 48px;
}

.resource-chip + .resource-chip {
  border-left: none;
}

.resource-chip[data-resource]:not([data-resource="coins"]) {
  cursor: pointer;
}

.resource-chip[data-flow="up"]::before,
.resource-chip[data-flow="down"]::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  width: 18px;
  height: 11px;
  transform: translateX(-50%);
  background: #58f05f;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.75));
  pointer-events: none;
}

.resource-chip[data-flow="down"]::before {
  transform: translateX(-50%) rotate(180deg);
  background: #ff5d4f;
}

.resource-chip.is-paused::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  width: 32px;
  height: 32px;
  transform: translateX(-50%);
  background:
    linear-gradient(45deg, transparent 44%, rgba(255, 44, 44, 0.95) 47%, rgba(255, 44, 44, 0.95) 53%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, rgba(255, 44, 44, 0.95) 47%, rgba(255, 44, 44, 0.95) 53%, transparent 56%);
  filter: none;
  pointer-events: none;
}

.resource-icon-img {
  width: 40px;
  height: 40px;
  image-rendering: auto;
  object-fit: contain;
}

/* Hide old SVG resource icons */
.resource-chip span.resource-icon {
  display: none;
}

.resource-chip strong {
  font-size: 1.2rem;
  line-height: 1;
}

/* ── Kill Counter (below resources, no background) ── */

.kill-counter-hud {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
}

.kill-counter-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  image-rendering: auto;
}

.kill-counter-hud strong {
  font-size: 1.5rem;
}

.kill-counter-wave,
.truce-timer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.truce-timer strong {
  font-size: 1.5rem;
}

/* ── Side Buttons (right side, vertically centered) ── */

.side-buttons {
  position: fixed;
  top: 47%;
  right: 12px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 18px;
  pointer-events: auto;
  z-index: 4;
}

.side-btn {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s;
}

.side-btn:hover {
  transform: scale(1.08);
}

.side-btn.is-hidden {
  display: none;
}

body.desktop-aim-active #btn-shop {
  position: relative;
}

body.desktop-aim-active #btn-debug-toggle,
body.desktop-aim-active #btn-menu-toggle {
  position: fixed;
}

body.desktop-aim-active #btn-shop::after,
body.desktop-aim-active #btn-menu-toggle::after {
  position: absolute;
  left: 50%;
  bottom: -18px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: linear-gradient(180deg, #ffffff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font: 900 13px/1 "Open Sans", "Arial Black", "Impact", "Segoe UI Black", sans-serif;
  letter-spacing: 0.03em;
  text-align: center;
  filter:
    drop-shadow(1px 0 0 #000)
    drop-shadow(-1px 0 0 #000)
    drop-shadow(0 1px 0 #000)
    drop-shadow(0 -1px 0 #000);
  transform: translateX(-50%);
  pointer-events: none;
}

body.desktop-aim-active #btn-shop::after {
  content: "Q";
}

body.desktop-aim-active #btn-menu-toggle::after {
  content: "Esc";
}

.desktop-build-hotbar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 12;
  display: flex;
  gap: 24px;
  align-items: flex-end;
  justify-content: center;
  transform: translate3d(-50%, 0, 0);
  pointer-events: auto;
  isolation: isolate;
  will-change: transform;
}

.desktop-build-hotbar.is-hidden {
  display: none;
}

.desktop-build-slot {
  position: relative;
  width: 72px;
  height: 108px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  overflow: visible;
}

.desktop-build-slot:hover:not(.is-empty) {
  transform: translateY(-2px);
}

.desktop-build-slot.is-empty {
  opacity: 0.52;
  cursor: default;
}

.desktop-build-slot-key {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  width: auto;
  height: auto;
  background: linear-gradient(180deg, #ffffff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font: 900 14px/1 "Open Sans", "Arial Black", "Impact", "Segoe UI Black", sans-serif;
  letter-spacing: 0.03em;
  text-align: center;
  filter:
    drop-shadow(1px 0 0 #000)
    drop-shadow(-1px 0 0 #000)
    drop-shadow(0 1px 0 #000)
    drop-shadow(0 -1px 0 #000);
}

.desktop-build-slot-icon {
  position: absolute;
  top: 0;
  left: 0;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: url('./sprites/bordered_panel.png') center / 100% 100% no-repeat;
}

.desktop-build-slot-icon img {
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.28));
}

.desktop-build-slot-cost {
  position: absolute;
  left: -14px;
  right: -14px;
  bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(180deg, #ffffff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font: 900 14px/1.05 "Open Sans", "Arial Black", "Impact", "Segoe UI Black", sans-serif;
  letter-spacing: 0.03em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  filter:
    drop-shadow(1px 0 0 #000)
    drop-shadow(-1px 0 0 #000)
    drop-shadow(0 1px 0 #000)
    drop-shadow(0 -1px 0 #000);
}

.desktop-build-slot-cost-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
}

.desktop-build-slot-cost-chip img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
}

.desktop-build-slot-cost-chip span {
  background: linear-gradient(180deg, #ffffff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.desktop-build-slot-cost-chip.is-missing span {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: #ff8f78;
  color: #ff8f78;
}

.shop-item-card {
  position: relative;
}

.shop-slot-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  width: auto;
  height: auto;
  background: linear-gradient(180deg, #ffffff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font: 900 15px/1 "Open Sans", "Arial Black", "Impact", "Segoe UI Black", sans-serif;
  letter-spacing: 0.03em;
  text-align: center;
  filter:
    drop-shadow(1px 0 0 #000)
    drop-shadow(-1px 0 0 #000)
    drop-shadow(0 1px 0 #000)
    drop-shadow(0 -1px 0 #000);
}

body.desktop-aim-active .placement-actions {
  display: none;
}

body.desktop-aim-active .shop-detail-buy {
  display: none;
}

.side-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Survival HUD — hidden, info shown via wave announce only ── */

.survival-hud {
  display: none !important;
}

/* ── Shop HUD (centered overlay, split layout) ── */

.shop-hud {
  position: fixed;
  inset: 0;
  font-family: "Open Sans", "Arial Black", "Impact", "Segoe UI Black", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  isolation: isolate;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: auto;
  z-index: 20;
}

.shop-hud::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  pointer-events: none;
  z-index: 0;
}

.shop-hud.is-hidden {
  display: none;
}

.shop-hud-frame {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(860px, calc(100vw - 48px));
  max-height: min(84vh, 660px);
  border-radius: 24px;
  border: 4px solid #7a5b34;
  background:
    linear-gradient(180deg, rgba(246, 221, 176, 0.08), rgba(0, 0, 0, 0)),
    linear-gradient(180deg, #6a4a2b 0%, #4a311b 9%, #22160d 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,244,214,0.16),
    inset 0 -1px 0 rgba(48,28,12,0.55),
    0 24px 64px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.shop-hud-frame::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 18px;
  border: 1px solid rgba(255, 226, 168, 0.08);
  pointer-events: none;
}

/* ── Close button (absolute top-right) ── */

.shop-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 52px;
  height: 52px;
  border: 0;
  padding: 0;
  background: url("./sprites/shop_close_btn.png") center / 100% 100% no-repeat;
  cursor: pointer;
  z-index: 2;
  font-size: 0;
  color: transparent;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.shop-close-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

/* ── Shop tabs ── */

.shop-tab-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  padding: 18px 72px 14px 18px;
  background:
    linear-gradient(180deg, rgba(255, 239, 205, 0.08), rgba(0,0,0,0)),
    linear-gradient(180deg, #8a6840 0%, #654829 100%);
  border-bottom: 3px solid rgba(32, 18, 8, 0.55);
}

.shop-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 6px 18px;
  border: 0;
  background: url("./sprites/shop_tab_inactive.png") center / 100% 100% no-repeat;
  color: rgba(58, 38, 16, 0.55);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, color 0.12s ease;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

.shop-tab-btn:hover {
  filter: brightness(1.04);
  color: rgba(48, 28, 12, 0.8);
}

.shop-tab-btn.is-active {
  background-image: url("./sprites/shop_tab_active.png");
  color: #3a2814;
}

.shop-tab-btn img {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
}

/* ── Shop body: left sidebar + right detail ── */

.shop-body {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 18px;
  min-height: 0;
  padding: 18px;
}

/* ── Left: item sidebar ── */

.shop-list-scroll {
  overflow-y: auto;
  padding: 12px;
  border-radius: 20px;
  border: 2px solid rgba(88, 58, 31, 0.8);
  background:
    linear-gradient(180deg, rgba(255, 219, 155, 0.06), rgba(0,0,0,0)),
    linear-gradient(180deg, #2f2419 0%, #1c1610 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
  scrollbar-width: thin;
  scrollbar-color: rgba(214, 173, 104, 0.45) transparent;
}

.shop-list-scroll::-webkit-scrollbar {
  width: 10px;
}

.shop-list-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(214, 173, 104, 0.45);
}

.shop-item-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.shop-item-card {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 10px;
  min-height: 188px;
  padding: 12px;
  border-radius: 18px;
  border: 2px solid rgba(112, 82, 46, 0.72);
  background:
    linear-gradient(180deg, rgba(255, 232, 184, 0.08), rgba(0,0,0,0)),
    linear-gradient(180deg, #344551 0%, #243039 100%);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 8px 18px rgba(0,0,0,0.22);
}

.shop-item-card:hover {
  transform: translateY(-2px);
  border-color: rgba(214, 175, 101, 0.72);
}

.shop-item-card.is-selected {
  border-color: #8fee7a;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 0 0 2px rgba(120, 226, 101, 0.18),
    0 12px 26px rgba(0,0,0,0.3);
}

.shop-item-card.is-unaffordable {
  opacity: 0.82;
}

.shop-item-card.is-owned {
  border-color: rgba(98, 244, 165, 0.82);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 0 0 2px rgba(98, 244, 165, 0.18),
    0 12px 26px rgba(0,0,0,0.3);
}

.shop-item-preview {
  height: 94px;
  border-radius: 16px;
  border: 2px solid rgba(255, 222, 177, 0.08);
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 215, 150, 0.12), transparent 48%),
    linear-gradient(180deg, #314752 0%, #1b2830 100%);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shop-item-preview img {
  max-width: 88%;
  max-height: 88%;
  object-fit: contain;
}

.shop-item-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.shop-item-card strong {
  font-size: 0.82rem;
  line-height: 1.05;
  text-align: left;
  text-transform: uppercase;
  word-break: break-word;
}

.shop-item-kind,
.shop-cost-list,
.shop-cost-chip {
  display: flex;
}

.shop-item-kind {
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(255, 235, 193, 0.62);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.shop-cost-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.shop-cost-chip,
.shop-detail-cost-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 225, 180, 0.1);
  background: rgba(14, 12, 10, 0.28);
  font-size: 0.76rem;
  font-weight: 800;
  color: rgba(255, 244, 219, 0.92);
}

.shop-cost-chip img,
.shop-detail-cost-chip img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.shop-cost-chip.is-missing,
.shop-detail-cost-chip.is-missing {
  color: #ff8f78;
  border-color: rgba(204, 96, 72, 0.34);
}

.shop-owned-chip {
  min-width: 34px;
  justify-content: center;
  color: #7ff0a3;
  border-color: rgba(98, 244, 165, 0.42);
  background: rgba(38, 98, 60, 0.34);
  font-size: 1rem;
  line-height: 1;
}

.shop-empty-state {
  margin: 0;
  padding: 28px 16px;
  text-align: center;
  color: rgba(239, 222, 188, 0.42);
  font-size: 0.84rem;
  grid-column: 1 / -1;
}

.shop-empty-state.is-hidden {
  display: none;
}

/* ── Right: detail panel ── */

.shop-detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 20px;
  border: 2px solid rgba(88, 58, 31, 0.8);
  background:
    linear-gradient(180deg, rgba(255, 229, 176, 0.08), rgba(0,0,0,0)),
    linear-gradient(180deg, #2d2419 0%, #18120d 100%);
  overflow-y: auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.shop-detail-top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.shop-detail-preview {
  width: 100%;
  min-height: 200px;
  border-radius: 18px;
  border: 2px solid rgba(255, 224, 176, 0.12);
  background:
    radial-gradient(circle at 50% 26%, rgba(255, 214, 140, 0.14), transparent 44%),
    linear-gradient(180deg, #344955 0%, #1d2d36 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.shop-detail-preview img {
  max-width: 88%;
  max-height: 88%;
  object-fit: contain;
}

.shop-detail-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
  align-items: center;
}

.shop-detail-name {
  font-size: 1.45rem;
  line-height: 0.95;
  text-transform: uppercase;
  margin: 0;
}

.shop-detail-kind {
  font-size: 0.76rem;
  font-weight: 800;
  color: rgba(255, 233, 193, 0.72);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.shop-detail-desc {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.42;
  color: rgba(244, 235, 214, 0.82);
  max-width: 30ch;
}

.shop-detail-reqs {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 221, 172, 0.09);
  background: rgba(7, 6, 4, 0.24);
}

.shop-detail-reqs.is-empty:empty {
  display: none;
}

.shop-detail-reqs-title {
  font-size: 0.74rem;
  font-weight: 800;
  color: rgba(255, 228, 180, 0.62);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.shop-detail-req-item {
  font-size: 0.82rem;
  color: rgba(245, 236, 216, 0.82);
}

/* ── Bottom bar: costs + buy ── */

.shop-detail-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}

.shop-detail-costs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 14px 12px;
  border-radius: 16px;
  background: rgba(7, 6, 4, 0.24);
  border: 1px solid rgba(255, 221, 172, 0.09);
}

.shop-detail-buy {
  width: 100%;
  min-height: 56px;
  border: 0;
  background: url("./sprites/shop_buy_btn.png") center / 100% 100% no-repeat;
  color: #fffbea;
  font: inherit;
  font-weight: 900;
  font-size: 1.05rem;
  padding: 10px 18px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: transform 0.12s ease, filter 0.12s ease;
  text-shadow: 0 2px 3px rgba(0,0,0,0.45);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.shop-detail-buy:hover:not(:disabled) {
  filter: brightness(1.05);
}

.shop-detail-buy:disabled {
  cursor: default;
  opacity: 0.45;
  filter: grayscale(0.8);
}

/* ── Warning text ── */

.shop-detail-warning {
  min-height: 18px;
  text-align: center;
  font-size: 0.74rem;
  font-weight: 800;
  color: #ff8c72;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Placement HUD ── */

.placement-hud {
  position: fixed;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: auto;
  z-index: 5;
}

.placement-hud.is-hidden {
  display: none;
}

.placement-hud-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.placement-hud-head span {
  color: rgba(255, 232, 198, 0.52);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
}

.placement-hud-head strong {
  color: #fff1cd;
  font-size: 0.96rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  max-width: 100%;
  line-height: 1.08;
  word-break: break-word;
}


/* ── Placement HUD ── */

.placement-callout {
  display: none;
}

.placement-status {
  margin: 8px 0 0;
  color: rgba(235, 227, 208, 0.82);
  font-size: 0.82rem;
  line-height: 1.38;
}

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

.placement-actions button {
  width: 56px;
  min-width: 56px;
  height: 56px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.placement-actions button:disabled {
  cursor: default;
  opacity: 0.5;
}

.placement-actions button::before {
  content: none;
}

.placement-actions button:hover:not(:disabled) {
  transform: scale(1.08);
}

#placement-confirm {
  background-image: url("./sprites/accept_bt.png");
}

#placement-confirm::before {
  content: "✓";
}

#placement-cancel {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(0,0,0,0)),
    linear-gradient(180deg, #5e4a34 0%, #3b2d1f 100%);
  border-color: rgba(118, 76, 41, 0.82);
}

#placement-cancel::before {
  content: "✕";
}

/* ── Ability HUD (bottom-center) ── */

#placement-cancel {
  background-image: url("./sprites/cancel_bt.png");
}

#placement-confirm::before,
#placement-cancel::before {
  content: none;
}

.placement-actions button#placement-confirm,
.placement-actions button#placement-cancel {
  background: none;
  border: none;
}

.placement-actions button#placement-confirm::before,
.placement-actions button#placement-cancel::before {
  content: none;
}

.placement-action-icon {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}

.placement-actions button:disabled .placement-action-icon {
  filter: grayscale(0.35) drop-shadow(0 2px 6px rgba(0,0,0,0.35));
}

.ability-hud {
  position: fixed;
  bottom: 20px;
  right: 12px;
  pointer-events: auto;
}

.ability-hud.is-hidden {
  display: none;
}

.ability-list {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ability-slot-btn {
  position: relative;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: none;
  background: none;
  color: #eef6fb;
  font: inherit;
  cursor: pointer;
  text-align: center;
}

.ability-slot-btn.is-empty {
  display: none;
}

.ability-slot-btn.is-cooling,
.ability-slot-btn.is-insufficient {
  filter: saturate(0.6) brightness(0.7);
}

.ability-slot-btn:disabled {
  cursor: default;
}

.ability-slot-icon {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('./sprites/round_button.png') center / contain no-repeat;
  border: none;
  box-shadow: none;
  font-size: 1.3rem;
  font-weight: 700;
  overflow: hidden;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.5));
}

.ability-slot-icon img {
  width: 60%;
  height: 60%;
  object-fit: contain;
  border-radius: 0;
}

.ability-slot-title {
  display: none;
}

.ability-slot-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: "Open Sans", "Arial Black", "Impact", "Segoe UI Black", sans-serif;
  font-size: 1.1rem;
  font-weight: 900;
  background: linear-gradient(180deg, #ffe870 0%, #d4a020 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 1.2px #000;
  paint-order: stroke fill;
}

.ability-slot-meta .bolt-icon {
  width: 18px;
  height: 18px;
}

.ability-slot-hotkey {
  display: none;
}

.ability-slot-cooldown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  z-index: 1;
}

/* ── Damage numbers ── */

.damage-number-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  contain: layout paint;
}

.damage-number {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  color: #ffd1d1;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  will-change: transform, opacity;
}

.resource-pickup {
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
  will-change: transform, opacity, left, top;
  z-index: -1;
}

/* ── Player hit overlay ── */

.player-hit-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(255, 70, 70, 0.18), transparent 32%),
    radial-gradient(circle at 50% 55%, rgba(255, 28, 28, 0.16), transparent 54%),
    linear-gradient(180deg, rgba(255, 18, 18, 0.28), transparent 16%, transparent 80%, rgba(255, 24, 24, 0.32));
  opacity: 0;
  transition: opacity 90ms linear;
  mix-blend-mode: screen;
}

/* ── Mobile Joystick ── */

.mobile-joystick {
  position: fixed;
  bottom: 30px;
  left: 30px;
  width: 140px;
  height: 140px;
  pointer-events: auto;
  touch-action: none;
  display: none;
  z-index: 5;
}

.joystick-base {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.7;
  pointer-events: none;
}

.joystick-stick {
  position: absolute;
  width: 60px;
  height: 60px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  object-fit: contain;
  opacity: 0.85;
  transition: transform 0.05s;
  pointer-events: none;
  touch-action: none;
}

.side-btn,
.ability-slot-btn,
.placement-actions button,
.weapon-ammo-buy,
.main-menu-cta,
.round-nav {
  touch-action: manipulation;
}

/* ── Mobile responsive ── */

@media (max-width: 960px) {
  :root {
    --player-status-bar-width: clamp(76px, calc(55vw - 305px), 180px);
  }

  .mobile-joystick {
    display: block;
  }

  .chat-history {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    width: min(430px, calc(100vw - 210px));
    max-height: 26vh;
    overflow: hidden;
    justify-items: center;
  }

  .chat-line {
    max-width: 100%;
    font-size: 0.74rem;
    line-height: 1.18;
  }

  .chat-input-shell {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: min(430px, calc(100vw - 210px));
  }

  .shop-hud {
    align-items: stretch;
    justify-content: center;
    padding: 10px;
  }

  .shop-hud-frame {
    width: min(860px, calc(100vw - 20px));
    max-height: calc(100vh - 20px);
    grid-template-rows: auto minmax(0, 1fr);
    border-radius: 20px;
  }

  .shop-hud-frame::before {
    inset: 8px;
    border-radius: 14px;
  }

  .shop-close-btn {
    top: 10px;
    right: 10px;
    width: 42px;
    height: 42px;
    font-size: 1.45rem;
  }

  .shop-tab-list {
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 8px;
    padding: 12px 58px 10px 12px;
  }

  .shop-tab-btn {
    min-height: 50px;
    padding: 8px 10px;
    border-radius: 14px;
    font-size: 0.72rem;
  }

  .resource-hud {
    left: 50%;
    flex-wrap: wrap;
    justify-content: center;
  }

  .placement-hud {
    top: 50%;
    right: 12px;
    left: auto;
    bottom: auto;
    transform: translateY(-50%);
    align-items: flex-end;
  }

  .shop-body {
    grid-template-columns: minmax(150px, 0.82fr) minmax(0, 1.18fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    overflow: hidden;
  }

  .shop-list-scroll {
    min-height: 0;
    padding: 10px;
    border-radius: 18px;
  }

  .shop-empty-state {
    padding: 20px 12px;
  }

  .shop-item-list {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .shop-item-card {
    min-height: 156px;
    padding: 10px;
    gap: 8px;
    border-radius: 16px;
  }

  .shop-item-preview {
    height: 72px;
    border-radius: 14px;
  }

  .shop-item-card strong {
    font-size: 10px;
  }

  .shop-item-kind {
    font-size: 0.62rem;
  }

  .shop-cost-list {
    gap: 6px;
  }

  .shop-cost-chip,
  .shop-detail-cost-chip {
    min-height: 24px;
    padding: 4px 6px;
    font-size: 0.68rem;
  }

  .shop-cost-chip img,
  .shop-detail-cost-chip img {
    width: 16px;
    height: 16px;
  }

  .shop-detail {
    min-height: 0;
    padding: 14px;
    gap: 10px;
    border-radius: 18px;
  }

  .shop-detail-top {
    gap: 10px;
  }

  .shop-detail-preview {
    min-height: 136px;
    max-height: 196px;
    border-radius: 16px;
  }

  .shop-detail-info {
    gap: 6px;
    align-items: center;
    text-align: center;
  }

  .shop-detail-name {
    font-size: 1.02rem;
  }

  .shop-detail-kind {
    font-size: 0.68rem;
    letter-spacing: 0.09em;
  }

  .shop-detail-desc {
    font-size: 0.8rem;
    line-height: 1.3;
    max-width: none;
  }

  .shop-detail-reqs {
    padding: 10px 12px;
    border-radius: 14px;
  }

  .shop-detail-reqs-title {
    font-size: 0.68rem;
  }

  .shop-detail-req-item {
    font-size: 0.74rem;
  }

  .shop-detail-bottom {
    gap: 8px;
  }

  .shop-detail-costs {
    gap: 6px;
    padding: 10px 8px;
  }

  .shop-detail-buy {
    min-height: 50px;
    padding: 8px 14px;
    font-size: 0.9rem;
  }

  .shop-detail-warning {
    min-height: 14px;
    font-size: 0.68rem;
  }
}

@media (max-width: 700px) {
  .resource-hud {
    width: max-content;
    flex-wrap: nowrap;
    gap: 4px;
  }

  .resource-chip {
    padding: 0 4px;
    min-width: 42px;
  }

  .resource-icon-img {
    width: 36px;
    height: 36px;
  }

  .resource-chip.is-paused::after {
    top: 4px;
    width: 30px;
    height: 30px;
  }

  .resource-chip strong {
    font-size: 1.05rem;
  }
}

@media (max-width: 960px) and (orientation: landscape) {
  .shop-hud {
    padding: 8px;
  }

  .shop-hud-frame {
    width: min(860px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
  }

  .shop-tab-list {
    padding: 10px 54px 8px 10px;
  }

  .shop-tab-btn {
    min-height: 44px;
    font-size: 0.68rem;
  }

  .shop-close-btn {
    top: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
  }

  .shop-body {
    gap: 10px;
    padding: 10px;
  }

  .shop-list-scroll,
  .shop-detail {
    padding: 10px;
    border-radius: 16px;
  }

  .shop-item-card {
    min-height: 138px;
    gap: 6px;
    padding: 8px;
  }

  .shop-item-preview {
    height: 64px;
  }

  .shop-item-card strong {
    font-size: 10px;
  }

  .shop-item-kind {
    font-size: 0.58rem;
  }

  .shop-cost-chip {
    min-height: 22px;
    padding: 3px 6px;
    font-size: 0.62rem;
  }

  .shop-cost-chip img {
    width: 14px;
    height: 14px;
  }

  .shop-detail {
    gap: 8px;
  }

  .shop-detail-top {
    gap: 8px;
  }

  .shop-detail-preview {
    min-height: 118px;
    max-height: 132px;
  }

  .shop-detail-name {
    font-size: 0.92rem;
  }

  .shop-detail-kind {
    font-size: 0.62rem;
  }

  .shop-detail-desc {
    font-size: 0.72rem;
    line-height: 1.2;
  }

  .shop-detail-reqs {
    padding: 8px 10px;
  }

  .shop-detail-reqs-title {
    font-size: 0.62rem;
    margin-bottom: 4px;
  }

  .shop-detail-req-item {
    font-size: 0.7rem;
  }

  .shop-detail-bottom {
    gap: 6px;
  }

  .shop-detail-costs {
    gap: 6px;
    padding: 8px 6px;
  }

  .shop-detail-cost-chip {
    min-height: 22px;
    padding: 3px 6px;
    font-size: 0.62rem;
  }

  .shop-detail-cost-chip img {
    width: 14px;
    height: 14px;
  }

  .shop-detail-buy {
    min-height: 42px;
    padding: 6px 12px;
    font-size: 0.82rem;
  }

  .shop-detail-warning {
    min-height: 12px;
    font-size: 0.62rem;
  }
}

@media (min-width: 961px) {
  .mobile-joystick {
    display: none;
  }
}

/* ── Shop Skin: framed window asset ── */

.shop-hud-frame {
  width: min(900px, calc(100vw - 32px), calc((100vh - 28px) * 714 / 616));
  max-height: none;
  aspect-ratio: 714 / 616;
  display: block;
  border: none;
  border-radius: 0;
  background: url("./sprites/shop_back.png") center / 100% 100% no-repeat;
  box-shadow: none;
  overflow: hidden;
  transform: translateZ(0);
  backface-visibility: hidden;
  contain: layout paint;
}

.shop-hud-frame::before {
  content: none;
}

.shop-frame-title {
  position: absolute;
  top: 1.45%;
  left: 50%;
  width: 36%;
  min-height: 6.6%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(-50%);
  font-size: clamp(1rem, 1.18vw, 1.24rem);
  line-height: 1;
  text-transform: uppercase;
  text-rendering: geometricPrecision;
  pointer-events: none;
  z-index: 3;
}

.shop-tab-list {
  position: absolute;
  top: 9.1%;
  left: 8.6%;
  right: 13.4%;
  height: 14.5%;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 8px;
  padding: 0;
  background: none;
  border: none;
  z-index: 2;
  overflow-x: visible;
  overflow-y: visible;
  scrollbar-width: none;
}

.shop-tab-list::-webkit-scrollbar {
  display: none;
}

.shop-tab-btn {
  flex: 0 0 auto;
  width: clamp(68px, 13%, 110px);
  height: auto;
  min-height: 0;
  aspect-ratio: 149 / 78;
  padding: 0 6px 5px;
  border-radius: 0;
  border: 0;
  background: url("./sprites/shop_tab_inactive.png") center / 100% 100% no-repeat;
  color: #fff;
  font-size: clamp(0.7rem, 0.9vw, 0.88rem);
  font-weight: 900;
  line-height: 1;
  box-shadow: none;
  filter: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  overflow: visible;
}

.shop-tab-btn:hover {
  filter: brightness(1.04);
}

.shop-tab-btn.is-active {
  aspect-ratio: 150 / 96;
  background-image: url("./sprites/shop_tab_active.png");
  margin-bottom: -1px;
}

.shop-tab-btn:not(.is-active) {
  margin-bottom: 2px;
}

.shop-tab-btn img {
  width: auto;
  height: 95%;
  aspect-ratio: 1;
  margin-top: -42%;
  margin-bottom: 1px;
  object-fit: contain;
  border-radius: 0;
  background: none;
  filter: none;
}

.shop-tab-btn span {
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
}

.shop-close-btn {
  top: 2.6%;
  right: 0.15%;
  width: clamp(38px, 6.6%, 48px);
  height: auto;
  aspect-ratio: 1 / 1;
  z-index: 3;
}

.shop-body {
  position: absolute;
  top: 24.9%;
  left: 4.35%;
  right: 4.1%;
  bottom: 5.7%;
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 0.93fr);
  gap: 2.2%;
  padding: 0;
  min-height: 0;
}

.shop-list-scroll,
.shop-detail {
  min-height: 0;
  padding: 10px 12px 12px;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.shop-list-scroll {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(169, 150, 111, 0.42) transparent;
}

.shop-list-scroll::-webkit-scrollbar {
  width: 8px;
}

.shop-list-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(169, 150, 111, 0.42);
}

.shop-item-list {
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
  justify-content: start;
}

.shop-item-list.is-single-item {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.shop-item-card {
  width: 100%;
  box-sizing: border-box;
  --shop-card-title-y: clamp(8px, 0.82vw, 10px);
  --shop-card-cost-y: clamp(4px, 0.48vw, 6px);
  aspect-ratio: 195 / 276;
  max-width: none;
  min-height: 0;
  justify-self: start;
  align-self: start;
  grid-template-rows: minmax(0, 1fr) clamp(20px, 2.35vw, 34px) clamp(16px, 1.7vw, 23px);
  gap: 2px;
  padding: clamp(5px, 4%, 9px) clamp(5px, 4%, 9px) clamp(8px, 5%, 12px);
  border-radius: 4px;
  border: 0;
  background: url("./sprites/shop_item_card.png") center / 100% 100% no-repeat;
  box-shadow: none;
  overflow: hidden;
}

.shop-item-card.is-selected {
  box-shadow: inset 0 0 0 2px #7cff5a;
}

.shop-item-preview {
  box-sizing: border-box;
  height: 100%;
  min-height: 0;
  border: none;
  border-radius: 0;
  background: none;
  overflow: visible;
  padding-top: 0;
  align-items: center;
}

.shop-item-preview img {
  width: min(88%, 136px);
  height: min(88%, 136px);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.shop-item-body {
  transform: translateY(var(--shop-card-title-y));
}

.shop-item-card strong {
  width: 100%;
  min-width: 0;
  height: 1.86em;
  max-height: 1.86em;
  font-size: clamp(10px, 1.45vw, 17px);
  text-transform: uppercase;
  text-align: center;
  line-height: 0.93;
  text-rendering: geometricPrecision;
  white-space: normal;
  overflow: hidden;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  align-self: center;
}

.shop-item-card strong.is-two-line {
  height: 2.08em;
  max-height: 2.08em;
  font-size: clamp(8px, 1vw, 12px);
  line-height: 1.04;
}

.shop-item-kind {
  font-size: clamp(0.5rem, 0.66vw, 0.62rem);
  font-weight: 700;
  color: rgba(236, 228, 208, 0.78);
  -webkit-text-fill-color: rgba(236, 228, 208, 0.78);
  -webkit-text-stroke: 0;
  paint-order: normal;
  text-rendering: geometricPrecision;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.shop-cost-list {
  gap: 5px;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
  transform: translateY(var(--shop-card-cost-y));
}

.shop-cost-chip,
.shop-detail-cost-chip {
  min-height: 0;
  padding: 0;
  font-size: clamp(0.62rem, 0.95vw, 0.86rem);
  border: 0;
  background: transparent;
}

.shop-cost-chip img,
.shop-detail-cost-chip img {
  width: clamp(13px, 1.28vw, 17px);
  height: clamp(13px, 1.28vw, 17px);
}

.shop-empty-state {
  padding: 18px 12px;
  font-size: 0.8rem;
}

.shop-detail {
  --shop-detail-preview-size: 110px;
  --shop-detail-icon-size: 95px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 14px 12px;
  overflow-y: auto;
}

.shop-detail-top {
  gap: 7px;
}

.shop-detail-preview {
  height: var(--shop-detail-preview-size);
  min-height: var(--shop-detail-preview-size);
  max-height: var(--shop-detail-preview-size);
  border: none;
  border-radius: 0;
  background: none;
}

.shop-detail-preview img {
  width: var(--shop-detail-icon-size);
  height: var(--shop-detail-icon-size);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform: none;
}

.shop-detail-info {
  order: -1;
  gap: 6px;
  align-items: center;
  text-align: center;
  width: 100%;
  min-width: 0;
}

.shop-detail-name {
  width: 100%;
  max-width: 100%;
  font-size: clamp(1.1rem, 1.24vw, 1.36rem);
  line-height: 0.96;
  text-align: center;
  text-transform: uppercase;
  text-rendering: geometricPrecision;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.shop-detail-kind {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fbf2d9;
  -webkit-text-fill-color: #fbf2d9;
  -webkit-text-stroke: 0.55px rgba(0, 0, 0, 0.9);
  paint-order: stroke fill;
  text-rendering: geometricPrecision;
}

.shop-detail-desc {
  font-size: 0.8rem;
  line-height: 1.28;
  max-width: 22ch;
  color: rgba(232, 238, 242, 0.9);
}

.shop-detail-reqs {
  width: 100%;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
}

.shop-detail-reqs-title {
  font-size: 0.66rem;
  margin-bottom: 4px;
}

.shop-detail-req-item {
  font-size: 0.72rem;
}

.shop-detail-bottom {
  gap: 10px;
}

.shop-detail-costs {
  gap: 14px;
  padding: 0;
  justify-content: center;
  border: none;
  border-radius: 0;
  background: none;
}

.shop-detail-cost-chip {
  gap: 7px;
  font-size: clamp(0.82rem, 1.45vw, 1.05rem);
}

.shop-detail-cost-chip img {
  width: clamp(17px, 1.7vw, 22px);
  height: clamp(17px, 1.7vw, 22px);
}

.shop-detail-buy {
  width: 70%;
  align-self: center;
  aspect-ratio: 168 / 63;
  height: auto;
  min-height: 0;
  padding: 0 10px;
  border-radius: 0;
  font-family: "Open Sans", "Arial Black", "Impact", "Segoe UI Black", sans-serif;
  font-weight: 900;
  font-size: clamp(0.68rem, 0.9vw, 0.92rem);
  color: #fff;
  text-shadow: none;
  filter: none;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
}

.shop-detail-warning {
  min-height: 16px;
  font-size: 0.66rem;
}

@media (max-width: 960px) {
  .shop-hud {
    padding: 10px;
  }

  .shop-hud-frame {
    width: min(calc(100vw - 8px), calc((100vh - 14px) * 714 / 616));
  }

  .shop-frame-title {
    width: 44%;
    font-size: clamp(0.84rem, 1.95vw, 0.98rem);
    top: 1.55%;
    min-height: 6.1%;
  }

  .shop-tab-list {
    top: 8.6%;
    left: 7.8%;
    right: 15.5%;
    gap: 8px;
  }

  .shop-tab-btn {
    padding: 0 6px 5px;
    font-size: 0.54rem;
  }

  .shop-body {
    top: 24.8%;
    left: 4.3%;
    right: 4.15%;
    bottom: 5.6%;
    grid-template-columns: minmax(0, 1.72fr) minmax(0, 0.95fr);
    gap: 2%;
  }

  .shop-list-scroll,
  .shop-detail {
    padding: 8px 10px 10px;
  }

  .shop-item-list {
    gap: 8px;
  }

  .shop-item-card {
    min-height: 0;
    padding: 5px 5px 8px;
    gap: 2px;
  }

  .shop-item-list.is-single-item .shop-item-card {
    min-height: 0;
  }

  .shop-item-preview {
    height: 100%;
    min-height: 0;
  }

  .shop-item-card strong {
    font-size: clamp(10px, 1.45vw, 17px);
  }

  .shop-item-kind {
    font-size: 0.56rem;
  }

  .shop-cost-chip,
  .shop-detail-cost-chip {
    min-height: 0;
    padding: 0;
    font-size: clamp(0.58rem, 0.95vw, 0.76rem);
  }

  .shop-detail-cost-chip {
    gap: 6px;
    font-size: clamp(0.82rem, 1.45vw, 0.98rem);
  }

  .shop-cost-chip img,
  .shop-detail-cost-chip img {
    width: 14px;
    height: 14px;
  }

  .shop-detail-cost-chip img {
    width: clamp(17px, 1.7vw, 20px);
    height: clamp(17px, 1.7vw, 20px);
  }

  .shop-detail {
    gap: 8px;
  }

  .shop-detail-top {
    gap: 8px;
  }

  .shop-detail-preview {
    height: var(--shop-detail-preview-size);
    min-height: var(--shop-detail-preview-size);
    max-height: var(--shop-detail-preview-size);
  }

  .shop-detail-name {
    font-size: 0.78rem;
    line-height: 0.98;
  }

  .shop-detail-kind {
    font-size: 0.58rem;
  }

  .shop-detail-desc {
    font-size: 0.66rem;
    line-height: 1.16;
    max-width: 18ch;
  }

  .shop-detail-reqs-title {
    font-size: 0.56rem;
  }

  .shop-detail-req-item {
    font-size: 0.62rem;
  }

  .shop-detail-buy {
    min-height: 36px;
    padding: 4px 8px;
    font-size: 0.68rem;
    border-radius: 0;
  }

  .shop-detail-warning {
    min-height: 10px;
    font-size: 0.54rem;
  }
}

@media (max-width: 960px) and (orientation: landscape) {
  .shop-frame-title {
    width: 40%;
    font-size: clamp(0.8rem, 1.7vw, 0.94rem);
    top: 1.5%;
    min-height: 6%;
  }

  .shop-tab-list {
    top: 8.6%;
    left: 8%;
    right: 15%;
  }

  .shop-body {
    top: 24.6%;
    bottom: 5.8%;
    gap: 1.8%;
  }

  .shop-item-card {
    min-height: 0;
  }

  .shop-item-list.is-single-item .shop-item-card {
    min-height: 0;
  }

  .shop-item-preview {
    height: 100%;
    min-height: 0;
  }

  .shop-detail-preview {
    height: var(--shop-detail-preview-size);
    min-height: var(--shop-detail-preview-size);
    max-height: var(--shop-detail-preview-size);
  }

  .shop-detail-buy {
    min-height: 36px;
  }
}

/* ── Wave Announcement (center overlay) ── */

/* Mobile menu fit and HUD alignment refinements */
@media (max-width: 960px) {
  .resource-hud {
    left: calc(50% + clamp(8px, 3vw, 28px));
    transform: translateX(-50%);
    width: max-content;
    flex-wrap: nowrap;
  }
}

@media (max-width: 960px) and (orientation: landscape) {
  .screen-overlay {
    padding: 8px;
  }

  .character-select-panel {
    width: min(560px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
    gap: 8px;
    padding: 12px 16px;
    overflow: hidden;
  }

  .character-select-head {
    gap: 8px;
    padding-bottom: 8px;
  }

  .character-select-head strong {
    font-size: 0.95rem;
  }

  .character-select-head .screen-secondary {
    min-height: 34px;
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .character-stage {
    grid-template-columns: 44px minmax(0, min(54vw, 238px)) 44px;
    justify-content: center;
    gap: 8px;
    padding: 8px;
  }

  #character-preview-canvas {
    width: min(54vw, 238px);
    height: clamp(132px, 43vh, 170px);
    min-height: 0;
    max-height: none;
  }

  .round-nav {
    width: 42px !important;
    height: clamp(58px, 18vh, 70px) !important;
    font-size: 1.75rem !important;
  }

  .character-preview-name {
    font-size: 0.95rem;
  }

  #character-continue {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  .resource-hud {
    left: calc(50% + clamp(24px, 5vw, 44px));
  }
}

@media (min-width: 961px) {
  .shop-item-card {
    --shop-card-title-y: clamp(1px, 0.22vw, 3px);
    --shop-card-cost-y: clamp(-4px, -0.25vw, -2px);
  }

  .shop-item-preview img {
    width: min(76%, 108px);
    height: min(76%, 108px);
  }

  .shop-detail {
    --shop-detail-icon-size: 84px;
  }

  .shop-tab-btn img {
    height: 82%;
    margin-top: -34%;
  }
}

.wave-announce {
  position: fixed;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wave-announce.is-hidden {
  display: none;
}

.wave-announce-text {
  font-family: "Open Sans", "Arial Black", "Impact", "Segoe UI Black", sans-serif;
  font-size: 2.2rem;
  font-weight: 900;
  -webkit-text-stroke: 2px #000;
  paint-order: stroke fill;
  background: linear-gradient(180deg, #ffffff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  animation: waveAnnounceIn 2.5s ease-out forwards;
}

@keyframes waveAnnounceIn {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  15% {
    opacity: 1;
    transform: scale(1.15);
  }
  25% {
    transform: scale(1);
  }
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.1) translateY(-20px);
  }
}

.debug-hud {
  width: min(320px, calc(100vw - 24px));
  top: 12px;
  left: 12px;
  bottom: 12px;
  gap: 8px;
}

.debug-hud > .card:nth-child(2) {
  display: none;
}

.debug-hud .card {
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(7, 15, 22, 0.86);
}

.debug-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.debug-card-title strong {
  font-size: 0.76rem;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.debug-room-chip,
.debug-card-title p {
  min-width: 0;
  margin: 0;
  color: rgba(238, 246, 251, 0.72);
  font-size: 0.72rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debug-room-chip b {
  color: #eef6fb;
  font-weight: 800;
}

.debug-two-col,
.debug-button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.debug-button-row--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.debug-button-row--four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.debug-hud .controls-card label {
  gap: 4px;
}

.debug-hud .controls-card label span {
  font-size: 0.7rem;
  color: rgba(238, 246, 251, 0.64);
}

.debug-hud .controls-card select,
.debug-hud .controls-card input,
.debug-hud .controls-card button {
  min-height: 32px;
  padding: 7px 8px;
  border-radius: 7px;
  font-size: 0.76rem;
}

.debug-hud .controls-card button {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debug-hud .controls-card button:disabled,
.debug-hud .controls-card input:disabled,
.debug-hud .controls-card select:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.debug-hud .network-card {
  gap: 6px;
}

.debug-hud .network-card label {
  display: none;
}

.debug-hud .network-card > .row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.debug-hud .network-card #create-room,
.debug-hud .network-card #join-room,
.debug-hud .network-card #leave-room {
  display: none;
}

.debug-hud .network-meta {
  gap: 2px;
  padding: 7px 8px;
  border-radius: 8px;
}

.debug-hud .network-meta p,
.debug-hud .network-meta strong {
  overflow: hidden;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debug-hud .compact {
  display: none;
}

@media (max-width: 520px) {
  .debug-hud {
    inset: 8px 8px 72px 8px;
    width: auto;
  }
}
