@property --ix {
  syntax: "<number>";
  inherits: true;
  initial-value: 54;
}
@property --iy {
  syntax: "<number>";
  inherits: true;
  initial-value: 50;
}

:root {
  --bg: #05070a;
  --text-1: #f2efe9;
  --text-2: #a6abb3;
  --text-3: #5f646c;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.2);
  --warm: 255, 196, 128;
  --up: #7ee08f;
  --down: #ff6b5e;

  --r-common: #b4bac3;
  --r-uncommon: #6fd08c;
  --r-rare: #5aa8ff;
  --r-epic: #b57bff;
  --r-legendary: #ffb547;

  --font-display: "Barlow Condensed", "Noto Sans JP", sans-serif;
  --font-ui: "Barlow", "Noto Sans JP", sans-serif;
  --font-jp: "Noto Sans JP", "Barlow", sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);

}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-jp);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: none;
}

kbd.key {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 5px;
  background: linear-gradient(180deg, #2b3038, #15181d);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 2px 0 #000;
  font: 700 15px/1 var(--font-display);
  letter-spacing: 0.04em;
  color: var(--text-1);
}

/* =========================================================================================== */
/* World layers                                                                                */

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  transition: --ix 0.9s var(--ease-out), --iy 0.9s var(--ease-out);
}

.scene {
  position: absolute;
  inset: -40px;
  z-index: -2;
  background: radial-gradient(90% 75% at calc(var(--ix) * 1%) 35%, #131a24 0%, #080b11 55%, var(--bg) 100%);
}
.scene-fog {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(40% 30% at 20% 70%, rgba(70, 90, 120, 0.08), transparent 70%),
    radial-gradient(35% 25% at 80% 30%, rgba(70, 90, 120, 0.06), transparent 70%);
  animation: fog-drift 26s var(--ease-io) infinite alternate;
}
@keyframes fog-drift {
  to { background-position: 6% -4%, -5% 3%; opacity: 0.7; }
}

.scene-light {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(20% 44% at calc(var(--ix) * 1%) calc(var(--iy) * 1% - 8%), rgba(var(--warm), 0.15), transparent 70%),
    conic-gradient(from 180deg at calc(var(--ix) * 1%) -12%, transparent 170deg, rgba(var(--warm), 0.045) 176.5deg, rgba(var(--warm), 0.06) 180deg, rgba(var(--warm), 0.045) 183.5deg, transparent 190deg);
}

.scene-floor {
  position: absolute;
  left: -50%;
  width: 200%;
  top: calc(var(--iy) * 1% + var(--floor-drop, 26vh));
  height: 90vh;
  transform: perspective(520px) rotateX(77deg);
  transform-origin: 50% 0;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 80px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 80px);
  -webkit-mask-image: radial-gradient(26% 55% at calc((var(--ix) + 50) / 2 * 1%) 0%, #000, transparent);
  mask-image: radial-gradient(26% 55% at calc((var(--ix) + 50) / 2 * 1%) 0%, #000, transparent);
}

.scene-ring {
  position: absolute;
  left: calc(var(--ix) * 1%);
  top: calc(var(--iy) * 1% + var(--floor-drop, 26vh));
  width: var(--ring-w, 48vh);
  aspect-ratio: 5 / 1;
  transform: translate(-50%, -50%);
}
.scene-ring i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}
.scene-ring i:nth-child(1) {
  background: radial-gradient(closest-side, rgba(var(--warm), 0.2), rgba(var(--warm), 0.05) 60%, transparent);
}
.scene-ring i:nth-child(2) {
  inset: 18% 22%;
  border: 1px solid rgba(var(--warm), 0.22);
}
.scene-ring i:nth-child(3) {
  border: 1px solid rgba(var(--warm), 0.45);
  opacity: 0;
}
.scene-ring.is-pulse i:nth-child(3) {
  animation: ring-pulse 1.1s var(--ease-out);
}
@keyframes ring-pulse {
  from { opacity: 0.9; transform: scale(0.35); }
  to { opacity: 0; transform: scale(1.3); }
}

.stage-canvas,
.fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.stage-canvas {
  z-index: 0;
  cursor: grab;
  touch-action: none;
}
.stage-canvas.is-dragging {
  cursor: grabbing;
}
.fx-canvas {
  z-index: 1;
  pointer-events: none;
  mix-blend-mode: screen;
}

/* Scrims behind the HUD columns + vignette */
.grade {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(120% 95% at 50% 48%, transparent 58%, rgba(0, 0, 0, 0.72) 100%),
    linear-gradient(90deg, rgba(5, 7, 10, 0.82) 0%, rgba(5, 7, 10, 0.4) 30%, transparent 42%, transparent 64%, rgba(5, 7, 10, 0.55) 76%, rgba(5, 7, 10, 0.85) 100%);
  transition: opacity 0.6s var(--ease-out);
}
.app[data-mode="inspect"] .grade {
  opacity: 0.35;
}

.letterbox {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 8;
  height: 11%;
  background: #000;
  pointer-events: none;
  transition: transform 0.7s var(--ease-io);
}
.letterbox-top {
  top: 0;
  transform: translateY(-100%);
}
.letterbox-bottom {
  bottom: 0;
  transform: translateY(100%);
}
.app[data-mode="inspect"] .letterbox {
  transform: none;
}

.boot-cover {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: #000;
  pointer-events: none;
  transition: opacity 1.1s var(--ease-io) 0.1s;
}
.app:not([data-booting]) .boot-cover {
  opacity: 0;
}

/* =========================================================================================== */
/* HUD frame: designed at 1920×1080 (landscape) / 430 wide (portrait); JS sets size + scale.   */

.hud {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  width: calc(var(--fw, 1920) * 1px);
  height: calc(var(--fh, 1080) * 1px);
  transform: scale(var(--s, 1));
  transform-origin: 0 0;
  pointer-events: none;
}
.hud > * {
  pointer-events: auto;
}

/* Slide-in choreography (boot) and slide-out (inspect) */
.topbar,
.left,
.detail,
.prompts {
  transition: transform 0.7s var(--ease-out), opacity 0.5s var(--ease-out);
}
.app[data-booting] .topbar,
.app[data-mode="inspect"] .topbar {
  transform: translateY(-30px);
  opacity: 0;
  pointer-events: none;
}
.app[data-booting] .left,
.app[data-mode="inspect"] .left {
  transform: translateX(-60px);
  opacity: 0;
  pointer-events: none;
}
.app[data-booting] .detail,
.app[data-mode="inspect"] .detail {
  transform: translateX(60px);
  opacity: 0;
  pointer-events: none;
}
.app[data-booting] .prompts {
  opacity: 0;
}
.app.is-revealing .topbar { transition-delay: 0.25s; }
.app.is-revealing .left { transition-delay: 0.4s; }
.app.is-revealing .detail { transition-delay: 0.55s; }
.app.is-revealing .prompts { transition-delay: 0.7s; }

/* ------------------------------------------------------------------------------------------ */
/* Top bar                                                                                     */

.topbar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 104px;
  padding: 0 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar::after {
  content: "";
  position: absolute;
  left: 80px;
  right: 80px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong) 12%, var(--line-strong) 88%, transparent);
}

.hub {
  display: flex;
  gap: 52px;
  height: 100%;
}
.hub-tab {
  position: relative;
  display: flex;
  align-items: center;
  font: 500 20px/1 var(--font-jp);
  letter-spacing: 0.2em;
  color: var(--text-3);
}
.hub-tab.is-active {
  color: var(--text-1);
  font-weight: 700;
}
.hub-tab.is-active::after {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  bottom: -1px;
  height: 2px;
  background: var(--text-1);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.6);
}

.wallet {
  display: flex;
  align-items: center;
  gap: 48px;
}
.wallet-gold {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 600 34px/1 var(--font-display);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.wallet-gold svg {
  width: 28px;
  height: 28px;
  color: rgb(var(--warm));
  filter: drop-shadow(0 0 6px rgba(var(--warm), 0.5));
}
.wallet-weight {
  display: grid;
  gap: 10px;
  width: 210px;
}
.wallet-weight-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 18px;
  letter-spacing: 0.14em;
  color: var(--text-2);
}
.wallet-weight-row b {
  font: 600 24px/1 var(--font-display);
  letter-spacing: 0.04em;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}
.wallet-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
}
.wallet-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--text-1);
  transition: width 1.1s var(--ease-out) 0.8s;
}

/* ------------------------------------------------------------------------------------------ */
/* Left column: categories + grid                                                              */

.left {
  position: absolute;
  left: 80px;
  top: 136px;
  bottom: 96px;
  width: 676px;
  display: flex;
  flex-direction: column;
}

.cats {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
}
.cat-list {
  position: relative;
  display: flex;
  height: 100%;
}
.cat {
  position: relative;
  display: flex;
  align-items: center;
  flex: none;
  gap: 7px;
  height: 100%;
  padding: 0 10px;
  font: 500 17px/1 var(--font-jp);
  letter-spacing: 0.12em;
  white-space: nowrap;
  color: var(--text-3);
  transition: color 0.25s var(--ease-out);
}
.cat svg {
  width: 24px;
  height: 24px;
  flex: none;
}
.cat:hover {
  color: var(--text-2);
}
.cat[aria-selected="true"] {
  color: var(--text-1);
}
.cat-count {
  font: 600 17px/1 var(--font-display);
  letter-spacing: 0.04em;
  opacity: 0.6;
}
.cat-indicator {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  background: var(--text-1);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.7);
  transition: transform 0.45s var(--ease-out), width 0.45s var(--ease-out);
}

.grid-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 58px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}
.grid-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font: 700 19px/1 var(--font-jp);
  letter-spacing: 0.14em;
}
.grid-title b {
  font: 600 19px/1 var(--font-display);
  color: var(--text-3);
  letter-spacing: 0.06em;
}
.sort {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  letter-spacing: 0.1em;
  color: var(--text-2);
}
.sort b {
  font-weight: 700;
  color: var(--text-1);
}
.sort:hover b {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.grid-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: -8px -16px 0;
  padding: 8px 16px 0;
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 64px), transparent);
  mask-image: linear-gradient(180deg, #000 calc(100% - 64px), transparent);
}
.grid {
  --tile: 104px;
  --gap: 10px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, var(--tile));
  grid-auto-rows: var(--tile);
  gap: var(--gap);
  height: calc(100% + 8px);
  overflow-y: auto;
  padding: 16px 16px 64px;
  margin: -8px -16px 0;
  scrollbar-width: none;
  overscroll-behavior: contain;
}
.grid::-webkit-scrollbar {
  display: none;
}
.grid.is-switching {
  animation: grid-switch 0.45s var(--ease-out);
}
@keyframes grid-switch {
  from { opacity: 0; transform: translateX(calc(var(--dir, 1) * 28px)); }
}

.tile {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  background:
    linear-gradient(180deg, transparent 35%, color-mix(in srgb, var(--rarity) 30%, transparent) 100%),
    radial-gradient(80% 70% at 50% 40%, color-mix(in srgb, var(--rarity) 12%, #1b2028), #0e1116);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 18px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
  animation: tile-in 0.5s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 14ms + var(--base-delay, 0ms));
}
@keyframes tile-in {
  from { opacity: 0; transform: translateY(12px) scale(0.94); }
}
.tile.is-empty {
  background: rgba(12, 15, 20, 0.6);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.tile.is-empty::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.015) 0 2px, transparent 2px 8px);
}
.tile:not(.is-empty)::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 38%);
  pointer-events: none;
}

.tile-thumb {
  position: absolute;
  inset: 3%;
  width: 94%;
  height: 94%;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.6));
  opacity: 0;
  transform: scale(0.88);
  transition: opacity 0.45s var(--ease-out), transform 0.45s var(--ease-out);
  pointer-events: none;
}
.tile-thumb.is-ready {
  opacity: 1;
  transform: none;
}
.tile-wrap.is-selected .tile-thumb.is-ready {
  transform: scale(1.07);
}
.tile-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  z-index: 3;
  background: var(--rarity);
  box-shadow: 0 0 10px var(--rarity);
}
.tile-power {
  position: absolute;
  left: 8px;
  bottom: 9px;
  z-index: 3;
  font: 700 19px/1 var(--font-display);
  letter-spacing: 0.02em;
  text-shadow: 0 1px 3px #000, 0 0 10px #000;
}
.tile-equipped {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--text-1) 50%, transparent 50%);
}
.tile-equipped::after {
  content: "E";
  position: absolute;
  left: 5px;
  top: 3px;
  font: 700 12px/1 var(--font-display);
  color: var(--bg);
}
.tile-new {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 3;
  width: 8px;
  height: 8px;
  background: rgb(var(--warm));
  transform: rotate(45deg);
  box-shadow: 0 0 10px rgba(var(--warm), 0.9);
  animation: new-blink 1.6s var(--ease-io) infinite alternate;
}
@keyframes new-blink {
  to { opacity: 0.35; }
}
.tile-glint {
  position: absolute;
  inset: -20%;
  z-index: 2;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.14) 50%, transparent 58%);
  transform: translateX(-100%);
  pointer-events: none;
}
.tile-wrap.is-selected .tile-glint {
  transform: translateX(100%);
  transition: transform 0.75s var(--ease-out);
}
.tile.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.06) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}
.tile-missing {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.22);
}
.tile-missing svg {
  width: 34px;
  height: 34px;
}

.tile-wrap {
  position: relative;
}
.tile-wrap > .tile {
  position: absolute;
  inset: 0;
}
.tile-wrap.is-selected > .tile {
  transform: scale(1.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3), 0 12px 24px rgba(0, 0, 0, 0.5);
}

@media (hover: hover) and (pointer: fine) {
  .tile-wrap:not(.is-selected):hover > .tile {
    transform: scale(1.02);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), 0 10px 20px rgba(0, 0, 0, 0.45);
  }
}

/* One cursor that glides between tiles. */
.cursor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  width: calc(var(--tile) + 10px);
  height: calc(var(--tile) + 10px);
  margin: -5px 0 0 -5px;
  border: 2px solid #fff;
  border-radius: 6px;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.32), inset 0 0 14px rgba(255, 255, 255, 0.12);
  pointer-events: none;
  opacity: 0;
  transition: transform 0.2s var(--ease-out), opacity 0.2s;
  animation: cursor-breathe 2.2s var(--ease-io) infinite alternate;
}
.cursor.is-visible {
  opacity: 1;
}
.cursor i {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 0 solid #fff;
}
.cursor i:nth-child(1) { left: -8px; top: -8px; border-top-width: 2px; border-left-width: 2px; }
.cursor i:nth-child(2) { right: -8px; top: -8px; border-top-width: 2px; border-right-width: 2px; }
.cursor i:nth-child(3) { left: -8px; bottom: -8px; border-bottom-width: 2px; border-left-width: 2px; }
.cursor i:nth-child(4) { right: -8px; bottom: -8px; border-bottom-width: 2px; border-right-width: 2px; }
@keyframes cursor-breathe {
  to { box-shadow: 0 0 28px rgba(255, 255, 255, 0.48), inset 0 0 18px rgba(255, 255, 255, 0.2); }
}

/* ------------------------------------------------------------------------------------------ */
/* Detail column                                                                               */

.detail {
  position: absolute;
  right: 80px;
  top: 150px;
  bottom: 110px;
  width: 560px;
  overflow: hidden auto;
  scrollbar-width: none;
  overscroll-behavior: contain;
}
.detail::-webkit-scrollbar {
  display: none;
}

.d-rarity {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 700 18px/1 var(--font-jp);
  letter-spacing: 0.2em;
  color: color-mix(in srgb, var(--rarity) 82%, #fff);
}
.d-rarity i {
  width: 8px;
  height: 8px;
  background: currentColor;
  transform: rotate(45deg);
  box-shadow: 0 0 10px currentColor;
}
.d-rarity span {
  color: var(--text-2);
  font-weight: 500;
  letter-spacing: 0.14em;
}
.d-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--rarity) 60%, transparent), transparent);
}

.d-name {
  position: relative;
  margin: 16px 0 0;
  font: 900 54px/1.2 var(--font-jp);
  letter-spacing: 0.05em;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  animation: name-wipe 0.65s var(--ease-out) both;
}
@keyframes name-wipe {
  from { clip-path: inset(0 100% 0 0); transform: translateX(-10px); }
  to { clip-path: inset(0 -10% 0 0); }
}

.d-chips {
  display: flex;
  gap: 8px;
}
.d-chips:empty {
  display: none;
}
.chip {
  height: 30px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  font: 700 16px/1 var(--font-jp);
  letter-spacing: 0.16em;
  border-radius: 3px;
}
.chip-equipped {
  background: var(--text-1);
  color: var(--bg);
}
.chip-new {
  box-shadow: inset 0 0 0 1px rgba(var(--warm), 0.8);
  color: rgb(var(--warm));
}

.d-power {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  margin-top: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.d-power-main {
  display: grid;
  gap: 4px;
}
.d-power-label {
  font: 500 18px/1 var(--font-jp);
  letter-spacing: 0.18em;
  color: var(--text-2);
}
.d-power-value {
  font: 600 86px/0.9 var(--font-display);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 40px rgba(255, 255, 255, 0.15);
}
.d-power-cmp {
  display: grid;
  gap: 8px;
  padding-bottom: 10px;
}
.delta {
  font: 700 26px/1 var(--font-display);
  letter-spacing: 0.02em;
}
.delta.up {
  color: var(--up);
}
.delta.down {
  color: var(--down);
}
.delta.same {
  color: var(--text-3);
}
.d-vs {
  font-size: 17px;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.d-vs b {
  color: var(--text-2);
  font-weight: 500;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 36px;
  margin: 22px 0 0;
}
.stat {
  display: grid;
  grid-template-columns: 1fr auto 52px;
  align-items: baseline;
  column-gap: 8px;
  row-gap: 8px;
  animation: row-in 0.5s var(--ease-out) both;
  animation-delay: calc(var(--s) * 55ms + 160ms);
}
@keyframes row-in {
  from { opacity: 0; transform: translateX(-10px); }
}
.stat dt {
  font-size: 18px;
  letter-spacing: 0.08em;
  color: var(--text-2);
}
.stat dd {
  margin: 0;
  font: 700 26px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
}
.stat .delta {
  font-size: 18px;
  text-align: right;
}
.seg {
  position: relative;
  grid-column: 1 / -1;
  height: 8px;
  --segs: repeating-linear-gradient(90deg, #000 0 calc(5% - 2px), transparent calc(5% - 2px) 5%);
  -webkit-mask-image: var(--segs);
  mask-image: var(--segs);
  background: rgba(255, 255, 255, 0.1);
}
.seg > span {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  transition: width 0.85s var(--ease-out);
  transition-delay: calc(var(--s) * 60ms + 220ms);
}
.seg .seg-base {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.7), #fff);
}
.seg .seg-gain {
  background: var(--up);
  left: var(--from);
}
.seg .seg-loss {
  background: var(--down);
  left: var(--from);
  opacity: 0.85;
}

.perks {
  display: grid;
  gap: 16px;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.perk {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 4px 14px;
  align-items: center;
  animation: row-in 0.5s var(--ease-out) both;
  animation-delay: calc(var(--s) * 70ms + 300ms);
}
.perk-icon {
  grid-row: span 2;
  width: 34px;
  height: 34px;
  margin: 3px;
  transform: rotate(45deg);
  border: 1px solid color-mix(in srgb, var(--rarity) 70%, #fff);
  background: color-mix(in srgb, var(--rarity) 18%, transparent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--rarity) 35%, transparent);
  display: grid;
  place-items: center;
}
.perk-icon::after {
  content: "";
  width: 10px;
  height: 10px;
  background: color-mix(in srgb, var(--rarity) 80%, #fff);
}
.perk-name {
  font: 700 19px/1.25 var(--font-jp);
  letter-spacing: 0.08em;
}
.perk-desc {
  font-size: 17px;
  line-height: 1.55;
  color: var(--text-2);
  letter-spacing: 0.04em;
}

.d-desc {
  margin: 24px 0 0;
  padding-left: 16px;
  border-left: 2px solid var(--line-strong);
  font-size: 18px;
  line-height: 1.8;
  letter-spacing: 0.05em;
  color: var(--text-2);
  animation: row-in 0.6s var(--ease-out) 0.4s both;
}

.d-meta {
  display: flex;
  gap: 28px;
  margin-top: 22px;
  font-size: 17px;
  letter-spacing: 0.12em;
  color: var(--text-3);
}
.d-meta b {
  margin-left: 10px;
  font: 600 21px/1 var(--font-display);
  letter-spacing: 0.04em;
  color: var(--text-2);
}

/* ------------------------------------------------------------------------------------------ */
/* Prompts                                                                                     */

.prompts {
  position: absolute;
  left: 80px;
  right: 80px;
  bottom: 0;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 38px;
  font-size: 18px;
  letter-spacing: 0.08em;
  color: var(--text-2);
  border-top: 1px solid var(--line);
}
.app[data-mode="inspect"] .prompts {
  border-top-color: transparent;
  z-index: 10;
  height: calc(var(--fh, 1080) * 0.11px);
}
.prompt {
  display: flex;
  align-items: center;
  gap: 10px;
  transition: color 0.2s;
}
.prompt.is-button {
  cursor: pointer;
}
.prompt.is-button:hover {
  color: var(--text-1);
}
.prompt .key + .key {
  margin-left: -5px;
}
.mouse-glyph {
  width: 20px;
  height: 30px;
  color: var(--text-1);
}
.prompts-left {
  margin-right: auto;
}

/* ------------------------------------------------------------------------------------------ */
/* Inspect                                                                                     */

.inspect-title {
  position: absolute;
  left: 80px;
  bottom: calc(var(--fh, 1080) * 0.11px + 44px);
  display: grid;
  gap: 14px;
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: opacity 0.4s var(--ease-out), transform 0.6s var(--ease-out);
}
.app[data-mode="inspect"] .inspect-title {
  opacity: 1;
  transform: none;
  transition-delay: 0.35s;
}
.inspect-rarity {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 700 18px/1 var(--font-jp);
  letter-spacing: 0.2em;
  color: color-mix(in srgb, var(--rarity) 82%, #fff);
}
.inspect-rarity i {
  width: 8px;
  height: 8px;
  background: currentColor;
  transform: rotate(45deg);
  box-shadow: 0 0 10px currentColor;
}
.inspect-name {
  font: 900 64px/1.1 var(--font-jp);
  letter-spacing: 0.05em;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.7);
}

.inspect-close {
  position: absolute;
  right: 80px;
  top: calc(var(--fh, 1080) * 0.11px + 32px);
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(10, 12, 16, 0.6);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-out) 0.3s;
}
.inspect-close svg {
  width: 26px;
  height: 26px;
}
.inspect-close:hover {
  background: rgba(255, 255, 255, 0.14);
}
.app[data-mode="inspect"] .inspect-close {
  opacity: 1;
  pointer-events: auto;
}

.adjust {
  position: absolute;
  right: 80px;
  bottom: calc(var(--fh, 1080) * 0.11px + 44px);
  width: 360px;
  padding: 24px;
  display: grid;
  gap: 18px;
  background: rgba(10, 13, 17, 0.88);
  backdrop-filter: blur(14px);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  animation: pop-in 0.3s var(--ease-out);
}
.adjust[hidden] {
  display: none;
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px); }
}
.adjust-title {
  display: grid;
  gap: 8px;
  font: 700 19px/1 var(--font-jp);
  letter-spacing: 0.12em;
}
.adjust-title span {
  font: 500 15px/1 var(--font-ui);
  color: var(--text-3);
  letter-spacing: 0.02em;
}
.adjust-rows {
  display: grid;
  gap: 10px;
}
.adjust-row {
  display: grid;
  grid-template-columns: 84px 38px 1fr 38px;
  align-items: center;
  gap: 8px;
  font: 600 17px/1 var(--font-jp);
  letter-spacing: 0.12em;
  color: var(--text-2);
}
.adjust-row output {
  text-align: center;
  font: 600 22px/1 var(--font-display);
  color: var(--text-1);
}
.adjust-row button {
  height: 36px;
  font-size: 20px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.adjust-row button:hover {
  background: rgba(255, 255, 255, 0.14);
}
.adjust-actions {
  display: flex;
  gap: 10px;
}
.adjust-actions button {
  flex: 1;
  height: 44px;
  border-radius: 4px;
  font-size: 16px;
  letter-spacing: 0.1em;
}
.btn-solid {
  background: var(--text-1);
  color: var(--bg);
}
.btn-ghost {
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

/* Equip / notice banner */
.banner {
  position: absolute;
  left: 50%;
  top: 138px;
  min-width: 460px;
  padding: 18px 44px;
  text-align: center;
  font: 700 20px/1 var(--font-jp);
  letter-spacing: 0.16em;
  white-space: nowrap;
  background: linear-gradient(90deg, transparent, rgba(10, 13, 17, 0.9) 20%, rgba(10, 13, 17, 0.9) 80%, transparent);
  border-top: 1px solid;
  border-bottom: 1px solid;
  border-image: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent) 1;
  transform: translate(-50%, -12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-out), transform 0.35s var(--ease-out);
}
.banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------------------------------------ */
/* Stage messages / loader (viewport positioned at the item)                                   */

.stage-msg,
.loader {
  position: absolute;
  z-index: 4;
  left: calc(var(--ix) * 1%);
  top: calc(var(--iy) * 1%);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.stage-msg[hidden],
.loader[hidden] {
  display: none;
}
.stage-msg {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}
.stage-msg-icon {
  color: rgba(255, 255, 255, 0.25);
}
.stage-msg-icon svg {
  width: 64px;
  height: 64px;
}
.stage-msg-title {
  font: 700 18px/1 var(--font-jp);
  letter-spacing: 0.2em;
  color: var(--text-2);
}
.stage-msg-sub {
  font: 500 15px/1.7 var(--font-ui);
  color: var(--text-3);
}
.loader {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
}
.loader svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}
.loader circle {
  fill: none;
  stroke-width: 1.5;
}
.loader-track {
  stroke: rgba(255, 255, 255, 0.1);
}
.loader-arc {
  stroke: #fff;
  stroke-dasharray: 125.6;
  stroke-dashoffset: 125.6;
  transition: stroke-dashoffset 0.15s linear;
}
.loader.is-indeterminate .loader-arc {
  stroke-dashoffset: 90;
  transform-origin: 24px 24px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loader span {
  font: 600 13px/1 var(--font-display);
  color: var(--text-2);
}

/* Thumbnail → stage hand-off */
.ghost {
  position: fixed;
  z-index: 3;
  pointer-events: none;
  object-fit: contain;
}

.boot-error {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-content: center;
  gap: 14px;
  padding: 24px;
  background: var(--bg);
  text-align: center;
  font-size: 15px;
}
.boot-error[hidden] {
  display: none;
}
.boot-error code {
  display: inline-block;
  margin-top: 6px;
  padding: 10px 14px;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font: 500 13px/1 var(--font-ui);
  color: var(--text-2);
}

.thumb-canvas {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 320px;
  height: 320px;
  pointer-events: none;
}

/* =========================================================================================== */
/* Portrait (phones): frame is 430 wide                                                        */

.app[data-layout="portrait"] {
  --floor-drop: 15vh;
  --ring-w: 70vw;
}
.app[data-layout="portrait"] .grade {
  background:
    radial-gradient(130% 80% at 50% 30%, transparent 50%, rgba(0, 0, 0, 0.65) 100%),
    linear-gradient(180deg, rgba(5, 7, 10, 0.7) 0%, transparent 14%, transparent 40%, rgba(5, 7, 10, 0.88) 54%, rgba(5, 7, 10, 0.96) 100%);
}
.app[data-layout="portrait"] .topbar {
  height: 92px;
  padding: 0 20px;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
}
.app[data-layout="portrait"] .topbar::after {
  left: 20px;
  right: 20px;
}
.app[data-layout="portrait"] .hub {
  gap: 22px;
  height: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.app[data-layout="portrait"] .hub-tab {
  font-size: 13px;
  letter-spacing: 0.14em;
  flex: none;
  padding-bottom: 6px;
}
.app[data-layout="portrait"] .hub-tab.is-active::after {
  left: -4px;
  right: -4px;
  bottom: 0;
}
.app[data-layout="portrait"] .wallet {
  justify-content: space-between;
  gap: 16px;
}
.app[data-layout="portrait"] .wallet-gold {
  font-size: 20px;
  gap: 8px;
}
.app[data-layout="portrait"] .wallet-gold svg {
  width: 18px;
  height: 18px;
}
.app[data-layout="portrait"] .wallet-weight {
  width: 150px;
  gap: 6px;
}
.app[data-layout="portrait"] .wallet-weight-row {
  font-size: 12px;
}
.app[data-layout="portrait"] .wallet-weight-row b {
  font-size: 16px;
}

/* Left column splits: categories under the top bar, grid at the bottom. */
.app[data-layout="portrait"] .left {
  position: absolute;
  left: 0;
  right: 0;
  top: 92px;
  bottom: 0;
  width: auto;
  display: block;
  pointer-events: none;
}
.app[data-layout="portrait"] .left > * {
  pointer-events: auto;
}
.app[data-layout="portrait"] .cats {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 48px;
  padding: 0 12px;
  gap: 0;
}
.app[data-layout="portrait"] .cats .key {
  display: none;
}
.app[data-layout="portrait"] .cat-list {
  width: 100%;
  justify-content: space-between;
}
.app[data-layout="portrait"] .cat {
  padding: 0 6px;
  font-size: 13px;
  gap: 6px;
  letter-spacing: 0.06em;
}
.app[data-layout="portrait"] .cat svg {
  width: 18px;
  height: 18px;
}
.app[data-layout="portrait"] .cat-count {
  display: none;
}
.app[data-layout="portrait"] .grid-head {
  position: absolute;
  left: 20px;
  right: 20px;
  top: calc((48 + var(--hero-h) + var(--sum-h) + var(--act-h)) * 1px);
  height: 40px;
  margin: 0;
}
.app[data-layout="portrait"] .grid-title {
  font-size: 14px;
}
.app[data-layout="portrait"] .grid-title b {
  font-size: 15px;
}
.app[data-layout="portrait"] .sort {
  font-size: 13px;
}
.app[data-layout="portrait"] .sort .key {
  display: none;
}
.app[data-layout="portrait"] .grid-frame {
  position: absolute;
  left: 20px;
  right: 20px;
  top: calc((48 + var(--hero-h) + var(--sum-h) + var(--act-h) + 40) * 1px);
  bottom: 0;
}
.app[data-layout="portrait"] .grid {
  --tile: 70px;
  --gap: 7px;
  height: 100%;
  grid-template-columns: repeat(5, var(--tile));
  padding: 6px 6px 40px;
  margin: 0 -6px;
}
.app[data-layout="portrait"] .tile-power {
  font-size: 14px;
  left: 5px;
  bottom: 7px;
}
.app[data-layout="portrait"] .tile-equipped {
  width: 22px;
  height: 22px;
}
.app[data-layout="portrait"] .tile-equipped::after {
  font-size: 10px;
  left: 3px;
  top: 2px;
}
.app[data-layout="portrait"] .cursor {
  width: calc(var(--tile) + 8px);
  height: calc(var(--tile) + 8px);
  margin: -4px 0 0 -4px;
}
.app[data-layout="portrait"] .cursor i {
  display: none;
}

/* Detail: fixed-height summary between the item and the action bar. Everything in it is sized to fit. */
.app[data-layout="portrait"] .detail {
  left: 20px;
  right: 20px;
  top: calc((140 + var(--hero-h)) * 1px);
  bottom: auto;
  width: auto;
  height: calc(var(--sum-h) * 1px);
  overflow: hidden;
}
.app[data-layout="portrait"] .d-rarity {
  font-size: 12px;
  gap: 8px;
  line-height: 22px;
}
.app[data-layout="portrait"] .d-rarity i {
  width: 6px;
  height: 6px;
}
.app[data-layout="portrait"] .d-name {
  margin-top: 6px;
  font-size: 26px;
  line-height: 32px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app[data-layout="portrait"] .chip {
  height: 22px;
  font-size: 11px;
  padding: 0 7px;
  letter-spacing: 0.1em;
}
.app[data-layout="portrait"] .d-power {
  align-items: center;
  margin-top: 8px;
  padding-bottom: 10px;
  gap: 14px;
}
.app[data-layout="portrait"] .d-power-label {
  font-size: 12px;
}
.app[data-layout="portrait"] .d-power-value {
  font-size: 40px;
}
.app[data-layout="portrait"] .d-power-cmp {
  padding: 12px 0 0;
  gap: 5px;
}
.app[data-layout="portrait"] .delta {
  font-size: 16px;
}
.app[data-layout="portrait"] .d-vs {
  font-size: 12px;
}
.app[data-layout="portrait"] .stats {
  gap: 10px 22px;
  margin-top: 10px;
}
.app[data-layout="portrait"] .stat {
  grid-template-columns: 1fr auto 38px;
  column-gap: 6px;
  row-gap: 5px;
}
.app[data-layout="portrait"] .stat dt {
  font-size: 13px;
  letter-spacing: 0.04em;
}
.app[data-layout="portrait"] .stat dd {
  font-size: 18px;
}
.app[data-layout="portrait"] .stat .delta {
  font-size: 13px;
}
.app[data-layout="portrait"] .seg {
  height: 5px;
}
.app[data-layout="portrait"] .detail .perks,
.app[data-layout="portrait"] .detail .d-desc,
.app[data-layout="portrait"] .detail .d-meta {
  display: none;
}

.m-actions {
  display: none;
}
.app[data-layout="portrait"] .m-actions {
  position: absolute;
  left: 20px;
  right: 20px;
  top: calc((140 + var(--hero-h) + var(--sum-h)) * 1px);
  height: calc(var(--act-h) * 1px);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.7s var(--ease-out), opacity 0.5s var(--ease-out);
}
.app[data-booting] .m-actions,
.app[data-mode="inspect"] .m-actions {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}
.d-action {
  flex: 1;
  height: 44px;
  border-radius: 4px;
  font: 700 15px/1 var(--font-jp);
  letter-spacing: 0.14em;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.d-action.primary {
  background: var(--text-1);
  color: var(--bg);
}

/* Inspect: full perks + lore under the title. */
.inspect-info {
  display: none;
  max-width: 500px;
  max-height: calc(var(--fh, 1080) * 0.3px);
  overflow-y: auto;
  scrollbar-width: none;
  pointer-events: none;
}
.app[data-mode="inspect"] .inspect-info {
  display: block;
  pointer-events: auto;
}
.app[data-layout="portrait"] .inspect-info {
  max-height: calc(var(--fh) * 0.26px);
  overflow-y: auto;
  scrollbar-width: none;
}
.app[data-layout="portrait"] .inspect-info .perks {
  margin-top: 4px;
  padding-top: 12px;
  gap: 10px;
}
.app[data-layout="portrait"] .inspect-info .perk {
  grid-template-columns: 28px 1fr;
  gap: 2px 10px;
}
.app[data-layout="portrait"] .inspect-info .perk-icon {
  width: 22px;
  height: 22px;
}
.app[data-layout="portrait"] .inspect-info .perk-icon::after {
  width: 7px;
  height: 7px;
}
.app[data-layout="portrait"] .inspect-info .perk-name {
  font-size: 14px;
}
.app[data-layout="portrait"] .inspect-info .perk-desc {
  font-size: 13px;
}
.app[data-layout="portrait"] .inspect-info .d-desc {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.8;
  padding-left: 12px;
}

.app[data-layout="portrait"] .prompts {
  display: none;
}
.app[data-layout="portrait"] .inspect-title {
  left: 20px;
  right: 20px;
  bottom: calc(var(--fh) * 0.11px + 16px);
  gap: 8px;
}
.app[data-layout="portrait"] .inspect-rarity {
  font-size: 12px;
}
.app[data-layout="portrait"] .inspect-name {
  font-size: 30px;
}
.app[data-layout="portrait"] .inspect-close {
  right: 20px;
  top: calc(var(--fh) * 0.11px + 16px);
  width: 44px;
  height: 44px;
}
.app[data-layout="portrait"] .adjust {
  left: 20px;
  right: 20px;
  width: auto;
  bottom: calc(var(--fh) * 0.11px + 100px);
}
.app[data-layout="portrait"] .banner {
  top: 150px;
  min-width: 300px;
  font-size: 13px;
  padding: 12px 24px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
