@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;700&display=swap');

:root {
  --bg: #05060f;
  --starfield: radial-gradient(circle at 20% 20%, rgba(124, 215, 255, 0.08), transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(159, 133, 255, 0.1), transparent 52%),
    linear-gradient(140deg, rgba(10, 14, 26, 0.92), rgba(6, 8, 18, 0.95));
  --panel: linear-gradient(135deg, rgba(28, 38, 68, 0.88), rgba(16, 24, 45, 0.96));
  --panel2: rgba(12, 20, 40, 0.84);
  --muted: rgba(126, 146, 196, 0.34);
  --muted2: rgba(126, 146, 196, 0.18);
  --text: #edf1ff;
  --sub: #7d88a6;
  --emerald: #3debb9;
  --accent: #7cd7ff;
  --accent-strong: #9f85ff;
  --orange: #ffb17f;
  --purple: #9f85ff;
  --gold: #ffe8a3;
  --border: rgba(120, 160, 255, 0.35);
  --border-strong: rgba(120, 160, 255, 0.6);
  --shadow-base: 0 28px 80px -40px rgba(86, 140, 255, 0.6);
  --shadow: var(--shadow-base);
  --shadow-purple: 0 24px 72px -38px rgba(159, 133, 255, 0.65);
  --shadow-gold: 0 24px 72px -38px rgba(255, 218, 140, 0.7);
  --glow: 0 0 24px rgba(124, 215, 255, 0.35);
  --chip-bg: rgba(116, 152, 255, 0.12);
  --chip-hover: rgba(159, 133, 255, 0.28);
  --chip-active-text: #04070f;
  --stat-red: #ff6b81;
  --stat-yellow: #ffe98a;
  --stat-green: #48f5c1;
  --stat-blue: #82deff;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: var(--starfield);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Rajdhani', 'Inter', 'Segoe UI', 'Roboto', Arial, sans-serif;
  letter-spacing: 0.01em;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: -30vh -30vw;
  background: radial-gradient(circle at 60% 20%, rgba(124, 215, 255, 0.35), transparent 60%),
    radial-gradient(circle at 10% 80%, rgba(73, 108, 220, 0.4), transparent 60%);
  filter: blur(160px);
  opacity: 0.65;
  z-index: -2;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 12, 26, 0.65) 0%, transparent 45%, rgba(4, 6, 12, 0.95) 100%);
  z-index: -1;
  pointer-events: none;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 36px);
  position: relative;
  z-index: 1;
}

h1 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(124, 215, 255, 0.45);
  font-family: 'Rajdhani', 'Inter', sans-serif;
  display: flex;
  align-items: center;
  gap: 10px;
}

h1::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(124, 215, 255, 0.4), transparent);
}

.muted {
  color: var(--sub);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(18px);
  isolation: isolate;
}

.panel::before {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 60%, transparent 100%);
  opacity: 0.9;
  pointer-events: none;
  mix-blend-mode: screen;
  z-index: -1;
}

.panel-header {
  margin-bottom: 16px;
}

.panel-header__layout {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.panel-header__content {
  flex: 1 1 auto;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  width: min(260px, 100%);
  position: relative;
}

.toolbar__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.tool-card {
  --tool-border: rgba(124, 215, 255, 0.48);
  --tool-bg: linear-gradient(135deg, rgba(26, 38, 68, 0.9), rgba(12, 20, 40, 0.88));
  --tool-glow: 0 22px 48px -30px rgba(124, 215, 255, 0.75);
  --tool-sheen: linear-gradient(135deg, rgba(124, 215, 255, 0.22), rgba(159, 133, 255, 0.14));
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 18px;
  border: 1px solid var(--tool-border);
  background: var(--tool-bg);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--tool-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  isolation: isolate;
}

.tool-card::after {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background: var(--tool-sheen);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 0;
}

.tool-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(124, 215, 255, 0.08);
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 0;
}

.tool-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 28px 60px -34px rgba(124, 215, 255, 0.85);
  border-color: rgba(124, 215, 255, 0.72);
}

.tool-card:hover::after {
  opacity: 0.6;
}

.tool-card:active {
  transform: translateY(0);
}

.tool-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.tool-card > * {
  position: relative;
  z-index: 1;
}

button.tool-card {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
}

.tool-card--upload {
  --tool-border: rgba(124, 215, 255, 0.6);
  --tool-bg: linear-gradient(135deg, rgba(32, 52, 92, 0.92), rgba(12, 20, 40, 0.88));
  --tool-glow: 0 24px 56px -30px rgba(124, 215, 255, 0.85);
  --tool-sheen: linear-gradient(135deg, rgba(124, 215, 255, 0.32), rgba(159, 133, 255, 0.18));
}

.tool-card--restore {
  --tool-border: rgba(61, 235, 185, 0.5);
  --tool-bg: linear-gradient(135deg, rgba(20, 52, 52, 0.92), rgba(10, 32, 30, 0.88));
  --tool-glow: 0 22px 48px -30px rgba(61, 235, 185, 0.7);
  --tool-sheen: linear-gradient(135deg, rgba(61, 235, 185, 0.26), rgba(124, 215, 255, 0.16));
}

.tool-card--clear {
  --tool-border: rgba(255, 107, 129, 0.52);
  --tool-bg: linear-gradient(135deg, rgba(68, 28, 40, 0.92), rgba(40, 16, 28, 0.88));
  --tool-glow: 0 22px 48px -30px rgba(255, 107, 129, 0.7);
  --tool-sheen: linear-gradient(135deg, rgba(255, 107, 129, 0.28), rgba(255, 177, 127, 0.18));
}

.tool-icon {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(124, 215, 255, 0.24), rgba(159, 133, 255, 0.12));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(124, 215, 255, 0.3);
  flex-shrink: 0;
}

.tool-card--restore .tool-icon {
  background: linear-gradient(135deg, rgba(61, 235, 185, 0.2), rgba(124, 215, 255, 0.12));
  color: var(--emerald);
  box-shadow: inset 0 0 0 1px rgba(61, 235, 185, 0.32);
}

.tool-card--clear .tool-icon {
  background: linear-gradient(135deg, rgba(255, 107, 129, 0.2), rgba(255, 177, 127, 0.12));
  color: var(--stat-red);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 129, 0.28);
}

.tool-icon svg {
  width: 22px;
  height: 22px;
}

.tool-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.tool-title {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent);
}

.tool-card--restore .tool-title {
  color: var(--emerald);
}

.tool-card--clear .tool-title {
  color: var(--stat-red);
}

.tool-sub {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sub);
}

.tool-card--clear .tool-sub {
  color: rgba(255, 196, 196, 0.72);
}

@media (max-width: 900px) {
  .panel-header__layout {
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
  }
}

.btn {
  border: 1px solid var(--border-strong);
  background: linear-gradient(120deg, rgba(124, 215, 255, 0.15), rgba(159, 133, 255, 0.08));
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;
  font-family: 'Rajdhani', 'Inter', sans-serif;
  backdrop-filter: blur(12px);
}

.btn:hover {
  background: var(--accent);
  color: var(--chip-active-text);
  border-color: var(--accent);
  box-shadow: var(--glow);
  transform: translateY(-1px);
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.line {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.label {
  width: 92px;
  font-size: 12px;
  color: var(--accent-strong);
  letter-spacing: 0.12em;
  font-family: 'Rajdhani', 'Inter', sans-serif;
  text-transform: uppercase;
}

.seg {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
}

.seg .chip {
  border: 1px solid var(--muted);
  background: var(--chip-bg);
  color: var(--text);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease, box-shadow 0.2s ease;
  font-family: 'Rajdhani', 'Inter', sans-serif;
  backdrop-filter: blur(8px);
}

.seg .chip.active {
  background: var(--accent);
  color: var(--chip-active-text);
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(124, 215, 255, 0.4);
}

.seg .chip:hover:not(.active) {
  border-color: var(--accent-strong);
  background: var(--chip-hover);
}

.chip .chip-icon:not(.rarity) {
  filter: saturate(0.4) brightness(1.2) opacity(0.85);
  transition: filter 0.2s ease;
}

.chip.active .chip-icon:not(.rarity),
.seg .chip:hover .chip-icon:not(.rarity) {
  filter: none;
}

.chip-icon.rarity {
  filter: none !important;
}

.list {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(20px);
}

.list::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(160deg, rgba(124, 215, 255, 0.08), transparent 40%),
    repeating-linear-gradient(135deg, transparent, transparent 14px, rgba(255, 255, 255, 0.03) 14px, rgba(255, 255, 255, 0.03) 18px);
  z-index: 0;
}

.row {
  display: grid;
  grid-template-columns: 0.6fr 2fr 1fr 5fr 1fr 2fr 2fr 1.4fr;
  gap: 12px;
  align-items: center;
  min-height: 32px;
  position: relative;
  z-index: 1;
}

.row.header {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-strong);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--muted);
  letter-spacing: 0.12em;
  font-family: 'Rajdhani', 'Inter', sans-serif;
  text-transform: uppercase;
  background: none !important;
}

.row.item {
  padding: 4px 0;
  border-bottom: 1px solid var(--muted2);
  transition: background 0.25s ease, border 0.25s ease;
  min-height: 34px;
}

.row.item:hover {
  background: rgba(124, 215, 255, 0.08);
  border-color: rgba(124, 215, 255, 0.25);
}

.row.altA {
  background: rgba(14, 20, 40, 0.72);
}

.row.altB {
  background: rgba(9, 14, 28, 0.72);
}

.empty {
  padding: 16px;
  color: var(--sub);
  font-size: 13px;
}

.chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.chipStat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  border: 1.5px solid var(--muted);
  background: linear-gradient(120deg, rgba(32, 46, 80, 0.85), rgba(22, 34, 60, 0.9));
  width: 52px;
  height: 22px;
  box-sizing: border-box;
  padding: 0 6px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: inset 0 1px 4px rgba(12, 18, 30, 0.4), 0 0 2px rgba(0, 0, 0, 0.3);
  font-family: 'Rajdhani', 'Inter', sans-serif;
  transition: border 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.chipStat:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 215, 255, 0.5);
}

.stat-ico {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.35));
}

.mono {
  font-variant-numeric: tabular-nums;
  font-family: 'Rajdhani', 'Inter', monospace;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  width: 22px;
  display: inline-block;
}

.stat-red {
  color: var(--stat-red);
  border-color: rgba(255, 107, 129, 0.6);
  background: linear-gradient(120deg, rgba(56, 24, 36, 0.95), rgba(87, 32, 48, 0.9));
  box-shadow: 0 0 10px rgba(255, 107, 129, 0.3);
}

.stat-yellow {
  color: var(--stat-yellow);
  border-color: rgba(255, 233, 138, 0.6);
  background: linear-gradient(120deg, rgba(61, 52, 28, 0.95), rgba(94, 80, 40, 0.9));
  box-shadow: 0 0 10px rgba(255, 233, 138, 0.28);
}

.stat-green {
  color: var(--stat-green);
  border-color: rgba(72, 245, 193, 0.6);
  background: linear-gradient(120deg, rgba(24, 56, 44, 0.95), rgba(32, 74, 56, 0.9));
  box-shadow: 0 0 10px rgba(72, 245, 193, 0.28);
}

.stat-cyan {
  color: var(--stat-blue);
  border-color: rgba(130, 222, 255, 0.6);
  background: linear-gradient(120deg, rgba(24, 52, 68, 0.95), rgba(30, 62, 84, 0.9));
  box-shadow: 0 0 10px rgba(130, 222, 255, 0.28);
}

.badge-warn {
  color: var(--orange);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline dotted var(--orange) 1px;
  text-underline-offset: 3px;
  background: rgba(255, 177, 127, 0.08);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 13px;
  letter-spacing: 0.02em;
  font-family: 'Rajdhani', 'Inter', sans-serif;
  border: 1px solid rgba(255, 177, 127, 0.4);
  backdrop-filter: blur(8px);
}

.badge-ok {
  color: var(--emerald);
  font-weight: 700;
  background: rgba(61, 235, 185, 0.08);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 13px;
  letter-spacing: 0.02em;
  font-family: 'Rajdhani', 'Inter', sans-serif;
  border: 1px solid rgba(61, 235, 185, 0.4);
  backdrop-filter: blur(8px);
}

.itemmeta {
  color: var(--sub);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.tiny {
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.right {
  text-align: right;
}

.center {
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.center-info {
  font-size: 9px;
  color: var(--accent);
  display: inline-flex;
  gap: 4px;
}

.tier {
  font-family: 'Rajdhani', monospace;
  text-align: center;
  color: var(--gold);
  font-size: 18px;
  letter-spacing: 0.12em;
  text-shadow: 0 0 12px rgba(255, 232, 163, 0.4);
}

input[type="number"] {
  background: var(--panel2);
  border: 1px solid var(--muted);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-family: 'Rajdhani', 'Inter', sans-serif;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 215, 255, 0.15);
}

::-webkit-scrollbar {
  height: 8px;
  width: 10px;
  background: rgba(12, 18, 32, 0.92);
}

::-webkit-scrollbar-thumb {
  background: rgba(60, 88, 140, 0.7);
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(92, 128, 190, 0.85);
}

.row > .center.mono {
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  font-size: 14px;
  min-height: 20px;
  text-align: center;
}

.chip-icon-mask {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: middle;
  margin-right: 4px;
  background-color: var(--text);
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  transition: background-color 0.2s ease;
}

.chip.active .chip-icon-mask {
  background-color: var(--chip-active-text);
}

@media (max-width: 960px) {
  .row {
    grid-template-columns: 0.8fr 2.2fr 1fr 4fr 1fr 2fr 2fr 1fr;
  }
}

@media (max-width: 720px) {
  .row {
    grid-template-columns: 1.2fr 2.4fr 1fr 3fr;
    grid-template-areas:
      'tag item tier stats'
      'tag total total group'
      'tag rank rank actions';
  }
}
