* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --scroll-track: #0a0e14;
  --scroll-thumb: #243444;
  --scroll-thumb-hover: #3a5068;
  --scroll-thumb-active: #2ecc71;
  --scroll-width: 9px;
}

html {
  overflow-x: hidden;
  overscroll-behavior: none;
}

/* Themed scrollbars — vertical only, no horizontal bars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

*::-webkit-scrollbar {
  width: var(--scroll-width);
  height: 0;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--scroll-thumb-hover), var(--scroll-thumb));
  border-radius: 6px;
  border: 2px solid var(--scroll-track);
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #4a6278, var(--scroll-thumb-hover));
}

*::-webkit-scrollbar-thumb:active {
  background: var(--scroll-thumb-active);
}

*::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 6px;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

.scroll-y {
  overflow-x: hidden !important;
  overflow-y: auto;
  max-width: 100%;
}

body {
  background: #0a0a12;
  color: #e0e0e0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  overscroll-behavior: none;
}

html.game-active body {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#app {
  position: relative;
  width: 100%;
  max-width: 100vw;
  height: 100vh;
  overflow-x: hidden;
  overscroll-behavior: none;
}

#menu-bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  background: #080c10;
}

#game-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

#game-canvas.menu-hidden {
  display: none;
}

.hidden { display: none !important; }

.boot-error {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(8, 10, 16, 0.96);
  color: #e8eef4;
  pointer-events: auto;
}

.boot-error p {
  color: #9ab;
  line-height: 1.5;
  max-width: 480px;
}

.boot-error code {
  background: #1a2332;
  padding: 2px 6px;
  border-radius: 4px;
  color: #2ecc71;
}

/* HUD — above game canvas (2), below menu/overlays (5+) */
#hud {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

/* --- RTS HUD top intel bar (trapezoid panel + side ears) --- */
.hud-top-wrap {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.hud-top-bar {
  display: flex;
  align-items: stretch;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.4));
}

.hud-top-ear {
  position: relative;
  width: 26px;
  flex-shrink: 0;
  align-self: stretch;
  pointer-events: none;
}

.hud-top-ear::before {
  content: '';
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 62%;
  background: var(--hud-panel-bg, rgba(18, 22, 30, 0.88));
  border: 2px solid var(--hud-panel-border, rgba(58, 74, 90, 0.85));
  box-sizing: border-box;
}

.hud-top-ear--left::before {
  right: 0;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  border-right: none;
}

.hud-top-ear--right::before {
  left: 0;
  clip-path: polygon(0 0, 0 100%, 100% 100%);
  border-left: none;
}

.hud-top-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: min(620px, 92vw);
  padding: 8px 14px 10px;
  background: var(--hud-panel-bg, rgba(18, 22, 30, 0.88));
  border: 2px solid var(--hud-panel-border, rgba(58, 74, 90, 0.85));
  clip-path: polygon(5% 0, 95% 0, 100% 100%, 0 100%);
  box-shadow: none;
  pointer-events: auto;
}

.hud-top-edge-btn {
  flex-shrink: 0;
  pointer-events: auto;
}

.hud-top-stars {
  flex-shrink: 0;
  pointer-events: none;
  white-space: nowrap;
  padding-right: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.hud-top-run {
  flex-shrink: 0;
  pointer-events: none;
  white-space: nowrap;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.hud-top-run.hidden {
  display: none;
}

.hud-top-core {
  display: flex;
  align-items: stretch;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 0;
  gap: 0;
}

.hud-kc-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 0 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.hud-kc-block + .hud-kc-block {
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.hud-kc-icon {
  font-size: 18px;
  line-height: 1.1;
}

.hud-kc-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #7a8fa3;
  margin-top: 2px;
}

.hud-kc-value {
  font-size: 14px;
  font-weight: 800;
  color: #e8eef4;
  margin-top: 1px;
}

.hud-top-stats {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 0 20px;
  min-width: 120px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.hud-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
}

.hud-stat-lbl {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7a8fa3;
}

.hud-stat-val {
  font-weight: 700;
  color: #e8eef4;
  font-variant-numeric: tabular-nums;
}

.hud-top-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--hud-chip-bg, rgba(0,0,0,0.5));
  border-radius: 4px;
}

#run-info {
  background: rgba(46, 204, 113, 0.35);
  color: #2ecc71;
}

.hud-icon-btn {
  pointer-events: auto;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
}

.hud-icon-btn:hover {
  background: rgba(255,255,255,0.12);
}

/* --- RTS HUD bottom command cluster (oval panel) --- */
.hud-bottom-area {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 12px;
  pointer-events: none;
}

.hud-command-panel {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 24px;
  background: var(--hud-panel-bg, rgba(10, 14, 20, 0.88));
  border: 2px solid var(--hud-panel-border, rgba(58, 74, 90, 0.9));
  border-radius: 999px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  max-width: min(920px, 98vw);
}

.hud-command-panel .slot-box {
  width: 48px;
  height: 48px;
  font-size: 20px;
}

#hud.hud-theme-premium .hud-command-panel,
#hud.hud-theme-premium .hud-minimap-frame,
#hud.hud-theme-premium .hud-top-panel,
#hud.hud-theme-premium .hud-top-ear::before {
  box-shadow: 0 0 12px var(--hud-aura-color, rgba(243, 156, 18, 0.35));
  border-color: var(--hud-panel-border-glow, var(--hud-panel-border, rgba(58, 74, 90, 0.9)));
}

#hud.hud-theme-premium .hud-top-bar {
  filter: drop-shadow(0 0 10px var(--hud-aura-color, rgba(243, 156, 18, 0.35)));
}

.hud-hero-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 72px;
}

.hud-hero-rings {
  position: relative;
  width: 72px;
  height: 72px;
}

.hud-ring-svg {
  width: 72px;
  height: 72px;
  display: block;
}

.hud-ring-bg {
  stroke: rgba(40, 48, 58, 0.9);
}

.hud-ring-hp {
  stroke: var(--hud-ring-hp, #2ecc71);
  stroke-dasharray: 201 201;
  transition: stroke-dasharray 0.2s;
}

.hud-ring-xp {
  stroke: var(--hud-ring-xp, #3498db);
  stroke-dasharray: 151 151;
  transition: stroke-dasharray 0.2s;
}

.hud-hero-portrait {
  position: absolute;
  inset: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--hud-portrait-bg, #c0392b);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

#hero-portrait-icon {
  font-size: 16px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.hud-hp-text {
  display: block;
  font-size: 9px;
  font-weight: 700;
  color: #9ab;
  text-align: center;
  margin-top: 2px;
}

.hud-level-text {
  display: block;
  font-size: 9px;
  font-weight: 600;
  color: #7a8fa3;
  text-align: center;
}

.hud-weapon-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-enh-grid {
  display: grid;
  grid-template-columns: repeat(2, 48px);
  grid-template-rows: repeat(2, 48px);
  gap: 5px;
  flex-shrink: 0;
}

.hud-item-grid {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(2, 48px);
  gap: 5px;
  flex-shrink: 0;
}

.hud-panel-divider {
  flex-shrink: 0;
  align-self: stretch;
  width: 1px;
  margin: 6px 10px;
  background: rgba(255, 255, 255, 0.1);
}

.hud-minimap-frame {
  flex-shrink: 0;
  padding: 3px;
  background: rgba(8, 12, 18, 0.9);
  border: 2px solid var(--hud-panel-border, rgba(58, 74, 90, 0.9));
  border-radius: 6px;
  pointer-events: none;
}

#hud-minimap {
  display: block;
  width: 100px;
  height: 100px;
  border-radius: 4px;
}

.slot-cooldown {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: conic-gradient(
    from -90deg,
    rgba(0, 0, 0, 0.78) 0deg,
    rgba(0, 0, 0, 0.78) calc(var(--cd-pct, 0) * 360deg),
    transparent calc(var(--cd-pct, 0) * 360deg)
  );
  pointer-events: none;
  z-index: 2;
}

.slot-cd-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px #000;
  z-index: 3;
  pointer-events: none;
}

/* Mobile touch ability — hidden on desktop; shown via JS during active runs */
.touch-ability-btn {
  display: none;
  position: fixed;
  right: max(10px, env(safe-area-inset-right, 0px));
  bottom: calc(max(6px, env(safe-area-inset-bottom, 0px)) + 112px);
  width: 56px;
  height: 56px;
  padding: 0;
  border: 2px solid var(--hud-slot-border, #3a4a5a);
  border-radius: 50%;
  background: rgba(20, 25, 35, 0.92);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  z-index: 12;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.touch-ability-btn.hidden {
  display: none !important;
}

.platform-mobile .touch-ability-btn:not(.hidden) {
  display: flex;
  align-items: center;
  justify-content: center;
}

.touch-ability-btn.empty {
  opacity: 0.45;
}

.touch-ability-btn:disabled {
  opacity: 0.45;
}

.touch-ability-btn .touch-ability-icon {
  position: relative;
  z-index: 1;
}

.platform-mobile #hud-minimap-wrap {
  display: block;
  position: fixed;
  top: calc(max(4px, env(safe-area-inset-top, 0px)) + 52px);
  right: max(6px, env(safe-area-inset-right, 0px));
  z-index: 11;
  margin: 0;
  pointer-events: none;
}

.platform-mobile #hud-minimap {
  width: 56px;
  height: 56px;
}

.store-header {
  text-align: center;
}

.btn-store-credits {
  margin-top: 8px;
  padding: 8px 16px;
  background: linear-gradient(180deg, #f39c12, #e67e22);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}

.btn-store-credits:hover {
  filter: brightness(1.1);
}

/* Tabbed store layout */
.store-tabbed {
  background: #0f1419;
  border: 1px solid #2a3a4a;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.store-tab-bar-wrap {
  background: #121820;
  border-bottom: 1px solid #2a3a4a;
  overflow-x: hidden;
}

.store-tab-bar {
  display: flex;
  flex-wrap: wrap;
  padding: 4px 4px 0;
  gap: 2px;
}

.store-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 14px 10px;
  min-width: 72px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #6a8099;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.store-tab-icon {
  font-size: 18px;
  line-height: 1;
}

.store-tab-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.store-tab:hover {
  color: #c8d8e8;
  background: rgba(52, 152, 219, 0.06);
}

.store-tab.active {
  color: #2ecc71;
  border-bottom-color: #2ecc71;
  background: rgba(46, 204, 113, 0.06);
}

.store-panel {
  padding: 16px 16px 20px;
  transition: opacity 0.12s ease;
}

.store-panel.store-panel-switching {
  opacity: 0.4;
}

.store-panel-head {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #1e2a38;
}

.store-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.store-category-icon {
  font-size: 24px;
}

.store-panel-title h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #e8eef4;
  letter-spacing: 0.04em;
}

.store-category-desc {
  margin: 0;
  font-size: 13px;
  color: #7a8fa3;
  line-height: 1.4;
}

.store-panel-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 8px;
}

.store-category-count {
  margin: 0;
  font-size: 11px;
  color: #f39c12;
  font-weight: 600;
}

.store-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: #9ab0c4;
}

.store-filter-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.store-filter-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: #2a3544;
  border: 1px solid #3d4f63;
  border-radius: 10px;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.store-filter-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #8a9bb0;
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}

.store-filter-toggle input:checked + .store-filter-toggle-track {
  background: #1a4a32;
  border-color: #2ecc71;
}

.store-filter-toggle input:checked + .store-filter-toggle-track::after {
  transform: translateX(16px);
  background: #2ecc71;
}

.store-filter-toggle input:focus-visible + .store-filter-toggle-track {
  outline: 2px solid #2ecc71;
  outline-offset: 2px;
}

.store-filter-toggle-label {
  line-height: 1.2;
}

.store-empty-filter {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 16px;
  color: #7a8fa3;
  font-size: 14px;
  line-height: 1.5;
}

.store-grid, #store-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  width: 100%;
}


.upgrade-card.cant-afford {
  opacity: 0.45;
  cursor: not-allowed;
}

.upgrade-card.store-card {
  width: auto;
}

.upgrade-card.store-card.equipped {
  border-color: #2ecc71;
  box-shadow: 0 0 12px rgba(46, 204, 113, 0.25);
}

.upgrade-card.store-card.owned:not(.equipped) {
  opacity: 0.9;
  cursor: pointer;
}

.store-preview-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #a8d4ff;
  background: rgba(52, 152, 219, 0.15);
  border: 1px solid #3498db;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  pointer-events: auto;
}

.store-preview-btn:hover {
  background: rgba(52, 152, 219, 0.35);
  color: #fff;
}

.menu-btn-testers {
  background: linear-gradient(135deg, #2c3e50, #34495e) !important;
  border-color: #7f8c8d !important;
  max-width: 200px;
  margin: 8px auto 0;
  font-size: 13px !important;
}


.testers-hint {
  color: #888;
  font-size: 13px;
  margin-bottom: 16px;
}

.testers-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 16px;
}

.testers-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: #9ab;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.testers-controls select {
  padding: 8px 12px;
  background: #1a2332;
  border: 1px solid #3a5068;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  min-width: 160px;
}

#tester-preview-canvas,
#tester-event-canvas {
  width: 100%;
  max-width: 400px;
  height: auto;
  border: 2px solid #2a3a4a;
  border-radius: 12px;
  display: block;
  margin: 0 auto 12px;
}

#tester-preview-canvas {
  height: 280px;
}

#tester-event-canvas {
  aspect-ratio: 400 / 220;
}

.tester-event-hud {
  max-width: 720px;
  margin: 0 auto 14px;
  pointer-events: none;
  border-radius: 999px !important;
}

.hud-minimap-preview {
  width: 72px;
  height: 72px;
}

.hud-minimap-placeholder {
  width: 66px;
  height: 66px;
  background: rgba(52, 152, 219, 0.25);
  border-radius: 4px;
}

.tester-event-hud-top {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.tester-event-bar {
  position: relative;
  height: 20px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #333;
  flex: 1;
  min-width: 120px;
  max-width: 160px;
}

.tester-event-hp { background: #2a1010; }
.tester-event-xp { background: #101a2a; }

.tester-event-bar-fill {
  height: 100%;
  transition: width 0.2s;
}

.tester-event-hp-fill {
  width: 72%;
  background: var(--hud-hp-fill, linear-gradient(90deg, #c0392b, #e74c3c));
}

.tester-event-xp-fill {
  background: var(--hud-xp-fill, linear-gradient(90deg, #2471a3, #3498db));
}

.tester-event-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  text-shadow: 0 1px 2px #000;
}

.tester-event-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  background: var(--hud-chip-bg, rgba(0, 0, 0, 0.5));
  border-radius: 4px;
}

.tester-event-hud-bottom {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tester-event-hud.hud-theme-premium .slot-box:not(.empty)::before,
.tester-event-hud.hud-theme-premium .tester-event-bar::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  background: var(--hud-aura-color, #f39c12);
  opacity: var(--hud-aura-opacity, 0.5);
  filter: blur(6px);
  z-index: -1;
  pointer-events: none;
}

.tester-event-hud.hud-theme-premium .tester-event-bar {
  overflow: visible;
}

.slot-box {
  width: 56px;
  height: 56px;
  background: rgba(20, 25, 35, 0.85);
  border: 2px solid var(--hud-slot-border, #3a4a5a);
  border-radius: 8px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

#hud.hud-theme-premium .slot-box:not(.empty)::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  background: var(--hud-aura-color, #f39c12);
  opacity: var(--hud-aura-opacity, 0.5);
  filter: blur(6px);
  z-index: -1;
  pointer-events: none;
}

.upgrade-card.store-card.event-locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.tester-event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.tester-event-actions .btn-secondary {
  font-size: 12px;
  padding: 8px 12px;
}

.slot-box .level-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #f39c12;
  color: #000;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #000;
}

.slot-box.empty {
  opacity: 0.4;
  border-style: dashed;
}

.slot-box .slot-name {
  font-size: 8px;
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  text-align: center;
  color: #aaa;
}

#enhancement-slots.hud-enh-grid,
#item-slots.hud-item-grid {
  display: grid;
}

/* Main menu */
.menu-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(8, 12, 16, 0.35) 0%, rgba(5, 8, 12, 0.72) 70%);
  pointer-events: auto;
  overflow-x: hidden;
  max-width: 100vw;
}

.menu-content {
  text-align: center;
  width: 100%;
  max-width: min(720px, 100%);
  padding: 56px 20px 20px;
  overflow-x: hidden;
  animation: menuFadeIn 0.6s ease-out;
}

@keyframes menuFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.menu-corner-btn {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 0px));
  z-index: 6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, #f39c12, #d35400);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(243, 156, 18, 0.35);
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s, filter 0.2s;
}

.menu-corner-btn--left {
  width: 44px;
  padding: 0;
}

.menu-corner-group--left {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 0px));
  left: max(16px, env(safe-area-inset-left, 0px));
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-corner-group--left .menu-corner-btn {
  position: static;
}

.menu-corner-btn--website {
  width: 44px;
  padding: 6px;
}

.menu-corner-img {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.menu-user-id {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(92vw, 420px);
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
}

.menu-user-id-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}

.menu-user-id-value {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #a4ff00;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-user-id-copy {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.menu-user-id-copy:hover {
  background: rgba(164, 255, 0, 0.15);
  transform: scale(1.05);
}

.menu-user-id-copy.copied {
  border-color: rgba(164, 255, 0, 0.5);
  background: rgba(164, 255, 0, 0.2);
}

.menu-corner-btn--right {
  right: max(16px, env(safe-area-inset-right, 0px));
}

.menu-corner-btn--store {
  padding: 0 14px;
}

.menu-corner-icon {
  font-size: 20px;
  line-height: 1;
}

.menu-corner-label {
  text-transform: uppercase;
}

.menu-corner-btn:hover {
  transform: scale(1.05);
  filter: brightness(1.05);
  box-shadow: 0 6px 22px rgba(243, 156, 18, 0.5);
}

.menu-corner-group {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-corner-group--right .menu-corner-btn {
  position: static;
}

.menu-corner-btn--inbox {
  width: 44px;
  padding: 0;
  position: relative;
}

.inbox-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #e74c3c;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(231, 76, 60, 0.5);
}

/* --- Splash screen --- */
body.splash-active {
  overflow: hidden;
}

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  transition: opacity 0.45s ease;
}

.splash-screen.hidden {
  display: none;
}

.splash-screen.splash-fade-out {
  opacity: 0;
  pointer-events: none;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vh, 16px);
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px 0;
  max-width: min(92vw, 640px);
  text-align: center;
}

.splash-game-title {
  margin: 0;
  font-size: clamp(1.75rem, 7vw, 2.75rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a4ff00;
  text-shadow: 0 0 20px rgba(164, 255, 0, 0.35);
  line-height: 1.15;
}

.splash-credit {
  margin: 0;
  font-size: clamp(0.75rem, 2.5vw, 0.95rem);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.splash-image {
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  max-height: min(52vh, 480px);
  object-fit: contain;
  object-position: center;
}

.splash-image:not([src]),
.splash-image[src=""] {
  display: none;
}

.splash-version {
  position: absolute;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 2;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.splash-loading {
  position: absolute;
  bottom: max(40px, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  gap: 8px;
}

.splash-loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a4ff00;
  box-shadow: 0 0 8px rgba(164, 255, 0, 0.6);
  animation: splashDotPulse 1.2s ease-in-out infinite;
}

.splash-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.splash-loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes splashDotPulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* --- Inbox --- */
.inbox-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-compact {
  padding: 6px 12px;
  font-size: 12px;
}

.inbox-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 16px;
  max-height: min(60vh, 480px);
  overflow-y: auto;
}

.inbox-mail {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.inbox-mail:hover {
  border-color: rgba(52, 152, 219, 0.45);
  background: rgba(20, 28, 38, 0.65);
}

.inbox-mail.unread {
  border-color: rgba(46, 204, 113, 0.45);
  background: rgba(20, 32, 28, 0.55);
}

.inbox-mail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.inbox-mail-subject {
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}

.inbox-mail-date {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
}

.inbox-mail-from {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 4px;
}

.inbox-mail-preview {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.4;
}

.inbox-mail-attach {
  margin-top: 8px;
  font-size: 11px;
  color: #f1c40f;
  font-weight: 600;
}

.inbox-mail-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.inbox-mail-actions button {
  font-size: 11px;
  padding: 4px 10px;
}

.inbox-empty {
  padding: 32px 16px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
}

.inbox-detail-body {
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 8px;
}

/* --- Sandbox run warning --- */
.hud-sandbox-warning {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #f39c12;
  background: rgba(243, 156, 18, 0.15);
  border: 1px solid rgba(243, 156, 18, 0.45);
  border-radius: 6px;
  padding: 4px 8px;
  animation: sandboxWarnPulse 2s ease-in-out infinite;
}

@keyframes sandboxWarnPulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; box-shadow: 0 0 10px rgba(243, 156, 18, 0.35); }
}

.sandbox-toast {
  position: fixed;
  top: max(72px, calc(env(safe-area-inset-top, 0px) + 56px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  max-width: 92vw;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(30, 20, 10, 0.95);
  border: 1px solid rgba(243, 156, 18, 0.55);
  color: #ffe0a8;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s, transform 0.35s;
}

.sandbox-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.menu-logo {
  margin-bottom: 16px;
}

.logo-ring {
  width: 72px;
  height: 72px;
  border: 2px solid rgba(46, 204, 113, 0.6);
  border-radius: 50%;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px rgba(46, 204, 113, 0.25);
}

.logo-circle {
  width: 36px;
  height: 36px;
  background: #2ecc71;
  border-radius: 50%;
  box-shadow: 0 0 16px rgba(46, 204, 113, 0.7);
}

.logo-title {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #fff;
  text-shadow: 0 0 30px rgba(255,255,255,0.15);
  line-height: 1;
  margin-bottom: 4px;
}

.logo-subtitle {
  font-size: clamp(1rem, 3vw, 1.4rem);
  font-weight: 600;
  letter-spacing: 0.45em;
  color: #2ecc71;
  text-shadow: 0 0 20px rgba(46, 204, 113, 0.4);
}

.menu-tagline {
  color: rgba(255,255,255,0.55);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 28px;
}

.difficulty-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
  width: 100%;
}

.difficulty-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.difficulty-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.difficulty-btn {
  padding: 8px 14px;
  border-radius: 6px;
  border: 2px solid #3a5068;
  background: #1a2332;
  color: #9ab;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.difficulty-btn:hover {
  border-color: #5dade2;
  color: #fff;
}

.difficulty-btn.active {
  border-color: #2ecc71;
  background: rgba(46, 204, 113, 0.12);
  color: #2ecc71;
}

.difficulty-btn[data-difficulty="difficult"].active {
  border-color: #f39c12;
  background: rgba(243, 156, 18, 0.12);
  color: #f39c12;
}

.difficulty-btn[data-difficulty="insane"].active {
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.12);
  color: #e74c3c;
}

.difficulty-btn[data-difficulty="afn"].active {
  border-color: #c0392b;
  background: linear-gradient(180deg, rgba(192, 57, 43, 0.22), rgba(142, 68, 173, 0.18));
  color: #ff6b81;
  box-shadow: 0 0 14px rgba(192, 57, 43, 0.35);
}

.difficulty-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  min-height: 2.9em;
}

.menu-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  justify-content: center;
  max-width: 340px;
  margin: 0 auto 20px;
}

.menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.2s, box-shadow 0.2s, filter 0.2s, opacity 0.2s;
  min-width: 0;
  width: 100%;
  justify-content: center;
}

.menu-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.menu-btn:not(:disabled):hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.menu-btn-solo {
  background: linear-gradient(180deg, #2ecc71, #1e8449);
  color: #fff;
  box-shadow: 0 4px 16px rgba(46, 204, 113, 0.35);
}

.menu-btn-solo:not(:disabled):hover {
  box-shadow: 0 6px 22px rgba(46, 204, 113, 0.5);
}

.menu-btn-competitive {
  background: linear-gradient(180deg, #e74c3c, #c0392b);
  color: #fff;
  box-shadow: 0 4px 16px rgba(231, 76, 60, 0.35);
}

.menu-btn-competitive:not(:disabled):hover {
  box-shadow: 0 6px 22px rgba(231, 76, 60, 0.5);
}

.menu-btn-profile {
  background: linear-gradient(180deg, #bb8fce, #8e44ad);
  color: #fff;
  box-shadow: 0 4px 16px rgba(142, 68, 173, 0.35);
}

.menu-btn-profile:not(:disabled):hover {
  box-shadow: 0 6px 22px rgba(187, 143, 206, 0.5);
}

.menu-btn-friends {
  background: linear-gradient(180deg, #5dade2, #2e86c1);
  color: #fff;
  box-shadow: 0 4px 16px rgba(46, 134, 193, 0.35);
}

.menu-btn-leaderboard {
  background: linear-gradient(180deg, #f4d03f, #d4ac0d);
  color: #2c2410;
  box-shadow: 0 4px 16px rgba(212, 172, 13, 0.35);
}

.menu-btn-friends:not(:disabled):hover {
  box-shadow: 0 6px 22px rgba(52, 152, 219, 0.5);
}

.menu-btn-leaderboard:not(:disabled):hover {
  box-shadow: 0 6px 22px rgba(244, 208, 63, 0.5);
}

/* Social — friends & leaderboard */
.social-subtitle {
  color: #9ab0c4;
  font-size: 14px;
  margin: 0;
}

.social-panel {
  text-align: left;
  background: #141c26;
  border: 1px solid #2a3a4a;
  border-radius: 12px;
  padding: 16px;
  margin: 0;
  max-height: min(50vh, 420px);
  overflow-x: hidden;
  overflow-y: auto;
}

.social-toast {
  background: rgba(46, 204, 113, 0.15);
  border: 1px solid rgba(46, 204, 113, 0.35);
  color: #b8e8c8;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}

.social-toast.hidden {
  display: none;
}

.profile-account-panel {
  margin-bottom: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid #2a3a4a;
}

.account-status-msg,
.account-signed-in {
  font-size: 13px;
  color: #9ab0c4;
  margin: 0 0 10px;
}

.account-auth-actions {
  margin-bottom: 10px;
}

.account-email-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.account-email-input {
  flex: 1;
  min-width: 180px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #3a5068;
  background: #1a2332;
  color: #e8eef4;
}

.account-email-hint {
  font-size: 11px;
  color: #6a8099;
  margin: 0 0 12px;
}

.account-id-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
}

.account-id-value {
  background: #1a2332;
  padding: 4px 10px;
  border-radius: 6px;
  color: #2ecc71;
  font-weight: 700;
}

.friends-hero {
  margin-bottom: 16px;
}

.friends-your-id code {
  color: #2ecc71;
  font-size: 15px;
}

.friends-invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.friends-invite-actions a {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.friends-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.friends-id-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #3a5068;
  background: #1a2332;
  color: #e8eef4;
  text-transform: uppercase;
}

.friends-list-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7a8fa3;
  margin: 0 0 8px;
}

.friends-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #1e2a38;
}

.friends-list-meta {
  display: block;
  font-size: 12px;
  color: #6a8099;
}

.friends-empty,
.leaderboard-empty,
.leaderboard-loading,
.leaderboard-note {
  color: #9ab0c4;
  font-size: 13px;
}

.leaderboard-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.leaderboard-tab {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #3a5068;
  background: #1a2332;
  color: #9ab0c4;
  font-weight: 600;
  cursor: pointer;
}

.leaderboard-tab.active {
  border-color: #2ecc71;
  color: #2ecc71;
  background: rgba(46, 204, 113, 0.1);
}

.leaderboard-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #1e2a38;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.leaderboard-table th {
  color: #7a8fa3;
  font-size: 11px;
  text-transform: uppercase;
}

.leaderboard-score {
  font-weight: 700;
  color: #f1c40f;
  text-align: right;
}

.leaderboard-row--self td {
  color: #2ecc71;
}

.gameover-body {
  text-align: center;
  font-size: 15px;
  color: #c8d8e8;
  line-height: 1.7;
}

.gameover-body p {
  margin: 0 0 6px;
}

.gameover-cloud-note {
  font-size: 13px;
  color: #9ab0c4;
  margin: 8px 0 0;
}

.menu-btn-icon {
  font-size: 16px;
}

.menu-link-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 8px;
}

.menu-link-btn:hover {
  color: rgba(255,255,255,0.75);
}

/* Tutorial */
.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  max-width: 800px;
  width: 100%;
  margin: 16px 0 24px;
  text-align: left;
}

.tutorial-section {
  background: rgba(20, 28, 38, 0.9);
  border: 1px solid #3a5068;
  border-radius: 10px;
  padding: 16px;
}

.tutorial-section h3 {
  color: #2ecc71;
  font-size: 14px;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.tutorial-section ul {
  list-style: none;
  font-size: 13px;
  color: #aab;
  line-height: 1.7;
}

.tutorial-icons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #aab;
}

/* Settings */
.settings-tabbed {
  display: flex;
  flex-direction: row;
  min-height: 380px;
  background: #0f1419;
  border: 1px solid #2a3a4a;
  border-radius: 14px;
  overflow: hidden;
}

.settings-tab-bar {
  flex: 0 0 180px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #2a3a4a;
  background: #121820;
  padding: 8px 0;
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: #8899aa;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.settings-tab:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #c8d8e8;
}

.settings-tab.active {
  background: rgba(46, 204, 113, 0.08);
  border-left-color: #2ecc71;
  color: #fff;
}

.settings-tab-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.settings-tab-label {
  line-height: 1.3;
}

.settings-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  max-height: min(55vh, 480px);
}

.settings-tab-panel {
  padding: 20px 24px;
}

.settings-section-title {
  margin: 0 0 6px;
  font-size: 16px;
  color: #e8f0f8;
  letter-spacing: 0.04em;
}

.settings-hint {
  margin: 0 0 18px;
  font-size: 13px;
  color: #8899aa;
  line-height: 1.5;
}

.settings-panel {
  width: 100%;
  margin: 0;
}

.settings-row {
  display: grid;
  grid-template-columns: 110px 1fr 48px;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  font-size: 14px;
}

.settings-row input[type="range"] {
  width: 100%;
  accent-color: #2ecc71;
}

.settings-note {
  font-size: 11px;
  color: #666;
  margin-bottom: 16px;
}

.social-connect-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.social-connect-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #141c26;
  border: 1px solid #2a3a4a;
  border-radius: 10px;
}

.social-connect-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.social-connect-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.social-connect-name {
  font-weight: 700;
  font-size: 14px;
  color: #e8f0f8;
}

.social-connect-status {
  font-size: 12px;
  color: #8899aa;
  margin-top: 2px;
}

.social-connect-status.linked {
  color: #2ecc71;
}

.btn-social-connect {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: filter 0.15s;
}

.btn-social-connect:hover {
  filter: brightness(1.1);
}

.btn-social-connect.btn-google { background: #fff; color: #333; }
.btn-social-connect.btn-facebook { background: #1877f2; color: #fff; }
.btn-social-connect.btn-twitter { background: #000; color: #fff; border: 1px solid #333; }
.btn-social-connect.btn-instagram { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); color: #fff; }
.btn-social-connect.btn-tiktok { background: #010101; color: #fff; border: 1px solid #25f4ee; }
.btn-social-connect.btn-disconnect { background: transparent; color: #e74c3c; border: 1px solid #e74c3c; }

.redeem-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
}

.redeem-form label {
  font-size: 14px;
  font-weight: 600;
  color: #c8d8e8;
}

.redeem-input-row {
  display: flex;
  gap: 10px;
}

.redeem-input-row input {
  flex: 1;
  padding: 10px 14px;
  background: #141c26;
  border: 1px solid #2a3a4a;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.support-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.support-report-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.support-report-form textarea {
  min-height: 100px;
  padding: 12px 14px;
  background: #141c26;
  border: 1px solid #2a3a4a;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.support-reports-list {
  border-top: 1px solid #2a3a4a;
  padding-top: 16px;
}

.support-report-item {
  background: #141c26;
  border: 1px solid #2a3a4a;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.support-report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.support-report-number {
  font-weight: 700;
  color: #3498db;
  font-size: 13px;
}

.support-report-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(52, 152, 219, 0.15);
  color: #5dade2;
}

.support-report-status.resolved {
  background: rgba(46, 204, 113, 0.15);
  color: #2ecc71;
}

.support-report-desc {
  font-size: 13px;
  color: #aab;
  margin-bottom: 8px;
}

.support-report-response {
  font-size: 12px;
  color: #c8d8e8;
  padding: 8px 10px;
  background: rgba(46, 204, 113, 0.08);
  border-left: 3px solid #2ecc71;
  border-radius: 0 6px 6px 0;
  margin-top: 6px;
}

@media (max-width: 700px) {
  .settings-tabbed {
    flex-direction: column;
    min-height: auto;
  }

  .settings-tab-bar {
    flex: none;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid #2a3a4a;
    padding: 4px;
  }

  .settings-tab {
    flex: 1 1 auto;
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 10px 12px;
    justify-content: center;
  }

  .settings-tab.active {
    border-left-color: transparent;
    border-bottom-color: #2ecc71;
  }

  .settings-tab-label {
    display: none;
  }
}

/* ── Standard UI form (center-screen modal for all non-gameplay panels) ── */
.ui-form-overlay,
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 15, 0.94);
  z-index: 10;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow: hidden;
  max-width: 100vw;
}

.ui-form-overlay--elevated,
.store-overlay {
  z-index: 15;
}

.ui-form {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(90vh, 900px);
  background: linear-gradient(180deg, #121820 0%, #0d1117 100%);
  border: 1px solid #2a3a4a;
  border-radius: 16px;
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(46, 204, 113, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  position: relative;
}

.ui-form::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(46, 204, 113, 0.65), transparent);
  pointer-events: none;
  z-index: 1;
}

.ui-form--compact { max-width: 480px; }
.ui-form--medium { max-width: 680px; }
.ui-form--wide { max-width: 960px; max-height: min(92vh, 920px); }

.ui-form-header {
  flex-shrink: 0;
  padding: 18px 22px 12px;
  text-align: center;
  border-bottom: 1px solid #1e2a38;
  background: rgba(20, 28, 38, 0.55);
}

.ui-form-title {
  font-size: clamp(1.25rem, 4vw, 1.65rem);
  color: #3498db;
  margin: 0 0 4px;
  letter-spacing: 0.04em;
}

.ui-form-subtitle {
  font-size: 13px;
  color: #8899aa;
  margin: 0;
  line-height: 1.45;
}

.ui-form-header .ui-form-subtitle + .ui-form-subtitle,
.ui-form-header .upgrade-queue-hint {
  margin-top: 6px;
}

.ui-form-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}

.ui-form-body {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px 22px;
  min-height: 0;
}

.ui-form-body--flush {
  padding: 0;
}

.ui-form-body--flush .store-tabbed {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.ui-form-header .testers-hint,
.ui-form-header .upgrade-queue-hint {
  margin-bottom: 0;
}

.ui-form-footer {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 12px 22px 18px;
  border-top: 1px solid #1e2a38;
  background: rgba(10, 14, 20, 0.45);
}

.ui-form-footer .btn-secondary,
.ui-form-footer .btn-primary {
  margin: 0;
}

.ui-form--enter {
  animation: uiFormEnter 0.25s ease-out;
}

@keyframes uiFormEnter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ui-form .social-toast {
  margin: 10px auto 0;
  max-width: 100%;
}

.overlay h1,
.ui-form-title--hero {
  font-size: clamp(2rem, 6vw, 3.5rem);
  letter-spacing: 0.15em;
  color: #2ecc71;
  text-shadow: 0 0 20px rgba(46, 204, 113, 0.4);
  margin-bottom: 8px;
}

.overlay h2 {
  font-size: 1.8rem;
  color: #3498db;
  margin-bottom: 12px;
}

.subtitle { color: #888; margin-bottom: 24px; }
.hint { color: #555; font-size: 12px; margin-top: 16px; }

button {
  cursor: pointer;
  border: none;
  padding: 12px 32px;
  margin: 6px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  transition: transform 0.1s, background 0.2s;
}

button:hover { transform: scale(1.03); }
button:active { transform: scale(0.97); }

.btn-primary {
  background: #27ae60;
  color: #fff;
}

.btn-primary:hover { background: #2ecc71; }

.btn-secondary {
  background: #34495e;
  color: #ecf0f1;
}

.btn-secondary:hover { background: #4a6278; }

/* Upgrade cards */
#upgrade-options, #weapon-options, #main-ability-options, #item-choice-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  width: 100%;
  margin: 0;
}

#upgrade-options.hidden,
#upgrade-tree-panel.hidden {
  display: none;
}


.upgrade-queue-hint {
  font-size: 12px;
  color: #7f8c9a;
  margin: -4px 0 8px;
}

.upgrade-tree-panel {
  width: 100%;
  max-width: 100%;
  margin-top: 12px;
  overflow-x: hidden;
}

.upgrade-tree-panel .tree-dag-scroll {
  max-height: min(58vh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
}

.upgrade-tree-panel .tree-panel-head {
  text-align: center;
}

.tree-node--pickable {
  border-color: #2ecc71 !important;
  box-shadow: 0 0 14px rgba(46, 204, 113, 0.4);
}

.slot-box.weapon-switchable {
  cursor: pointer;
  border-color: #f1c40f;
}

.slot-box.weapon-switchable:hover {
  border-color: #2ecc71;
  transform: scale(1.05);
}

.upgrade-card {
  background: #1a2332;
  border: 2px solid #3a5068;
  border-radius: 10px;
  padding: 16px;
  width: 200px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
  pointer-events: auto;
}

.upgrade-card:hover {
  border-color: #3498db;
  transform: translateY(-2px);
}

.upgrade-card .card-icon { font-size: 32px; margin-bottom: 8px; }
.upgrade-card .card-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.upgrade-card .card-desc { font-size: 11px; color: #9ab; line-height: 1.4; }
.upgrade-card .card-level { font-size: 10px; color: #f39c12; margin-top: 6px; }
.upgrade-card .card-tag { font-size: 9px; color: #3498db; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.upgrade-card .card-category {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.upgrade-card--weapon { border-top: 3px solid #e74c3c; }
.upgrade-card--weapon .card-category { color: #e74c3c; }
.upgrade-card--ability { border-top: 3px solid #9b59b6; }
.upgrade-card--ability .card-category { color: #9b59b6; }
.upgrade-card--enhancement { border-top: 3px solid #2ecc71; }
.upgrade-card--enhancement .card-category { color: #2ecc71; }

#upgrade-options.upgrade-options--grouped {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 20px;
  align-items: stretch;
}
.upgrade-section { width: 100%; }
.upgrade-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}
.upgrade-section-title--weapons { color: #e74c3c; }
.upgrade-section-title--abilities { color: #9b59b6; }
.upgrade-section-title--enhancements { color: #2ecc71; }
.upgrade-section-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.upgrade-section-empty {
  font-size: 11px;
  color: #678;
  font-style: italic;
  margin: 0;
  padding: 8px 0;
}
.upgrade-card.owned:not(.store-card) { opacity: 0.5; cursor: default; }

/* Profile */
.profile-header {
  text-align: center;
}

.profile-meta {
  color: #9ab;
  font-size: 14px;
  margin: 4px 0 0;
}

.btn-profile-buy-point {
  margin-top: 10px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #2ecc71;
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid #2ecc71;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-profile-buy-point:hover:not(:disabled) {
  background: rgba(46, 204, 113, 0.2);
}

.btn-profile-buy-point:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: #3a5068;
  color: #6a8099;
}

.profile-main-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px;
  align-items: flex-start;
}

.profile-tabbed {
  flex: 1 1 300px;
  min-width: 0;
}

.profile-tab-panel-wrap {
  min-height: 280px;
}

.profile-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-tab-panel.hidden {
  display: none;
}

.profile-stats-actions {
  display: flex;
  justify-content: flex-start;
}

.profile-stats-actions .btn-profile-buy-point {
  margin-top: 0;
}

.profile-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  width: 100%;
  align-items: flex-start;
  justify-content: center;
}

.profile-main-layout .profile-hero-panel {
  flex: 0 0 260px;
  width: 260px;
  max-width: 260px;
}

.profile-hero-panel {
  flex: 0 1 320px;
  background: linear-gradient(180deg, #121820 0%, #0d1117 100%);
  border: 2px solid #2a3a4a;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

#profile-character-canvas {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  display: block;
  border-radius: 10px;
}

.profile-hero-caption {
  text-align: center;
  font-size: 12px;
  color: #6a8;
  margin: 10px 0 0;
}

.profile-side-panel {
  flex: 1 1 340px;
  min-width: 280px;
  max-width: 560px;
}

.profile-actions {
  display: contents;
}

#profile-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin: 8px 0 16px;
}

.profile-stat {
  background: #1a2332;
  border: 1px solid #3a5068;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  cursor: default;
}

.profile-stat:hover {
  transform: translateX(4px);
}

.profile-stat[data-stat-id="stat_hp"]:hover { border-color: #e74c3c; box-shadow: -4px 0 12px rgba(231, 76, 60, 0.2); }
.profile-stat[data-stat-id="stat_damage"]:hover { border-color: #ff6600; box-shadow: -4px 0 12px rgba(255, 102, 0, 0.2); }
.profile-stat[data-stat-id="stat_speed"]:hover { border-color: #3498db; box-shadow: -4px 0 12px rgba(52, 152, 219, 0.2); }
.profile-stat[data-stat-id="stat_armor"]:hover { border-color: #95a5a6; box-shadow: -4px 0 12px rgba(149, 165, 166, 0.2); }
.profile-stat[data-stat-id="stat_xp_gain"]:hover { border-color: #9b59b6; box-shadow: -4px 0 12px rgba(155, 89, 182, 0.2); }
.profile-stat[data-stat-id="stat_cooldown"]:hover { border-color: #1abc9c; box-shadow: -4px 0 12px rgba(26, 188, 156, 0.2); }

.profile-stat[data-stat-id="stat_hp"] .profile-stat-fill { background: linear-gradient(90deg, #c0392b, #e74c3c); }
.profile-stat[data-stat-id="stat_damage"] .profile-stat-fill { background: linear-gradient(90deg, #d35400, #ff6600); }
.profile-stat[data-stat-id="stat_speed"] .profile-stat-fill { background: linear-gradient(90deg, #2471a3, #3498db); }
.profile-stat[data-stat-id="stat_armor"] .profile-stat-fill { background: linear-gradient(90deg, #7f8c8d, #bdc3c7); }
.profile-stat[data-stat-id="stat_xp_gain"] .profile-stat-fill { background: linear-gradient(90deg, #8e44ad, #9b59b6); }
.profile-stat[data-stat-id="stat_cooldown"] .profile-stat-fill { background: linear-gradient(90deg, #16a085, #1abc9c); }

.profile-stat-icon {
  font-size: 26px;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.profile-stat-body {
  flex: 1;
  min-width: 0;
}

.profile-stat-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.profile-stat-lv {
  font-size: 12px;
  color: #f39c12;
  font-weight: 700;
}

.profile-stat-bar {
  height: 4px;
  background: #0d1117;
  border-radius: 2px;
  margin: 6px 0 4px;
  overflow: hidden;
}

.profile-stat-fill {
  height: 100%;
  background: linear-gradient(90deg, #2980b9, #2ecc71);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.profile-stat small {
  color: #888;
  font-size: 11px;
}

.profile-stat-upgrade {
  padding: 8px 14px;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(180deg, #3498db, #2980b9);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(41, 128, 185, 0.35);
}

.profile-stat-upgrade:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(41, 128, 185, 0.5);
}

.profile-stat-upgrade:active:not(:disabled) {
  transform: scale(0.96);
}

.profile-stat-upgrade:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.profile-subsection {
  color: #888;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 12px 0 6px;
  text-align: left;
}

.profile-section-title {
  color: #2ecc71;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 16px 0 6px;
  width: 100%;
  text-align: left;
}

.profile-hint {
  font-size: 12px;
  color: #888;
  margin-bottom: 8px;
  text-align: left;
}

.profile-loadout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.profile-loadout-head .profile-section-title {
  margin: 0;
}

.btn-profile-reset-loadout {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #c8d8e8;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid #3a4a5a;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-profile-reset-loadout:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: #5dade2;
  color: #fff;
}

.btn-profile-reset-loadout:disabled {
  opacity: 0.45;
  cursor: default;
}

.profile-loadout-section {
  width: 100%;
  margin-top: 0;
}

.profile-loadout-tabbed {
  background: #121820;
  border: 1px solid #2a3a4a;
  border-radius: 10px;
  overflow: hidden;
}

.profile-loadout-tab-bar-wrap {
  overflow-x: hidden;
  border-bottom: 1px solid #2a3a4a;
}

.profile-loadout-tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px 4px 0;
}

.profile-loadout-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 10px 6px;
  min-width: 58px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #6a8099;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s, border-color 0.2s;
}

.profile-loadout-tab-icon { font-size: 16px; line-height: 1; }
.profile-loadout-tab-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.profile-loadout-tab:hover { color: #c8d8e8; }
.profile-loadout-tab.active {
  color: #2ecc71;
  border-bottom-color: #2ecc71;
}

.profile-loadout-sub-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #1e2a38;
  background: #0f1419;
}

.profile-loadout-sub-wrap.hidden { display: none; }

.profile-loadout-sub-label {
  font-size: 11px;
  color: #7a8fa3;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.profile-loadout-sub {
  flex: 1;
  padding: 6px 8px;
  background: #1a2332;
  border: 1px solid #3a5068;
  border-radius: 6px;
  color: #e8eef4;
  font-size: 12px;
}

.profile-loadout-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  max-height: 220px;
  overflow-x: hidden;
  overflow-y: auto;
}

.profile-loadout-card {
  background: #1a2332;
  border: 2px solid #3a5068;
  border-radius: 10px;
  padding: 10px 12px;
  width: 108px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, transform 0.1s;
}

.profile-loadout-card:hover {
  border-color: #3498db;
  transform: translateY(-2px);
}

.profile-loadout-card.active {
  border-color: #2ecc71;
  box-shadow: 0 0 12px rgba(46, 204, 113, 0.3);
}

.profile-loadout-card .card-icon { font-size: 24px; }
.profile-loadout-card .card-title { font-size: 11px; font-weight: 700; margin-top: 4px; line-height: 1.2; }
.profile-loadout-card .active-badge {
  font-size: 9px;
  color: #2ecc71;
  margin-top: 4px;
  font-weight: 700;
}

.profile-loadout-empty {
  color: #888;
  font-size: 12px;
  padding: 8px 4px;
  width: 100%;
}

/* Codex */
.menu-btn-codex {
  background: linear-gradient(180deg, #7e6bc4, #4a3d82);
  color: #fff;
  box-shadow: 0 4px 16px rgba(91, 74, 158, 0.35);
  min-width: 150px;
}

.menu-btn-codex:not(:disabled):hover {
  box-shadow: 0 6px 22px rgba(126, 107, 196, 0.5);
}

.codex-header {
  text-align: center;
}

#codex-subtitle {
  font-size: 13px;
  color: #8899aa;
}

.codex-tabbed {
  margin: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

.codex-subtabs {
  padding: 10px 12px 0;
  border-bottom: 1px solid #1e2a38;
}

.codex-panel {
  min-height: 360px;
}

.codex-content {
  min-height: 320px;
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: min(62vh, 520px);
  max-width: 100%;
}

.codex-ref-head {
  margin-bottom: 16px;
}

.codex-ref-title {
  margin: 0 0 4px;
  font-size: 18px;
  color: #e8eef4;
}

.codex-ref-desc {
  color: #9ab0c4;
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 12px;
}

.codex-ref-note {
  color: #6a8099;
  font-size: 12px;
  margin: 8px 0 0;
}

.codex-ref-section {
  margin-bottom: 18px;
}

.codex-ref-section-title {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #2ecc71;
}

.codex-ref-list {
  margin: 0;
  padding-left: 18px;
  color: #b8c8d8;
  font-size: 13px;
  line-height: 1.55;
}

.codex-enemy-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.codex-enemy-hero-icon {
  font-size: 42px;
  line-height: 1;
}

.codex-enemy-role {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #f39c12;
}

.codex-tier-table-wrap {
  width: 100%;
  overflow-x: hidden;
}

.codex-tier-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 11px;
}

.codex-tier-table th,
.codex-tier-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid #1e2a38;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.codex-tier-table th {
  color: #7a8fa3;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.codex-tier-table td {
  color: #c8d8e8;
}

.codex-tier-badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: 6px;
  font-weight: 700;
  font-size: 11px;
}

.codex-ability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.codex-ability-card {
  background: #1a2332;
  border: 1px solid #2a3a4a;
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
  color: #9ab0c4;
  line-height: 1.45;
}

.codex-ability-card strong {
  display: block;
  color: #e8eef4;
  margin: 6px 0 4px;
}

.codex-ability-icon {
  font-size: 22px;
}

.codex-tip-box {
  background: rgba(46, 204, 113, 0.08);
  border: 1px solid rgba(46, 204, 113, 0.25);
  border-radius: 10px;
  padding: 12px 14px;
}

.codex-tip-box p {
  margin: 0;
  color: #b8dcc8;
  font-size: 13px;
}

.codex-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.codex-stat-card {
  background: #1a2332;
  border: 1px solid #2a3a4a;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.codex-stat-card-icon {
  font-size: 22px;
  display: block;
  margin-bottom: 4px;
}

.codex-stat-card-label {
  display: block;
  font-size: 11px;
  color: #7a8fa3;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.codex-stat-card-value {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #e8eef4;
  margin-top: 4px;
}

.codex-profile-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.codex-profile-stat-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #1a2332;
  border: 1px solid #2a3a4a;
  border-radius: 10px;
  padding: 12px;
}

.codex-profile-stat-icon {
  font-size: 24px;
}

.codex-profile-stat-body strong {
  display: block;
  color: #e8eef4;
  font-size: 14px;
}

.codex-profile-stat-desc {
  display: block;
  font-size: 12px;
  color: #9ab0c4;
  margin-top: 2px;
}

.codex-profile-stat-max {
  display: block;
  font-size: 11px;
  color: #6a8099;
  margin-top: 4px;
}

.codex-scale-block {
  background: #141c26;
  border: 1px solid #1e2a38;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.codex-scale-block p {
  margin: 6px 0 10px;
  font-size: 13px;
  color: #9ab0c4;
  line-height: 1.45;
}

.codex-scale-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e8eef4;
  font-size: 14px;
}

.codex-stat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.codex-stat-pill {
  display: inline-flex;
  flex-direction: column;
  background: #1a2332;
  border: 1px solid #2a3a4a;
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 72px;
}

.codex-stat-pill-label {
  font-size: 10px;
  color: #6a8099;
  text-transform: uppercase;
}

.codex-stat-pill-value {
  font-size: 14px;
  font-weight: 700;
  color: #2ecc71;
}

.codex-enemy-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.codex-enemy-overview-card {
  background: #1a2332;
  border: 1px solid #2a3a4a;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.codex-enemy-overview-card strong {
  display: block;
  color: #e8eef4;
  margin: 8px 0 2px;
}

.codex-enemy-overview-card p {
  font-size: 12px;
  color: #9ab0c4;
  margin: 8px 0 0;
  line-height: 1.4;
}

/* Build tree renderer */
.tree-panel-head {
  margin-bottom: 12px;
}

.tree-panel-title {
  font-size: 16px;
  color: #c8d8e8;
}

.tree-panel-body {
  position: relative;
}

.tree-panel-footer {
  margin-top: 14px;
  font-size: 12px;
  color: #6a8099;
  line-height: 1.5;
}

.tree-dag-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.tree-dag-scroll {
  overflow-x: hidden;
  overflow-y: auto;
  max-width: 100%;
  padding-bottom: 8px;
}

.tree-dag-scale {
  position: relative;
  overflow: hidden;
  margin: 0 auto;
}

.tree-dag-stage {
  position: relative;
  transform-origin: top left;
}

.tree-dag-svg,
.tree-hub-svg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tree-dag-nodes,
.tree-hub-nodes {
  position: relative;
  z-index: 1;
}

.tree-node {
  position: absolute;
  width: 96px;
  min-height: 72px;
  padding: 6px 4px;
  background: #1a2332;
  border: 2px solid #3a5068;
  border-radius: 10px;
  text-align: center;
  box-sizing: border-box;
}

.tree-node--crafted {
  border-color: #9b59b6;
  background: linear-gradient(180deg, #2a1f3d, #1a2332);
}

.tree-node--base {
  border-color: #2ecc71;
}

.tree-node--root {
  border-color: #3498db;
  background: linear-gradient(180deg, #1a2a3d, #1a2332);
  z-index: 4;
}

.tree-node--icon.tree-node--root {
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.35), 0 0 16px rgba(52, 152, 219, 0.25);
}

.tree-node--owned,
.tree-node--taken,
.tree-node--active-root {
  border-color: #2ecc71;
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.35);
}

.tree-node--craft-ready {
  border-color: #f1c40f;
  box-shadow: 0 0 12px rgba(241, 196, 15, 0.4);
}

.tree-node--craft-ingredient {
  border-color: #f39c12;
}

.tree-node--available {
  border-color: #5dade2;
}

.tree-node--pickable {
  border-color: #2ecc71 !important;
  box-shadow: 0 0 14px rgba(46, 204, 113, 0.4);
}

.tree-node--locked {
  opacity: 0.45;
}

.tree-node--meta-unlocked {
  border-color: #9b59b6;
  box-shadow: 0 0 8px rgba(155, 89, 182, 0.35);
}

.slot-path-complete {
  box-shadow: 0 0 10px rgba(255, 193, 7, 0.55);
  border-color: #f1c40f !important;
}

.slot-mastery {
  box-shadow: 0 0 12px rgba(46, 204, 113, 0.65);
  border-color: #2ecc71 !important;
}

.weapon-milestone-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 28, 38, 0.95);
  border: 1px solid #3498db;
  border-radius: 10px;
  padding: 12px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.35s, transform 0.35s;
  pointer-events: none;
  max-width: 90vw;
}

.weapon-milestone-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.weapon-milestone-icon {
  font-size: 28px;
}

.tree-node--clickable {
  cursor: pointer;
}

.tree-node--clickable:hover {
  transform: translateY(-2px);
  border-color: #3498db;
}

.tree-compact-wrap {
  overflow: visible;
}

.tree-compact-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tree-compact-root {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.tree-compact-tier,
.tree-compact-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tree-compact-tier-label {
  font-size: 11px;
  font-weight: 700;
  color: #7a8fa3;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tree-compact-grid,
.tree-enh-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.tree-node--compact {
  position: static;
  width: auto;
  min-width: 104px;
  max-width: 148px;
  flex: 1 1 104px;
}

.tree-node--grid-card {
  position: static;
  width: auto;
  min-width: 140px;
  flex: 1 1 160px;
  max-width: 220px;
}

.tree-node--root-chip {
  min-width: 120px;
  max-width: 200px;
  flex: 0 1 auto;
}

.tester-trees-content .tree-compact-wrap,
.codex-content .tree-compact-wrap {
  max-height: none;
}

.tree-node-icon {
  font-size: 22px;
  line-height: 1.2;
}

.tree-node-icon-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
  margin: 0 auto 2px;
  opacity: 0.95;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.tree-node--icon .tree-node-icon-img {
  width: 24px;
  height: 24px;
  margin: 0;
}

.tree-node--icon.tree-node--root .tree-node-icon-img {
  width: 28px;
  height: 28px;
}

.card-icon--tree.tree-node-icon-img,
.upgrade-card .card-icon--tree {
  width: 36px;
  height: 36px;
  margin: 0 auto 6px;
}

.tree-node-label {
  font-size: 11px;
  font-weight: 700;
  margin-top: 2px;
  color: #e0e8f0;
}

.tree-node-desc {
  font-size: 9px;
  color: #8899aa;
  margin-top: 2px;
  line-height: 1.25;
}

.tree-node-state,
.tree-node-meta {
  display: block;
  font-size: 9px;
  font-weight: 700;
  color: #2ecc71;
  margin-top: 4px;
}

.tree-node-badge {
  position: absolute;
  top: -8px;
  right: -6px;
  font-size: 8px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 8px;
  background: #f39c12;
  color: #1a1200;
}

.tree-edge {
  stroke: #3a5068;
  stroke-width: 2;
  stroke-linecap: round;
}

.tree-edge--branch {
  stroke: #5dade2;
  stroke-width: 2.5;
  opacity: 0.85;
}

.tree-segment {
  pointer-events: none;
}

.tree-segment-divider {
  stroke-width: 1.5;
  stroke-opacity: 0.4;
  stroke-dasharray: 5 7;
  pointer-events: none;
}

.tree-segment-divider--0 { stroke: #5dade2; }
.tree-segment-divider--1 { stroke: #2ecc71; }
.tree-segment-divider--2 { stroke: #f1c40f; }
.tree-segment-divider--3 { stroke: #9b59b6; }

.tree-edge--segment-0 { stroke: #5dade2; stroke-width: 2.5; opacity: 0.9; }
.tree-edge--segment-1 { stroke: #2ecc71; stroke-width: 2.5; opacity: 0.9; }
.tree-edge--segment-2 { stroke: #f1c40f; stroke-width: 2.5; opacity: 0.9; }
.tree-edge--segment-3 { stroke: #9b59b6; stroke-width: 2.5; opacity: 0.9; }

.tree-junction--segment-0 { fill: #5dade2; }
.tree-junction--segment-1 { fill: #2ecc71; }
.tree-junction--segment-2 { fill: #f1c40f; }
.tree-junction--segment-3 { fill: #9b59b6; }

.tree-node--icon.tree-node--segment-0 { border-color: rgba(93, 173, 226, 0.65); }
.tree-node--icon.tree-node--segment-1 { border-color: rgba(46, 204, 113, 0.65); }
.tree-node--icon.tree-node--segment-2 { border-color: rgba(241, 196, 15, 0.65); }
.tree-node--icon.tree-node--segment-3 { border-color: rgba(155, 89, 182, 0.65); }

.tree-node--icon.tree-node--segment-0 .tree-node-icon-img {
  filter: drop-shadow(0 0 5px rgba(93, 173, 226, 0.65));
}
.tree-node--icon.tree-node--segment-1 .tree-node-icon-img {
  filter: drop-shadow(0 0 5px rgba(46, 204, 113, 0.65));
}
.tree-node--icon.tree-node--segment-2 .tree-node-icon-img {
  filter: drop-shadow(0 0 5px rgba(241, 196, 15, 0.65));
}
.tree-node--icon.tree-node--segment-3 .tree-node-icon-img {
  filter: drop-shadow(0 0 5px rgba(155, 89, 182, 0.65));
}

.tree-edge--reachable {
  stroke: #9b59b6;
  stroke-width: 2.5;
  stroke-dasharray: 6 4;
  opacity: 0.9;
}

.tree-edge--craft-ready {
  stroke: #f1c40f;
  stroke-width: 2.5;
}

.tree-edge--taken {
  stroke: #2ecc71;
  stroke-width: 3;
  opacity: 1;
}

.tree-tier-guide {
  stroke: rgba(93, 173, 226, 0.12);
  stroke-width: 1;
  stroke-dasharray: 4 6;
}

.tree-tier-label {
  fill: #6a8099;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
}

.tree-junction {
  fill: #3498db;
  stroke: #1a2332;
  stroke-width: 2;
}

.tree-dag-nodes .tree-node--linked::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: #5dade2;
  border: 2px solid #1a2332;
  z-index: 2;
}

.tree-dag-nodes .tree-node--has-children::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: #5dade2;
  border: 2px solid #1a2332;
  z-index: 2;
}

.tree-dag-nodes .tree-node--taken.tree-node--linked::before,
.tree-dag-nodes .tree-node--taken.tree-node--has-children::after,
.tree-dag-nodes .tree-node--active-root.tree-node--has-children::after {
  background: #2ecc71;
}

/* Compact icon-only nodes (weapon/ability factor trees) */
.tree-node--icon {
  width: 40px;
  height: 40px;
  min-height: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: default;
}

.tree-node--icon.tree-node--root {
  width: 48px;
  height: 48px;
  border-radius: 10px;
}

.tree-node--icon.tree-node--clickable {
  cursor: pointer;
}

.tree-node--icon .tree-node-icon {
  font-size: 20px;
  line-height: 1;
  margin: 0;
}

.tree-node--icon.tree-node--root .tree-node-icon {
  font-size: 24px;
}

.tree-dag-wrap--icon .tree-dag-scale {
  overflow: visible;
}

.tree-dag-wrap--icon .tree-dag-scroll {
  padding-top: 12px;
  padding-bottom: 24px;
}

.tree-node--icon .tree-node-tooltip {
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  bottom: auto;
  transform: translateX(-50%) translateY(-6px);
  min-width: 168px;
  max-width: 240px;
  padding: 10px 12px;
  background: rgba(10, 14, 20, 0.98);
  border: 1px solid #3a5068;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(93, 173, 226, 0.12);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.14s ease, visibility 0.14s ease, transform 0.14s ease;
  z-index: 30;
  text-align: left;
}

.tree-node--icon:hover .tree-node-tooltip,
.tree-node--icon:focus-visible .tree-node-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.tree-node--icon:hover {
  z-index: 25;
  transform: scale(1.08);
}

.tree-node--icon.tree-node--clickable:hover {
  transform: scale(1.12);
}

.tree-node-tooltip-name {
  font-size: 13px;
  font-weight: 700;
  color: #e8eef4;
  line-height: 1.25;
  margin-bottom: 3px;
}

.tree-node-tooltip-tier {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #f39c12;
  margin-bottom: 6px;
}

.tree-node-tooltip-desc {
  font-size: 11px;
  color: #9ab0c4;
  line-height: 1.45;
  margin: 0;
}

.tree-node-tooltip-status {
  display: inline-block;
  margin-top: 7px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #2ecc71;
  padding: 3px 7px;
  border-radius: 5px;
  background: rgba(46, 204, 113, 0.14);
  border: 1px solid rgba(46, 204, 113, 0.28);
}

.tree-node--icon.tree-node--locked .tree-node-tooltip-status,
.tree-node--icon.tree-node--locked .tree-node-tooltip-tier {
  color: #7a8fa3;
}

.tree-node--icon.tree-node--pickable .tree-node-tooltip-status {
  color: #2ecc71;
  border-color: rgba(46, 204, 113, 0.45);
}

.tree-node--icon.tree-node--meta-unlocked .tree-node-tooltip-status {
  color: #bb8fce;
  background: rgba(155, 89, 182, 0.14);
  border-color: rgba(155, 89, 182, 0.3);
}

.tree-dag-nodes .tree-node--icon.tree-node--linked::before,
.tree-dag-nodes .tree-node--icon.tree-node--has-children::after {
  display: none;
}

.codex-content .tree-dag-scroll {
  max-height: min(58vh, 540px);
}

.codex-content .tree-panel-body {
  padding: 0;
}

.codex-content .tree-panel-head {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #1e2a38;
}

.tree-hub-stage {
  position: relative;
  margin: 0 auto;
}

.tree-enh-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.tree-subtab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tree-subtab {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #3a5068;
  background: #1a2332;
  color: #aabbcc;
  cursor: pointer;
  font-size: 12px;
}

.tree-subtab.active {
  border-color: #2ecc71;
  color: #2ecc71;
}

.tree-subtab:hover {
  border-color: #3498db;
}

/* Testers trees mode */
.testers-mode-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.tester-mode-btn {
  padding: 8px 20px;
  border-radius: 8px;
  border: 2px solid #3a5068;
  background: #1a2332;
  color: #aabbcc;
  cursor: pointer;
  font-weight: 600;
}

.tester-mode-btn.active {
  border-color: #2ecc71;
  color: #2ecc71;
}

.tester-trees-content {
  min-height: 380px;
  max-height: 50vh;
  overflow-x: hidden;
  overflow-y: auto;
  background: #0f1419;
  border: 1px solid #2a3a4a;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  max-width: 100%;
}

/* In-game tester overlay */
.ingame-tester-panel {
  padding: 0 4px 8px;
}

.ingame-tester-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  margin-bottom: 8px;
}

.ingame-tester-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #aabbcc;
}

.ingame-tester-toolbar select {
  background: #1a2332;
  border: 1px solid #3a5068;
  color: #e8eef4;
  border-radius: 6px;
  padding: 4px 8px;
}

.ingame-tester-tree {
  min-height: 340px;
  max-height: 48vh;
  overflow: auto;
  background: #0f1419;
  border: 1px solid #2a3a4a;
  border-radius: 12px;
  padding: 8px;
}

.ingame-tester-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.ingame-tester-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border-radius: 10px;
  border: 2px solid #3a5068;
  background: #1a2332;
  color: #ccd6e0;
  cursor: pointer;
  font-size: 12px;
  text-align: center;
}

.ingame-tester-card:hover {
  border-color: #5dade2;
}

.ingame-tester-card.active {
  border-color: #2ecc71;
  background: rgba(46, 204, 113, 0.12);
  color: #2ecc71;
}

.ingame-tester-card .ig-card-icon {
  font-size: 22px;
}

.ingame-tester-loadout {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  min-height: 36px;
}

.ingame-tester-loadout-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #243040;
  border: 1px solid #3a5068;
  font-size: 12px;
}

.ingame-tester-loadout-item button {
  background: transparent;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
}

.btn-compact {
  padding: 6px 12px;
  font-size: 12px;
}

/* QA testing checklist (in-game tester) */
.qa-checklist-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  margin-bottom: 8px;
}

.qa-checklist-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #aabbcc;
}

.qa-checklist-toolbar select {
  background: #1a2332;
  border: 1px solid #3a5068;
  color: #e8eef4;
  border-radius: 6px;
  padding: 4px 8px;
  min-width: 200px;
}

.qa-checklist-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.qa-checklist-progress {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: #8ab4d4;
}

.qa-progress-overall {
  color: #2ecc71;
  font-weight: 600;
}

.qa-checklist-gaps {
  margin-bottom: 8px;
}

.qa-gaps-details {
  font-size: 12px;
  color: #f0ad4e;
  background: rgba(240, 173, 78, 0.08);
  border: 1px solid rgba(240, 173, 78, 0.25);
  border-radius: 8px;
  padding: 6px 10px;
}

.qa-gaps-details summary {
  cursor: pointer;
  font-weight: 600;
}

.qa-gaps-details ul {
  margin: 6px 0 0 16px;
  padding: 0;
}

.qa-checklist-list {
  max-height: 46vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.qa-checklist-group {
  font-size: 13px;
  color: #5dade2;
  margin: 8px 0 4px;
  font-weight: 600;
}

.qa-checklist-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #2a3a4a;
  background: #141c26;
}

.qa-checklist-row--done {
  border-color: rgba(46, 204, 113, 0.45);
  background: rgba(46, 204, 113, 0.06);
}

.qa-checklist-row-main {
  flex: 1 1 220px;
  min-width: 0;
}

.qa-checklist-label {
  font-size: 13px;
  font-weight: 600;
  color: #e8eef4;
  margin-bottom: 4px;
}

.qa-checklist-hints {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.qa-hint {
  font-size: 11px;
  color: #8899aa;
  line-height: 1.35;
}

.qa-warn {
  font-size: 11px;
  color: #f0ad4e;
  margin-top: 2px;
}

.qa-checklist-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.qa-check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #ccd6e0;
  cursor: pointer;
  user-select: none;
}

.qa-notes {
  width: 120px;
  background: #1a2332;
  border: 1px solid #3a5068;
  color: #e8eef4;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
}

.qa-load-btn {
  white-space: nowrap;
}

/* --- Mobile / phone HUD (browser + native app WebView) --- */
#app {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

@media (max-width: 900px) {
  .hud-top-panel {
    min-width: unset;
    width: min(96vw, 100%);
    padding: 6px 10px 8px;
    gap: 6px;
  }

  .hud-top-ear {
    width: 14px;
  }

  .hud-kc-block {
    min-width: 52px;
    padding: 0 6px;
  }

  .hud-kc-icon {
    font-size: 14px;
  }

  .hud-kc-value {
    font-size: 12px;
  }

  .hud-top-stats {
    padding: 0 10px;
    min-width: 96px;
  }

  .hud-stat-row {
    font-size: 10px;
    gap: 8px;
  }

  .hud-icon-btn {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .hud-command-panel {
    padding: 6px 12px;
    max-width: 100%;
  }

  .hud-command-panel .slot-box {
    width: 40px;
    height: 40px;
    font-size: 17px;
  }

  .hud-hero-rings,
  .hud-ring-svg {
    width: 58px;
    height: 58px;
  }

  .hud-hero-block {
    min-width: 58px;
  }

  .hud-enh-grid {
    grid-template-columns: repeat(2, 40px);
    grid-template-rows: repeat(2, 40px);
    gap: 4px;
  }

  .hud-item-grid {
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(2, 40px);
    gap: 4px;
  }

  #hud-minimap {
    width: 72px;
    height: 72px;
  }

  .slot-box .level-badge {
    width: 15px;
    height: 15px;
    font-size: 9px;
    top: -4px;
    right: -4px;
  }

  .slot-box .slot-name {
    font-size: 7px;
  }
}

@media (max-width: 600px) {
  .hud-top-wrap {
    top: max(4px, env(safe-area-inset-top, 0px));
  }

  .hud-bottom-area {
    bottom: max(6px, env(safe-area-inset-bottom, 0px));
    padding: 0 4px;
  }

  /* Hide decorative ears — saves horizontal space */
  .hud-top-ear {
    display: none;
  }

  .hud-top-panel {
    clip-path: none;
    border-radius: 10px;
    width: 100%;
    max-width: 100%;
    padding: 4px 8px;
  }

  /* Kill counters → compact single row under stats on very small screens */
  .hud-kc-block {
    display: none;
  }

  .hud-top-stars {
    font-size: 10px;
    padding-right: 4px;
  }

  .hud-top-chip {
    font-size: 10px;
    padding: 2px 6px;
  }

  .hud-top-stats {
    padding: 0 6px;
    min-width: 0;
    flex: 1;
  }

  .hud-stat-row {
    font-size: 9px;
    gap: 6px;
  }

  .hud-icon-btn {
    width: 28px;
    height: 28px;
    font-size: 13px;
    border-radius: 6px;
  }

  /* Bottom command bar: two compact rows; minimap moves to fixed top-right on mobile */
  .hud-command-panel {
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px 6px;
    padding: 6px 8px;
    border-radius: 14px;
  }

  .hud-panel-divider {
    display: none;
  }

  .hud-hero-rings,
  .hud-ring-svg {
    width: 48px;
    height: 48px;
  }

  .hud-hero-portrait {
    inset: 14px;
  }

  #hero-portrait-icon {
    font-size: 13px;
  }

  .hud-hp-text,
  .hud-level-text {
    font-size: 8px;
  }

  .hud-hero-block {
    min-width: 48px;
    order: 1;
  }

  .hud-weapon-col {
    flex-direction: row;
    gap: 4px;
    order: 2;
  }

  #enhancement-slots.hud-enh-grid {
    order: 3;
    grid-template-columns: repeat(4, 34px);
    grid-template-rows: 34px;
    gap: 3px;
  }

  #item-slots.hud-item-grid {
    order: 4;
    width: 100%;
    justify-content: center;
    grid-template-columns: repeat(6, 34px);
    grid-template-rows: 34px;
    gap: 3px;
  }

  .hud-command-panel .slot-box,
  .slot-box {
    width: 34px;
    height: 34px;
    font-size: 15px;
    border-radius: 6px;
  }

  .slot-box .level-badge {
    width: 13px;
    height: 13px;
    font-size: 8px;
  }

  .slot-box .slot-name {
    display: none;
  }

  .touch-ability-btn:not(.hidden) {
    width: 52px;
    height: 52px;
    font-size: 22px;
    bottom: calc(max(6px, env(safe-area-inset-bottom, 0px)) + 96px);
  }

  .platform-mobile #hud-minimap-wrap {
    top: calc(max(4px, env(safe-area-inset-top, 0px)) + 44px);
  }

  /* Menu / overlays — slightly tighter on phones */
  .menu-buttons {
    max-width: min(100%, 320px);
    gap: 8px;
  }

  .menu-btn {
    min-width: 0;
    width: 100%;
    padding: 10px 12px;
    font-size: 12px;
  }

  .menu-corner-label {
    display: none;
  }

  .menu-corner-btn--store {
    width: 44px;
    padding: 0;
  }

  .menu-content {
    padding-top: 72px;
  }

  .menu-user-id {
    padding: 6px 10px;
    gap: 6px;
  }

  .menu-user-id-label {
    font-size: 10px;
  }

  .menu-user-id-value {
    font-size: 11px;
    max-width: 120px;
  }

  .menu-user-id-copy {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .ui-form-overlay,
  .overlay {
    padding: 10px;
  }

  .ui-form {
    max-height: 94vh;
    border-radius: 12px;
  }

  .ui-form-header {
    padding: 14px 16px 10px;
  }

  .ui-form-body {
    padding: 12px 16px;
  }

  .ui-form-footer {
    padding: 10px 16px 14px;
  }

  .upgrade-card {
    width: min(160px, 42vw);
    padding: 12px;
  }

  .upgrade-card .card-icon {
    font-size: 26px;
  }
}

@media (max-width: 700px) {
  .profile-main-layout {
    flex-direction: column;
    align-items: stretch;
  }

  .profile-main-layout .profile-hero-panel {
    width: min(260px, 100%);
    max-width: 260px;
    margin: 0 auto;
  }
}

/* Portrait phones — stack top stats if still cramped */
@media (max-width: 400px) {
  .hud-top-core {
    flex-direction: column;
    align-items: stretch;
  }

  .hud-top-stats {
    border: none;
    padding: 2px 0;
  }

  #item-slots.hud-item-grid {
    grid-template-columns: repeat(3, 34px);
    grid-template-rows: repeat(2, 34px);
  }
}

