.masteries-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.masteries-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.mastery-free-pick-pill {
  min-height: 30px;
}

.mastery-free-pick-pill span {
  font-size: 12px;
}

.mastery-lock-toggle {
  min-width: 34px;
  padding: 5px 8px;
  color: #f7e9c4;
}

.mastery-lock-toggle [data-masteries-lock-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: currentColor;
}

.mastery-lock-toggle [data-masteries-lock-icon] svg {
  display: block;
}

.mastery-lock-status {
  font-size: 12px;
  line-height: 1;
  color: #f1dfb1;
}

.mastery-tree-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  line-height: 1;
}

.mastery-tree-count[hidden] {
  display: none !important;
}

.masteries-rules {
  display: grid;
  gap: 4px;
  line-height: 1.35;
}

.masteries-view-switch {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.masteries-view-switch [data-masteries-view-toggle].is-active {
  border-color: rgba(235, 198, 125, 0.8);
  background: linear-gradient(180deg, rgba(235, 198, 125, 0.32), rgba(235, 198, 125, 0.14));
}

.masteries-view-switch [data-masteries-view-toggle]:disabled {
  opacity: 0.42;
  color: rgba(210, 214, 222, 0.6);
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(120, 128, 146, 0.2), rgba(95, 104, 124, 0.1));
  cursor: not-allowed;
  filter: grayscale(0.35);
}

.masteries-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 2px;
}

.masteries-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.masteries-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: inline-block;
}

.masteries-legend-dot.is-available {
  background: rgba(145, 166, 201, 0.85);
}

.masteries-legend-dot.is-selected {
  background: rgba(203, 214, 238, 0.95);
}

.masteries-legend-dot.is-blocked {
  background: rgba(255, 120, 120, 0.9);
}

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

.mastery-tree {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.mastery-tree-offense { background: linear-gradient(180deg, rgba(51, 17, 17, 0.96), rgba(35, 11, 11, 0.98)); }
.mastery-tree-defense { background: linear-gradient(180deg, rgba(17, 51, 17, 0.96), rgba(11, 35, 11, 0.98)); }
.mastery-tree-support { background: linear-gradient(180deg, rgba(17, 17, 51, 0.96), rgba(11, 11, 35, 0.98)); }

.mastery-tree-head {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.mastery-tree-head h3 {
  margin: 0;
  font-size: 18px;
}

.mastery-tree-body {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.mastery-tier {
  display: block;
}

.mastery-tier-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.mastery-tier-slots {
  display: grid;
  grid-template-columns: repeat(4, 56px);
  justify-content: center;
  gap: 6px;
}

.mastery-slot {
  width: 56px;
  height: 56px;
  border: 0;
  background: transparent;
  padding: 0;
  display: grid;
  place-items: center;
}

.mastery-slot-empty {
  opacity: 0;
  pointer-events: none;
}

.mastery-slot-item {
  --mastery-hex-shape: polygon(
    22% 0%,
    78% 0%,
    100% 22%,
    100% 78%,
    78% 100%,
    22% 100%,
    0% 78%,
    0% 22%
  );
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 0;
  border: 0;
  background: transparent;
  padding: 0;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
  box-shadow: none;
  position: relative;
  isolation: isolate;
}

.mastery-slot-item:disabled {
  cursor: not-allowed;
}

.mastery-slot-item:hover {
  transform: none;
  box-shadow: none;
}

.mastery-slot-item:focus-visible {
  outline: 2px solid rgba(203, 214, 238, 0.95);
  outline-offset: 1px;
}

.mastery-hex {
  width: 100%;
  height: 100%;
  background: transparent;
  clip-path: var(--mastery-hex-shape);
  border: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  filter: grayscale(0.08) brightness(0.98) opacity(1);
  position: relative;
  box-shadow: none;
}

.mastery-hex img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  clip-path: var(--mastery-hex-shape);
  position: relative;
  z-index: 0;
  display: block;
  filter: none;
}

.mastery-slot-item:hover .mastery-hex {
  filter: none;
  box-shadow: none;
}

.mastery-slot-item:not(.is-selected):not(.is-blocked) .mastery-hex {
  filter: grayscale(0.2) brightness(0.88) opacity(0.92);
}

.mastery-slot-item:not(.is-selected):not(.is-blocked):hover .mastery-hex {
  filter: grayscale(0.1) brightness(0.95) opacity(0.96);
  box-shadow: 0 0 6px rgba(214, 211, 228, 0.22);
}

.mastery-slot-item.is-selected .mastery-hex {
  filter: none;
  box-shadow: 0 0 10px rgba(248, 170, 70, 0.32);
}

.mastery-slot-item.is-selected {
  box-shadow: none;
}

.mastery-slot-item.is-blocked .mastery-hex {
  filter: grayscale(0.65) brightness(0.72) opacity(0.82);
  box-shadow: none;
}

.mastery-slot-item.is-blocked {
  cursor: not-allowed;
  box-shadow: none;
}

.mastery-slot-item.is-blocked:hover {
  transform: none;
  box-shadow: none;
}

.mastery-slot-item.is-blocked:hover .mastery-hex {
  filter: grayscale(0.75) brightness(0.68) opacity(0.78);
  box-shadow: none;
}

.mastery-info {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  min-height: 96px;
}

.mastery-info h3 {
  margin: 6px 0 6px;
  font-size: 16px;
}

.mastery-info p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.mastery-build-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.mastery-build-code {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  word-break: break-all;
  font-size: 12px;
}

.mastery-build button[disabled] {
  opacity: 0.62;
  cursor: not-allowed;
}

.mastery-minor-wrap {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 8px 10px;
}

.mastery-minor-row {
  display: block;
  padding: 2px 0;
}

.mastery-minor-tier-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 1px 4px;
  min-height: 48px;
  flex-wrap: wrap;
}

.mastery-minor-empty-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
}

.mastery-minor-tier-icons.has-items .mastery-minor-empty-dot {
  display: none;
}

.mastery-minor-item {
  width: 44px;
  height: 44px;
  border: 0;
  padding: 0;
  display: inline-block;
  border-radius: 8px;
  background: transparent;
}

.mastery-minor-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.mastery-action-status {
  font-size: 12px;
  line-height: 1.2;
  color: #f1dfb1;
}

.saved-delete-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.saved-confirm[hidden] {
  display: none;
}

.saved-confirm {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: grid;
  place-items: center;
}

.saved-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 18, 0.72);
  backdrop-filter: blur(2px);
}

.saved-confirm-card {
  position: relative;
  z-index: 1;
  width: min(520px, calc(100vw - 24px));
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(circle at 10% -25%, rgba(255, 75, 75, 0.2), transparent 48%),
    linear-gradient(180deg, rgba(20, 24, 38, 0.96), rgba(14, 18, 30, 0.97));
  box-shadow: 0 24px 46px rgba(0, 0, 0, 0.58);
  padding: 14px;
}

@media (max-width: 1060px) {
  .masteries-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .mastery-minor-tier-icons {
    min-height: 40px;
    gap: 6px;
  }

  .mastery-minor-item {
    width: 36px;
    height: 36px;
  }
}
