@font-face {
  font-family: "Upheaval";
  src: url("./assets/fonts/upheavtt.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ui-font: "Upheaval", system-ui, sans-serif;
  --ui-ink: #f8fbff;
  --ui-muted: #9fb0d1;
  --ui-panel: rgba(43, 24, 76, 0.98);
  --ui-panel-dark: rgba(20, 11, 39, 0.98);
  --ui-line: #8d5cff;
  --ui-line-light: #f0dcff;
  --ui-accent: #c87cff;
  --ui-accent-dark: #6f3bb3;
  --ui-accent-line: #e6b8ff;
  --ui-shadow: rgba(4, 6, 12, 0.62);
  --ui-control-bg: rgba(36, 20, 64, 0.98);
  --ui-control-bg-hover: rgba(56, 30, 92, 0.98);
  --ui-danger: #ff5d5d;
  --ui-control-size: 42px;
}

.game-ui {
  color: var(--ui-ink);
  font-family: var(--ui-font);
  letter-spacing: 0;
  image-rendering: pixelated;
}

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

.left-green-panel {
  --quick-button-size: min(116px, calc((50vh - 12px) / 2), 116px);
  position: fixed;
  left: 0;
  top: 50%;
  bottom: auto;
  z-index: 6;
  width: 128px;
  padding: 0 6px;
  pointer-events: auto;
  display: grid;
  grid-template-rows: repeat(2, auto);
  align-content: center;
  align-items: center;
  justify-items: center;
  gap: clamp(6px, 1.2vh, 10px);
  transform: translateY(-50%);
}

.left-green-panel__button {
  width: var(--quick-button-size);
  height: var(--quick-button-size);
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  place-self: center;
  padding: 0;
  border: 3px solid rgba(255, 240, 165, 0.92);
  background:
    linear-gradient(180deg, #ffd166, #b86e13);
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.14),
    inset -4px -4px 0 rgba(0, 0, 0, 0.24),
    4px 4px 0 rgba(4, 6, 12, 0.42);
  color: #2b1607;
  cursor: pointer;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  font-family: var(--ui-font);
  text-transform: uppercase;
}

.left-green-panel__button strong,
.left-green-panel__button span {
  display: block;
  line-height: 1;
  color: #fffdf2;
  text-shadow:
    2px 0 0 #3b2208,
    -2px 0 0 #3b2208,
    0 2px 0 #3b2208,
    0 -2px 0 #3b2208,
    2px 2px 0 rgba(0, 0, 0, 0.48);
}

.left-green-panel__button strong {
  font-size: clamp(28px, 5.5vw, 42px);
}

.left-green-panel__button span {
  font-size: clamp(12px, 2.2vw, 18px);
}

.left-green-panel__button:active {
  transform: translate(1px, 1px);
}

.game-ui-chip,
.game-ui-button,
.sword-option,
.enemy-card {
  border: 3px solid var(--ui-line);
  background: var(--ui-panel);
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.08),
    inset -4px -4px 0 rgba(0, 0, 0, 0.18),
    6px 6px 0 var(--ui-shadow);
}

.game-ui-topbar {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 10px;
  pointer-events: auto;
  transform: none;
}

.combat-stats {
  position: absolute;
  inset: auto auto auto auto;
  top: calc(16px + env(safe-area-inset-top));
  right: auto;
  bottom: auto;
  left: calc(16px + env(safe-area-inset-left));
  width: min(300px, calc(50vw - 36px));
  z-index: 8;
  pointer-events: none;
  transform: none;
}

.combat-stats.game-ui-topbar {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
}

.combat-stats .game-ui-chip {
  min-width: 0;
  flex: 1 1 0;
  max-width: none;
  padding: 7px 8px 6px;
}

.combat-stats .game-ui-label {
  font-size: 10px;
}

.combat-stats .game-ui-value {
  font-size: 18px;
}

.game-ui .hud > .game-ui-chip,
.game-ui-chip {
  min-width: 104px;
  padding: 8px 10px 7px;
  border-color: #9c5cff;
  background:
    linear-gradient(180deg, rgba(71, 36, 116, 0.98), rgba(25, 13, 49, 0.98));
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.1),
    inset -4px -4px 0 rgba(0, 0, 0, 0.24),
    0 0 18px rgba(156, 92, 255, 0.22),
    6px 6px 0 var(--ui-shadow);
}

.game-ui .hud > .game-ui-chip--gold,
.game-ui-chip--gold {
  border-color: #b76dff;
  background:
    linear-gradient(180deg, rgba(88, 42, 139, 0.98), rgba(33, 12, 63, 0.98));
}

.game-ui .hud > .game-ui-chip--gold .game-ui-label,
.game-ui-chip--gold .game-ui-label {
  color: #c7b8ff;
}

.game-ui .hud > .game-ui-chip--gold .game-ui-value,
.game-ui-chip--gold .game-ui-value {
  color: #f1e9ff;
  text-shadow:
    2px 2px 0 rgba(0, 0, 0, 0.32),
    0 0 10px rgba(156, 116, 255, 0.52);
}

.game-ui .hud > .game-ui-chip--wave,
.game-ui-chip--wave {
  border-color: #8b7cff;
  background:
    linear-gradient(180deg, rgba(62, 47, 126, 0.98), rgba(25, 19, 62, 0.98));
}

.game-ui .hud > .game-ui-chip--wave .game-ui-label,
.game-ui-chip--wave .game-ui-label {
  color: #b9c0ff;
}

.game-ui .hud > .game-ui-chip--wave .game-ui-value,
.game-ui-chip--wave .game-ui-value {
  color: #e5e8ff;
  text-shadow:
    2px 2px 0 rgba(0, 0, 0, 0.32),
    0 0 9px rgba(111, 75, 255, 0.38);
}

.game-ui .hud > .game-ui-chip--combo,
.game-ui-chip--combo {
  border-color: #d26dff;
  background:
    linear-gradient(180deg, rgba(91, 38, 120, 0.98), rgba(38, 15, 57, 0.98));
}

.game-ui .hud > .game-ui-chip--combo .game-ui-label,
.game-ui-chip--combo .game-ui-label {
  color: #dcb4ff;
}

.game-ui .hud > .game-ui-chip--combo .game-ui-value,
.game-ui-chip--combo .game-ui-value {
  color: #f3deff;
  text-shadow:
    2px 2px 0 rgba(0, 0, 0, 0.32),
    0 0 9px rgba(192, 111, 255, 0.42);
}

.game-ui-label {
  display: block;
  margin-bottom: 4px;
  color: var(--ui-muted);
  font-size: 11px;
  line-height: 1;
  text-transform: uppercase;
}

.game-ui-value {
  display: block;
  color: var(--ui-ink);
  font-size: 20px;
  line-height: 1;
  font-weight: 400;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.28);
}

.game-ui-button,
.sword-option {
  width: auto;
  min-width: 92px;
  height: var(--ui-control-size);
  min-height: var(--ui-control-size);
  padding: 0 14px;
  border-radius: 0;
  color: var(--ui-ink);
  font: 18px/1 var(--ui-font);
  text-transform: uppercase;
  cursor: pointer;
  display: inline-grid;
  gap: 8px;
  place-content: center;
  align-items: center;
  justify-items: center;
  transition:
    transform 120ms ease,
    filter 120ms ease,
    background 120ms ease;
}

.game-ui-button:hover:not(:disabled),
.sword-option:hover:not(:disabled) {
  filter: brightness(1.13);
  transform: translateY(-2px);
}

.game-ui-button:active:not(:disabled),
.sword-option:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow:
    inset -2px -2px 0 rgba(255, 255, 255, 0.06),
    inset 4px 4px 0 rgba(0, 0, 0, 0.22),
    3px 3px 0 var(--ui-shadow);
}

.game-ui-button.is-primary {
  background: linear-gradient(180deg, var(--ui-accent), var(--ui-accent-dark));
  color: #2a1a0a;
  border-color: var(--ui-accent-line);
}

.game-ui-button.is-primary span {
  color: #5b3511;
}

.upgrade-button {
  min-width: 238px;
  height: 64px;
  min-height: 64px;
  padding: 8px 18px 7px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
  gap: 5px;
  place-items: center;
  line-height: 1;
  white-space: nowrap;
}

.upgrade-button strong {
  display: block;
  margin: 0;
  font-size: 20px;
  line-height: 1;
  font-weight: 400;
}

.upgrade-button span {
  display: block;
  margin: 0;
  font-size: 13px;
  line-height: 1;
}

.bottom-ui {
  gap: 10px;
  transform: none;
  width: 100%;
  pointer-events: auto;
}

.sword-shop {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  justify-content: stretch;
  pointer-events: auto;
  min-width: 0;
  overflow: visible;
}

.sword-option {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 58px;
  min-height: 58px;
  padding: 5px;
  gap: 2px;
  background: var(--ui-control-bg);
}

.side-ui {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50vw;
  min-width: 0;
  max-width: 50vw;
  display: grid;
  grid-template-columns: clamp(72px, 10vw, 96px) minmax(0, 1fr);
  align-content: stretch;
  gap: 10px;
  pointer-events: none;
  z-index: 7;
  overflow: visible;
  overflow-x: hidden;
  padding: 0;
  background: transparent;
}

.side-panel {
  min-width: 0;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  padding:
    calc(16px + env(safe-area-inset-top))
    calc(16px + env(safe-area-inset-right))
    calc(16px + env(safe-area-inset-bottom))
    16px;
  border-left: 4px solid #14091f;
  background:
    linear-gradient(180deg, rgba(28, 18, 48, 0.99), rgba(18, 13, 34, 0.99));
  box-shadow:
    inset 4px 0 0 rgba(255, 255, 255, 0.08),
    inset 10px 0 0 rgba(156, 92, 255, 0.1),
    -10px 0 0 rgba(0, 0, 0, 0.34);
  pointer-events: auto;
}

.side-ui-head {
  display: none;
  margin-bottom: 0;
  padding: 0;
  border: 3px solid #9c5cff;
  background:
    linear-gradient(180deg, rgba(95, 46, 146, 0.98), rgba(35, 16, 65, 0.98));
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.1),
    inset -4px -4px 0 rgba(0, 0, 0, 0.2),
    6px 6px 0 rgba(4, 6, 12, 0.62);
}

.side-ui-head h1 {
  margin: 0;
  color: #ffffff;
  font: 24px/0.95 var(--ui-font);
  text-transform: uppercase;
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    3px 3px 0 rgba(0, 0, 0, 0.72);
}

.side-ui-head span {
  display: none;
  margin-top: 0;
  color: #d8c8ff;
  font-size: 13px;
  line-height: 1;
  text-transform: uppercase;
}

.side-ui-body {
  width: 100%;
  height: 100%;
  min-height: 0;
  align-self: stretch;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  overflow-y: hidden;
  overflow-x: hidden;
  padding: 0 2px 8px 0;
  scrollbar-width: thin;
  scrollbar-color: #9c5cff rgba(20, 11, 39, 0.5);
}

.side-tabs {
  order: -1;
  width: 100%;
  height: 70%;
  max-height: 70%;
  align-self: start;
  box-sizing: border-box;
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-left: 5px;
  border-right: 0;
  background: transparent;
  box-shadow: none;
  display: grid;
  grid-template-rows: repeat(6, minmax(0, 1fr));
  align-content: stretch;
  gap: clamp(3px, 1vh, 8px);
  min-width: 0;
  justify-items: stretch;
  z-index: 9;
  pointer-events: auto;
}

.side-tab {
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: clamp(3px, 1.05vh, 8px) clamp(3px, 0.75vw, 8px);
  border: 3px solid #3d245d;
  background: rgba(12, 9, 24, 0.72);
  color: #d8c8ff;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.05),
    inset -3px -3px 0 rgba(0, 0, 0, 0.2),
    4px 4px 0 rgba(4, 6, 12, 0.48);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(1px, 0.55vh, 4px);
  font: clamp(7px, min(1.1vw, 1.25vh), 12px)/1 var(--ui-font);
  text-transform: uppercase;
  cursor: pointer;
}

.side-tab svg {
  width: clamp(15px, min(3.1vw, 4.3vh), 28px);
  height: clamp(15px, min(3.1vw, 4.3vh), 28px);
  display: block;
  color: currentColor;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.62));
}

.side-tab span {
  display: block;
  max-width: 100%;
  color: currentColor;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.side-tab.is-active {
  border-color: #b76dff;
  background: linear-gradient(180deg, #8c4fe2, #47246f);
  color: #ffffff;
}

.side-content {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  align-content: stretch;
  gap: 12px;
  padding-right: 4px;
}

.side-section {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 3px solid #3d245d;
  background: rgba(12, 9, 24, 0.42);
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.04),
    inset -3px -3px 0 rgba(0, 0, 0, 0.16);
  min-width: 0;
  min-height: 0;
  overflow: visible;
}

.side-ui-title {
  width: 100%;
  color: #e7d6ff;
  font-size: 40px;
  line-height: 1;
  text-transform: uppercase;
  text-align: left;
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.side-ui .game-ui-chip {
  width: 100%;
  max-width: none;
  min-width: 0;
}

.side-ui .upgrade-button {
  width: 100%;
  min-width: 0;
}

@media (max-height: 560px) and (orientation: landscape) {
  .equip-dock {
    --slot-size: clamp(38px, calc(var(--play-area-width, 50vw) / 11.5), 64px);
    --slot-gap: clamp(5px, calc(var(--slot-size) * 0.09), 10px);
    padding-inline: clamp(6px, 1.6vw, 14px);
  }

  .equip-dock .merge-equip-row {
    padding: clamp(4px, calc(var(--slot-size) * 0.075), 8px);
    border-width: 2px;
  }

  .equip-dock .merge-slot-label {
    top: calc(var(--slot-size) * -0.2);
    min-width: calc(var(--slot-size) * 0.68);
    max-width: calc(var(--slot-size) * 0.92);
    padding: 1px 3px;
    border-width: 1px;
  }

  .equip-dock .merge-slot-label__title {
    font-size: clamp(5px, calc(var(--slot-size) * 0.078), 7px);
  }

  .equip-dock .merge-slot-label__value {
    font-size: clamp(6px, calc(var(--slot-size) * 0.09), 8px);
  }

  .equip-dock .merge-slot-lock-price {
    padding: 1px 3px;
    border-width: 1px;
    font-size: clamp(6px, calc(var(--slot-size) * 0.1), 9px);
    max-width: 90%;
  }

  .equip-dock .merge-slot img {
    width: 56%;
    height: 56%;
  }

  .combat-stats {
    top: calc(10px + env(safe-area-inset-top));
    right: auto;
    bottom: auto;
    left: calc(10px + env(safe-area-inset-left));
    width: min(286px, calc(50vw - 30px));
  }

  .side-ui {
    width: 50vw;
    min-width: 0;
    max-width: 50vw;
    grid-template-columns: clamp(72px, 10vw, 96px) minmax(0, 1fr);
    gap: 6px;
  }

  .side-panel {
    padding: 10px calc(10px + env(safe-area-inset-right)) 10px 10px;
  }

  .side-ui-head {
    margin-bottom: 6px;
    padding: 5px 8px;
  }

  .side-ui-head h1 {
    font-size: 20px;
  }

  .side-ui-head span {
    display: none;
  }

  .side-ui-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .side-tabs {
    width: 100%;
    padding: 10% 4px 10% max(0px, env(safe-area-inset-left));
  }

  .side-tab {
    min-height: 0;
    font-size: 7px;
    gap: 2px;
  }

  .side-tab svg {
    width: 18px;
    height: 18px;
  }

  .merge-grid {
    --slot-size: 116px;
    gap: 4px;
  }

  .merge-category {
    padding: 2px 6px 1px;
    font-size: 8px;
  }

  .game-ui-topbar {
    gap: 6px;
  }

  .game-ui .hud > .game-ui-chip,
  .game-ui-chip {
    padding: 6px 8px 5px;
  }

  .game-ui .game-ui-label,
  .game-ui .label {
    font-size: 10px;
  }

  .game-ui .game-ui-value,
  .game-ui strong {
    font-size: 18px;
  }

  .bottom-ui {
    gap: 7px;
    overflow: auto;
    padding-right: 4px;
  }

  .upgrade-button {
    height: 54px;
    min-height: 54px;
  }

  .game-ui .upgrade-button strong {
    font-size: 17px;
  }

  .game-ui .upgrade-button span {
    font-size: 11px;
  }

  .sword-option {
    height: 48px;
    min-height: 48px;
  }

  .sword-option img {
    width: 23px;
    height: 23px;
  }
}

.sword-option img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  image-rendering: pixelated;
}

.sword-option span {
  margin: 0;
  color: var(--ui-muted);
  font-size: 10px;
  line-height: 1;
}

.sword-option.is-active {
  border-color: var(--ui-accent-line);
  background: linear-gradient(180deg, var(--ui-accent), var(--ui-accent-dark));
}

.sword-option.is-active span {
  color: #2a1a0a;
}

.sword-option.is-locked {
  opacity: 0.58;
  filter: grayscale(0.28);
}

.enemy-card {
  background: var(--ui-panel-dark);
  border-color: var(--ui-line);
  padding: 4px;
}

.enemy-namebox {
  background: var(--ui-control-bg);
  color: var(--ui-ink);
}

.enemy-card.is-boss {
  border-color: var(--ui-accent-line);
}

.enemy-card.is-boss .enemy-namebox {
  background: linear-gradient(180deg, rgba(75, 35, 52, 0.98), rgba(35, 18, 30, 0.98));
}

.enemy-hp {
  border: 2px solid var(--ui-line);
  background: #202a43;
}

@media (max-width: 720px) {
  .equip-dock {
    --slot-size: clamp(42px, calc(var(--play-area-width, 50vw) / 10.5), 72px);
    --slot-gap: clamp(6px, calc(var(--slot-size) * 0.1), 12px);
    padding-inline: clamp(8px, 2vw, 18px);
  }

  .equip-dock .merge-equip-row {
    padding: clamp(5px, calc(var(--slot-size) * 0.08), 9px);
    border-width: max(2px, calc(var(--slot-size) * 0.025));
    box-shadow:
      inset 2px 2px 0 rgba(255, 255, 255, 0.08),
      inset -2px -2px 0 rgba(0, 0, 0, 0.24),
      3px 4px 0 rgba(4, 6, 12, 0.34);
  }

  .equip-dock .merge-slot-label {
    top: calc(var(--slot-size) * -0.22);
    min-width: calc(var(--slot-size) * 0.72);
    max-width: calc(var(--slot-size) * 0.98);
    padding: max(1px, calc(var(--slot-size) * 0.018)) max(3px, calc(var(--slot-size) * 0.04));
    border-width: max(1px, calc(var(--slot-size) * 0.016));
    gap: 0;
  }

  .equip-dock .merge-slot-label__title {
    font-size: clamp(5px, calc(var(--slot-size) * 0.082), 8px);
  }

  .equip-dock .merge-slot-label__value {
    font-size: clamp(6px, calc(var(--slot-size) * 0.096), 9px);
  }

  .equip-dock .merge-slot-lock-price {
    padding: max(1px, calc(var(--slot-size) * 0.02)) max(3px, calc(var(--slot-size) * 0.045));
    border-width: max(1px, calc(var(--slot-size) * 0.016));
    font-size: clamp(6px, calc(var(--slot-size) * 0.105), 10px);
    line-height: 1;
    max-width: 92%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .equip-dock .merge-slot img {
    width: 58%;
    height: 58%;
    filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.42));
  }

  .side-ui {
    grid-template-columns: clamp(72px, 16vw, 96px) minmax(0, 1fr);
    gap: 6px;
  }

  .side-tabs {
    padding-left: max(0px, env(safe-area-inset-left));
  }

  .side-tab {
    padding-inline: 3px;
  }

  .side-tab span {
    display: none;
  }

  .side-tab svg {
    width: clamp(18px, 6vw, 25px);
    height: clamp(18px, 6vw, 25px);
  }

  .game-ui-topbar {
    gap: 7px;
  }

  .game-ui-chip {
    min-width: 0;
    flex: 1;
    padding: 7px 8px 6px;
  }

  .game-ui-label {
    font-size: 10px;
  }

  .game-ui-value {
    font-size: 18px;
  }

  .sword-option {
    width: 52px;
    min-width: 52px;
    height: 52px;
    min-height: 52px;
  }

  .sword-option img {
    width: 25px;
    height: 25px;
  }
}

.game-ui .game-ui-label,
.game-ui .label {
  color: #f0eaff;
  font-size: 12px;
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.game-ui .game-ui-value,
.game-ui strong {
  color: #ffffff;
  font-size: 22px;
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    3px 3px 0 rgba(0, 0, 0, 0.72);
}

.game-ui .enemy-namebox span,
.game-ui .enemy-namebox strong,
.game-ui .game-ui-button,
.game-ui .game-ui-button span,
.game-ui .sword-option span {
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.game-ui .game-ui-button.is-primary,
.game-ui .sword-option.is-active {
  color: #ffffff;
  background: linear-gradient(180deg, #9f5cff, #49246f);
}

.game-ui .game-ui-button.is-primary span,
.game-ui .sword-option.is-active span {
  color: #ffffff;
}

.game-ui .upgrade-button strong {
  font-size: 20px;
  line-height: 1;
}

.game-ui .upgrade-button span {
  font-size: 13px;
  line-height: 1;
}

/* Final readability pass: keep menu labels complete on tight landscape screens. */
.combat-stats .game-ui-chip {
  min-width: 0;
  overflow: visible;
}

.combat-stats .game-ui-label,
.combat-stats .game-ui-value {
  white-space: nowrap;
}

.side-tab {
  min-height: 0;
  padding: clamp(3px, 1.05vh, 8px) clamp(3px, 0.75vw, 8px);
  overflow: hidden;
}

.side-tab span {
  width: 100%;
  font-size: clamp(7px, min(1.1vw, 1.25vh), 11px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
  word-break: normal;
}

.sword-shop {
  grid-template-columns: 1fr;
  gap: 8px;
  overflow: visible;
}

.sword-option {
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: 1fr;
  justify-content: stretch;
  justify-items: stretch;
  align-items: center;
  min-height: 54px;
  height: auto;
  padding: 6px 8px;
  gap: 8px;
  text-align: left;
  overflow: visible;
}

.sword-option img {
  width: 30px;
  height: 30px;
  justify-self: center;
}

.sword-option__text {
  display: grid;
  min-width: 0;
  gap: 3px;
  line-height: 1;
}

.game-ui .sword-option .sword-option__name {
  display: block;
  margin: 0;
  color: #ffffff;
  font-size: 11px;
  line-height: 1;
  white-space: normal;
  overflow: visible;
  overflow-wrap: normal;
  word-break: normal;
}

.game-ui .sword-option .sword-option__meta {
  display: block;
  color: #d8c8ff;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
  overflow: visible;
}

.sword-option.is-active .sword-option__meta,
.game-ui .sword-option.is-active .sword-option__meta {
  color: #ffffff;
}

.upgrade-button {
  white-space: normal;
  overflow: visible;
}

.upgrade-button strong,
.upgrade-button span {
  white-space: nowrap;
}

@media (max-height: 560px) and (orientation: landscape) {
  .side-tab {
    min-height: 0;
    padding: 3px 4px;
  }

  .side-tab span {
    display: none;
    font-size: 7px;
  }

  .sword-option {
    min-height: 48px;
    padding: 5px 7px;
  }

  .sword-option img {
    width: 26px;
    height: 26px;
  }

  .game-ui .sword-option .sword-option__name {
    font-size: 10px;
  }

  .game-ui .sword-option .sword-option__meta {
    font-size: 9px;
  }
}

.side-panel-view {
  display: none;
}

.side-panel-view.is-active {
  display: grid;
  min-height: 0;
}

.side-content:has(.side-panel-view[data-panel="swords"].is-active) {
  overflow: hidden;
}

.side-content:has(.side-panel-view[data-panel="upgrades"].is-active) {
  overflow: hidden;
}

.side-panel-view[data-panel="table"].is-active {
  position: relative;
  height: 100%;
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: stretch;
  overflow: visible;
}

.side-panel-view[data-panel="table"] .side-ui-title {
  display: block;
  margin-bottom: 2px;
  font-size: var(--table-title-size, 40px);
  line-height: 0.9;
}

.merge-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 2.12fr) minmax(0, 1fr);
  gap: var(--table-toolbar-gap, 8px);
  align-items: stretch;
  min-width: 0;
  margin: var(--table-toolbar-margin, 30px) 0 72px;
}

.side-panel-view[data-panel="table"].is-compact-table .merge-toolbar {
  grid-template-columns: minmax(0, 2.18fr) minmax(0, 0.82fr);
  margin: var(--table-toolbar-margin, 8px) 0 clamp(18px, 5vh, 34px);
}

.merge-buy-combo {
  min-width: 0;
  min-height: var(--table-buy-height, 52px);
  border: 3px solid #f0ca61;
  background: linear-gradient(180deg, rgba(113, 69, 18, 0.44), rgba(35, 19, 55, 0.96));
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.08),
    inset -4px -4px 0 rgba(0, 0, 0, 0.22),
    5px 5px 0 rgba(4, 6, 12, 0.5);
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  align-items: stretch;
  overflow: hidden;
}

.side-panel-view[data-panel="table"].is-compact-table .merge-buy-combo {
  min-height: var(--table-buy-height, 42px);
  grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.96fr);
  border-width: 2px;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.08),
    inset -2px -2px 0 rgba(0, 0, 0, 0.22),
    3px 3px 0 rgba(4, 6, 12, 0.5);
}

.merge-category {
  min-width: 0;
  padding: 3px 8px 2px;
  border: 2px solid rgba(141, 92, 255, 0.68);
  background: rgba(12, 8, 26, 0.72);
  color: #e7d6ff;
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
  text-align: center;
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.merge-category--merge {
  grid-column: 1 / -1;
}

.merge-buy-button {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: var(--table-buy-height, 52px);
  padding: var(--table-buy-pad-y, 7px) var(--table-buy-pad-x, 12px) var(--table-buy-pad-bottom, 6px);
  border: 3px solid #9c5cff;
  background: linear-gradient(180deg, rgba(82, 43, 128, 0.96), rgba(29, 18, 58, 0.96));
  color: #f7f1ff;
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.08),
    inset -4px -4px 0 rgba(0, 0, 0, 0.22),
    5px 5px 0 rgba(4, 6, 12, 0.5);
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  align-content: center;
  justify-items: center;
  justify-content: stretch;
  gap: var(--table-buy-gap, 8px);
}

.merge-buy-combo .merge-buy-button {
  min-height: 100%;
  border: 0;
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.08),
    inset -4px -4px 0 rgba(0, 0, 0, 0.2);
}

.merge-buy-combo .merge-buy-button:disabled,
.merge-buy-combo .merge-buy-button.locked {
  border: 0;
}

.merge-buy-button--action {
  border-color: #f0ca61;
  background: linear-gradient(180deg, rgba(181, 127, 36, 0.98), rgba(113, 69, 18, 0.98));
  color: #ffe8a6;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "level level"
    "sword value";
  justify-content: center;
  justify-items: center;
  align-items: center;
  padding-inline: max(8px, calc(var(--table-buy-height, 52px) * 0.14));
  column-gap: max(3px, calc(var(--table-buy-height, 52px) * 0.06));
}

.side-panel-view[data-panel="table"].is-compact-table .merge-buy-button {
  min-height: var(--table-buy-height, 42px);
  border-width: 2px;
  padding: var(--table-buy-pad-y, 1px) var(--table-buy-pad-x, 5px) var(--table-buy-pad-bottom, 1px);
  gap: var(--table-buy-gap, 4px);
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.08),
    inset -2px -2px 0 rgba(0, 0, 0, 0.22),
    3px 3px 0 rgba(4, 6, 12, 0.45);
}

.side-panel-view[data-panel="table"].is-compact-table .merge-buy-combo .merge-buy-button {
  border-width: 0;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.08),
    inset -2px -2px 0 rgba(0, 0, 0, 0.2);
}

.side-panel-view[data-panel="table"].is-compact-table .merge-buy-combo .merge-buy-button--action {
  border-right: 2px solid rgba(255, 233, 168, 0.58);
}

.side-panel-view[data-panel="table"].is-compact-table .merge-buy-button--secondary {
  column-gap: 2px;
}

.side-panel-view[data-panel="table"].is-compact-table .merge-buy-button--upgrade {
  column-gap: 2px;
  row-gap: 1px;
}

.side-panel-view[data-panel="table"].is-compact-table .merge-buy-button--upgrade .merge-buy-button__label {
  justify-self: center;
  text-align: center;
}

.side-panel-view[data-panel="table"].is-compact-table .merge-buy-button__label,
.side-panel-view[data-panel="table"].is-compact-table .merge-buy-button__level,
.side-panel-view[data-panel="table"].is-compact-table .merge-buy-button__value {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow:
    1px 0 0 #090512,
    -1px 0 0 #090512,
    0 1px 0 #090512,
    0 -1px 0 #090512;
}

.side-panel-view[data-panel="table"].is-compact-table .merge-buy-button--crate {
  min-width: 0;
  padding-inline: 2px;
}

.side-panel-view[data-panel="table"].is-compact-table .merge-buy-button--crate .merge-buy-button__label {
  font-size: min(var(--table-buy-secondary-size, 12px), 11px);
}

.merge-buy-combo .merge-buy-button--action {
  border-right: 3px solid rgba(255, 233, 168, 0.58);
}

.merge-buy-button--secondary {
  grid-template-columns: auto auto;
  grid-template-areas: "icon label";
  justify-content: center;
  align-content: center;
  align-items: center;
  justify-items: center;
  padding-block: 0;
  padding-inline: var(--table-buy-pad-x, 10px);
  column-gap: max(3px, calc(var(--table-buy-height, 52px) * 0.06));
}

.merge-buy-button--crate {
  border-color: #8d5cff;
  background: linear-gradient(180deg, rgba(92, 57, 146, 0.98), rgba(36, 22, 70, 0.98));
  color: #efe5ff;
}



.merge-buy-button--crate::after {
  content: "";
  position: absolute;
  top: max(4px, calc(var(--table-buy-height, 52px) * 0.08));
  right: max(4px, calc(var(--table-buy-height, 52px) * 0.08));
  width: clamp(8px, calc(var(--table-buy-height, 52px) * 0.2), 12px);
  height: clamp(8px, calc(var(--table-buy-height, 52px) * 0.2), 12px);
  border: 2px solid rgba(255, 236, 190, 0.96);
  background: #ff344c;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.18),
    inset -2px -2px 0 rgba(0, 0, 0, 0.26),
    0 0 0 2px rgba(28, 11, 22, 0.78);
  opacity: 0;
  transform: scale(0.65);
  transform-origin: center;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.merge-buy-button--crate.is-crate-ready::after {
  opacity: 1;
  transform: scale(1);
  animation: crate-ready-pulse 0.9s steps(2) infinite;
}

.side-panel-view[data-panel="table"].is-compact-table .merge-buy-button--crate::after {
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border-width: 1px;
}

@keyframes crate-ready-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.45); }
}

.merge-buy-button--upgrade {
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "level level"
    "label value";
  justify-content: center;
  justify-items: center;
  align-items: center;
  column-gap: max(8px, calc(var(--table-buy-height, 52px) * 0.16));
  border-color: #b981ff;
  background: linear-gradient(180deg, rgba(96, 52, 145, 0.98), rgba(42, 24, 78, 0.98));
  color: #f4eaff;
  row-gap: 3px;
}

.merge-buy-combo .merge-buy-button--upgrade {
  border-left: 2px solid rgba(185, 129, 255, 0.78);
  background: linear-gradient(180deg, rgba(96, 52, 145, 0.98), rgba(42, 24, 78, 0.98));
}

.merge-buy-button--upgrade .merge-buy-button__level {
  grid-area: level;
  color: #efe0ff;
  font-size: var(--table-buy-upgrade-level-size, calc(var(--table-buy-level-size, 13px) - 2px));
}

.merge-buy-button--upgrade .merge-buy-button__label {
  grid-area: label;
  color: #ffffff;
  font-size: var(--table-buy-upgrade-label-size, calc(var(--table-buy-secondary-size, 18px) - 4px));
  justify-self: end;
  text-align: right;
}

.merge-buy-combo .merge-buy-button--upgrade .merge-buy-button__label {
  font-size: var(--table-buy-upgrade-label-size, calc(var(--table-buy-secondary-size, 18px) - 4px));
}

.merge-buy-button--upgrade .merge-buy-button__value {
  grid-area: value;
  color: #ffe788;
  font-size: var(--table-buy-upgrade-value-size, calc(var(--table-buy-secondary-size, 18px) - 3px));
  justify-self: start;
  text-align: left;
}

.merge-buy-button__label,
.merge-buy-button__level,
.merge-buy-button__value,
.merge-buy-button__cost-icon,
.merge-buy-button__icon {
  margin-top: 0;
  line-height: 1;
  text-transform: uppercase;
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.merge-buy-button__level {
  grid-area: level;
  color: #fff4cf;
  font-size: var(--table-buy-level-size, calc(var(--table-buy-title-size, 15px) - 1px));
  letter-spacing: 0;
  white-space: nowrap;
}

.merge-buy-button__label {
  min-width: 0;
  text-align: left;
  font-size: var(--table-buy-main-size, calc(var(--table-buy-title-size, 15px) + 6px));
}

.merge-buy-button--action .merge-buy-button__label,
.merge-buy-button--action .merge-buy-button__value,
.merge-buy-button--action .merge-buy-button__icon {
  justify-self: center;
}

.merge-buy-button--action .merge-buy-button__label {
  display: none;
}

.merge-buy-button--action .merge-buy-button__value {
  color: #fff8df;
}

.merge-buy-button--action .merge-buy-button__icon {
  color: #ffe9a8;
}

.merge-buy-button--secondary .merge-buy-button__label {
  display: block;
  min-width: auto;
  justify-self: center;
  text-align: center;
  font-size: var(--table-buy-secondary-size, calc(var(--table-buy-title-size, 15px) + 1px));
}

.merge-buy-button--secondary .merge-buy-button__icon {
  display: inline-grid;
  grid-area: icon;
  justify-self: center;
}

.merge-buy-button__value {
  display: block;
  font-size: var(--table-buy-main-size, calc(var(--table-buy-title-size, 15px) + 6px));
  color: inherit;
  padding: 0;
  white-space: nowrap;
}

.merge-buy-button__cost-icon {
  display: inline-grid;
  grid-area: coin;
  width: var(--table-buy-main-icon-size, calc(var(--table-buy-title-size, 15px) + 3px));
  height: var(--table-buy-main-icon-size, calc(var(--table-buy-title-size, 15px) + 3px));
  color: inherit;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.48));
}

.merge-buy-button__cost-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.merge-buy-button__icon {
  grid-area: sword;
  width: var(--table-buy-main-icon-size, calc(var(--table-buy-title-size, 15px) + 3px));
  height: var(--table-buy-main-icon-size, calc(var(--table-buy-title-size, 15px) + 3px));
  display: inline-grid;
  place-items: center;
  color: inherit;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.48));
  position: relative;
}

.merge-buy-button__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.merge-buy-button.locked {
  border-color: #6c557f;
  background: linear-gradient(180deg, rgba(66, 48, 88, 0.96), rgba(29, 21, 45, 0.96));
  color: #e6ddf1;
  filter: grayscale(0.12) brightness(0.9);
}

.merge-buy-button:disabled,
.merge-buy-button.locked {
  border-color: #6c557f;
  background: linear-gradient(180deg, rgba(55, 40, 75, 0.96), rgba(25, 18, 40, 0.96));
  color: #d8cdea;
  cursor: default;
  filter: grayscale(0.16) brightness(0.9);
}

.merge-buy-button--secondary .merge-buy-button__icon {
  width: var(--table-buy-secondary-icon-size, calc(var(--table-buy-title-size, 15px) + 8px));
  height: var(--table-buy-secondary-icon-size, calc(var(--table-buy-title-size, 15px) + 8px));
  color: #efe7ff;
}

.merge-buy-button--secondary .merge-buy-button__label {
  grid-area: label;
  font-size: var(--table-buy-secondary-size, calc(var(--table-buy-title-size, 15px) + 1px));
}

.merge-buy-button--action .merge-buy-button__icon {
  width: var(--table-buy-main-icon-size, calc(var(--table-buy-title-size, 15px) + 3px));
  height: var(--table-buy-main-icon-size, calc(var(--table-buy-title-size, 15px) + 3px));
}

.merge-buy-button--action .merge-buy-button__value {
  grid-area: value;
  display: block;
  justify-self: center;
  font-size: var(--table-buy-main-size, calc(var(--table-buy-title-size, 15px) + 6px));
}

.merge-buy-button--action .merge-buy-button__cost-icon {
  display: none;
}

.merge-grid {
  --slot-size: 116px;
  --slot-gap: clamp(7px, calc(var(--slot-size) * 0.09), 14px);
  display: grid;
  grid-template-columns: repeat(3, var(--slot-size));
  grid-auto-rows: auto;
  gap: var(--slot-gap);
  min-width: 0;
  min-height: 0;
  width: max-content;
  max-width: none;
  justify-content: center;
  justify-self: center;
  height: auto;
  align-content: start;
  overflow: visible;
}

.merge-slot {
  --tier-accent: #a391bd;
  --tier-glow: rgba(163, 145, 189, 0.22);
  --tier-panel: rgba(48, 33, 71, 0.88);
  --tier-floor: rgba(22, 15, 36, 0.96);
  position: relative;
  width: var(--slot-size);
  height: var(--slot-size);
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  padding: max(3px, calc(var(--slot-size) * 0.035));
  border: max(2px, calc(var(--slot-size) * 0.018)) solid rgba(72, 54, 103, 0.96);
  background: var(--tier-floor);
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.04),
    inset -3px -3px 0 rgba(0, 0, 0, 0.28),
    4px 4px 0 rgba(4, 6, 12, 0.48);
  cursor: pointer;
  overflow: visible;
  touch-action: none;
}

.stage,
.canvas-layer,
#game {
  touch-action: none;
  user-select: none;
}

.merge-slot-label {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: calc(var(--slot-size) * -0.28);
  width: max-content;
  min-width: calc(var(--slot-size) * 0.78);
  max-width: calc(var(--slot-size) * 1.1);
  transform: translateX(-50%);
  padding: max(3px, calc(var(--slot-size) * 0.026)) max(5px, calc(var(--slot-size) * 0.052));
  border: max(2px, calc(var(--slot-size) * 0.018)) solid color-mix(in srgb, var(--tier-accent) 76%, #fff 10%);
  background:
    linear-gradient(180deg, rgba(39, 25, 66, 0.96), rgba(12, 8, 24, 0.96));
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.07),
    inset -2px -2px 0 rgba(0, 0, 0, 0.24),
    3px 4px 0 rgba(4, 6, 12, 0.46);
  color: #fff8e8;
  display: grid;
  gap: max(1px, calc(var(--slot-size) * 0.012));
  justify-items: center;
  align-items: center;
  font-family: var(--ui-font);
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: visible;
  pointer-events: none;
  text-shadow:
    1px 0 0 #090512,
    -1px 0 0 #090512,
    0 1px 0 #090512,
    0 -1px 0 #090512;
}

.merge-slot-label__title,
.merge-slot-label__value {
  display: block;
  max-width: 100%;
  margin: 0;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
}

.merge-slot-label__title {
  color: #f5edff;
  font-size: clamp(7px, calc(var(--slot-size) * 0.092), 12px);
}

.merge-slot-label__value {
  color: color-mix(in srgb, var(--tier-accent) 55%, #fff7bf 45%);
  font-size: clamp(8px, calc(var(--slot-size) * 0.112), 15px);
}

.merge-slot::before {
  content: "";
  position: absolute;
  inset: calc(var(--slot-size) * 0.08);
  border: max(2px, calc(var(--slot-size) * 0.02)) solid color-mix(in srgb, var(--tier-accent) 56%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--tier-panel) 90%, white 10%), var(--tier-panel));
  box-shadow:
    inset 0 0 0 1px rgba(11, 7, 20, 0.9),
    inset 0 0 calc(var(--slot-size) * 0.08) var(--tier-glow);
  pointer-events: none;
}

.merge-slot.has-sword {
  border-color: color-mix(in srgb, var(--tier-accent) 72%, #261a3f);
}

.merge-slot.has-sword::before {
  border-color: color-mix(in srgb, var(--tier-accent) 78%, transparent);
}

.merge-slot.is-new-tier-shine {
  overflow: hidden;
}

.merge-slot.is-new-tier-shine::after {
  content: "";
  position: absolute;
  inset: -35%;
  z-index: 4;
  pointer-events: none;
  background:
    linear-gradient(115deg,
      transparent 34%,
      rgba(255, 255, 255, 0.08) 42%,
      rgba(255, 241, 166, 0.95) 49%,
      rgba(255, 255, 255, 0.22) 56%,
      transparent 66%);
  mix-blend-mode: screen;
  animation: newTierSlotShine 1.05s ease-in-out 2;
}

@keyframes newTierSlotShine {
  0% {
    transform: translate3d(-65%, 42%, 0);
    opacity: 0;
  }

  18% {
    opacity: 1;
  }

  64% {
    opacity: 0.95;
  }

  100% {
    transform: translate3d(65%, -42%, 0);
    opacity: 0;
  }
}

.merge-slot.is-active {
  border-color: color-mix(in srgb, var(--tier-accent) 78%, white 22%);
}

.merge-slot.is-dragging {
  opacity: 0.45;
  filter: grayscale(0.25);
}

.merge-slot.is-drop-target {
  border-color: #7eecff;
  background: rgba(15, 19, 38, 0.96);
}

.merge-slot.is-drop-target::before {
  border-color: rgba(126, 236, 255, 0.82);
  background: linear-gradient(180deg, rgba(28, 53, 78, 0.44), rgba(18, 25, 43, 0.44));
}

.merge-slot img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62%;
  height: 62%;
  object-fit: contain;
  image-rendering: pixelated;
  transform: translate(-50%, -50%);
  filter: drop-shadow(3px 4px 0 rgba(0, 0, 0, 0.44));
}

.merge-slot img.is-secret {
  opacity: 0;
  filter: none;
}

.merge-slot.is-revealing {
  overflow: hidden;
}

.merge-slot-reveal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.08));
}

.merge-slot-reveal__img {
  position: absolute;
  width: 66%;
  height: 66%;
  object-fit: contain;
  image-rendering: pixelated;
  opacity: 0;
  filter: drop-shadow(3px 4px 0 rgba(0, 0, 0, 0.5));
}

.drag-sword-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  pointer-events: none;
  filter: drop-shadow(5px 7px 0 rgba(0, 0, 0, 0.42));
  will-change: transform;
  transform: translate3d(-9999px, -9999px, 0);
}

body.is-sword-dragging,
body.is-sword-dragging * {
  cursor: grabbing !important;
}

.drag-sword-ghost img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.stage.is-orbit-drop-target canvas {
  cursor: copy;
}

.sword-shop {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}

.sword-option,
.game-ui .sword-option {
  grid-template-columns: minmax(0, 1fr);
  min-height: 132px;
  padding: 8px;
  gap: 6px;
  border-width: 3px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(47, 27, 82, 0.98), rgba(18, 10, 34, 0.98));
}

.sword-option__icon {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  justify-self: center;
  border: 3px solid rgba(183, 109, 255, 0.78);
  background:
    radial-gradient(circle at 50% 38%, rgba(210, 109, 255, 0.24), transparent 58%),
    rgba(8, 6, 18, 0.62);
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.08),
    inset -4px -4px 0 rgba(0, 0, 0, 0.22);
}

.sword-option img,
.game-ui .sword-option img {
  width: 66px;
  height: 66px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(4px 5px 0 rgba(0, 0, 0, 0.42));
}

.game-ui .sword-option .sword-option__name {
  font-size: 12px;
  line-height: 1;
}

.game-ui .sword-option .sword-option__text {
  display: grid;
  align-content: center;
  justify-items: center;
  min-width: 0;
}

.game-ui .sword-option .sword-option__power {
  display: block;
  margin-top: 3px;
  color: #cdbdff;
  font-size: 9px;
  line-height: 1;
  text-transform: uppercase;
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.game-ui .sword-option .sword-option__meta {
  width: max-content;
  min-width: 64px;
  margin-top: 6px;
  padding: 5px 8px 4px;
  border: 2px solid #d8b8ff;
  background: linear-gradient(180deg, #9f5cff, #49246f);
  color: #ffffff;
  font-size: 9px;
  text-align: center;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.12),
    3px 3px 0 rgba(4, 6, 12, 0.5);
}

.game-ui .sword-option.is-active .sword-option__meta {
  border-color: #ffffff;
  background: linear-gradient(180deg, #7eecff, #4d42c9);
}

.game-ui .sword-option.is-locked .sword-option__meta {
  border-color: #8d5cff;
  background: rgba(18, 10, 34, 0.9);
}

.game-ui .sword-option.is-locked {
  opacity: 0.55;
  cursor: default;
}

.game-ui .sword-option:disabled {
  opacity: 1;
  cursor: default;
}

.game-ui .sword-option.is-locked:disabled {
  opacity: 0.55;
}

.game-ui .sword-option.is-locked img {
  filter: grayscale(1) brightness(0.42) drop-shadow(4px 5px 0 rgba(0, 0, 0, 0.42));
}

@media (max-height: 560px) and (orientation: landscape) {
  .sword-shop {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sword-option,
  .game-ui .sword-option {
    min-height: 106px;
    padding: 6px;
    gap: 4px;
  }

  .sword-option__icon {
    width: 56px;
    height: 56px;
  }

  .sword-option img,
  .game-ui .sword-option img {
    width: 50px;
    height: 50px;
  }

  .game-ui .sword-option .sword-option__name {
    font-size: 13px;
  }

  .game-ui .sword-option .sword-option__power {
    font-size: 9px;
    margin-top: 4px;
  }

  .game-ui .sword-option .sword-option__meta {
    margin-top: 4px;
    min-width: 58px;
    padding: 4px 7px 3px;
    font-size: 8px;
  }
}

/* Progression UI overrides */
.merge-grid {
  --slot-size: 116px;
  --slot-gap: clamp(7px, calc(var(--slot-size) * 0.09), 14px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: calc(var(--slot-size) * 3 + var(--slot-gap) * 2);
  gap: var(--slot-gap);
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 0;
  justify-self: center;
  justify-items: center;
  align-content: center;
  overflow: visible;
}

.equip-dock {
  --slot-size: clamp(82px, calc(var(--play-area-width, 50vw) / 6.25), 136px);
  --slot-gap: clamp(14px, calc(var(--slot-size) * 0.15), 24px);
  position: absolute;
  left: 0;
  bottom: calc(8px + env(safe-area-inset-bottom));
  width: var(--play-area-width, 50vw);
  min-width: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 4;
  padding: 0 clamp(20px, 4vw, 42px);
}

.side-ui:has(.side-panel-view[data-panel="table"].is-compact-table) ~ .equip-dock,
.equip-dock:has(~ .side-ui .side-panel-view[data-panel="table"].is-compact-table) {
  --slot-size: clamp(42px, calc(var(--play-area-width, 50vw) / 10.5), 72px);
  --slot-gap: clamp(6px, calc(var(--slot-size) * 0.1), 12px);
  padding-inline: clamp(8px, 2vw, 18px);
}

.equip-dock .merge-equip-row {
  pointer-events: auto;
  padding: clamp(12px, calc(var(--slot-size) * 0.12), 18px);
  border: max(2px, calc(var(--slot-size) * 0.035)) solid rgba(127, 227, 154, 0.72);
  background:
    linear-gradient(180deg, rgba(35, 24, 58, 0.86), rgba(12, 8, 24, 0.88));
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.08),
    inset -3px -3px 0 rgba(0, 0, 0, 0.28),
    5px 6px 0 rgba(4, 6, 12, 0.36);
}

.side-ui:has(.side-panel-view[data-panel="table"].is-compact-table) ~ .equip-dock .merge-equip-row,
.equip-dock:has(~ .side-ui .side-panel-view[data-panel="table"].is-compact-table) .merge-equip-row {
  padding: clamp(5px, calc(var(--slot-size) * 0.08), 9px);
  border-width: max(2px, calc(var(--slot-size) * 0.025));
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.08),
    inset -2px -2px 0 rgba(0, 0, 0, 0.24),
    3px 4px 0 rgba(4, 6, 12, 0.34);
}

.side-ui:has(.side-panel-view[data-panel="table"].is-compact-table) ~ .equip-dock .merge-slot-label,
.equip-dock:has(~ .side-ui .side-panel-view[data-panel="table"].is-compact-table) .merge-slot-label {
  top: calc(var(--slot-size) * -0.22);
  min-width: calc(var(--slot-size) * 0.72);
  max-width: calc(var(--slot-size) * 0.98);
  padding: max(1px, calc(var(--slot-size) * 0.018)) max(3px, calc(var(--slot-size) * 0.04));
  border-width: max(1px, calc(var(--slot-size) * 0.016));
  gap: 0;
}

.side-ui:has(.side-panel-view[data-panel="table"].is-compact-table) ~ .equip-dock .merge-slot-label__title,
.equip-dock:has(~ .side-ui .side-panel-view[data-panel="table"].is-compact-table) .merge-slot-label__title {
  font-size: clamp(5px, calc(var(--slot-size) * 0.082), 8px);
}

.side-ui:has(.side-panel-view[data-panel="table"].is-compact-table) ~ .equip-dock .merge-slot-label__value,
.equip-dock:has(~ .side-ui .side-panel-view[data-panel="table"].is-compact-table) .merge-slot-label__value {
  font-size: clamp(6px, calc(var(--slot-size) * 0.096), 9px);
}

.side-ui:has(.side-panel-view[data-panel="table"].is-compact-table) ~ .equip-dock .merge-slot-lock-price,
.equip-dock:has(~ .side-ui .side-panel-view[data-panel="table"].is-compact-table) .merge-slot-lock-price {
  padding: max(1px, calc(var(--slot-size) * 0.02)) max(3px, calc(var(--slot-size) * 0.045));
  border-width: max(1px, calc(var(--slot-size) * 0.016));
  font-size: clamp(6px, calc(var(--slot-size) * 0.105), 10px);
  line-height: 1;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-ui:has(.side-panel-view[data-panel="table"].is-compact-table) ~ .equip-dock .merge-slot img,
.equip-dock:has(~ .side-ui .side-panel-view[data-panel="table"].is-compact-table) .merge-slot img {
  width: 58%;
  height: 58%;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.42));
}

.merge-grid-shell {
  position: relative;
  min-height: 0;
  height: 100%;
  display: grid;
  place-items: center;
}

.merge-crate-modal {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  padding: clamp(10px, 1.8vw, 18px);
  z-index: 30;
  overflow: hidden;
}

.merge-crate-modal.is-open .merge-crate-dialog,
.merge-crate-modal.is-open .merge-crate-backdrop {
  opacity: 1;
}

.merge-crate-modal[hidden] {
  display: none !important;
}

.merge-crate-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(12, 8, 24, 0.72);
  cursor: pointer;
}

.merge-crate-dialog {
  --crate-button-min: 286px;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: min(100%, 700px);
  height: min(100%, calc(var(--crate-button-min) * 2 + clamp(8px, 1.2vw, 12px) + 86px));
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: clamp(10px, 1.6vw, 16px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  justify-items: stretch;
  gap: clamp(8px, 1.3vw, 12px);
  border: 3px solid #8d5cff;
  background: linear-gradient(180deg, rgba(31, 20, 52, 0.98), rgba(14, 10, 28, 0.98));
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.08),
    inset -4px -4px 0 rgba(0, 0, 0, 0.24),
    0 24px 60px rgba(0, 0, 0, 0.44);
}

.merge-crate-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.merge-crate-heading {
  display: grid;
  gap: 4px;
}

.merge-crate-heading strong,
.merge-crate-heading span,
.merge-crate-close,
.merge-crate-option strong,
.merge-crate-option span,
.merge-crate-cost span {
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.merge-crate-heading strong {
  font-size: 28px;
  line-height: 1;
  color: #fff4cf;
}

.merge-crate-heading span {
  font-size: 12px;
  line-height: 1;
  color: #d1c4f2;
}

.merge-crate-close {
  min-width: 44px;
  min-height: 44px;
  border: 3px solid #8d5cff;
  background: rgba(26, 17, 45, 0.96);
  color: #efe6ff;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
}

.merge-crate-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.2vw, 12px);
  margin-top: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  justify-self: center;
  align-self: center;
  align-content: center;
}

.merge-crate-option {
  --crate-accent: #8d5cff;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "icon title"
    "icon meta"
    "icon tiers"
    "icon cost";
  gap: 4px 10px;
  align-items: center;
  padding: 14px 14px 12px;
  border: 3px solid color-mix(in srgb, var(--crate-accent) 74%, #201332);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--crate-accent) 20%, rgba(45, 28, 70, 0.96) 80%),
    rgba(19, 13, 34, 0.98)
  );
  color: #f6f2ff;
  text-align: left;
  cursor: pointer;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.07),
    inset -3px -3px 0 rgba(0, 0, 0, 0.24),
    4px 4px 0 rgba(4, 6, 12, 0.4);
}

.merge-crate-option__icon {
  grid-area: icon;
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  color: color-mix(in srgb, var(--crate-accent) 66%, #fff1be);
}

.merge-crate-option__icon svg,
.merge-crate-cost svg {
  width: 100%;
  height: 100%;
  display: block;
}

.merge-crate-option strong {
  grid-area: title;
  font-size: 16px;
  line-height: 1;
  color: #fff4d2;
}

.merge-crate-option__meta {
  grid-area: meta;
  font-size: 11px;
  line-height: 1;
  color: #d8c9fb;
}

.merge-crate-option__tiers {
  grid-area: tiers;
  font-size: 10px;
  line-height: 1.1;
  color: color-mix(in srgb, var(--crate-accent) 72%, #fff4cf);
}

.merge-crate-cost {
  grid-area: cost;
  display: inline-grid;
  grid-auto-flow: column;
  gap: 6px;
  align-items: center;
  justify-content: start;
  margin-top: 4px;
  color: #ffe8a6;
}

.merge-crate-cost svg {
  width: 16px;
  height: 16px;
}

.merge-crate-option.locked {
  filter: grayscale(0.16) brightness(0.84);
}

.merge-crate-option--simple {
  --crate-accent: #8d5cff;
  position: relative;
  container-type: size;
  width: 100%;
  max-width: 100%;
  height: 100%;
  align-self: center;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  padding: clamp(6px, 1vw, 9px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) clamp(58px, 7.6vh, 74px);
  grid-template-areas: none;
  align-items: stretch;
  justify-items: stretch;
  gap: clamp(4px, 0.8vw, 7px);
  overflow: visible;
  border: 3px solid color-mix(in srgb, var(--crate-accent) 74%, #2a1d46);
  background:
    linear-gradient(180deg, rgba(47, 30, 77, 0.98), rgba(18, 11, 33, 0.98));
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.08),
    inset -4px -4px 0 rgba(0, 0, 0, 0.24),
    5px 5px 0 rgba(4, 6, 12, 0.5);
  transition:
    filter 0.12s ease,
    transform 0.12s ease;
}

.merge-crate-option--simple span,
.merge-crate-option--simple strong {
  margin-top: 0;
  color: inherit;
}

.merge-crate-option--simple .merge-crate-option__icon {
  grid-area: unset;
  width: 100% !important;
  height: 100% !important;
  min-width: 0;
  min-height: 0;
  margin: 0;
  align-self: stretch;
  justify-self: stretch;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: color-mix(in srgb, var(--crate-accent) 70%, #fff1be);
  filter:
    drop-shadow(0 0 10px color-mix(in srgb, var(--crate-accent) 28%, transparent))
    drop-shadow(4px 5px 0 rgba(0, 0, 0, 0.48));
}

.merge-crate-info {
  grid-area: auto;
  position: relative;
  z-index: 2;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  gap: 3px;
  min-height: 56px;
}

.merge-crate-info strong {
  grid-area: auto;
  max-width: 100%;
  display: block;
  color: #fff4d2;
  font: clamp(10px, 1.9vw, 15px)/1 var(--ui-font);
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.merge-crate-price {
  grid-area: auto;
  width: 100%;
  max-width: 100%;
  min-height: clamp(28px, 4vh, 36px);
  margin: 0;
  box-sizing: border-box;
  padding: 4px 7px 3px;
  border: 2px solid color-mix(in srgb, var(--crate-accent) 72%, #fff1be);
  background: rgba(10, 7, 20, 0.76);
  color: #ffe8a6;
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  justify-content: center;
  gap: clamp(3px, 0.75vw, 6px);
  font-family: var(--ui-font);
  font-size: clamp(12px, min(2.8vw, 4vh), 24px);
  line-height: 0.94;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.08),
    3px 3px 0 rgba(4, 6, 12, 0.34);
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

@supports (font-size: 1cqw) {
  .merge-crate-price {
    font-size: clamp(12px, min(8cqw, 18cqh), 24px);
  }
}
.merge-crate-price__value {
  display: block;
  min-width: 0;
  max-width: 100%;
  line-height: 0.94;
  overflow: hidden;
  text-overflow: ellipsis;
}

.merge-crate-price__icon {
  width: clamp(14px, min(2.35vw, 3.5vh), 22px);
  height: clamp(14px, min(2.35vw, 3.5vh), 22px);
  display: inline-grid;
  place-items: center;
  color: currentColor;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.48));
}

.merge-crate-price__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.merge-crate-option--simple.is-ad-crate .merge-crate-price {
  color: #f3fbff;
  border-color: #7eecff;
}

.merge-crate-frame {
  width: min(94%, 210px);
  height: min(94%, 210px);
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
  image-rendering: pixelated;
  position: relative;
  z-index: 1;
}

.merge-crate-option--simple.locked {
  opacity: 1;
  filter: grayscale(0.18) brightness(0.78);
}

.merge-crate-list.is-opening .merge-crate-option--simple:not(.is-opening) {
  filter: grayscale(0.3) brightness(0.62);
}

.merge-crate-option--simple.is-opening {
  z-index: 2;
  filter: brightness(1.14) saturate(1.08);
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.1),
    inset -4px -4px 0 rgba(0, 0, 0, 0.24),
    0 0 0 2px color-mix(in srgb, var(--crate-accent) 38%, transparent),
    0 0 26px color-mix(in srgb, var(--crate-accent) 32%, transparent),
    5px 5px 0 rgba(4, 6, 12, 0.5);
}

@media (max-width: 900px) {
  .merge-crate-modal {
    padding: 10px;
  }

  .merge-crate-dialog {
    padding: 12px;
    gap: 12px;
  }

  .merge-crate-heading strong {
    font-size: 22px;
  }

  .merge-crate-heading span {
    font-size: 10px;
  }

  .merge-crate-close {
    min-width: 38px;
    min-height: 38px;
  }

  .merge-crate-list {
    gap: 10px;
  }
}

.merge-crate-reward {
  min-height: 56px;
  margin-top: 16px;
  padding: 12px 14px 10px;
  border: 3px solid rgba(141, 92, 255, 0.68);
  background: rgba(16, 11, 31, 0.9);
  display: grid;
  gap: 4px;
  align-content: center;
}

.merge-crate-reward strong,
.merge-crate-reward span {
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.merge-crate-reward strong {
  font-size: 15px;
  line-height: 1;
  color: #fff4cf;
}

.merge-crate-reward span,
.merge-crate-reward {
  font-size: 11px;
  line-height: 1.1;
  color: #d7c9f6;
}

.merge-crate-reward[data-tier="epic"] strong { color: #ddb4ff; }
.merge-crate-reward[data-tier="legendary"] strong { color: #ffd090; }
.merge-crate-reward[data-tier="mythic"] strong { color: #ff9dc3; }
.merge-crate-reward[data-tier="ancient"] strong { color: #ff9d86; }
.merge-crate-reward[data-tier="divine"] strong { color: #fff2a4; }

.merge-equip-row,
.merge-board {
  display: grid;
  gap: var(--slot-gap);
  width: max-content;
  max-width: none;
}

.merge-equip-row {
  grid-template-columns: repeat(var(--equip-cols), var(--slot-size));
  grid-template-rows: var(--slot-size);
}

.merge-board {
  grid-template-columns: repeat(var(--merge-cols), var(--slot-size));
  grid-template-rows: repeat(3, var(--slot-size));
}

.merge-slot.equip-slot {
  border-color: #7fe39a;
}

.merge-slot.equip-slot::before {
  border-color: color-mix(in srgb, var(--tier-accent) 56%, transparent);
}

.merge-slot.is-locked-slot {
  opacity: 0.42;
  filter: grayscale(0.55) brightness(0.72);
  cursor: not-allowed;
}

.merge-slot.is-buyable-slot {
  opacity: 1;
  filter: none;
  cursor: pointer;
  border-color: #d7bd6b;
}

.merge-slot.is-buyable-slot::before {
  border-color: rgba(255, 221, 126, 0.68);
  background: linear-gradient(180deg, rgba(64, 44, 26, 0.72), rgba(25, 16, 28, 0.96));
  box-shadow:
    inset 0 0 0 1px rgba(11, 7, 20, 0.9),
    inset 0 0 calc(var(--slot-size) * 0.1) rgba(255, 221, 126, 0.18);
}

.merge-slot-lock-price {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: max(3px, calc(var(--slot-size) * 0.035)) max(5px, calc(var(--slot-size) * 0.06));
  border: max(2px, calc(var(--slot-size) * 0.018)) solid rgba(255, 221, 126, 0.72);
  background: rgba(28, 17, 23, 0.92);
  color: #fff0a8;
  font-family: var(--ui-font);
  font-size: max(12px, calc(var(--slot-size) * 0.13));
  line-height: 1;
  text-transform: uppercase;
  text-shadow:
    1px 0 0 #090512,
    -1px 0 0 #090512,
    0 1px 0 #090512,
    0 -1px 0 #090512;
  pointer-events: none;
}

.merge-slot.is-locked-slot::after {
  content: "";
}

.merge-slot.is-locked-slot img {
  opacity: 0.35;
}

.side-panel-view[data-panel="swords"].is-active {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  overflow: hidden;
}

.side-panel-view[data-panel="swords"] .side-ui-title {
  min-height: 0;
}

.sword-shop,
.game-ui .sword-shop {
  --sword-cell-size: 54px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: var(--sword-cell-size);
  gap: 10px;
  min-height: 0;
  height: 100%;
  width: 100%;
  align-content: start;
  align-items: start;
  justify-items: center;
  overflow: visible;
}

.sword-option,
.game-ui .sword-option {
  --tier-accent: #a391bd;
  --tier-bg: rgba(36, 25, 56, 0.88);
  --tier-border: rgba(121, 95, 167, 0.9);
  position: relative;
  width: var(--sword-cell-size);
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  height: var(--sword-cell-size);
  aspect-ratio: 1;
  align-self: center;
  justify-self: center;
  display: grid;
  place-items: center;
  padding: 4px;
  border: 2px solid var(--tier-border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--tier-bg) 90%, white 10%), var(--tier-bg));
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.05),
    inset -3px -3px 0 rgba(0, 0, 0, 0.28),
    3px 3px 0 rgba(4, 6, 12, 0.42);
  overflow: hidden;
}

.sword-option img,
.game-ui .sword-option img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  image-rendering: pixelated;
}

.sword-option.is-locked img,
.game-ui .sword-option.is-locked img {
  filter: brightness(0) saturate(0) contrast(1.02) opacity(0.92);
}

.sword-option.is-locked,
.game-ui .sword-option.is-locked {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--tier-bg) 72%, rgba(20, 16, 28, 0.95) 28%),
    color-mix(in srgb, var(--tier-bg) 52%, rgba(14, 10, 22, 0.95) 48%)
  );
}

.sword-option.is-locked::before,
.game-ui .sword-option.is-locked::before {
  content: "";
  position: absolute;
  inset: 6%;
  border: 1px solid color-mix(in srgb, var(--tier-accent) 42%, transparent);
  pointer-events: none;
}

.merge-slot[data-tier="common"],
.sword-option[data-tier="common"],
.game-ui .sword-option[data-tier="common"] {
  --tier-accent: #c6c8d2;
  --tier-glow: rgba(198, 200, 210, 0.16);
  --tier-panel: rgba(83, 88, 101, 0.82);
  --tier-floor: rgba(31, 34, 43, 0.96);
  --tier-bg: rgba(67, 72, 84, 0.88);
  --tier-border: rgba(163, 168, 184, 0.92);
}

.merge-slot[data-tier="uncommon"],
.sword-option[data-tier="uncommon"],
.game-ui .sword-option[data-tier="uncommon"] {
  --tier-accent: #79da77;
  --tier-glow: rgba(121, 218, 119, 0.2);
  --tier-panel: rgba(42, 92, 52, 0.84);
  --tier-floor: rgba(16, 38, 21, 0.96);
  --tier-bg: rgba(39, 85, 48, 0.9);
  --tier-border: rgba(130, 222, 127, 0.94);
}

.merge-slot[data-tier="rare"],
.sword-option[data-tier="rare"],
.game-ui .sword-option[data-tier="rare"] {
  --tier-accent: #69b8ff;
  --tier-glow: rgba(105, 184, 255, 0.22);
  --tier-panel: rgba(36, 71, 118, 0.84);
  --tier-floor: rgba(12, 24, 47, 0.96);
  --tier-bg: rgba(33, 63, 111, 0.9);
  --tier-border: rgba(109, 188, 255, 0.96);
}

.merge-slot[data-tier="epic"],
.sword-option[data-tier="epic"],
.game-ui .sword-option[data-tier="epic"] {
  --tier-accent: #be7fff;
  --tier-glow: rgba(190, 127, 255, 0.24);
  --tier-panel: rgba(76, 38, 120, 0.84);
  --tier-floor: rgba(28, 13, 47, 0.96);
  --tier-bg: rgba(67, 33, 105, 0.9);
  --tier-border: rgba(196, 139, 255, 0.96);
}

.merge-slot[data-tier="legendary"],
.sword-option[data-tier="legendary"],
.game-ui .sword-option[data-tier="legendary"] {
  --tier-accent: #ffb347;
  --tier-glow: rgba(255, 179, 71, 0.24);
  --tier-panel: rgba(120, 67, 20, 0.84);
  --tier-floor: rgba(49, 24, 7, 0.96);
  --tier-bg: rgba(106, 57, 16, 0.9);
  --tier-border: rgba(255, 194, 101, 0.96);
}

.merge-slot[data-tier="mythic"],
.sword-option[data-tier="mythic"],
.game-ui .sword-option[data-tier="mythic"] {
  --tier-accent: #ff5f93;
  --tier-glow: rgba(255, 95, 147, 0.24);
  --tier-panel: rgba(122, 28, 69, 0.84);
  --tier-floor: rgba(48, 10, 28, 0.96);
  --tier-bg: rgba(108, 22, 61, 0.9);
  --tier-border: rgba(255, 123, 170, 0.96);
}

.merge-slot[data-tier="ancient"],
.sword-option[data-tier="ancient"],
.game-ui .sword-option[data-tier="ancient"] {
  --tier-accent: #ff6d5f;
  --tier-glow: rgba(255, 109, 95, 0.24);
  --tier-panel: rgba(128, 43, 30, 0.84);
  --tier-floor: rgba(53, 14, 11, 0.96);
  --tier-bg: rgba(113, 36, 28, 0.9);
  --tier-border: rgba(255, 132, 118, 0.96);
}

.merge-slot[data-tier="divine"],
.sword-option[data-tier="divine"],
.game-ui .sword-option[data-tier="divine"] {
  --tier-accent: #ffe77a;
  --tier-glow: rgba(255, 231, 122, 0.26);
  --tier-panel: rgba(122, 108, 35, 0.84);
  --tier-floor: rgba(46, 41, 12, 0.96);
  --tier-bg: rgba(107, 95, 31, 0.9);
  --tier-border: rgba(255, 238, 142, 0.98);
}

.sword-option.is-active,
.game-ui .sword-option.is-active {
  border-color: #e6b8ff;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.08),
    inset -3px -3px 0 rgba(0, 0, 0, 0.25),
    0 0 14px rgba(183, 109, 255, 0.4),
    3px 3px 0 rgba(4, 6, 12, 0.42);
}

.upgrade-list {
  display: grid;
  gap: 14px;
  align-content: start;
  overflow: visible;
}

.upgrade-group {
  min-width: 0;
  display: grid;
  gap: 7px;
  align-content: start;
}

.upgrade-group-title {
  width: max-content;
  max-width: 100%;
  padding: 7px 12px 6px;
  border: 2px solid #7eecff;
  background: linear-gradient(180deg, rgba(28, 48, 76, 0.96), rgba(12, 15, 33, 0.96));
  color: #e5fbff;
  font: 16px/1 var(--ui-font);
  text-transform: uppercase;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.08),
    inset -3px -3px 0 rgba(0, 0, 0, 0.22),
    3px 3px 0 rgba(4, 6, 12, 0.46);
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.upgrade-group[data-group="orbit"] .upgrade-group-title {
  border-color: #ffe08a;
  background: linear-gradient(180deg, rgba(78, 54, 22, 0.96), rgba(29, 21, 13, 0.96));
  color: #fff4cf;
}

.upgrade-group[data-group="forge"] .upgrade-group-title {
  border-color: #ff8ad8;
  background: linear-gradient(180deg, rgba(78, 28, 65, 0.96), rgba(29, 13, 31, 0.96));
  color: #ffe3f6;
}

.upgrade-group[data-group="economy"] .upgrade-group-title {
  border-color: #ffd166;
  background: linear-gradient(180deg, rgba(83, 55, 18, 0.96), rgba(32, 23, 12, 0.96));
  color: #fff1bd;
}

.upgrade-row {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0;
}

.upgrade-row.locked {
  filter: grayscale(0.18) brightness(0.82);
}

.upgrade-card {
  width: 100%;
  min-width: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 0;
  padding: 13px 16px;
  border: 3px solid #9c5cff;
  border-right: 0;
  background: linear-gradient(180deg, rgba(82, 43, 128, 0.96), rgba(29, 18, 58, 0.96));
  color: #ffffff;
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.08),
    inset -4px -4px 0 rgba(0, 0, 0, 0.24),
    5px 5px 0 rgba(4, 6, 12, 0.5);
  overflow: hidden;
}

.upgrade-card.locked {
  border-color: #6c557f;
}

.upgrade-card.is-maxed {
  border-color: #7eecff;
}

.upgrade-card strong,
.upgrade-buy {
  line-height: 1;
  text-transform: uppercase;
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.upgrade-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.upgrade-card strong {
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  color: #f7f1ff;
  font-size: 22px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.upgrade-chip {
  flex: 0 0 auto;
  min-width: 0;
  padding: 6px 8px 5px;
  border: 2px solid #5e3f87;
  background: rgba(14, 10, 30, 0.64);
  color: #efe6ff;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.06),
    inset -2px -2px 0 rgba(0, 0, 0, 0.2);
}

.upgrade-chip--level {
  color: #d8c8ff;
}

.upgrade-chip--value {
  color: #f3deff;
}

.upgrade-buy {
  min-width: 132px;
  min-height: 76px;
  padding: 10px 16px;
  border: 3px solid #ffe08a;
  background: linear-gradient(180deg, #ffd166, #c77b11);
  color: #fffdf2;
  font: 24px/1 var(--ui-font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.12),
    inset -4px -4px 0 rgba(0, 0, 0, 0.22),
    5px 5px 0 rgba(4, 6, 12, 0.5);
  transition:
    transform 120ms ease,
    filter 120ms ease;
}

.upgrade-buy:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.upgrade-buy:active:not(:disabled) {
  transform: translateY(1px);
}

.upgrade-buy.locked:not(:disabled) {
  border-color: #b58835;
  background: linear-gradient(180deg, #c79a42, #7d5311);
  color: #fff4d0;
}

.upgrade-buy.is-maxed {
  border-color: #7eecff;
  background: linear-gradient(180deg, #4a6481, #23364a);
}

.upgrade-buy:disabled {
  cursor: default;
}

.upgrade-buy__value {
  display: block;
  font-size: 28px;
  line-height: 1;
  color: inherit;
}

.upgrade-buy__icon {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  color: inherit;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.48));
}

.upgrade-buy__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Scoped fixes: do not affect Table/Merge. */
.side-panel-view[data-panel="swords"].is-active,
.side-panel-view[data-panel="upgrades"].is-active {
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.side-panel-view[data-panel="swords"].is-active .sword-shop {
  --sword-cell-size: 54px;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: var(--sword-cell-size);
  gap: 10px;
  align-content: start;
  align-items: start;
  justify-items: center;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #9c5cff rgba(20, 11, 39, 0.5);
}

.side-panel-view[data-panel="swords"].is-active .sword-option {
  width: var(--sword-cell-size);
  height: var(--sword-cell-size);
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 4px;
}

.side-panel-view[data-panel="swords"].is-active .sword-option img {
  width: 82%;
  height: 82%;
  object-fit: contain;
}

.side-panel-view[data-panel="upgrades"].is-active .upgrade-list {
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  align-content: start;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #9c5cff rgba(20, 11, 39, 0.5);
}

.side-panel-view[data-panel="upgrades"].is-active .upgrade-list.is-compact {
  gap: 10px;
}

.side-panel-view[data-panel="upgrades"].is-active .upgrade-list.is-compact .upgrade-group {
  gap: 5px;
}

.side-panel-view[data-panel="upgrades"].is-active .upgrade-list.is-compact .upgrade-group-title {
  padding: 5px 9px 4px;
  font-size: 13px;
}

.side-panel-view[data-panel="upgrades"].is-active .upgrade-list.is-compact .upgrade-card {
  min-height: 48px;
  padding: 8px 10px;
}

.side-panel-view[data-panel="upgrades"].is-active .upgrade-list.is-compact .upgrade-line {
  gap: 5px;
}

.side-panel-view[data-panel="upgrades"].is-active .upgrade-list.is-compact .upgrade-card strong {
  font-size: 14px;
}

.side-panel-view[data-panel="upgrades"].is-active .upgrade-list.is-compact .upgrade-chip {
  padding: 4px 6px 3px;
  font-size: 10px;
}

.side-panel-view[data-panel="upgrades"].is-active .upgrade-list.is-compact .upgrade-chip--value {
  display: none;
}

.side-panel-view[data-panel="upgrades"].is-active .upgrade-list.is-compact .upgrade-buy {
  min-width: 110px;
  min-height: 48px;
  padding: 8px 10px;
  font-size: 18px;
}

.side-panel-view[data-panel="upgrades"].is-active .upgrade-list.is-compact .upgrade-buy__value {
  font-size: 21px;
}

.side-panel-view[data-panel="upgrades"].is-active .upgrade-list.is-compact .upgrade-buy__icon {
  width: 18px;
  height: 18px;
}

/* Side panel height contract: one fixed viewport column, one internal scroll per tab. */
.side-ui {
  height: 100dvh;
  max-height: 100dvh;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
}

.side-tabs,
.side-panel,
.side-ui-body,
.side-content,
.side-panel-view {
  min-height: 0;
  max-height: 100%;
}

.side-tabs {
  align-self: start;
  height: 70%;
  max-height: 70%;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

.side-tabs::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.side-ui:has(.side-panel-view[data-panel="table"].is-compact-table) {
  grid-template-columns: clamp(72px, 10vw, 96px) minmax(0, 1fr);
  gap: 6px;
}

.side-ui:has(.side-panel-view[data-panel="table"].is-compact-table) .side-tabs {
  padding-left: 5px;
}

.side-ui:has(.side-panel-view[data-panel="table"].is-compact-table) .side-tab {
  padding-inline: 3px;
}

.side-ui:has(.side-panel-view[data-panel="table"].is-compact-table) .side-tab span {
  display: none;
}

.side-ui:has(.side-panel-view[data-panel="table"].is-compact-table) .side-tab svg {
  width: clamp(18px, 5.5vw, 25px);
  height: clamp(18px, 5.5vw, 25px);
}

.side-panel {
  align-self: stretch;
  overflow: hidden;
}

.side-ui-body {
  height: 100%;
  overflow: hidden;
  padding-bottom: 0;
}

.side-content {
  height: 100%;
  overflow: hidden;
  padding-right: 0;
}

.side-panel-view.is-active {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.side-panel-view[data-panel="table"].is-active,
.side-panel-view[data-panel="swords"].is-active,
.side-panel-view[data-panel="upgrades"].is-active {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.side-panel-view[data-panel="table"].is-active {
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: visible;
}

.side-panel-view[data-panel="swords"].is-active,
.side-panel-view[data-panel="upgrades"].is-active {
  grid-template-rows: auto minmax(0, 1fr);
}

.merge-grid,
.side-panel-view[data-panel="swords"].is-active .sword-shop,
.side-panel-view[data-panel="upgrades"].is-active .upgrade-list {
  min-height: 0;
  max-height: 100%;
}

.merge-grid {
  overflow: visible;
}

.side-panel-view[data-panel="swords"].is-active .sword-shop,
.side-panel-view[data-panel="upgrades"].is-active .upgrade-list {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-top: 8px;
}

/* Extended armory tabs */
.side-content:has(.side-panel-view[data-panel="bestiary"].is-active),
.side-content:has(.side-panel-view[data-panel="achievements"].is-active),
.side-content:has(.side-panel-view[data-panel="settings"].is-active) {
  overflow: hidden;
}

.side-panel-view[data-panel="bestiary"].is-active,
.side-panel-view[data-panel="achievements"].is-active,
.side-panel-view[data-panel="settings"].is-active {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.bestiary-grid {
  --bestiary-cell-size: 54px;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: var(--bestiary-cell-size);
  gap: 10px;
  align-content: start;
  align-items: start;
  justify-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #9c5cff rgba(20, 11, 39, 0.5);
  padding-top: 8px;
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option {
  --rarity-accent: var(--enemy-accent, #9c5cff);
  width: var(--bestiary-cell-size);
  height: var(--bestiary-cell-size);
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 4px;
  border-color: color-mix(in srgb, var(--rarity-accent) 72%, #261a3f);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--enemy-accent, #9c5cff) 30%, #211338), #100a1f);
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option[data-rarity="uncommon"] {
  --rarity-accent: #79da77;
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option[data-rarity="rare"] {
  --rarity-accent: #7eecff;
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option[data-rarity="elite"] {
  --rarity-accent: #5ca6ff;
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option[data-rarity="epic"] {
  --rarity-accent: #c87cff;
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option[data-rarity="legendary"] {
  --rarity-accent: #ffe08a;
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option[data-rarity="mythic"] {
  --rarity-accent: #ff7ab8;
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option[data-rarity="ancient"] {
  --rarity-accent: #ff7f6e;
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option[data-rarity="divine"] {
  --rarity-accent: #fff2a4;
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option[data-rarity="boss"] {
  --rarity-accent: #ff4d6d;
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option.is-shiny {
  border-color: #fff0a5;
  background:
    linear-gradient(135deg, rgba(255, 240, 165, 0.18), transparent 42%),
    linear-gradient(180deg, color-mix(in srgb, var(--enemy-accent, #ffe08a) 42%, #211338), #110a20);
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.12),
    inset -4px -4px 0 rgba(0, 0, 0, 0.26),
    0 0 16px color-mix(in srgb, var(--rarity-accent) 48%, transparent),
    4px 4px 0 rgba(4, 6, 12, 0.48);
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(4px 5px 0 rgba(0, 0, 0, 0.46));
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option.is-locked {
  border-color: #4d3b63;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--enemy-accent, #6c557f) 18%, rgba(34, 25, 50, 0.96)), rgba(14, 10, 26, 0.96));
}

.side-panel-view[data-panel="bestiary"].is-active .bestiary-option.is-locked img {
  opacity: 0.78;
  filter: brightness(0) saturate(1) drop-shadow(4px 5px 0 rgba(0, 0, 0, 0.5));
}

.achievement-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.settings-list {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #9c5cff rgba(20, 11, 39, 0.5);
  padding-top: 8px;
}

.setting-row {
  width: 100%;
  min-height: clamp(58px, 8.2vh, 76px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(8px, 1.4vw, 14px);
  padding: clamp(8px, 1.4vh, 12px) clamp(10px, 1.5vw, 16px);
  border: 3px solid #6c557f;
  background: linear-gradient(180deg, rgba(50, 32, 78, 0.96), rgba(18, 12, 34, 0.96));
  color: #efe6ff;
  font-family: var(--ui-font);
  font-size: clamp(17px, min(2.3vw, 3.1vh), 26px);
  line-height: 1;
  text-transform: uppercase;
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.08),
    inset -4px -4px 0 rgba(0, 0, 0, 0.24),
    5px 5px 0 rgba(4, 6, 12, 0.5);
}

button.setting-row {
  cursor: pointer;
}

.setting-row span,
.setting-row strong {
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.setting-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setting-row strong {
  min-width: clamp(58px, 7.6vw, 82px);
  padding: 0.34em 0.5em 0.3em;
  border: 2px solid #6c557f;
  background: rgba(14, 10, 30, 0.76);
  color: #d8c8ff;
  font-size: 0.9em;
  text-align: center;
}

.setting-row.is-on {
  border-color: #7eecff;
  background: linear-gradient(180deg, rgba(48, 55, 116, 0.96), rgba(21, 18, 54, 0.96));
}

.setting-row.is-on strong {
  border-color: #7eecff;
  color: #f3fbff;
}

.setting-row--range {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: clamp(8px, 1.4vh, 12px);
  cursor: default;
}

.setting-row__head,
.setting-row__controls {
  min-width: 0;
  display: grid;
  align-items: center;
}

.setting-row__head {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(8px, 1.4vw, 14px);
}

.setting-row__controls {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(8px, 1.3vw, 12px);
}

.setting-slider {
  --setting-slider-value: 100%;
  --setting-slider-fill: #8d5cff;
  --setting-slider-empty: rgba(14, 10, 30, 0.94);
  width: 100%;
  min-width: 0;
  height: 34px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  accent-color: var(--setting-slider-fill);
}

.setting-slider::-webkit-slider-runnable-track {
  height: 18px;
  border: 2px solid #6c557f;
  background:
    linear-gradient(90deg, var(--setting-slider-fill) 0 var(--setting-slider-value), var(--setting-slider-empty) var(--setting-slider-value) 100%);
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.08),
    inset -3px -3px 0 rgba(0, 0, 0, 0.24);
}

.setting-slider::-moz-range-track {
  height: 18px;
  border: 2px solid #6c557f;
  background: var(--setting-slider-empty);
}

.setting-slider::-moz-range-progress {
  height: 18px;
  border: 2px solid #6c557f;
  background: var(--setting-slider-fill);
}

.setting-slider::-webkit-slider-thumb {
  width: 24px;
  height: 32px;
  margin-top: -9px;
  appearance: none;
  -webkit-appearance: none;
  border: 3px solid #f3eaff;
  background: #8d5cff;
  box-shadow: 3px 3px 0 rgba(4, 6, 12, 0.55);
}

.setting-slider::-moz-range-thumb {
  width: 24px;
  height: 32px;
  border: 3px solid #f3eaff;
  border-radius: 0;
  background: #8d5cff;
  box-shadow: 3px 3px 0 rgba(4, 6, 12, 0.55);
}

.setting-mute-button {
  min-width: clamp(82px, 9vw, 106px);
  min-height: clamp(34px, 4.7vh, 42px);
  padding: 0.42em 0.58em 0.36em;
  border: 2px solid #6c557f;
  background: rgba(14, 10, 30, 0.86);
  color: #efe6ff;
  font-family: var(--ui-font);
  font-size: clamp(13px, min(1.5vw, 2.1vh), 18px);
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.08),
    3px 3px 0 rgba(4, 6, 12, 0.5);
}

.setting-row--range.is-muted {
  border-color: #5b4b6f;
  filter: grayscale(0.18) brightness(0.9);
}

.setting-mute-button.is-muted {
  border-color: #ff6d7a;
  color: #fff2f3;
  background: linear-gradient(180deg, rgba(122, 42, 72, 0.96), rgba(54, 18, 42, 0.96));
}

.setting-row--danger {
  border-color: #9d405f;
  background: linear-gradient(180deg, rgba(92, 34, 58, 0.96), rgba(32, 12, 28, 0.96));
}

.setting-row--danger strong {
  border-color: #ff6d7a;
  color: #ffe3e8;
}

.setting-row--danger.is-armed {
  border-color: #ff6d7a;
  background: linear-gradient(180deg, rgba(142, 43, 65, 0.98), rgba(58, 16, 34, 0.98));
}

.tutorial-guide {
  position: fixed;
  inset: 0;
  z-index: 420;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.tutorial-guide.is-visible {
  opacity: 1;
}

.tutorial-hand {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 421;
  pointer-events: none;
  visibility: hidden;
  filter:
    drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.86))
    drop-shadow(0 0 12px rgba(255, 231, 136, 0.28));
  animation: tutorialHandTap 0.82s steps(4, end) infinite;
  transform-origin: 78% 34%;
  transform: translate3d(var(--tutorial-hand-x, 0px), var(--tutorial-hand-y, 0px), 0);
  will-change: transform;
}

.tutorial-hand.is-drag-loop {
  animation: tutorialHandDragLoop 1.48s cubic-bezier(0.2, 0.82, 0.22, 1) infinite;
}

.tutorial-hand.is-drag-loop.is-equip-drag {
  animation-duration: 2.05s;
}

.tutorial-hand svg {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.is-tutorial-focus {
  position: relative;
  z-index: 421 !important;
  filter:
    drop-shadow(2px 0 0 #ffe788)
    drop-shadow(-2px 0 0 #ffe788)
    drop-shadow(0 2px 0 #ffe788)
    drop-shadow(0 -2px 0 #ffe788)
    drop-shadow(0 0 12px rgba(255, 231, 136, 0.35));
}

.stage.is-tutorial-focus {
  z-index: 8 !important;
}

@keyframes tutorialHandTap {
  0%,
  100% {
    transform: translate3d(var(--tutorial-hand-x, 0px), var(--tutorial-hand-y, 0px), 0);
  }

  45% {
    transform: translate3d(calc(var(--tutorial-hand-x, 0px) + 7px), calc(var(--tutorial-hand-y, 0px) + 7px), 0);
  }
}

@keyframes tutorialHandDragLoop {
  0%,
  100% {
    transform: translate3d(var(--tutorial-hand-x, 0px), var(--tutorial-hand-y, 0px), 0);
  }

  11% {
    transform: translate3d(calc(var(--tutorial-hand-x, 0px) + 4px), calc(var(--tutorial-hand-y, 0px) + 4px), 0);
  }

  21% {
    transform: translate3d(calc(var(--tutorial-hand-x, 0px) + 4px), calc(var(--tutorial-hand-y, 0px) + 4px), 0);
  }

  64% {
    transform: translate3d(calc(var(--tutorial-hand-x, 0px) + var(--tutorial-drag-x, 0px)), calc(var(--tutorial-hand-y, 0px) + var(--tutorial-drag-y, 0px)), 0);
  }

  78% {
    transform: translate3d(calc(var(--tutorial-hand-x, 0px) + var(--tutorial-drag-x, 0px)), calc(var(--tutorial-hand-y, 0px) + var(--tutorial-drag-y, 0px)), 0);
  }

  94% {
    transform: translate3d(var(--tutorial-hand-x, 0px), var(--tutorial-hand-y, 0px), 0);
  }
}

/* v5: recoverable trash slot */
.trash-slot.merge-slot {
  --trash-size: clamp(48px, 6.2vw, 128px);
  --slot-size: var(--trash-size);
  --tier-accent: #ff6d7a;
  --tier-glow: rgba(255, 109, 122, 0.24);
  --tier-panel: rgba(52, 20, 34, 0.92);
  --tier-floor: rgba(18, 8, 18, 0.96);
  position: absolute;
  left: -32px;
  bottom: calc(36px + env(safe-area-inset-bottom));
  z-index: 16;
  width: var(--trash-size);
  height: var(--trash-size);
  padding: 3px;
  border-color: #7d2a42;
  pointer-events: auto;
  display: grid;
  place-items: center;
  overflow: visible;
}

.trash-slot.merge-slot::before {
  inset: 5px;
}

.trash-slot__icon {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: rgba(255, 224, 224, 0.86);
  pointer-events: none;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.55));
}

.trash-slot__icon svg {
  width: 52%;
  height: 52%;
  display: block;
}

.trash-slot.has-sword .trash-slot__icon {
  opacity: 0.24;
}

.trash-slot.merge-slot img {
  z-index: 3;
  width: 68%;
  height: 68%;
}

.trash-slot.is-empty {
  opacity: 0.82;
  filter: grayscale(0.16) brightness(0.9);
}

.trash-slot.is-drop-target {
  border-color: #ff9dac;
  filter: brightness(1.14);
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.08),
    inset -3px -3px 0 rgba(0, 0, 0, 0.28),
    0 0 0 2px rgba(255, 157, 172, 0.28),
    0 0 24px rgba(255, 109, 122, 0.25),
    4px 4px 0 rgba(4, 6, 12, 0.52);
}

.gold-collector-dock {
  --table-buy-height: clamp(54px, 7.2vh, 76px);
  --table-buy-title-size: clamp(10px, 1vw, 13px);
  --table-buy-main-size: clamp(14px, 1.55vw, 21px);
  --table-buy-level-size: clamp(9px, 0.92vw, 12px);
  --table-buy-main-icon-size: clamp(15px, 1.7vw, 22px);
  position: absolute;
  left: max(8px, env(safe-area-inset-left));
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 22;
  width: clamp(116px, 12vw, 154px);
  height: var(--table-buy-height);
  grid-template-areas:
    "level level"
    "label label"
    "sword value";
  row-gap: 2px;
  pointer-events: auto;
  transform-origin: left bottom;
}

.gold-collector-dock.locked {
  opacity: 0.68;
}

.gold-collector-dock .merge-buy-button__label {
  display: block;
  grid-area: label;
  justify-self: center;
  text-align: center;
  font-size: clamp(8px, 0.85vw, 11px);
  white-space: nowrap;
}

.gold-collector-dock .merge-buy-button__icon {
  grid-area: sword;
}

.gold-collector-dock .merge-buy-button__value {
  grid-area: value;
}

@media (max-width: 720px), (max-height: 560px) and (orientation: landscape) {
  .side-panel-view[data-panel="upgrades"].is-active,
  .side-panel-view[data-panel="achievements"].is-active,
  .side-panel-view[data-panel="settings"].is-active {
    gap: 5px;
  }

  .side-panel-view[data-panel="upgrades"].is-active .side-ui-title,
  .side-panel-view[data-panel="achievements"].is-active .side-ui-title,
  .side-panel-view[data-panel="settings"].is-active .side-ui-title {
    font-size: clamp(16px, 5.6vw, 24px);
    line-height: 0.9;
    margin-bottom: 0;
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-list,
  .side-panel-view[data-panel="achievements"].is-active .badge-list,
  .side-panel-view[data-panel="settings"].is-active .settings-list {
    gap: 6px;
    padding-top: 4px;
    padding-right: 2px;
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-group {
    gap: 4px;
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-group-title {
    width: fit-content;
    padding: 4px 7px 3px;
    border-width: 2px;
    font-size: clamp(9px, 2.9vw, 12px);
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-row {
    grid-template-columns: minmax(0, 1fr) clamp(68px, 24vw, 92px);
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-card {
    min-height: 42px;
    padding: 6px 7px;
    border-width: 2px;
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-card strong {
    font-size: clamp(10px, 3.2vw, 14px);
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-line {
    gap: 4px;
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-chip {
    padding: 3px 4px 2px;
    border-width: 1px;
    font-size: clamp(7px, 2.3vw, 9px);
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-chip--value {
    display: none;
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-buy {
    min-width: 0;
    min-height: 42px;
    padding: 5px 5px;
    border-width: 2px;
    gap: 3px;
    font-size: clamp(11px, 3.4vw, 15px);
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-buy__value {
    font-size: clamp(12px, 4vw, 17px);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-buy__icon {
    width: clamp(10px, 3.6vw, 15px);
    height: clamp(10px, 3.6vw, 15px);
  }

  .achievement-panel {
    gap: 6px;
  }

  .badge-summary {
    min-height: 34px;
    gap: 5px;
    padding: 5px 6px 4px;
    border-width: 2px;
  }

  .badge-summary strong {
    font-size: clamp(11px, 3.8vw, 15px);
  }

  .badge-summary span {
    max-width: clamp(72px, 26vw, 110px);
    padding: 3px 4px 2px;
    border-width: 1px;
    font-size: clamp(6px, 2.2vw, 9px);
  }

  .badge-row {
    grid-template-columns: minmax(0, 1fr) clamp(58px, 22vw, 88px);
    min-height: 42px;
    gap: 5px;
    padding: 5px;
    border-width: 2px;
  }

  .badge-row__body {
    gap: 1px;
  }

  .badge-row__body strong {
    font-size: clamp(9px, 3vw, 12px);
  }

  .badge-row__body small {
    font-size: clamp(6px, 2.2vw, 8px);
  }

  .badge-row__reward {
    min-height: 28px;
    padding: 3px 4px 2px;
    border-width: 1px;
    font-size: clamp(6px, 2.15vw, 8px);
  }

  .settings-list {
    gap: 6px;
  }

  .setting-row {
    min-height: 42px;
    grid-template-columns: minmax(0, 1fr) minmax(44px, auto);
    gap: 5px;
    padding: 5px 6px;
    border-width: 2px;
    font-size: clamp(11px, 3.4vw, 15px);
  }

  .setting-row strong {
    min-width: clamp(42px, 14vw, 58px);
    padding: 0.24em 0.34em 0.2em;
    border-width: 1px;
    font-size: 0.8em;
  }

  .setting-row--range {
    gap: 5px;
  }

  .setting-row__head,
  .setting-row__controls {
    gap: 5px;
  }

  .setting-slider {
    height: 24px;
  }

  .setting-slider::-webkit-slider-runnable-track {
    height: 12px;
    border-width: 1px;
  }

  .setting-slider::-webkit-slider-thumb {
    width: 16px;
    height: 24px;
    margin-top: -7px;
    border-width: 2px;
  }

  .setting-slider::-moz-range-track,
  .setting-slider::-moz-range-progress {
    height: 12px;
    border-width: 1px;
  }

  .setting-slider::-moz-range-thumb {
    width: 16px;
    height: 24px;
    border-width: 2px;
  }

  .setting-mute-button {
    min-width: 56px;
    min-height: 28px;
    padding: 0.28em 0.4em 0.22em;
    border-width: 2px;
    font-size: clamp(9px, 2.8vw, 12px);
  }
}

/* v5: crate affordability states */
.merge-crate-info {
  grid-template-rows: auto auto;
  gap: 3px;
}

.merge-crate-option--simple::after {
  content: "";
  position: absolute;
  top: clamp(5px, 1.1cqh, 8px);
  right: clamp(5px, 1.1cqh, 8px);
  width: clamp(8px, 3.7cqw, 12px);
  height: clamp(8px, 3.7cqw, 12px);
  border: 2px solid rgba(255, 236, 190, 0.96);
  background: #ff344c;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.18),
    inset -2px -2px 0 rgba(0, 0, 0, 0.26),
    0 0 0 2px rgba(28, 11, 22, 0.78);
  opacity: 0;
  transform: scale(0.65);
  transform-origin: center;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 5;
}

.merge-crate-option--simple.is-crate-ready::after {
  opacity: 1;
  transform: scale(1);
  animation: crate-ready-pulse 0.9s steps(2) infinite;
}

.merge-crate-option--simple:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  border-color: rgba(155, 132, 184, 0.68);
  filter: saturate(0.62);
}

.merge-crate-price__old {
  opacity: 0.68;
  font-size: 0.76em;
  text-decoration: line-through;
  color: #c7b9e8;
}

/* v5: Badges panel */
.achievement-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
}

.badge-summary {
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 3px solid #8d5cff;
  background: linear-gradient(180deg, rgba(65, 39, 105, 0.96), rgba(18, 12, 34, 0.96));
  color: #fff4d2;
  font-family: var(--ui-font);
  text-transform: uppercase;
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.08),
    inset -4px -4px 0 rgba(0, 0, 0, 0.24),
    5px 5px 0 rgba(4, 6, 12, 0.46);
}

.badge-summary strong,
.badge-summary span,
.badge-row strong,
.badge-row small,
.badge-row__reward {
  text-shadow:
    2px 0 0 #090512,
    -2px 0 0 #090512,
    0 2px 0 #090512,
    0 -2px 0 #090512,
    2px 2px 0 rgba(0, 0, 0, 0.72);
}

.badge-summary strong {
  font-size: clamp(16px, 2.2vw, 24px);
}

.badge-summary span {
  min-width: 0;
  max-width: clamp(120px, 16vw, 210px);
  padding: 5px 8px 4px;
  border: 2px solid #bfa4ff;
  background: rgba(12, 8, 24, 0.74);
  color: #ffe8a6;
  font-size: clamp(9px, 1.15vw, 14px);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: #9c5cff rgba(20, 11, 39, 0.5);
  padding-right: 2px;
}

.badge-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(82px, 11vw, 130px);
  gap: 8px;
  align-items: center;
  min-height: clamp(58px, 7.6vh, 74px);
  padding: 8px;
  border: 3px solid #4f3a69;
  background: linear-gradient(180deg, rgba(39, 27, 60, 0.94), rgba(14, 10, 27, 0.96));
  color: #d8c9fb;
  font-family: var(--ui-font);
  text-transform: uppercase;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.05),
    inset -3px -3px 0 rgba(0, 0, 0, 0.2),
    4px 4px 0 rgba(4, 6, 12, 0.42);
}

.badge-row.is-unlocked {
  border-color: #ffe08a;
  background:
    linear-gradient(135deg, rgba(255, 224, 138, 0.14), transparent 45%),
    linear-gradient(180deg, rgba(71, 47, 87, 0.96), rgba(18, 12, 34, 0.96));
}

.badge-row.is-claimed {
  border-color: #60d994;
}

.badge-row.is-claimable {
  border-color: #ffd166;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.08),
    inset -3px -3px 0 rgba(0, 0, 0, 0.22),
    0 0 0 2px rgba(255, 209, 102, 0.18),
    4px 4px 0 rgba(4, 6, 12, 0.42);
}

.badge-row__body {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.badge-row__body strong {
  min-width: 0;
  color: #f5edff;
  font-size: clamp(11px, 1.65vw, 16px);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-row__body small {
  min-width: 0;
  color: #bcaee1;
  font-size: clamp(8px, 1.2vw, 11px);
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-row__reward {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 34px;
  padding: 5px 7px 4px;
  border: 2px solid #6d557f;
  background: rgba(10, 7, 20, 0.72);
  color: #ffe8a6;
  font-family: var(--ui-font);
  font-size: clamp(8px, 1.15vw, 11px);
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-row__reward:disabled {
  cursor: default;
}

.badge-row.is-claimable .badge-row__reward {
  border: 2px solid #fff0a5;
  background: linear-gradient(180deg, #ffd166, #b86e13);
  color: #ffffff;
  cursor: pointer;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.18),
    3px 3px 0 rgba(4, 6, 12, 0.52);
}

.badge-row.is-claimed .badge-row__reward {
  border-color: rgba(96, 217, 148, 0.72);
  color: #b9ffd6;
}

.badge-row.is-claimable .badge-row__reward:active {
  transform: translate(1px, 1px);
}

.reward-ad-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: auto;
  background: rgba(4, 3, 10, 0.86);
}

.reward-ad-panel {
  width: min(420px, 92vw);
  min-height: 260px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 16px;
  padding: 28px;
  border: 4px solid #ffd166;
  background: linear-gradient(180deg, rgba(42, 28, 65, 0.98), rgba(14, 10, 27, 0.98));
  box-shadow:
    inset 4px 4px 0 rgba(255, 255, 255, 0.1),
    inset -5px -5px 0 rgba(0, 0, 0, 0.3),
    8px 8px 0 rgba(4, 6, 12, 0.72);
  color: #fff6d8;
  font-family: var(--ui-font);
  text-align: center;
}

.reward-ad-panel--confirm {
  min-height: 220px;
  gap: 20px;
}

.reward-ad-panel strong {
  font-size: clamp(28px, 7vw, 44px);
  line-height: 0.95;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.45);
}

.reward-ad-panel span {
  font-size: clamp(18px, 4vw, 25px);
  color: #d9c7ff;
}

.reward-ad-actions {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.reward-ad-countdown {
  width: 82px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 3px solid #f0dcff;
  background: linear-gradient(180deg, #6f3bb3, #2a164a);
  box-shadow: 5px 5px 0 rgba(4, 6, 12, 0.58);
  font-size: 42px;
  color: #ffffff;
}

.reward-ad-claim {
  min-width: 190px;
  padding: 12px 18px 10px;
  border: 3px solid #fff0a5;
  background: linear-gradient(180deg, #ffd166, #b86e13);
  box-shadow: 5px 5px 0 rgba(4, 6, 12, 0.62);
  color: #2b1607;
  font: inherit;
  font-size: 22px;
  cursor: pointer;
}

.reward-ad-claim--secondary {
  border-color: rgba(217, 199, 255, 0.86);
  background: linear-gradient(180deg, #4f3a78, #211638);
  color: #f2eaff;
}

.reward-ad-claim:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.45);
}


/* Boot loading overlay -------------------------------------------------- */
.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #f7e8b4;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 211, 109, 0.08), transparent 34%),
    radial-gradient(circle at 50% 60%, rgba(93, 145, 255, 0.07), transparent 40%),
    #020204;
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transition: opacity 700ms cubic-bezier(.22, 1, .36, 1), visibility 700ms linear;
}

.boot-loader::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 18px 18px;
  mask-image: radial-gradient(circle at center, black 0 45%, transparent 80%);
  opacity: 0.55;
}

.boot-loader::after {
  content: "";
  position: absolute;
  inset: -10% 0;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.055), transparent);
  transform: translateY(-70%);
  animation: bootScan 2.2s linear infinite;
  opacity: 0.5;
}

.boot-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-loader__glow {
  position: absolute;
  width: min(78vw, 520px);
  aspect-ratio: 1;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 211, 109, 0.14), transparent 58%);
  filter: blur(8px);
  animation: bootGlow 1.8s ease-in-out infinite alternate;
}

.boot-loader__panel {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 12px;
  min-width: min(82vw, 380px);
  padding: 28px 30px 26px;
  border: 2px solid rgba(255, 211, 109, 0.28);
  background:
    linear-gradient(180deg, rgba(17, 18, 28, 0.92), rgba(5, 6, 10, 0.96)),
    #08090d;
  box-shadow:
    0 0 0 4px rgba(0, 0, 0, 0.45),
    0 18px 70px rgba(0, 0, 0, 0.68),
    inset 0 0 32px rgba(255, 211, 109, 0.045);
}

.boot-loader__crest {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  color: #ffd36d;
  border: 2px solid rgba(255, 211, 109, 0.38);
  background: rgba(255, 211, 109, 0.07);
  box-shadow: 0 0 28px rgba(255, 211, 109, 0.14);
  animation: bootCrestPulse 900ms steps(2, end) infinite;
}

.boot-loader__crest svg {
  width: 34px;
  height: 34px;
}

.boot-loader__title {
  letter-spacing: 0.16em;
  font-size: clamp(18px, 4vw, 25px);
  font-weight: 900;
  text-shadow: 0 2px 0 #000, 0 0 18px rgba(255, 211, 109, 0.22);
}

.boot-loader__subtitle,
.boot-loader__hint {
  color: rgba(247, 232, 180, 0.72);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.boot-loader__hint {
  color: rgba(247, 232, 180, 0.46);
  font-size: 10px;
}

.boot-loader__bar {
  width: min(260px, 62vw);
  height: 10px;
  padding: 2px;
  border: 1px solid rgba(255, 211, 109, 0.32);
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.boot-loader__bar span {
  display: block;
  width: 38%;
  height: 100%;
  background: linear-gradient(90deg, rgba(255, 211, 109, 0.28), #ffd36d, rgba(255, 211, 109, 0.28));
  box-shadow: 0 0 16px rgba(255, 211, 109, 0.38);
  animation: bootBar 1.05s ease-in-out infinite;
}

@keyframes bootBar {
  0% { transform: translateX(-115%); }
  100% { transform: translateX(280%); }
}

@keyframes bootScan {
  0% { transform: translateY(-72%); }
  100% { transform: translateY(72%); }
}

@keyframes bootGlow {
  from { transform: scale(0.92); opacity: 0.45; }
  to { transform: scale(1.04); opacity: 0.78; }
}

@keyframes bootCrestPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  .boot-loader,
  .boot-loader__bar span,
  .boot-loader::after,
  .boot-loader__glow,
  .boot-loader__crest {
    animation: none !important;
    transition-duration: 200ms;
  }
}

@media (max-width: 720px), (max-height: 560px) and (orientation: landscape) {
  .side-panel-view[data-panel="upgrades"].is-active .upgrade-row {
    grid-template-columns: minmax(0, 1fr) clamp(68px, 24vw, 92px);
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-card {
    min-height: 42px;
    padding: 6px 7px;
    border-width: 2px;
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-card strong {
    font-size: clamp(10px, 3.2vw, 14px);
  }

  .side-panel-view[data-panel="upgrades"].is-active .upgrade-buy {
    min-width: 0;
    min-height: 42px;
    padding: 5px;
    border-width: 2px;
    gap: 3px;
    font-size: clamp(11px, 3.4vw, 15px);
  }

  .achievement-panel {
    gap: 6px;
  }

  .badge-summary {
    min-height: 34px;
    gap: 5px;
    padding: 5px 6px 4px;
    border-width: 2px;
  }

  .badge-summary strong {
    font-size: clamp(11px, 3.8vw, 15px);
  }

  .badge-summary span {
    max-width: clamp(72px, 26vw, 110px);
    padding: 3px 4px 2px;
    border-width: 1px;
    font-size: clamp(6px, 2.2vw, 9px);
  }

  .badge-row {
    grid-template-columns: minmax(0, 1fr) clamp(58px, 22vw, 88px);
    min-height: 42px;
    gap: 5px;
    padding: 5px;
    border-width: 2px;
  }

  .badge-row__body strong {
    font-size: clamp(9px, 3vw, 12px);
  }

  .badge-row__body small {
    font-size: clamp(6px, 2.2vw, 8px);
  }

  .badge-row__reward {
    min-height: 28px;
    padding: 3px 4px 2px;
    border-width: 1px;
    font-size: clamp(6px, 2.15vw, 8px);
  }

  .setting-row {
    min-height: 42px;
    grid-template-columns: minmax(0, 1fr) minmax(44px, auto);
    gap: 5px;
    padding: 5px 6px;
    border-width: 2px;
    font-size: clamp(11px, 3.4vw, 15px);
  }

  .setting-row strong {
    min-width: clamp(42px, 14vw, 58px);
    padding: 0.24em 0.34em 0.2em;
    border-width: 1px;
    font-size: 0.8em;
  }

  .setting-mute-button {
    min-width: 56px;
    min-height: 28px;
    padding: 0.28em 0.4em 0.22em;
    border-width: 2px;
    font-size: clamp(9px, 2.8vw, 12px);
  }
}

.side-ui:has(.side-panel-view[data-panel="table"].is-active),
.side-ui:has(.side-panel-view[data-panel="table"].is-active) .side-panel,
.side-ui:has(.side-panel-view[data-panel="table"].is-active) .side-ui-body,
.side-ui:has(.side-panel-view[data-panel="table"].is-active) .side-content,
.side-ui:has(.side-panel-view[data-panel="table"].is-active) .side-panel-view[data-panel="table"].is-active {
  overflow: visible;
}
