:root {
  /* Dai duong sau (70%) */
  --bg-root: #050C16;
  --bg-surface: #0B172A;
  --bg-elevated: #0F2038;
  --bg-hover: #152B4A;
  --bg-input: #071120;

  /* Anh bien (20%) */
  --accent-cyan: #22D3EE;
  --accent-cyan-bright: #67E8F9;
  --accent-cyan-dim: rgba(34, 211, 238, 0.14);

  --border-subtle: rgba(34, 211, 238, 0.16);
  --border-strong: rgba(34, 211, 238, 0.36);
  --border-gold: rgba(249, 115, 22, 0.58);

  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  /* Lua phuong hoang (10%) */
  --phoenix-gradient: linear-gradient(135deg, #FF512F 0%, #F97316 52%, #FBBF24 100%);
  --phoenix-gradient-hover: linear-gradient(135deg, #FF6647 0%, #FB8224 52%, #FCD34D 100%);
  --accent-gold: #F97316;
  --accent-gold-bright: #FBBF24;
  --accent-gold-dim: rgba(249, 115, 22, 0.16);

  /* Canh bao nguy hiem (Tilt & Top 3 Tu Huyet) */
  --accent-hot: #EF4444;
  --accent-hot-dim: rgba(239, 68, 68, 0.16);
  --accent-anti: #22D3EE;
  --accent-anti-dim: rgba(34, 211, 238, 0.16);
  --accent-good: #10B981;
  --accent-good-dim: rgba(16, 185, 129, 0.18);
  --accent-warn: #F59E0B;
  --accent-danger: #EF4444;
  --accent-danger-dim: rgba(239, 68, 68, 0.18);

  /* Chuan mau gia tuong TFT */
  --cost-1: #94A3B8;
  --cost-2: #22C55E;
  --cost-3: #3B82F6;
  --cost-4: #A855F7;
  --cost-5: #F59E0B;

  /* Typography */
  --font-display: 'Chakra Petch', 'Be Vietnam Pro', system-ui, sans-serif;
  --font-body: 'Be Vietnam Pro', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* Bo goc sac Esport (4px - 6px) */
  --radius-sm: 4px;
  --radius-md: 5px;
  --radius-lg: 6px;
  --shadow-card: 0 10px 28px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(34, 211, 238, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-root);
  background-image:
    radial-gradient(ellipse 75% 28% at 50% 0%, rgba(34, 211, 238, 0.08), transparent 70%),
    radial-gradient(ellipse 45% 22% at 88% 0%, rgba(249, 115, 22, 0.06), transparent 65%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Luoi tactical mo opacity 0.04 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.04;
  background-image:
    linear-gradient(to right, #22D3EE 1px, transparent 1px),
    linear-gradient(to bottom, #22D3EE 1px, transparent 1px);
  background-size: 36px 36px;
}

.app-shell {
  position: relative;
  z-index: 1;
}

h1, h2, h3, h4,
.brand-title,
.card-title,
.nav-group-btn,
.nav-tab,
.tier-label,
.tuhuyet-title,
.tft-tip-title {
  font-family: var(--font-display);
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
}

input[type='number'] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease, transform 0.08s ease;
}

button:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.34);
}

button:active:not(:disabled) {
  transform: scale(0.98) translateY(0);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

input[type='text'],
input[type='password'],
input[type='number'],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  min-height: 36px;
  outline: none;
  width: 100%;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.22);
}

/* Primary action: Lua phuong hoang + Chamfered corners */
.btn-primary {
  background: var(--phoenix-gradient);
  color: #050C16;
  border: none;
  border-radius: 0;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.3px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  filter: drop-shadow(0 2px 10px rgba(249, 115, 22, 0.32));
}

.btn-primary:hover:not(:disabled) {
  background: var(--phoenix-gradient-hover);
  box-shadow: none;
  filter: drop-shadow(0 4px 16px rgba(255, 81, 47, 0.5));
}

/* Quick utility: Anh bien (#22D3EE) */
.btn-cyan {
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent-cyan-bright);
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 2px 10px rgba(34, 211, 238, 0.12);
}

.btn-cyan:hover:not(:disabled) {
  background: rgba(34, 211, 238, 0.24);
  border-color: var(--accent-cyan);
  color: #ECFEFF;
  box-shadow: 0 4px 16px rgba(34, 211, 238, 0.28);
}

.btn-emerald {
  background: linear-gradient(135deg, #059669, #10B981);
  color: #032219;
  border-color: #34D399;
  font-weight: 800;
  box-shadow: 0 3px 12px rgba(16, 185, 129, 0.28);
}

.btn-emerald:hover:not(:disabled) {
  background: linear-gradient(135deg, #10B981, #34D399);
  border-color: #6EE7B7;
  box-shadow: 0 5px 18px rgba(16, 185, 129, 0.42);
}

.btn-copied {
  background: linear-gradient(135deg, #10B981, #34D399) !important;
  color: #032219 !important;
  border-color: #A7F3D0 !important;
  font-weight: 800 !important;
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.48) !important;
}

/* Danger / Canh bao do (#EF4444) */
.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #FECACA;
  border-color: rgba(239, 68, 68, 0.6);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.34);
  border-color: #EF4444;
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.32);
}

.btn-sm {
  min-height: 30px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
}

.btn-sm.btn-primary {
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

.search-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.search-bar-row input {
  flex: 1;
  min-width: 0;
}

.btn-quick-clear {
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Header & Top Bars */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(5, 12, 22, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-strong);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.header-main {
  max-width: 1460px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Bang ty so giai dau Esport */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 5px;
  background: linear-gradient(90deg, rgba(11, 23, 42, 0.95) 0%, rgba(15, 32, 56, 0.72) 100%);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent-cyan);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.12);
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.65);
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.25);
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #F8FAFC;
  line-height: 1;
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.35);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.patch-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan-bright);
  white-space: nowrap;
}

.patch-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

/* Thanh Canh Bao Tu Huyet (HUD Do) & Checklist Chong Ngu */
.tuhuyet-bar {
  background: rgba(7, 15, 29, 0.92);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.tuhuyet-inner {
  max-width: 1460px;
  margin: 0 auto;
  padding: 6px 20px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px 14px;
  flex-wrap: wrap;
}

.tuhuyet-section {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.tuhuyet-alert-panel {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.14) 0%, rgba(239, 68, 68, 0.04) 100%);
  border: 1px solid rgba(239, 68, 68, 0.42);
  border-left: 3px solid #EF4444;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  box-shadow: inset 0 0 14px rgba(239, 68, 68, 0.08);
}

.tuhuyet-checklist-panel {
  flex: 1 1 360px;
  justify-content: flex-end;
  background: rgba(11, 23, 42, 0.72);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-cyan);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}

.tuhuyet-title {
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #FCA5A5;
  white-space: nowrap;
}

.tuhuyet-rules-title {
  color: var(--accent-cyan-bright);
}

.error-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.58);
  color: #FEE2E2;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.16);
}

.error-pill-count {
  background: #EF4444;
  color: #FFFFFF;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 800;
}

.checklist-rules-list {
  gap: 6px;
}

.rule-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(5, 12, 22, 0.92);
  border: 1px solid rgba(34, 211, 238, 0.34);
  border-left: 2px solid var(--accent-cyan);
  color: #E2E8F0;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  max-width: 100%;
}

.rule-chip::before {
  content: '✓';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: rgba(34, 211, 238, 0.16);
  border: 1px solid rgba(34, 211, 238, 0.55);
  color: var(--accent-cyan-bright);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
}

.rule-chip button {
  background: none;
  border: none;
  min-height: 0;
  padding: 0 2px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1;
}

.rule-chip button:hover:not(:disabled) {
  background: none;
  color: #EF4444;
  box-shadow: none;
  transform: none;
}

.quick-pin-form {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.quick-pin-form input {
  width: 175px;
  min-height: 28px;
  padding: 3px 8px;
  font-size: 12px;
}

/* 4-Group Primary + Sub-Tab Navigation */
.nav-shell {
  max-width: 1460px;
  margin: 0 auto;
  padding: 6px 20px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-groups {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-group-btn {
  min-height: 36px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: rgba(11, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-group-btn:hover:not(.active) {
  color: #F8FAFC;
  background: var(--bg-hover);
  border-color: var(--border-strong);
  transform: none;
  box-shadow: none;
}

.nav-group-btn.active {
  color: #ECFEFF;
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.22) 0%, rgba(11, 23, 42, 0.92) 100%);
  border-color: var(--accent-cyan);
  box-shadow: inset 0 -2px 0 var(--accent-cyan), 0 0 14px rgba(34, 211, 238, 0.18);
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: rgba(11, 23, 42, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  scrollbar-width: thin;
}

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  min-height: 32px;
  padding: 5px 12px;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  position: relative;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.nav-tab.nav-tab-hidden {
  display: none !important;
}

.nav-tab:hover:not(.active) {
  color: #F8FAFC;
  background: rgba(34, 211, 238, 0.1);
  border-color: rgba(34, 211, 238, 0.28);
  transform: none;
  box-shadow: none;
}

.nav-tab.active {
  color: #050C16;
  font-weight: 700;
  border-color: transparent;
  background: var(--phoenix-gradient);
  box-shadow: 0 2px 12px rgba(249, 115, 22, 0.32);
}

/* Main Content */
.main-content {
  max-width: 1460px;
  width: 100%;
  margin: 0 auto;
  padding: 14px 20px 38px;
  flex: 1;
}

@keyframes tabFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tab-panel:not(.hidden) {
  animation: tabFadeIn 0.15s ease-out;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.card-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.muted {
  color: var(--text-secondary);
  font-size: 12.5px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.grid-sidebar {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.grid-2 > *,
.grid-sidebar > * {
  min-width: 0;
}

/* Badges & Tags */
.badge-hot {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: var(--accent-hot-dim);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.42);
}

.badge-anti {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: var(--accent-anti-dim);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.42);
}

.badge-sample {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Icon tiles */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 9px;
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 6px 4px 2px;
}

.icon-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 13px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease;
}

.icon-tile:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.34);
}

.icon-tile:active {
  transform: scale(0.96);
}

.icon-tile.selected {
  border-color: var(--accent-gold-bright);
  background: var(--accent-gold-dim);
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.5), 0 6px 16px rgba(232, 185, 61, 0.22);
}

.icon-tile img {
  width: 48px;
  height: 48px;
  border-radius: 11px;
  object-fit: cover;
  background: #0a101c;
  border: 2.5px solid rgba(148, 163, 184, 0.28);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}

.icon-tile span {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Chuan vien mau gia tuong TFT */
.cost-1 { border-color: var(--cost-1) !important; box-shadow: 0 2px 8px rgba(148, 163, 184, 0.16); }
.cost-2 { border-color: var(--cost-2) !important; box-shadow: 0 2px 10px rgba(34, 197, 94, 0.24); }
.cost-3 { border-color: var(--cost-3) !important; box-shadow: 0 2px 10px rgba(59, 130, 246, 0.28); }
.cost-4 { border-color: var(--cost-4) !important; box-shadow: 0 2px 12px rgba(168, 85, 247, 0.34); }
.cost-5 {
  border-color: var(--cost-5) !important;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.38);
}
.cost-7 {
  border-color: #f472b6 !important;
  box-shadow: 0 0 12px rgba(244, 114, 182, 0.45), 0 0 5px rgba(250, 204, 21, 0.38);
}

.champ-avatar {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  border: 2.5px solid var(--cost-1);
  object-fit: cover;
  background: #0a101c;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.42);
}

.item-icon-sm {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1.5px solid var(--border-strong);
  object-fit: cover;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.38);
}

.item-icon-md {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1.5px solid var(--border-strong);
  object-fit: cover;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.42);
}

/* Sub-tabs / Pills */
.pill-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.pill-btn {
  min-height: 34px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.pill-btn:hover:not(:disabled) {
  color: var(--text-primary);
}

.pill-btn.active {
  background: var(--accent-gold-dim);
  border-color: var(--accent-gold);
  color: var(--accent-gold-bright);
  box-shadow: 0 0 10px rgba(226, 180, 75, 0.14);
}

/* Meta Editor Header */
.meta-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 280px;
  min-width: 0;
}

.meta-title-group input {
  min-width: 160px;
  flex: 1;
}

/* TFT 4x7 Interlocking Pointy-Top Hex Board */
.hex-board {
  display: flex;
  flex-direction: column;
  padding: 20px 24px 22px;
  background: radial-gradient(circle at center, #141e33 0%, #090e1a 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.hex-row {
  display: flex;
  gap: 6px;
  width: max-content;
  margin-left: auto;
  margin-right: auto;
  transform: translateX(-16px);
}

.hex-row + .hex-row {
  margin-top: -15px;
}

.hex-row.odd {
  transform: translateX(16px);
}

.hex-cell {
  width: 74px;
  height: 84px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  background: transparent;
  border: none;
  transition: transform 0.12s ease;
}

.hex-border {
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: rgba(148, 163, 184, 0.28);
  transition: background 0.14s ease, filter 0.14s ease;
}

.hex-fill {
  position: absolute;
  inset: 3px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: linear-gradient(180deg, #152038 0%, #0a101d 100%);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hex-cell:hover {
  transform: translateY(-1px);
  z-index: 4;
}

.hex-cell:hover .hex-border {
  background: var(--accent-gold);
}

.hex-cell.drag-over {
  transform: scale(1.06);
  z-index: 5;
}

.hex-cell.drag-over .hex-border {
  background: #38bdf8;
}

.hex-cell.occupied.cost-1 .hex-border { background: var(--cost-1); }
.hex-cell.occupied.cost-2 .hex-border { background: var(--cost-2); }
.hex-cell.occupied.cost-3 .hex-border { background: var(--cost-3); }
.hex-cell.occupied.cost-4 .hex-border { background: var(--cost-4); }
.hex-cell.occupied.cost-5 .hex-border { background: var(--cost-5); }
.hex-cell.occupied.cost-7 .hex-border {
  background: linear-gradient(135deg, #f472b6, #facc15, #38bdf8);
}

.hex-cell.occupied.cost-5,
.hex-cell.occupied.cost-7 {
  box-shadow: none !important;
  filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.38));
}

.hex-fill img.unit-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  pointer-events: none;
}

.hex-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 42%, rgba(7, 11, 20, 0.88) 100%);
  pointer-events: none;
}

.hex-unit-name {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9.5px;
  font-weight: 800;
  color: #f8fafc;
  background: rgba(7, 11, 20, 0.84);
  padding: 1px 5px;
  border-radius: 4px;
  max-width: 66px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 2;
}

.hex-carry-star {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--accent-gold-bright);
  color: #070b14;
  font-size: 10px;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.75);
  z-index: 3;
}

.hex-3star-badge {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #f59e0b, #fde047);
  color: #070b14;
  font-size: 9px;
  font-weight: 900;
  line-height: 1.1;
  padding: 1px 5px;
  border-radius: 999px;
  letter-spacing: -0.5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
  z-index: 4;
  pointer-events: none;
  white-space: nowrap;
}

.hex-cell.is-3star .hex-carry-star {
  top: 14px;
  right: -2px;
}

/* Power Condition Badges & 3-Star Reroll Strip */
.power-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  border: 1px solid transparent;
}

.power-badge-units {
  background: rgba(139, 92, 246, 0.16);
  border-color: rgba(139, 92, 246, 0.48);
  color: #ddd6fe;
}

.power-badge-items {
  background: rgba(249, 115, 22, 0.16);
  border-color: rgba(249, 115, 22, 0.48);
  color: #fdba74;
}

.power-badge-both {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.45);
  color: #67e8f9;
}

.power-badge-emblem {
  background: rgba(236, 72, 153, 0.16);
  border-color: rgba(236, 72, 153, 0.48);
  color: #f9a8d4;
}

.power-note-box {
  background: var(--bg-root);
  padding: 7px 10px;
  border-radius: 8px;
  border-left: 3px solid #38bdf8;
  margin-bottom: 9px;
  font-size: 12.5px;
  color: #cbd5e1;
}

.power-note-box.power-note-units { border-left-color: #a78bfa; }
.power-note-box.power-note-items { border-left-color: #fb923c; }
.power-note-box.power-note-both { border-left-color: #22d3ee; }
.power-note-box.power-note-emblem { border-left-color: #f472b6; }

.reroll-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.12), rgba(226, 180, 75, 0.04));
  border: 1px solid rgba(250, 204, 21, 0.35);
  border-radius: 10px;
  padding: 7px 10px;
  margin-bottom: 9px;
}

.reroll-strip-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.reroll-unit-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-root);
  border: 1px solid rgba(250, 204, 21, 0.42);
  border-radius: 10px;
  padding: 3px 10px 3px 4px;
  cursor: pointer;
}

.reroll-unit-chip img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid var(--cost-1);
}

.reroll-unit-stars {
  color: #fde047;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: -0.6px;
}

.reroll-unit-name {
  font-size: 12px;
  font-weight: 700;
  color: #f8fafc;
}

.meta-list-3star {
  margin-top: 5px;
  font-size: 11.5px;
  font-weight: 700;
  color: #fde047;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hex-items-strip {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  z-index: 3;
}

.hex-items-strip img {
  width: 17px;
  height: 17px;
  border-radius: 4px;
  border: 1px solid #070b14;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
}

/* Early Game HP-Saving Boards */
.early-boards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.early-board-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.early-unit-pill {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: 48px;
  text-align: center;
}

.early-unit-pill img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 2.5px solid var(--cost-1);
  object-fit: cover;
  background: #0a101c;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.early-unit-pill span {
  font-size: 10px;
  font-weight: 700;
  max-width: 48px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

@media (max-width: 960px) {
  .early-boards-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Tier List */
.tier-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 10px;
  background: var(--bg-surface);
}

.tier-label {
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 900;
  color: #070b14;
}

.tier-S {
  background: var(--phoenix-gradient);
  color: #050C16;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}
.tier-A { background: linear-gradient(135deg, #22D3EE, #0284C7); color: #050C16; }
.tier-B { background: linear-gradient(135deg, #10B981, #059669); color: #050C16; }
.tier-C { background: linear-gradient(135deg, #64748B, #475569); color: #F8FAFC; }

.tier-dropzone {
  min-height: 76px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tier-dropzone.drag-over {
  background: rgba(226, 180, 75, 0.1);
}

.tier-card-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 11px;
  cursor: pointer;
  max-width: 250px;
  transition: border-color 0.14s ease, transform 0.1s ease;
}

.tier-card-item:hover {
  border-color: var(--accent-gold);
  transform: translateY(-1px);
}

.tier-card-item img {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  object-fit: cover;
  flex-shrink: 0;
  border: 2.5px solid transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.36);
}

.tier-card-note {
  font-size: 11px;
  color: var(--accent-gold-bright);
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Roll Calculator & KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  min-width: 0;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 800;
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-input);
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* Chong Ngu */
.rank-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.rank-btn {
  padding: 10px 4px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 800;
  border-radius: var(--radius-sm);
}

.rank-btn.active-top4 {
  background: var(--accent-good-dim);
  border-color: var(--accent-good);
  color: #6ee7b7;
}

.rank-btn.active-5 {
  background: rgba(245, 158, 11, 0.16);
  border-color: var(--accent-warn);
  color: #fcd34d;
}

.rank-btn.active-bot4 {
  background: var(--accent-danger-dim);
  border-color: var(--accent-danger);
  color: #fda4af;
}

.paste-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  background: rgba(10, 16, 28, 0.72);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.paste-zone:focus,
.paste-zone:hover {
  border-color: var(--accent-gold);
  background: rgba(226, 180, 75, 0.06);
  outline: none;
}

.shot-thumb-wrap {
  position: relative;
  display: inline-block;
}

.shot-thumb {
  width: 110px;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
}

.shot-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: none;
  font-size: 12px;
  line-height: 1;
}

/* Modals & Cooldown & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.8);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  z-index: 150;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.68);
}

.cooldown-box {
  position: relative;
  border: 1px solid #EF4444;
  border-radius: 0;
  clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px);
  background:
    repeating-linear-gradient(
      0deg,
      rgba(239, 68, 68, 0.05) 0px,
      rgba(239, 68, 68, 0.05) 1px,
      transparent 1px,
      transparent 4px
    ),
    linear-gradient(180deg, #260A10 0%, #090E18 100%);
  text-align: center;
  max-width: 480px;
  padding: 22px 20px;
  box-shadow: inset 0 0 36px rgba(239, 68, 68, 0.22);
}

.cooldown-hud-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #FCA5A5;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.65);
  border-radius: 3px;
  padding: 2px 10px;
}

.cooldown-heading {
  margin: 8px 0 6px;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.8px;
  color: #FCA5A5;
  text-transform: uppercase;
}

.cooldown-desc {
  margin: 0 auto 12px;
  color: #FEE2E2;
  font-size: 13.5px;
  max-width: 390px;
}

.cooldown-timer {
  display: inline-block;
  padding: 8px 24px;
  background: rgba(5, 12, 22, 0.88);
  border: 1px solid rgba(239, 68, 68, 0.65);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 54px;
  font-weight: 800;
  color: #EF4444;
  text-shadow: 0 0 22px rgba(239, 68, 68, 0.55);
  letter-spacing: 3px;
  margin: 8px 0;
  font-variant-numeric: tabular-nums;
}

.toast-container {
  position: fixed;
  bottom: 76px;
  right: 18px;
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 36px);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent-gold);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 9px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  font-weight: 600;
  font-size: 13px;
  animation: toastSlideIn 0.16s ease-out;
}

.toast.good { border-left-color: var(--accent-good); }
.toast.danger { border-left-color: var(--accent-danger); }

/* Floating Hover Tooltip */
.tft-tooltip {
  position: fixed;
  z-index: 320;
  pointer-events: none;
  width: max-content;
  max-width: 315px;
  background: rgba(5, 12, 22, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.82), 0 0 18px rgba(34, 211, 238, 0.14);
  color: var(--text-primary);
  font-size: 12.5px;
  line-height: 1.44;
}

.tft-tip-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
}

.tft-tip-icon {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  object-fit: cover;
  border: 2px solid var(--border-strong);
  background: #070b14;
  flex-shrink: 0;
}

.tft-tip-title {
  font-weight: 800;
  font-size: 13.5px;
  color: #f8fafc;
}

.tft-tip-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.tft-tip-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  color: #e2e8f0;
}

.tft-tip-desc {
  color: #cbd5e1;
  font-size: 12px;
  white-space: normal;
}

.tft-tip-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.tft-tip-stat-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #bae6fd;
}

.tft-tip-ability {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-gold);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 11.8px;
  color: #e2e8f0;
  white-space: normal;
}

.tft-tip-breakpoints {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11.5px;
}

.tft-tip-recipe {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11.5px;
  color: var(--text-secondary);
}

.tft-tip-recipe img {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
}

.hidden {
  display: none !important;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.flex-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-md { display: flex; flex-direction: column; gap: 12px; }

/* Tab 6: Giai Toc He */
.trait-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  border: 1px solid transparent;
  transition: transform 0.1s ease;
}

.trait-badge img {
  width: 17px;
  height: 17px;
  object-fit: contain;
}

.trait-tier-bronze {
  background: rgba(180, 108, 55, 0.22);
  border-color: #c9804d;
  color: #f6c8a4;
}

.trait-tier-silver {
  background: rgba(148, 163, 184, 0.2);
  border-color: #cbd5e1;
  color: #f8fafc;
}

.trait-tier-gold {
  background: rgba(234, 179, 8, 0.22);
  border-color: #facc15;
  color: #fef08a;
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.16);
}

.trait-tier-prismatic {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.3), rgba(6, 182, 212, 0.3), rgba(236, 72, 153, 0.3));
  border-color: #e879f9;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(217, 70, 239, 0.32);
}

.trait-tier-unique {
  background: rgba(249, 115, 22, 0.2);
  border-color: #fb923c;
  color: #fed7aa;
}

.solver-champ-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.solver-champ-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90px;
  padding: 7px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 13px;
  text-align: center;
  position: relative;
  transition: border-color 0.14s ease, transform 0.1s ease;
}

.solver-champ-card:hover {
  border-color: var(--accent-gold);
  transform: translateY(-1px);
}

.solver-champ-card img {
  width: 62px;
  height: 62px;
  border-radius: 11px;
  border: 3px solid var(--cost-1);
  object-fit: cover;
  background: #0a101c;
}

.solver-champ-cost {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(7, 11, 20, 0.92);
  border: 1px solid var(--border-strong);
  color: var(--accent-gold-bright);
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
}

.solver-champ-name {
  font-size: 11.5px;
  font-weight: 700;
  margin-top: 4px;
  line-height: 1.2;
  max-width: 74px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.solver-champ-traits {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.15;
  margin-top: 2px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  cursor: pointer;
}

.toggle-switch {
  appearance: none;
  -webkit-appearance: none;
  width: 42px;
  height: 22px;
  border-radius: 999px;
  background: #334155;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f8fafc;
  transition: transform 0.15s;
}

.toggle-switch:checked {
  background: var(--accent-gold);
}

.toggle-switch:checked::after {
  transform: translateX(20px);
  background: #070b14;
}

@media (min-width: 1081px) {
  .solver-results-sticky {
    position: sticky;
    top: 152px;
    max-height: calc(100vh - 172px);
    overflow-y: auto;
  }
}

/* Responsive: Tablet & Half-Screen (760px) */
@media (max-width: 1080px) {
  .grid-2,
  .grid-sidebar {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (max-width: 920px) {
  .grid-2,
  .grid-sidebar {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .nav-tabs {
    padding: 4px 12px 0;
    gap: 5px;
  }
  .nav-tab {
    min-height: 38px;
    padding: 7px 12px;
    font-size: 13px;
  }
}

@media (max-width: 860px) {
  .header-main,
  .tuhuyet-inner,
  .nav-tabs,
  .main-content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .nav-tabs {
    flex-wrap: wrap;
    overflow-x: visible;
    gap: 4px;
    padding-bottom: 4px;
  }

  .nav-tab {
    padding: 7px 10px;
    font-size: 12.5px;
    border-radius: 7px;
  }

  .card {
    padding: 12px;
  }

  .hex-board {
    padding: 14px 8px 16px;
  }

  .hex-row {
    gap: 4px;
    transform: translateX(-16px);
  }

  .hex-row + .hex-row {
    margin-top: -12px;
  }

  .hex-row.odd {
    transform: translateX(16px);
  }

  .hex-cell {
    width: 60px;
    height: 68px;
  }

  .hex-unit-name {
    font-size: 8.5px;
    max-width: 54px;
    bottom: 11px;
  }

  .hex-items-strip img {
    width: 14px;
    height: 14px;
  }

  .tier-row {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .tier-label {
    font-size: 22px;
  }

  .kpi-value {
    font-size: 22px;
  }

  .quick-pin-form input {
    width: 150px;
  }
}

@media (max-width: 600px) {
  .kpi-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .rank-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Match Review Scorecard (Tab 5) */
.review-pillars-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.review-pillar {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 8px 9px;
  text-align: center;
  min-width: 0;
}

.review-pillar-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-pillar-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 800;
  margin-top: 3px;
}

.review-grade-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 700;
}

.grade-S {
  background: var(--phoenix-gradient);
  color: #050C16;
  border: 1px solid #FBBF24;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.35);
}
.grade-A { background: rgba(34, 211, 238, 0.18); color: #67E8F9; border: 1px solid rgba(34, 211, 238, 0.45); }
.grade-B { background: rgba(16, 185, 129, 0.18); color: #6EE7B7; border: 1px solid rgba(16, 185, 129, 0.45); }
.grade-C { background: rgba(249, 115, 22, 0.18); color: #FDBA74; border: 1px solid rgba(249, 115, 22, 0.45); }
.grade-D { background: rgba(239, 68, 68, 0.22); color: #FCA5A5; border: 1px solid rgba(239, 68, 68, 0.55); }

.review-phase-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.review-phase-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.tempo-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tempo-chip {
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 7px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.tempo-chip.benchmark {
  border-style: dashed;
  border-color: #38bdf8;
  color: #bae6fd;
}

.tempo-chip.active {
  background: var(--accent-gold-dim);
  border-color: var(--accent-gold);
  border-style: solid;
  color: var(--accent-gold-bright);
  font-weight: 800;
}

.item-opt-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
}

.item-opt-chip.bis { border-color: rgba(16, 185, 129, 0.55); background: rgba(16, 185, 129, 0.1); }
.item-opt-chip.good { border-color: rgba(234, 179, 8, 0.5); background: rgba(234, 179, 8, 0.1); }
.item-opt-chip.off { border-color: rgba(244, 63, 94, 0.55); background: rgba(244, 63, 94, 0.1); }

@media (max-width: 960px) {
  .review-phase-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 920px) {
  .grid-2,
  .grid-sidebar {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .nav-tabs {
    padding: 4px 12px 0;
    gap: 5px;
  }
  .nav-tab {
    min-height: 38px;
    padding: 7px 12px;
    font-size: 13px;
  }
}

@media (max-width: 860px) {
  .review-pillars-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Riot ID Sync & Final Board Strip */
.riot-sync-banner {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.08), rgba(15, 23, 42, 0.92));
  border-color: rgba(6, 182, 212, 0.36);
}

.riot-inline-form {
  display: grid;
  grid-template-columns: minmax(140px, 1.1fr) minmax(130px, 0.9fr) minmax(150px, 1.2fr) auto auto;
  gap: 8px;
  align-items: center;
}

.riot-count-select {
  width: auto;
  min-width: 132px;
}

.riot-guide-box {
  background: rgba(15, 23, 42, 0.65);
  border: 1px dashed rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.riot-guide-box summary {
  cursor: pointer;
  font-weight: 700;
  color: #bae6fd;
  user-select: none;
}

.riot-guide-steps {
  margin: 8px 0 2px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #cbd5e1;
  line-height: 1.45;
}

.riot-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(6, 182, 212, 0.16);
  border: 1px solid rgba(6, 182, 212, 0.45);
  color: #67e8f9;
}

.riot-warn-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(244, 63, 94, 0.2);
  border: 1px solid rgba(244, 63, 94, 0.55);
  color: #fda4af;
}

.riot-board-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.riot-unit-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 44px;
  position: relative;
}

.riot-unit-stars {
  font-size: 9.5px;
  line-height: 1;
  font-weight: 900;
  margin-bottom: 1px;
  letter-spacing: -0.5px;
}

.riot-unit-stars.star-1 { color: #94a3b8; }
.riot-unit-stars.star-2 { color: #6ee7b7; }
.riot-unit-stars.star-3 { color: #fde047; text-shadow: 0 0 6px rgba(250, 204, 21, 0.65); }

.riot-unit-img {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  object-fit: cover;
  border: 2px solid var(--cost-1);
  background: #070b14;
}

.riot-unit-items {
  display: flex;
  gap: 1px;
  margin-top: -6px;
  z-index: 2;
  background: rgba(7, 11, 20, 0.92);
  padding: 1px 2px;
  border-radius: 4px;
}

.riot-unit-items img {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.riot-unit-name {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
  max-width: 46px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

@media (max-width: 980px) {
  .riot-inline-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .riot-inline-form #cnRiotQuickSyncBtn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .riot-inline-form {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Tab 7: Chi so Do & An */
.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stats-kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  min-width: 0;
  transition: border-color 0.14s ease, transform 0.1s ease;
}

.stats-kpi-card:hover {
  border-color: rgba(226, 180, 75, 0.55);
  transform: translateY(-1px);
}

.stats-kpi-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stats-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  border: 2px solid var(--border-strong);
  object-fit: cover;
  background: #070b14;
  flex-shrink: 0;
}

.stats-kpi-name {
  font-weight: 800;
  font-size: 14px;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-kpi-metric {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 800;
  margin-top: 2px;
}

.stats-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.stats-table thead th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.stats-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.stats-table tbody tr:hover {
  background: rgba(148, 163, 184, 0.06);
}

.stats-sort-th {
  cursor: pointer;
  user-select: none;
  transition: color 0.12s;
}

.stats-sort-th:hover,
.stats-th-active {
  color: var(--accent-gold-bright) !important;
}

.stats-item-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.stats-item-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1.5px solid var(--border-strong);
  object-fit: cover;
  background: #070b14;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.stats-item-name {
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.25;
}

.stats-cat-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  border: 1px solid transparent;
}

.cat-pill-emblems {
  background: rgba(234, 179, 8, 0.16);
  border-color: rgba(234, 179, 8, 0.45);
  color: #fde047;
}

.cat-pill-items {
  background: rgba(6, 182, 212, 0.14);
  border-color: rgba(6, 182, 212, 0.4);
  color: #67e8f9;
}

.cat-pill-artifacts {
  background: rgba(168, 85, 247, 0.18);
  border-color: rgba(168, 85, 247, 0.48);
  color: #e9d5ff;
}

.cat-pill-radiant {
  background: rgba(250, 204, 21, 0.22);
  border-color: rgba(253, 224, 71, 0.65);
  color: #fef9c3;
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.18);
}

.stats-recipe {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.stats-recipe img {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
}

.stats-mini-bar {
  width: 58px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  margin-left: auto;
  margin-top: 3px;
  overflow: hidden;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Tab 8: Phan tich phien ban */
.patch-verdict-box {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(6, 182, 212, 0.35);
  background: rgba(6, 182, 212, 0.07);
}

.patch-verdict-box.tone-gold {
  border-color: rgba(234, 179, 8, 0.45);
  background: rgba(234, 179, 8, 0.08);
}

.patch-verdict-box.tone-good {
  border-color: rgba(16, 185, 129, 0.42);
  background: rgba(16, 185, 129, 0.08);
}

.pace-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.pace-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.champ-stars-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.champ-star-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  min-width: 0;
  transition: border-color 0.12s ease;
}

.champ-star-row:hover {
  border-color: rgba(226, 180, 75, 0.55);
}

.champ-star-rank {
  width: 18px;
  text-align: center;
  font-weight: 800;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.champ-star-img {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  border: 2px solid var(--cost-1);
  object-fit: cover;
  flex-shrink: 0;
}

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

.rising-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 13px;
  min-width: 0;
}

.rising-units-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.rising-units-strip img {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  border: 2px solid var(--cost-1);
  object-fit: cover;
}

.ai-patch-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.patch-ai-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: #cbd5e1;
  line-height: 1.42;
}

@media (max-width: 760px) {
  body.hud-mode .pace-grid,
  body.hud-mode .champ-stars-grid,
  body.hud-mode .rising-grid,
  body.hud-mode .ai-patch-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (max-width: 1080px) {
  .champ-stars-grid,
  .ai-patch-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 920px) {
  .grid-2,
  .grid-sidebar {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .nav-tabs {
    padding: 4px 12px 0;
    gap: 5px;
  }
  .nav-tab {
    min-height: 38px;
    padding: 7px 12px;
    font-size: 13px;
  }
}

@media (max-width: 860px) {
  .pace-grid,
  .rising-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stats-mini-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
}

/* In-Game Mini HUD & Mobile QR Modal */
.hud-control-bar {
  max-width: 1460px;
  margin: 0 auto;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: rgba(5, 12, 22, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(34, 211, 238, 0.34);
  border-bottom: 1px solid rgba(34, 211, 238, 0.24);
}

#hudOpacityVal {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

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

.qr-box {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: rgba(11, 23, 42, 0.76);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  min-height: 196px;
}

.qr-box svg {
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

/* Mini HUD (F8) — Nen kinh bien mo (Glassmorphism) */
body.hud-mode {
  background-color: rgba(5, 12, 22, 0.86);
  background-image:
    radial-gradient(ellipse 90% 35% at 50% 0%, rgba(34, 211, 238, 0.12), transparent 72%);
}

body.hud-mode .app-header {
  position: static;
  background: rgba(5, 12, 22, 0.76);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid rgba(34, 211, 238, 0.38);
}

body.hud-mode .tuhuyet-bar {
  background: rgba(5, 12, 22, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body.hud-mode .card {
  padding: 10px;
  background: rgba(11, 23, 42, 0.74);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  border-color: rgba(34, 211, 238, 0.24);
}

body.hud-mode .brand-sub,
body.hud-mode #btnSyncGame,
body.hud-mode #btnOpenInGame,
body.hud-mode .quick-pin-form {
  display: none !important;
}

body.hud-mode .header-main {
  padding: 6px 10px;
}

body.hud-mode .brand {
  padding: 3px 9px 3px 4px;
  gap: 7px;
}

body.hud-mode .brand-logo {
  width: 24px;
  height: 24px;
}

body.hud-mode .brand-title {
  font-size: 14px;
  letter-spacing: 1.2px;
}

body.hud-mode .tuhuyet-inner {
  padding: 5px 10px;
  gap: 6px;
}

body.hud-mode .tuhuyet-alert-panel,
body.hud-mode .tuhuyet-checklist-panel {
  flex: 1 1 280px;
  justify-content: flex-start;
  padding: 4px 8px;
}

body.hud-mode .nav-shell {
  padding: 5px 10px 6px;
  gap: 5px;
}

body.hud-mode .nav-groups {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

body.hud-mode .nav-group-btn {
  min-height: 30px;
  padding: 4px 6px;
  font-size: 11.5px;
  letter-spacing: 0.1px;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.hud-mode .nav-tabs {
  padding: 3px 4px;
  gap: 4px;
}

body.hud-mode .nav-tab {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
}

body.hud-mode .main-content {
  padding: 10px 12px;
}

@media (max-width: 760px) {
  body.hud-mode .tuhuyet-alert-panel,
  body.hud-mode .tuhuyet-checklist-panel {
    flex: 1 1 100%;
  }

  body.hud-mode .grid-2,
  body.hud-mode .grid-sidebar,
  body.hud-mode .stats-kpi-grid,
  body.hud-mode .review-phase-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.hud-mode .col-count-hide-sm {
    display: none;
  }
}

@media (max-width: 680px) {
  body.hud-mode .hex-board {
    padding: 10px 12px 12px;
  }

  body.hud-mode .hex-row {
    gap: 2px;
    transform: translateX(-9px);
  }

  body.hud-mode .hex-row + .hex-row {
    margin-top: -7px;
  }

  body.hud-mode .hex-row.odd {
    transform: translateX(9px);
  }

  body.hud-mode .hex-cell {
    width: 42px;
    height: 48px;
  }

  body.hud-mode .hex-unit-name {
    font-size: 7px;
    max-width: 38px;
    bottom: 6px;
  }

  body.hud-mode .hex-items-strip img {
    width: 11px;
    height: 11px;
  }

  body.hud-mode .hex-3star-badge {
    font-size: 7.5px;
    padding: 1px 3px;
    top: -4px;
  }

  body.hud-mode .hex-cell.is-3star .hex-carry-star {
    top: 11px;
    right: -2px;
    font-size: 8.5px;
    padding: 0 4px;
  }
}

@media (max-width: 920px) {
  .grid-2,
  .grid-sidebar {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .nav-tabs {
    padding: 4px 12px 0;
    gap: 5px;
  }
  .nav-tab {
    min-height: 38px;
    padding: 7px 12px;
    font-size: 13px;
  }
}

@media (max-width: 860px) {
  .app-header {
    position: static;
  }
  .stats-kpi-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .col-count-hide-sm {
    display: none;
  }
  .stats-table thead th,
  .stats-table tbody td {
    padding: 8px 8px;
    font-size: 12px;
  }
}

@media (max-width: 720px) {
  .ingame-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .header-main,
  .tuhuyet-inner,
  .nav-tabs,
  .main-content {
    padding-left: 8px;
    padding-right: 8px;
  }

  .hex-board {
    padding: 10px 12px 12px;
  }

  .hex-row {
    gap: 2px;
    transform: translateX(-9px);
  }

  .hex-row + .hex-row {
    margin-top: -7px;
  }

  .hex-row.odd {
    transform: translateX(9px);
  }

  .hex-cell {
    width: 42px;
    height: 48px;
  }

  .hex-unit-name {
    font-size: 7px;
    max-width: 38px;
    bottom: 6px;
  }

  .hex-items-strip img {
    width: 11px;
    height: 11px;
  }

  .hex-3star-badge {
    font-size: 7.5px;
    padding: 1px 3px;
    top: -4px;
  }

  .hex-cell.is-3star .hex-carry-star {
    top: 11px;
    right: -2px;
    font-size: 8.5px;
    padding: 0 4px;
  }

  .stats-table thead th,
  .stats-table tbody td {
    padding: 7px 5px;
    font-size: 11.5px;
  }
}

#edPowerType {
  max-width: 100%;
}

/* Tab Tuong & Do */
.tuong-layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.tuong-list-wrap {
  max-height: 680px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.tuong-row {
  display: grid;
  grid-template-columns: 32px 42px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.1s ease;
}

.tuong-row:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.tuong-row.active {
  background: rgba(226, 180, 75, 0.12);
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 1px rgba(226, 180, 75, 0.35);
}

.tuong-row-avatar {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  object-fit: cover;
  border: 2.5px solid var(--cost-1);
  background: #070b14;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.36);
}

.tuong-row-name {
  font-weight: 800;
  font-size: 13.5px;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tuong-row-sub {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tuong-row-metrics {
  text-align: right;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.tuong-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.tuong-detail-avatar {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: cover;
  border: 2.5px solid var(--cost-1);
  background: #070b14;
  flex-shrink: 0;
}

.tuong-stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.tuong-stat-pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 8px 10px;
  min-width: 0;
}

.tuong-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}

.tuong-stat-val {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.tuong-star-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tuong-star-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tuong-builds-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tuong-build-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}

.tuong-build-icons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tuong-build-icons img {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: #070b14;
}

.tuong-item-cats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tuong-cat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 11px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.tuong-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.tuong-cat-item-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 4px 6px;
  border-radius: 7px;
  background: rgba(7, 11, 20, 0.45);
  border: 1px solid transparent;
}

.tuong-cat-item-row:hover {
  border-color: rgba(226, 180, 75, 0.45);
  background: rgba(15, 23, 42, 0.85);
}

.tuong-cat-item-row img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: #070b14;
}

.tuong-cat-item-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tuong-cat-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

.tuong-cat-item-stats {
  text-align: right;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  white-space: nowrap;
}

.delta-good { color: #6ee7b7; font-weight: 800; }
.delta-mid { color: #fde047; font-weight: 800; }
.delta-bad { color: #fda4af; font-weight: 800; }

.tuong-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, 180px);
  gap: 8px;
}

.tuong-specs-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tuong-base-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(146px, 1fr));
  gap: 8px;
}

.tuong-base-stat-item {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 7px 9px;
  min-width: 0;
}

.tuong-base-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.tuong-base-stat-val {
  font-size: 13px;
  font-weight: 800;
  color: #f8fafc;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tuong-ability-box {
  background: rgba(7, 11, 20, 0.72);
  border: 1px solid rgba(226, 180, 75, 0.28);
  border-left: 3px solid var(--accent-gold);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 12.5px;
  color: #cbd5e1;
  line-height: 1.48;
}

.tuong-suggest-card {
  background: linear-gradient(180deg, rgba(226, 180, 75, 0.08) 0%, rgba(15, 23, 42, 0.72) 100%);
  border: 1px solid rgba(250, 204, 21, 0.35);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.tuong-suggest-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tuong-suggest-row-label {
  font-size: 12px;
  font-weight: 800;
  color: #e2e8f0;
}

.tuong-suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tuong-suggest-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-root);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 5px 9px 5px 5px;
  max-width: 100%;
  transition: border-color 0.14s ease, transform 0.1s ease;
}

.tuong-suggest-chip:hover {
  border-color: var(--accent-gold);
  transform: translateY(-1px);
}

.tuong-suggest-chip-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: #070b14;
  flex-shrink: 0;
}

.tuong-suggest-chip-name {
  font-size: 12px;
  font-weight: 800;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 165px;
}

.tuong-suggest-chip-sub {
  font-size: 10.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}

.tuong-suggest-recipe {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.tuong-suggest-recipe img {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

body.hud-mode .tuong-filter-row {
  grid-template-columns: minmax(0, 1fr);
}

body.hud-mode .tuong-base-stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.hud-mode .tuong-layout,
body.hud-mode .tuong-builds-grid,
body.hud-mode .tuong-item-cats-grid {
  grid-template-columns: minmax(0, 1fr) !important;
}

body.hud-mode .tuong-stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 1020px) {
  .tuong-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .tuong-list-wrap {
    max-height: 360px;
  }
}

@media (max-width: 780px) {
  .tuong-filter-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .tuong-item-cats-grid,
  .tuong-builds-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .tuong-stat-grid,
  .tuong-base-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Global Typography & Sharp Esport Polish */
.tuong-row-metrics,
.tuong-stat-val,
.tuong-base-stat-val,
.tuong-star-chip,
.tuong-cat-item-stats,
.tuong-suggest-chip-sub,
.solver-champ-cost,
.champ-star-rank {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.icon-tile,
.tier-card-item,
.solver-champ-card,
.tuong-row,
.tuong-cat-card,
.tuong-specs-card,
.tuong-suggest-card,
.tuong-build-card,
.tuong-stat-pill,
.tuong-base-stat-item,
.tuong-ability-box,
.early-board-card,
.review-phase-card,
.review-pillar,
.reroll-strip,
.reroll-unit-chip,
.switch-row,
.toast,
.riot-guide-box {
  border-radius: var(--radius-md);
}

.icon-tile img,
.champ-avatar,
.tier-card-item img,
.solver-champ-card img,
.early-unit-pill img,
.stats-item-icon,
.stats-kpi-icon,
.tuong-row-avatar,
.tuong-detail-avatar,
.item-icon-sm,
.item-icon-md {
  border-radius: var(--radius-sm);
}

@media (max-width: 860px) {
  .nav-shell {
    padding: 5px 12px 6px;
  }
  .nav-groups {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }
  .nav-group-btn {
    padding: 6px 6px;
    font-size: 12px;
    min-height: 34px;
  }
  .nav-tabs {
    padding: 4px 5px;
    gap: 4px;
  }
  .nav-tab {
    padding: 5px 9px;
    font-size: 12px;
    min-height: 30px;
  }
}

@media (max-width: 560px) {
  .nav-shell {
    padding: 5px 8px 6px;
  }
  .nav-group-btn {
    padding: 5px 4px;
    font-size: 11px;
    letter-spacing: 0.1px;
  }
  .tuhuyet-alert-panel,
  .tuhuyet-checklist-panel {
    flex: 1 1 100%;
    justify-content: flex-start;
  }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-root); }
::-webkit-scrollbar-thumb { background: rgba(34, 211, 238, 0.28); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(34, 211, 238, 0.48); }

/* Desktop Auto-Update & Web Download Desktop CTA */
.btn-update-now {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #022c22;
  border: 1px solid rgba(110, 231, 183, 0.75);
  font-weight: 800;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.35);
  cursor: pointer;
}
.btn-update-now:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 22px rgba(16, 185, 129, 0.55);
}

.btn-download-desktop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  text-decoration: none;
  background: linear-gradient(135deg, #f59e0b 0%, #eab308 100%);
  color: #0b1120;
  border: 1px solid rgba(254, 240, 138, 0.8);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.32);
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
}
.btn-download-desktop:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
  box-shadow: 0 0 22px rgba(245, 158, 11, 0.5);
}
.btn-download-desktop.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.web-desktop-notice {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.12) 0%, rgba(34, 211, 238, 0.08) 100%);
  border-top: 1px solid rgba(245, 158, 11, 0.24);
  border-bottom: 1px solid rgba(245, 158, 11, 0.24);
  padding: 5px 16px;
  text-align: center;
  font-size: 12px;
  color: #fde68a;
  line-height: 1.4;
}

/* Meta Comp List — Inline Form Tướng & Đồ Chuẩn Preview */
.meta-grid-sidebar {
  grid-template-columns: 330px minmax(0, 1fr);
}
@media (max-width: 1200px) {
  .meta-grid-sidebar {
    grid-template-columns: 300px minmax(0, 1fr);
  }
}
@media (max-width: 1080px) {
  .meta-grid-sidebar {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}
@media (max-width: 960px) {
  body.hud-mode .meta-grid-sidebar {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}
.meta-detail-panel,
.meta-board-hero {
  min-width: 0;
  max-width: 100%;
}

.meta-comp-list {
  max-height: calc(100vh - 250px);
  min-height: 540px;
  overflow-y: auto;
  padding-right: 4px;
}
body.hud-mode .meta-comp-list {
  max-height: 440px;
  min-height: 240px;
}

.meta-comp-card {
  cursor: pointer;
  padding: 10px 11px;
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  transition: border-color 0.14s ease, background 0.14s ease;
}
.meta-comp-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.meta-comp-card.active {
  background: var(--bg-hover);
  border-color: var(--accent-gold);
}

.meta-preview-board {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
}

.meta-preview-unit {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.meta-preview-avatar {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 2px solid var(--cost-1);
  object-fit: cover;
  display: block;
}

.meta-preview-3star {
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #fde047;
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
  padding: 1px 3px;
  border-radius: 4px;
  border: 1px solid rgba(250, 204, 21, 0.65);
  letter-spacing: -0.5px;
  white-space: nowrap;
  pointer-events: none;
}

.meta-preview-carry {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: #f59e0b;
  color: #0b1120;
  font-size: 9px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(15, 23, 42, 0.9);
  pointer-events: none;
}

.meta-preview-builds {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.meta-preview-build-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-root);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 2px 5px 2px 3px;
}

.meta-preview-build-champ {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1.5px solid var(--cost-1);
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}

.meta-preview-build-items {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.meta-preview-build-item {
  width: 19px;
  height: 19px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  object-fit: cover;
  display: block;
}

/* Meta Comp Variants — Card Toggle + Inline Drawer + Top Switcher Bar */
.meta-card-variant-row {
  margin-top: 7px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.meta-variant-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 7px;
  background: rgba(34, 211, 238, 0.1);
  color: #67e8f9;
  border: 1px solid rgba(34, 211, 238, 0.32);
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.meta-variant-toggle:hover,
.meta-variant-toggle.open {
  background: rgba(34, 211, 238, 0.2);
  border-color: rgba(34, 211, 238, 0.65);
}

.meta-variants-drawer {
  margin-top: 7px;
  padding: 6px;
  border-radius: 8px;
  background: var(--bg-root);
  border: 1px solid rgba(34, 211, 238, 0.28);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-variant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.meta-variant-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}
.meta-variant-item.active {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.55);
  color: #fde68a;
  font-weight: 800;
}
.meta-variant-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta-variant-item-avp {
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.meta-variant-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.08) 0%, rgba(15, 23, 42, 0.6) 100%);
  border: 1px solid rgba(34, 211, 238, 0.28);
}

.meta-variant-bar-label {
  font-size: 12px;
  font-weight: 800;
  color: #67e8f9;
  white-space: nowrap;
}

.meta-variant-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.meta-variant-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  background: var(--bg-root);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.meta-variant-pill:hover {
  border-color: rgba(34, 211, 238, 0.6);
  background: var(--bg-hover);
}
.meta-variant-pill.active {
  background: rgba(245, 158, 11, 0.16);
  border-color: var(--accent-gold);
  color: #fde68a;
}
.meta-variant-pill-avp {
  font-size: 10.5px;
  font-weight: 700;
  color: #6ee7b7;
  opacity: 0.9;
}

/* Meta Detail — Centerpiece Fluid Full-Width Hex Board (>=40% screen area) */
.meta-board-hero {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.78) 0%, rgba(9, 14, 26, 0.56) 100%);
  border: 1px solid rgba(250, 204, 21, 0.28);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
}

.meta-hex-board-lg {
  container-type: inline-size;
  --hex-w: clamp(46px, 11.8cqw, 126px);
  --hex-h: calc(var(--hex-w) * 1.14);
  --hex-gap: calc(var(--hex-w) * 0.08);
  --hex-shift: calc(var(--hex-w) * 0.27);
  --hex-overlap: calc(var(--hex-h) * -0.21);
  padding: 22px 2.2cqw 28px;
  border-color: rgba(250, 204, 21, 0.28);
  box-shadow: inset 0 0 44px rgba(15, 23, 42, 0.72);
  overflow-x: hidden;
}
.meta-hex-board-lg .hex-row {
  gap: var(--hex-gap) !important;
  transform: translateX(calc(var(--hex-shift) * -1)) !important;
}
.meta-hex-board-lg .hex-row.odd {
  transform: translateX(var(--hex-shift)) !important;
}
.meta-hex-board-lg .hex-row + .hex-row {
  margin-top: var(--hex-overlap) !important;
}
.meta-hex-board-lg .hex-cell {
  width: var(--hex-w) !important;
  height: var(--hex-h) !important;
}
.meta-hex-board-lg .hex-unit-name {
  font-size: clamp(8.5px, 1.35cqw, 13px) !important;
  max-width: calc(var(--hex-w) * 0.88) !important;
  bottom: calc(var(--hex-h) * 0.17) !important;
  padding: 2px 6px !important;
}
.meta-hex-board-lg .hex-items-strip {
  bottom: -3px !important;
  gap: 3px !important;
}
.meta-hex-board-lg .hex-items-strip img {
  width: clamp(13px, 2.85cqw, 30px) !important;
  height: clamp(13px, 2.85cqw, 30px) !important;
  border-radius: 5px !important;
  border: 1.5px solid rgba(15, 23, 42, 0.92);
}
.meta-hex-board-lg .hex-3star-badge {
  font-size: clamp(8px, 1.25cqw, 12px) !important;
  padding: 1px 5px !important;
  top: -5px !important;
}
.meta-hex-board-lg .hex-carry-star {
  font-size: clamp(9px, 1.3cqw, 13px) !important;
  padding: 1px 6px !important;
}
.meta-hex-board-lg .hex-cell.is-3star .hex-carry-star {
  top: calc(var(--hex-h) * 0.15) !important;
}

.meta-champ-drawer {
  margin-top: 2px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  padding-top: 8px;
}
.meta-champ-drawer-summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: #67e8f9;
  user-select: none;
  list-style: none;
}
.meta-champ-drawer-summary::-webkit-details-marker {
  display: none;
}
.meta-champ-drawer-summary:hover {
  color: #a5f3fc;
}

.meta-notes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 1080px) {
  .meta-notes-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
body.hud-mode .meta-notes-grid {
  grid-template-columns: minmax(0, 1fr);
}

.meta-note-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}
.meta-note-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}
.meta-note-textarea {
  font-size: 12px !important;
  line-height: 1.4;
  padding: 6px 8px !important;
  min-height: 46px;
}

.meta-power-compact {
  background: var(--bg-elevated);
  padding: 8px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Multi Gemini API Key pills (Settings) */
.gemini-key-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gemini-key-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(5, 12, 22, 0.72);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.gemini-key-pill.active {
  background: rgba(34, 211, 238, 0.14);
  border-color: rgba(34, 211, 238, 0.55);
  color: #67e8f9;
}

/* Floating AI Chat Assistant (Desktop, Web & Mini HUD F8) */
.ai-chat-root {
  position: fixed;
  bottom: 16px;
  right: 18px;
  z-index: 140;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.ai-chat-root > * {
  pointer-events: auto;
}

.ai-chat-fab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 15px;
  border: 1px solid rgba(251, 191, 36, 0.72);
  border-radius: 0;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  background: var(--phoenix-gradient);
  color: #050c16;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(249, 115, 22, 0.36), 0 0 0 1px rgba(5, 12, 22, 0.7);
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}

.ai-chat-fab:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 14px 32px rgba(249, 115, 22, 0.48), 0 0 18px rgba(34, 211, 238, 0.28);
}

.ai-chat-fab.is-open {
  background: linear-gradient(135deg, #0b172a 0%, #0f2038 100%);
  color: #67e8f9;
  border-color: var(--accent-cyan);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55), 0 0 14px rgba(34, 211, 238, 0.25);
}

.ai-chat-fab-icon {
  font-size: 15px;
  line-height: 1;
}

.ai-chat-panel {
  width: min(400px, calc(100vw - 24px));
  height: min(550px, calc(100vh - 96px));
  display: flex;
  flex-direction: column;
  background: rgba(5, 12, 22, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(34, 211, 238, 0.42);
  border-radius: var(--radius-lg);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.72), 0 0 24px rgba(34, 211, 238, 0.14);
  overflow: hidden;
  animation: aiChatPopIn 0.16s ease-out;
}

@keyframes aiChatPopIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(90deg, rgba(11, 23, 42, 0.98) 0%, rgba(15, 32, 56, 0.96) 100%);
  border-bottom: 1px solid rgba(34, 211, 238, 0.28);
  flex-shrink: 0;
}

.ai-chat-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ai-chat-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: var(--phoenix-gradient);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.35);
}

.ai-chat-title-block {
  min-width: 0;
}

.ai-chat-title {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: #f8fafc;
  line-height: 1.15;
}

.ai-chat-subtitle {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #67e8f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.ai-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.ai-chat-icon-btn {
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: rgba(5, 12, 22, 0.72);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.ai-chat-icon-btn:hover {
  border-color: var(--accent-cyan);
  color: #f8fafc;
  background: rgba(34, 211, 238, 0.14);
}

.ai-chat-close-btn {
  padding: 4px 9px;
}

.ai-chat-key-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 11px;
  background: rgba(249, 115, 22, 0.14);
  border-bottom: 1px solid rgba(249, 115, 22, 0.42);
  font-size: 12px;
  color: #fed7aa;
  flex-shrink: 0;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
}

.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 92%;
}

.ai-msg-user {
  align-self: flex-end;
}

.ai-msg-model,
.ai-msg-welcome {
  align-self: flex-start;
  width: 100%;
  max-width: 96%;
}

.ai-msg-bubble {
  padding: 8px 11px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.48;
  word-break: break-word;
}

.ai-msg-user .ai-msg-bubble {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.24), rgba(251, 191, 36, 0.16));
  border: 1px solid rgba(249, 115, 22, 0.55);
  color: #fff7ed;
}

.ai-msg-model .ai-msg-bubble,
.ai-msg-welcome .ai-msg-bubble {
  background: var(--bg-surface);
  border: 1px solid rgba(34, 211, 238, 0.24);
  color: var(--text-primary);
}

.ai-msg-bubble p {
  margin: 0 0 6px;
}

.ai-msg-bubble p:last-child {
  margin-bottom: 0;
}

.ai-msg-list {
  margin: 4px 0 6px;
  padding-left: 17px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ai-msg-list:last-child {
  margin-bottom: 0;
}

.ai-inline-pill {
  display: inline-block;
  padding: 0 5px;
  border-radius: 3px;
  background: rgba(34, 211, 238, 0.14);
  border: 1px solid rgba(34, 211, 238, 0.3);
  color: #a5f3fc;
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.ai-msg-notice {
  font-size: 11px;
  font-weight: 600;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin-bottom: 5px;
  line-height: 1.35;
}

.ai-msg-error {
  font-size: 12px;
  font-weight: 600;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.5);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  line-height: 1.4;
}

.ai-msg-typing .ai-msg-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #67e8f9;
  font-size: 12.5px;
}

.ai-typing-dots {
  display: inline-flex;
  gap: 3px;
}

.ai-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: aiTypingBounce 1.1s infinite ease-in-out both;
}

.ai-typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes aiTypingBounce {
  0%, 80%, 100% { transform: scale(0.55); opacity: 0.45; }
  40% { transform: scale(1); opacity: 1; }
}

.ai-chat-quick-prompts {
  display: flex;
  gap: 6px;
  padding: 7px 10px 6px;
  overflow-x: auto;
  border-top: 1px solid rgba(34, 211, 238, 0.16);
  background: rgba(7, 17, 32, 0.85);
  flex-shrink: 0;
  scrollbar-width: thin;
}

.ai-quick-chip {
  flex: 0 0 auto;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: rgba(11, 23, 42, 0.92);
  border: 1px solid rgba(34, 211, 238, 0.32);
  color: #bae6fd;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.ai-quick-chip:hover {
  border-color: var(--accent-gold-bright);
  background: rgba(249, 115, 22, 0.18);
  color: #fef3c7;
}

.ai-chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 8px 10px;
  background: var(--bg-surface);
  border-top: 1px solid rgba(34, 211, 238, 0.24);
  flex-shrink: 0;
}

.ai-chat-input-bar textarea {
  flex: 1;
  min-height: 36px;
  max-height: 86px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.38;
  resize: none;
  outline: none;
}

.ai-chat-input-bar textarea:focus {
  border-color: var(--accent-cyan);
}

.ai-chat-send-btn {
  padding: 8px 14px;
  min-height: 36px;
  border: 1px solid rgba(251, 191, 36, 0.7);
  border-radius: 0;
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  background: var(--phoenix-gradient);
  color: #050c16;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter 0.12s ease, opacity 0.12s ease;
}

.ai-chat-send-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.ai-chat-send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Mini HUD (F8) & Narrow screen responsive tuning */
body.hud-mode .ai-chat-root {
  bottom: 10px;
  right: 10px;
}

body.hud-mode .ai-chat-fab {
  padding: 7px 11px;
  font-size: 12px;
}

body.hud-mode .ai-chat-panel {
  width: min(350px, calc(100vw - 18px));
  height: min(430px, calc(100vh - 70px));
  background: rgba(5, 12, 22, 0.88);
  backdrop-filter: blur(16px);
}

body.hud-mode .ai-chat-header {
  padding: 8px 10px;
}

body.hud-mode .ai-chat-messages {
  padding: 8px 9px;
}

body.hud-mode .ai-msg-bubble {
  font-size: 12.2px;
  padding: 7px 9px;
}

@media (max-width: 600px) {
  .ai-chat-root {
    bottom: 10px;
    right: 10px;
  }
  .ai-chat-fab {
    padding: 8px 12px;
    font-size: 12.5px;
  }
  .ai-chat-panel {
    width: calc(100vw - 20px);
    height: min(480px, calc(100vh - 82px));
  }
}
