:root {
  color-scheme: dark;
  --ink: #f6f3e8;
  --muted: #c9c1a9;
  --panel: rgba(28, 22, 18, 0.94);
  --panel-2: rgba(43, 31, 22, 0.95);
  --line: rgba(255, 236, 173, 0.24);
  --gold: #f6c85f;
  --blue: #56c7ff;
  --red: #ff6b6b;
  --green: #7ee081;
  --violet: #b785ff;
  --cell-editor: 58px;
  --cell-mini: 22px;
  --side-width: 700px;
  --cell-storage: clamp(30px, min(calc((var(--side-width) - 42px) / 15), 4.8vh), 44px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #111;
  color: var(--ink);
  font-family:
    "Segoe UI",
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI",
    Meiryo,
    sans-serif;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #172414;
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  right: auto;
  bottom: 0;
  width: calc(100vw - var(--side-width));
  height: 100vh;
  image-rendering: auto;
}

#app[data-screen="title"] #gameCanvas,
#app[data-screen="stageSelect"] #gameCanvas {
  width: 100vw;
}

#app[data-screen="title"] .hud,
#app[data-screen="stageSelect"] .hud,
#app[data-screen="title"] .side-panel,
#app[data-screen="stageSelect"] .side-panel,
#app[data-screen="title"] .pause-badge,
#app[data-screen="stageSelect"] .pause-badge {
  display: none;
}

.menu-screen {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  background: #151515;
  color: #f4f4f4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.menu-screen.open {
  opacity: 1;
  pointer-events: auto;
}

.title-layout {
  width: min(1080px, 100%);
  min-height: min(620px, calc(100vh - 64px));
  display: grid;
  grid-template-rows: 1fr auto 1.1fr;
  justify-items: center;
  align-items: center;
}

.title-layout h1 {
  align-self: end;
  margin: 0;
  color: #f4f4f4;
  font-size: clamp(58px, 8.5vw, 124px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0;
}

.menu-button {
  min-width: 220px;
  min-height: 72px;
  padding: 12px 34px;
  border: 4px solid #f4f4f4;
  border-radius: 999px;
  background: transparent;
  color: #f4f4f4;
  cursor: pointer;
  font-size: clamp(28px, 3.4vw, 48px);
  font-weight: 500;
  letter-spacing: 0;
}

.menu-button:hover,
.menu-button:focus-visible {
  background: #f4f4f4;
  color: #151515;
  outline: none;
}

.stage-select-layout {
  width: min(1320px, calc(100vw - 64px));
  min-height: min(720px, calc(100vh - 64px));
  display: grid;
  grid-template-rows: auto auto 1fr;
  align-content: center;
  align-items: start;
  justify-items: center;
  gap: 16px;
}

.stage-bgm-controls {
  position: absolute;
  z-index: 3;
  top: 28px;
  right: 32px;
  display: grid;
  grid-template-columns: auto auto minmax(150px, 190px) minmax(150px, 190px) auto;
  align-items: end;
  gap: 10px;
  color: #f4f4f4;
}

.stage-bgm-controls label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  font-weight: 800;
}

.stage-bgm-controls select,
.stage-bgm-controls input {
  min-height: 32px;
}

.stage-bgm-controls select {
  min-width: 150px;
  border: 2px solid #3a3a3a;
  border-radius: 6px;
  background: #242424;
  color: #f4f4f4;
  font: inherit;
}

.stage-volume-control b {
  font-variant-numeric: tabular-nums;
}

.stage-volume-control input {
  width: 100%;
  accent-color: #f4f4f4;
}

.achievement-button {
  min-height: 32px;
  padding: 0 14px;
  border: 2px solid rgba(244, 244, 244, 0.58);
  border-radius: 6px;
  background: #242424;
  color: #f4f4f4;
  cursor: pointer;
  font-weight: 800;
}

.achievement-button:hover,
.achievement-button:focus-visible {
  border-color: rgba(244, 244, 244, 0.92);
  background: #303030;
  outline: none;
}

.stage-select-layout h1 {
  margin: 0;
  color: #f4f4f4;
  font-size: clamp(34px, 4.2vw, 60px);
  font-weight: 500;
  letter-spacing: 0;
}

.stage-select-screen[data-stage-phase="character"] .stage-select-layout {
  grid-template-rows: auto auto;
}

.stage-select-screen[data-stage-phase="character"] .stage-choice-panel,
.stage-select-screen[data-stage-phase="stage"] .character-select-panel {
  display: none !important;
}

.stage-select-screen[data-stage-phase="stage"] #stageFlowTitle {
  display: none;
}

.stage-flow-panel {
  width: 100%;
  min-height: min(540px, calc(100vh - 190px));
}

.character-select-panel {
  width: min(1260px, 100%);
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  column-gap: 0;
  row-gap: 16px;
  align-items: stretch;
}

.character-select {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: minmax(112px, auto);
  gap: 12px;
  grid-row: 1 / 3;
  align-content: start;
}

.character-card {
  position: relative;
  min-height: 112px;
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  column-gap: 12px;
  padding: 14px;
  border: 3px solid #3a3a3a;
  border-radius: 8px;
  background: #242424;
  color: #f4f4f4;
  cursor: pointer;
  text-align: left;
}

.character-card:hover,
.character-card:focus-visible,
.character-card.is-active {
  border-color: rgba(244, 244, 244, 0.9);
  outline: none;
}

.character-card.is-active {
  z-index: 2;
  border-right-color: transparent;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  box-shadow:
    -5px 0 0 rgba(244, 244, 244, 0.12),
    0 -5px 0 rgba(244, 244, 244, 0.12),
    0 5px 0 rgba(244, 244, 244, 0.12),
    0 0 24px rgba(86, 199, 255, 0.18);
}

.character-orb {
  grid-row: 1 / -1;
  width: 42px;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.12) inset,
    0 0 18px currentColor;
}

.character-orb.blue {
  color: #48a8ff;
  background: #48a8ff;
}

.character-orb.red {
  color: #ff5a4f;
  background: #ff5a4f;
}

.character-orb.green {
  color: #58d66f;
  background: #58d66f;
}

.character-name {
  align-self: end;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.character-meta {
  align-self: start;
  color: #cfcfcf;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.character-stats {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(480px, 0.95fr) minmax(320px, 380px);
  gap: 10px;
  align-items: stretch;
}

.character-gauge-list,
.character-loadout {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 2px solid #3a3a3a;
  border-radius: 6px;
  background: #202020;
  color: #f4f4f4;
}

.character-gauge-list {
  grid-template-columns: 1fr;
  align-content: center;
  justify-content: center;
  justify-items: center;
  padding: 18px 22px;
  border-left-width: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.character-gauge {
  width: min(100%, 540px);
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(128px, 164px) minmax(56px, 72px) minmax(180px, 260px);
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.character-gauge-name {
  min-width: 0;
  overflow: hidden;
  color: #f4f4f4;
  font-size: 14px;
  font-weight: 800;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-gauge-value {
  color: #dcefff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  text-align: right;
}

.character-gauge-dots {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(24, minmax(3px, 1fr));
  gap: 2px;
}

.character-gauge-dots span {
  height: 11px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.11);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

.character-gauge-dots span.is-filled {
  background: linear-gradient(180deg, #76d7ff, #ffe08a);
  box-shadow:
    0 0 7px rgba(86, 199, 255, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.character-loadout {
  align-content: start;
}

.character-bag-card,
.character-weapon-card {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
}

.character-bag-card > div:first-child,
.character-weapon-card > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.character-bag-card b,
.character-weapon-card b {
  color: #ffe08a;
  font-size: 12px;
  font-weight: 900;
}

.character-bag-card span,
.character-weapon-card p {
  margin: 0;
  color: rgba(244, 244, 244, 0.72);
  font-size: 12px;
  line-height: 1.35;
}

.character-bag-preview {
  --slot-size: 12px;
  width: max-content;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--slot-size));
  grid-template-rows: repeat(var(--rows), var(--slot-size));
  gap: 2px;
  padding: 5px;
  border: 1px solid rgba(255, 224, 138, 0.32);
  border-radius: 6px;
  background: rgba(32, 24, 19, 0.72);
}

.character-bag-preview span {
  border-radius: 2px;
  background: rgba(86, 199, 255, 0.25);
}

.character-weapon-card {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.character-weapon-card.compact {
  padding-block: 8px;
}

.character-weapon-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 24px;
}

.character-weapon-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.2;
}

.character-specialty {
  margin: 0;
  color: rgba(244, 244, 244, 0.72);
  font-size: 12px;
  line-height: 1.45;
}

.stage-flow-button {
  min-height: 42px;
  padding: 0 20px;
  border: 2px solid rgba(244, 244, 244, 0.42);
  border-radius: 8px;
  background: #242424;
  color: #f4f4f4;
  cursor: pointer;
  font-weight: 900;
}

.stage-flow-button:hover,
.stage-flow-button:focus-visible {
  border-color: rgba(244, 244, 244, 0.9);
  background: #303030;
  outline: none;
}

.stage-flow-button.primary {
  border-color: rgba(246, 200, 95, 0.72);
  background: linear-gradient(180deg, #3a3020, #242424);
  color: #ffe08a;
}

.character-select-panel > .stage-flow-button {
  grid-column: 2;
  justify-self: end;
  align-self: end;
}

.stage-choice-panel {
  width: min(1120px, 100%);
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 28px;
  align-items: center;
}

.stage-route {
  display: grid;
  grid-template-columns: minmax(220px, 260px) auto minmax(220px, 260px) auto minmax(220px, 260px);
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3vw, 44px);
}

.stage-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1.3;
  padding: 0;
  border: 4px solid #3a3a3a;
  border-radius: 8px;
  background: #242424;
  color: #f4f4f4;
  cursor: pointer;
  overflow: visible;
}

.stage-card.available:hover,
.stage-card.available:focus-visible,
.stage-card.available.is-selected {
  outline: none;
  border-color: rgba(244, 244, 244, 0.86);
  box-shadow: 0 0 0 6px rgba(244, 244, 244, 0.12);
  transform: translateY(-2px);
}

.stage-card.available.is-selected {
  border-color: rgba(246, 200, 95, 0.92);
  box-shadow:
    0 0 0 6px rgba(246, 200, 95, 0.12),
    0 0 28px rgba(246, 200, 95, 0.18);
}

.stage-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.stage-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 2px;
}

.stage-card.locked {
  cursor: not-allowed;
  background: #202020;
}

.stage-label {
  position: absolute;
  left: 6px;
  bottom: calc(100% + 10px);
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1;
  white-space: nowrap;
}

.stage-name {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(21, 21, 21, 0.86);
  color: #f4f4f4;
  font-size: 14px;
  font-weight: 800;
  text-align: left;
}

.stage-mystery {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(92px, 10vw, 138px);
  font-weight: 300;
}

.stage-arrow {
  color: #f4f4f4;
  font-size: clamp(38px, 4vw, 64px);
  line-height: 1;
}

.hud {
  position: absolute;
  z-index: 4;
  top: 12px;
  left: 12px;
  right: calc(var(--side-width) + 12px);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto minmax(160px, auto);
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.hud-bar.hp {
  display: none;
}

.side-panel {
  position: absolute;
  z-index: 6;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--side-width);
  display: grid;
  grid-template-rows: minmax(250px, 38%) 1fr;
  gap: 0;
  border-left: 1px solid rgba(255, 238, 177, 0.24);
  background:
    linear-gradient(180deg, rgba(40, 30, 22, 0.98), rgba(20, 18, 16, 0.98)),
    #201813;
  box-shadow: -18px 0 42px rgba(0, 0, 0, 0.35);
}

.side-section {
  min-height: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid rgba(255, 238, 177, 0.18);
}

.bag-section {
  display: grid;
  grid-template-columns: 120px 1fr;
  grid-template-rows: auto auto 1fr;
  column-gap: 22px;
  align-items: start;
}

.bag-section .side-header,
.bag-section .bag-meta {
  grid-column: 1 / -1;
}

.storage-section {
  border-bottom: 0;
}

.side-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.side-header h1,
.side-header h2 {
  font-size: 20px;
}

.side-panel .bag-grid.editor {
  --cell-editor: clamp(34px, min(calc((var(--side-width) - 36px) / 12), 5vh), 46px);
  grid-column: 2;
  grid-row: 3;
  justify-self: start;
  align-self: center;
  margin-left: clamp(54px, calc(var(--side-width) * 0.12), 104px);
  flex: 0 0 auto;
}

.side-panel .stash-list,
.side-panel .craft-grid {
  flex: 0 0 auto;
}

.hud-bar,
.hud-stat,
.hud-evolution,
.pause-badge {
  border: 1px solid rgba(255, 238, 177, 0.24);
  background: rgba(20, 17, 13, 0.72);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px);
}

.hud-bar {
  position: relative;
  min-height: 36px;
  overflow: hidden;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
}

.hud-bar span,
.hud-bar b {
  position: relative;
  z-index: 2;
}

.hud-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  transition: width 160ms ease-out;
  opacity: 0.82;
}

.hud-bar.hp i {
  background: linear-gradient(90deg, #db3348, #ff9269);
}

.hud-bar.exp i {
  background: linear-gradient(90deg, #225fe8, #47d0ff);
}

.hud-stat,
.hud-evolution {
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
}

.hud-evolution {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  color: #ffe299;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  pointer-events: auto;
}

#evolutionText {
  display: none;
}

.debug-button {
  min-width: 62px;
  min-height: 26px;
  border: 1px solid rgba(246, 200, 95, 0.6);
  border-radius: 7px;
  background: rgba(246, 200, 95, 0.12);
  color: #ffe299;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.debug-button:hover,
.debug-button:focus-visible {
  border-color: rgba(86, 199, 255, 0.8);
  background: rgba(86, 199, 255, 0.14);
  outline: none;
}

.bag-thumb {
  position: absolute;
  z-index: 5;
  right: 18px;
  bottom: 18px;
  width: 220px;
  height: 144px;
  padding: 12px 12px 14px;
  border: 2px solid rgba(246, 200, 95, 0.65);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(98, 57, 30, 0.95), rgba(42, 28, 20, 0.96)),
    #3a2318;
  color: var(--ink);
  cursor: pointer;
  box-shadow:
    0 18px 36px rgba(0, 0, 0, 0.38),
    inset 0 0 24px rgba(255, 220, 126, 0.1);
  transform-origin: 100% 100%;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.bag-thumb:hover,
.bag-thumb:focus-visible {
  transform: translateY(-3px) scale(1.02);
  border-color: rgba(86, 199, 255, 0.9);
  box-shadow:
    0 22px 40px rgba(0, 0, 0, 0.45),
    0 0 24px rgba(86, 199, 255, 0.18),
    inset 0 0 24px rgba(255, 220, 126, 0.13);
  outline: none;
}

.bag-thumb-title {
  display: block;
  margin-bottom: 7px;
  color: #f7d67c;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.pause-badge {
  position: absolute;
  z-index: 4;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 8px;
  color: #ffe299;
  font-weight: 800;
}

.bag-overlay,
.level-overlay,
.end-overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}

.bag-overlay.open,
.level-overlay.open,
.end-overlay.open {
  pointer-events: auto;
  opacity: 1;
}

.bag-overlay {
  background: rgba(8, 8, 10, 0.2);
}

.bag-panel {
  width: min(920px, calc(100vw - 36px));
  max-height: min(680px, calc(100vh - 36px));
  overflow: hidden;
  border: 1px solid rgba(255, 230, 161, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(55, 38, 25, 0.98), rgba(23, 20, 18, 0.98)),
    var(--panel);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.52),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  transform-origin: center;
}

.panel-header,
.level-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.1;
  letter-spacing: 0;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: rgba(86, 199, 255, 0.7);
  background: rgba(86, 199, 255, 0.14);
  outline: none;
}

.bag-workspace {
  display: grid;
  grid-template-columns: minmax(380px, auto) minmax(230px, 1fr);
  gap: 18px;
  padding: 18px 20px 20px;
}

.bag-board-wrap {
  min-width: 0;
}

.bag-meta,
.stash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.bag-grid {
  position: relative;
  --cols: 6;
  --rows: 4;
  background: rgba(32, 24, 19, 0.52);
  border: 2px solid rgba(255, 229, 151, 0.42);
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    inset 0 0 18px rgba(0, 0, 0, 0.38),
    0 10px 24px rgba(0, 0, 0, 0.24);
}

.bag-cell {
  position: absolute;
  z-index: 0;
  border: 1px solid rgba(255, 238, 177, 0.16);
  border-radius: 4px;
  background:
    radial-gradient(circle at 40% 35%, rgba(255, 214, 116, 0.1), transparent 36%),
    rgba(65, 42, 25, 0.98);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.bag-grid.editor {
  width: calc(var(--cols) * var(--cell-editor));
  height: calc(var(--rows) * var(--cell-editor));
  max-width: 100%;
  background-size:
    var(--cell-editor) var(--cell-editor),
    var(--cell-editor) var(--cell-editor),
    auto,
    auto;
  touch-action: none;
  overflow: visible;
}

.trash-drop-zone {
  position: relative;
  grid-column: 1;
  grid-row: 3;
  align-self: end;
  justify-self: start;
  width: 78px;
  height: 96px;
  margin-left: -2px;
  margin-bottom: 2px;
}

.trash-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
  filter:
    drop-shadow(0 14px 14px rgba(0, 0, 0, 0.48))
    drop-shadow(0 0 10px rgba(255, 238, 177, 0.08));
}

.trash-open {
  opacity: 0;
}

.trash-drop-zone.is-open .trash-closed {
  opacity: 0;
}

.trash-drop-zone.is-open .trash-open {
  opacity: 1;
}

.trash-gold-text {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 18px);
  z-index: 2;
  transform: translateX(-50%);
  color: #f6c85f;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  text-shadow:
    0 2px 3px rgba(0, 0, 0, 0.78),
    0 0 10px rgba(246, 200, 95, 0.72);
}

.trash-gold-text.show {
  animation: trashGoldFloat 760ms ease-out;
}

.bag-grid.mini {
  width: calc(var(--cols) * var(--cell-mini));
  height: calc(var(--rows) * var(--cell-mini));
  background-size:
    var(--cell-mini) var(--cell-mini),
    var(--cell-mini) var(--cell-mini),
    auto,
    auto;
  pointer-events: none;
}

.level-bag-preview {
  flex: 0 0 auto;
  width: 178px;
  min-height: 94px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 229, 151, 0.3);
  border-radius: 8px;
  background: rgba(59, 38, 27, 0.7);
}

.item-tile {
  position: absolute;
  z-index: 2;
  display: grid;
  grid-template-rows: 1fr;
  align-items: center;
  justify-items: center;
  padding: 3px;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.12), transparent 38%),
    linear-gradient(145deg, rgba(84, 58, 39, 0.95), rgba(32, 25, 21, 0.95));
  color: var(--ink);
  cursor: grab;
  user-select: none;
  overflow: hidden;
  box-shadow:
    inset 0 0 14px rgba(255, 255, 255, 0.06),
    0 8px 18px rgba(0, 0, 0, 0.24);
  touch-action: none;
}

.item-tile:active {
  cursor: grabbing;
}

.item-tile.weapon {
  border-color: rgba(86, 199, 255, 0.38);
}

.item-tile.accessory,
.item-tile.material,
.item-tile.passive {
  border-color: rgba(126, 224, 129, 0.34);
}

.item-tile.summon {
  border-color: rgba(183, 133, 255, 0.45);
}

.item-tile.expansion {
  border-color: rgba(246, 200, 95, 0.7);
}

.item-tile.ammo {
  border-color: rgba(246, 200, 95, 0.48);
}

.item-tile.shape-item {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  pointer-events: none;
}

.shape-grid {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--shape-cols), 1fr);
  grid-template-rows: repeat(var(--shape-rows), 1fr);
  gap: 2px;
  pointer-events: none;
}

.shape-cell {
  border-radius: 7px;
  pointer-events: none;
}

.shape-cell.is-occupied {
  border: 1px solid rgba(86, 199, 255, 0.46);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.16), transparent 38%),
    linear-gradient(145deg, rgba(72, 57, 46, 0.96), rgba(30, 26, 24, 0.96));
  box-shadow:
    inset 0 0 14px rgba(255, 255, 255, 0.06),
    0 6px 14px rgba(0, 0, 0, 0.22);
  cursor: grab;
  pointer-events: auto;
}

.shape-cell.is-empty {
  opacity: 0;
}

.item-tile.shape-item .cooldown-fill {
  display: none;
}

.item-tile.shape-item .item-icon,
.item-tile.shape-item .item-name,
.item-tile.shape-item .uses-badge,
.item-tile.shape-item .buff-mark {
  pointer-events: none;
}

.item-tile.is-buffed {
  box-shadow:
    inset 0 0 14px rgba(255, 255, 255, 0.08),
    0 0 16px rgba(86, 199, 255, 0.34),
    0 8px 18px rgba(0, 0, 0, 0.24);
}

.item-tile.is-evolved {
  border-color: rgba(246, 200, 95, 0.9);
  box-shadow:
    inset 0 0 18px rgba(246, 200, 95, 0.18),
    0 0 24px rgba(246, 200, 95, 0.36),
    0 8px 18px rgba(0, 0, 0, 0.24);
}

.item-tile.is-flashing {
  animation: tilePulse 280ms ease-out;
}

.item-tile.is-low-uses {
  animation: lowUsesPulse 820ms ease-in-out infinite;
}

.item-tile.drag-source {
  opacity: 0.32;
}

.item-icon {
  position: relative;
  z-index: 2;
  max-width: 100%;
  max-height: 100%;
  font-size: 1.35em;
  line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}

.item-name {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  z-index: 2;
  width: auto;
  padding: 1px 2px 2px;
  border-radius: 3px;
  background: rgba(13, 10, 8, 0.58);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.42em;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.uses-badge {
  position: absolute;
  z-index: 5;
  left: 4px;
  top: 4px;
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff2c2;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
}

.bag-grid.mini .item-tile {
  border-radius: 4px;
  pointer-events: none;
}

.bag-grid.mini .item-icon {
  font-size: 13px;
}

.bag-grid.mini .item-name,
.bag-grid.mini .cooldown-fill,
.bag-grid.mini .buff-mark,
.bag-grid.mini .uses-badge {
  display: none;
}

.cooldown-fill {
  position: absolute;
  z-index: 3;
  inset: auto 0 0 0;
  height: 0;
  background: rgba(10, 12, 16, 0.58);
  pointer-events: none;
}

.buff-mark {
  position: absolute;
  z-index: 4;
  top: 4px;
  right: 5px;
  min-width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(86, 199, 255, 0.86);
  color: #062538;
  font-size: 11px;
  font-weight: 900;
}

.preview-layer {
  position: absolute;
  z-index: 8;
  inset: 0;
  pointer-events: none;
}

.preview-cell {
  position: absolute;
  width: var(--cell-editor);
  height: var(--cell-editor);
  border: 2px solid;
  border-radius: 6px;
}

.preview-cell.valid {
  border-color: rgba(86, 199, 255, 0.9);
  background: rgba(86, 199, 255, 0.28);
  box-shadow: inset 0 0 16px rgba(86, 199, 255, 0.2);
}

.preview-cell.invalid {
  border-color: rgba(255, 107, 107, 0.95);
  background: rgba(255, 107, 107, 0.28);
  box-shadow: inset 0 0 16px rgba(255, 107, 107, 0.18);
}

.stash-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255, 229, 151, 0.2);
  border-radius: 8px;
  background: rgba(21, 18, 15, 0.42);
}

.stash-list {
  position: relative;
  --cols: 12;
  --rows: 12;
  width: calc(var(--cols) * var(--cell-storage));
  height: calc(var(--rows) * var(--cell-storage));
  max-width: 100%;
  flex: 0 0 auto;
  overflow: visible;
  border: 2px solid rgba(255, 229, 151, 0.35);
  border-radius: 8px;
  background: rgba(32, 24, 19, 0.52);
  box-shadow:
    inset 0 0 18px rgba(0, 0, 0, 0.38),
    0 10px 24px rgba(0, 0, 0, 0.18);
  touch-action: none;
}

.storage-workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: auto auto;
  align-items: start;
  justify-content: start;
  gap: 10px;
}

.craft-station {
  position: relative;
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 2px 0 0;
}

.craft-grid {
  position: relative;
  z-index: 1;
  --cols: 5;
  --rows: 5;
  width: calc(var(--cols) * var(--cell-storage));
  height: calc(var(--rows) * var(--cell-storage));
  overflow: visible;
  border: 2px solid rgba(255, 229, 151, 0.35);
  border-radius: 7px;
  background: rgba(32, 24, 19, 0.58);
  box-shadow:
    inset 0 0 18px rgba(0, 0, 0, 0.42),
    0 10px 24px rgba(0, 0, 0, 0.18);
  touch-action: none;
}

.craft-cell {
  border-color: rgba(246, 200, 95, 0.18);
}

.craft-anvil {
  position: absolute;
  z-index: 3;
  top: calc(var(--cell-storage) * 2.5);
  left: 50%;
  width: min(170px, calc(var(--cell-storage) * 4.15));
  max-height: calc(var(--cell-storage) * 2.2);
  object-fit: contain;
  opacity: 0.28;
  transform: translate(-50%, -50%);
  filter:
    drop-shadow(0 12px 14px rgba(0, 0, 0, 0.42))
    drop-shadow(0 0 8px rgba(255, 238, 177, 0.06));
  image-rendering: auto;
  pointer-events: none;
}

.craft-button {
  position: relative;
  z-index: 2;
  min-width: min(168px, 100%);
  min-height: 38px;
  padding: 4px 22px 5px;
  border: 1px solid rgba(246, 200, 95, 0.74);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(123, 82, 45, 0.98), rgba(83, 53, 29, 0.98));
  color: #fff8e5;
  cursor: pointer;
  font-size: clamp(17px, 1.35vw, 22px);
  font-weight: 900;
  letter-spacing: 0;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.craft-button:not(:disabled):hover,
.craft-button:not(:disabled):focus-visible {
  border-color: rgba(86, 199, 255, 0.9);
  background:
    linear-gradient(180deg, rgba(137, 92, 50, 1), rgba(90, 61, 35, 1));
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.3),
    0 0 26px rgba(86, 199, 255, 0.22);
  outline: none;
}

.craft-button:disabled {
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(67, 54, 43, 0.58);
  color: rgba(255, 248, 229, 0.34);
  box-shadow: none;
}

.craft-hint {
  width: 100%;
  min-height: 36px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.storage-grid .item-tile {
  border-radius: 5px;
}

.storage-grid .item-name {
  display: none;
}

.item-icon {
  display: inline-grid;
  place-items: center;
  transform: rotate(var(--item-rotation, 0deg));
  transition: transform 100ms ease;
}

.storage-grid .uses-badge,
.storage-grid .buff-mark {
  transform: scale(0.9);
  transform-origin: top left;
}

.storage-cell {
  border-color: rgba(255, 238, 177, 0.13);
}

.stash-item {
  position: relative;
  min-height: 78px;
  padding: 18px 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.1), transparent 42%),
    rgba(56, 41, 29, 0.86);
  color: var(--ink);
  cursor: grab;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  gap: 4px;
  user-select: none;
  touch-action: none;
}

.stash-item.is-flashing {
  animation: storagePulse 560ms ease-out;
}

.stash-item.drag-source {
  opacity: 0.3;
}

.stash-icon {
  font-size: 24px;
  line-height: 1;
}

.stash-name {
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.94);
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
}

.stash-size {
  color: var(--muted);
  font-size: 9px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stash-count {
  position: absolute;
  top: 6px;
  right: 7px;
  min-width: 22px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(86, 199, 255, 0.9);
  color: #061c2a;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

.drag-ghost {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  opacity: 0.82;
  transform: translate(-50%, -50%);
}

.quick-sell-ghost {
  position: fixed;
  z-index: 31;
  pointer-events: none;
  margin: 0;
  opacity: 0.92;
  transform-origin: center;
  transition:
    left 180ms ease-in,
    top 180ms ease-in,
    transform 180ms ease-in,
    opacity 180ms ease-in;
}

.level-overlay {
  z-index: 12;
  top: auto;
  right: calc(var(--side-width) + 14px);
  bottom: 16px;
  left: 14px;
  place-items: end center;
  background: transparent;
  pointer-events: none;
}

.level-overlay.open {
  pointer-events: none;
}

.level-overlay.open .level-card {
  pointer-events: auto;
}

.recipe-overlay {
  position: absolute;
  z-index: 42;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.recipe-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.recipe-card {
  width: min(620px, calc(100vw - var(--side-width) - 32px));
  max-height: min(620px, calc(100vh - 48px));
  overflow: hidden;
  border: 1px solid rgba(255, 238, 177, 0.25);
  border-radius: 8px;
  background: rgba(25, 20, 17, 0.97);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.recipe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 238, 177, 0.18);
}

.recipe-list {
  max-height: 520px;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding: 14px 16px 16px;
}

.recipe-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.recipe-combo {
  min-width: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
}

.recipe-result {
  color: #ffe08a;
  font-weight: 900;
  white-space: nowrap;
}

.debug-overlay,
.debug-refill-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.debug-overlay {
  z-index: 34;
}

.debug-refill-overlay {
  z-index: 46;
}

.debug-overlay.open,
.debug-refill-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.debug-card,
.debug-refill-card {
  overflow: hidden;
  border: 1px solid rgba(255, 238, 177, 0.25);
  border-radius: 8px;
  background: rgba(25, 20, 17, 0.98);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.debug-card {
  width: min(380px, calc(100vw - 48px));
}

.debug-refill-card {
  width: min(780px, calc(100vw - 48px));
  max-height: min(720px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 238, 177, 0.18);
}

.debug-header h2 {
  margin: 2px 0 0;
  color: #f6f3e8;
}

.debug-actions {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.debug-action-button,
.debug-close-button,
.debug-refill-add {
  min-height: 40px;
  border: 1px solid rgba(246, 200, 95, 0.48);
  border-radius: 7px;
  background: rgba(246, 200, 95, 0.1);
  color: #ffe299;
  cursor: pointer;
  font-weight: 900;
}

.debug-action-button:hover,
.debug-action-button:focus-visible,
.debug-close-button:hover,
.debug-close-button:focus-visible,
.debug-refill-add:hover,
.debug-refill-add:focus-visible {
  border-color: rgba(86, 199, 255, 0.82);
  background: rgba(86, 199, 255, 0.14);
  outline: none;
}

.debug-action-button.is-active {
  border-color: rgba(126, 224, 129, 0.75);
  background: rgba(126, 224, 129, 0.14);
  color: #baffc0;
}

.debug-status {
  margin: 0;
  padding: 0 16px 14px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 800;
}

.debug-close-button {
  width: calc(100% - 32px);
  margin: 0 16px 16px;
}

.debug-refill-feedback {
  min-height: 30px;
  margin: 0;
  padding: 10px 16px 0;
  color: #baffc0;
  font-size: 13px;
  font-weight: 900;
}

.debug-refill-feedback.is-error {
  color: #ff9a9a;
}

.debug-refill-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 16px;
  padding: 12px 16px 16px;
}

.debug-refill-section {
  display: grid;
  gap: 8px;
}

.debug-refill-section h3 {
  margin: 0;
  color: #ffe08a;
  font-size: 14px;
}

.debug-refill-section-list {
  display: grid;
  gap: 8px;
}

.debug-refill-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.debug-refill-icon {
  width: 42px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 24px;
}

.debug-refill-body {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.debug-refill-body strong {
  color: #f6f3e8;
  font-size: 14px;
}

.debug-refill-body span,
.debug-refill-body p {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debug-refill-add {
  min-width: 70px;
  min-height: 34px;
}

.achievement-overlay {
  position: absolute;
  z-index: 28;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.achievement-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.achievement-card {
  width: min(920px, calc(100vw - 48px));
  max-height: min(720px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: #202020;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58);
}

.achievement-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.achievement-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.achievement-tab {
  min-height: 34px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #f4f4f4;
  cursor: pointer;
  font-weight: 800;
}

.achievement-tab.is-active,
.achievement-tab:hover,
.achievement-tab:focus-visible {
  border-color: rgba(86, 199, 255, 0.7);
  background: rgba(86, 199, 255, 0.16);
  outline: none;
}

.achievement-content {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 16px;
}

.achievement-item-row,
.achievement-recipe-row {
  display: grid;
  gap: 14px;
  align-items: start;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.achievement-item-row {
  grid-template-columns: auto 1fr;
}

.achievement-footprint {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), 24px);
  grid-template-rows: repeat(var(--rows), 24px);
  border: 1px solid rgba(255, 229, 151, 0.34);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(32, 24, 19, 0.72);
}

.achievement-footprint span {
  border-right: 1px solid rgba(255, 229, 151, 0.18);
  border-bottom: 1px solid rgba(255, 229, 151, 0.18);
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 225, 150, 0.12), rgba(255, 225, 150, 0) 58%),
    rgba(65, 42, 26, 0.72);
}

.achievement-footprint-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}

.achievement-item-body {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.achievement-item-body h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.achievement-item-body p,
.achievement-empty {
  margin: 0;
  color: rgba(244, 244, 244, 0.86);
  font-size: 13px;
  line-height: 1.5;
}

.achievement-meta {
  color: rgba(244, 244, 244, 0.58) !important;
  font-weight: 800;
}

.achievement-recipe-row {
  grid-template-columns: 80px minmax(0, 1fr) auto;
  align-items: center;
}

.achievement-recipe-type {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.achievement-recipe-combo {
  min-width: 0;
  color: rgba(244, 244, 244, 0.9);
  font-size: 14px;
}

.achievement-recipe-result {
  color: #ffe08a;
  font-weight: 900;
  white-space: nowrap;
}

.level-card {
  width: min(680px, calc(100vw - var(--side-width) - 36px));
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  background: rgba(13, 22, 23, 0.24);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
  padding: 14px;
  pointer-events: auto;
}

.level-card .level-top {
  align-items: end;
}

.level-card .level-bag-preview {
  display: none;
}

.level-card .eyebrow {
  margin-bottom: 2px;
}

.level-card h2 {
  font-size: 22px;
}

.reward-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.reward-card {
  position: relative;
  min-height: 148px;
  padding: 12px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(9, 15, 17, 0.2);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 6px;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.reward-card:hover,
.reward-card:focus-visible {
  transform: translateY(-8px) scale(1.04);
  border-color: #f6c85f;
  background: rgba(73, 48, 25, 0.26);
  outline: none;
}

.reward-card.rarity-common {
  border-color: #c9d2d8;
}

.reward-card.rarity-rare {
  border-color: #56c7ff;
  box-shadow: 0 0 18px rgba(86, 199, 255, 0.12) inset;
}

.reward-card.rarity-epic {
  border-color: #b785ff;
  box-shadow: 0 0 22px rgba(183, 133, 255, 0.18) inset;
}

.reward-card.rarity-legendary {
  border-color: #ffe08a;
  box-shadow:
    0 0 26px rgba(255, 224, 138, 0.2),
    0 0 24px rgba(255, 224, 138, 0.18) inset;
}

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

.reward-icon {
  font-size: 32px;
  line-height: 1;
}

.reward-rarity {
  color: #ffe08a;
  font-size: 11px;
  font-weight: 900;
}

.reward-card h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.reward-amount {
  color: #ffe08a;
  font-size: 22px;
  line-height: 1;
}

.reward-card p {
  margin: 0;
  color: #f4f4f4;
  font-size: 12px;
  line-height: 1.45;
}

.reward-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: #f7e7b0;
  font-size: 11px;
}

.end-overlay {
  z-index: 14;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(3px);
}

.end-card {
  width: min(460px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(25, 20, 18, 0.96);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58);
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  margin: 18px 0;
  color: var(--muted);
}

.result-grid b {
  color: var(--ink);
}

.primary-button {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(246, 200, 95, 0.8);
  border-radius: 8px;
  background: linear-gradient(135deg, #e8aa3f, #d5763a);
  color: #1c1009;
  cursor: pointer;
  font-weight: 800;
}

@keyframes tilePulse {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes lowUsesPulse {
  0%,
  100% {
    border-color: rgba(255, 107, 107, 0.65);
    box-shadow:
      inset 0 0 14px rgba(255, 255, 255, 0.08),
      0 0 8px rgba(255, 107, 107, 0.28);
  }
  50% {
    border-color: rgba(255, 107, 107, 1);
    box-shadow:
      inset 0 0 18px rgba(255, 107, 107, 0.18),
      0 0 20px rgba(255, 107, 107, 0.52);
  }
}

@keyframes storagePulse {
  0% {
    transform: scale(1);
    border-color: rgba(86, 199, 255, 0.3);
  }
  45% {
    transform: scale(1.04);
    border-color: rgba(86, 199, 255, 1);
    box-shadow: 0 0 20px rgba(86, 199, 255, 0.34);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes trashGoldFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -26px);
  }
}

@media (max-width: 1180px) {
  .character-select-panel {
    grid-template-columns: minmax(180px, 230px) minmax(0, 1fr);
  }

  .character-stats {
    grid-template-columns: 1fr;
  }

  .character-gauge {
    grid-template-columns: minmax(92px, 118px) minmax(44px, 62px) minmax(92px, 1fr);
    gap: 6px;
  }

  .character-gauge-dots {
    gap: 1px;
  }
}

@media (max-width: 780px) {
  :root {
    --side-width: min(100vw, 320px);
    --cell-storage: min(4.9vw, 25px);
  }

  .menu-screen {
    place-items: start center;
    overflow: auto;
    padding: 18px 16px 28px;
  }

  .stage-select-layout {
    min-height: auto;
    align-content: start;
    gap: 22px;
  }

  #gameCanvas {
    right: 0;
    bottom: 42vh;
  }

  .hud {
    grid-template-columns: 1fr 1fr;
    right: 10px;
    left: 10px;
  }

  .hud-evolution {
    grid-column: 1 / -1;
  }

  .side-panel {
    top: 58vh;
    left: 0;
    width: 100vw;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
    border-left: 0;
    border-top: 1px solid rgba(255, 238, 177, 0.24);
  }

  .side-panel .bag-grid.editor {
    --cell-editor: min(5.8vw, 34px);
  }

  .bag-section {
    grid-template-columns: 64px 1fr;
    column-gap: 8px;
  }

  .trash-drop-zone {
    width: 54px;
    height: 68px;
  }

  .side-panel .stash-list {
    max-height: none;
  }

  .storage-workspace {
    gap: 10px;
  }

  .stage-route {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .stage-flow-panel {
    min-height: auto;
  }

  .character-select-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .character-select {
    grid-template-columns: 1fr;
    grid-row: auto;
  }

  .character-stats {
    grid-template-columns: 1fr;
  }

  .character-gauge-list {
    grid-template-columns: 1fr;
  }

  .character-gauge {
    grid-template-columns: minmax(96px, 128px) minmax(48px, 64px) minmax(120px, 1fr);
  }

  .character-select-panel > .stage-flow-button {
    grid-column: auto;
  }

  .stage-actions {
    justify-content: stretch;
  }

  .stage-actions .stage-flow-button {
    flex: 1;
  }

  .stage-bgm-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    width: min(520px, calc(100vw - 24px));
    grid-template-columns: 1fr 1fr;
  }

  .debug-overlay,
  .debug-refill-overlay {
    padding: 16px;
  }

  .debug-refill-card {
    width: 100%;
    max-height: calc(100vh - 32px);
  }

  .debug-refill-row {
    grid-template-columns: 38px 1fr;
  }

  .debug-refill-add {
    grid-column: 2;
    justify-self: start;
  }

  .achievement-button {
    min-height: 36px;
  }

  .stage-arrow {
    transform: rotate(90deg);
    justify-self: center;
  }

  .stage-card {
    max-width: 280px;
    justify-self: center;
  }

  .reward-list {
    grid-template-columns: 1fr;
  }

  .level-overlay {
    right: 10px;
    bottom: calc(42vh + 10px);
    left: 10px;
  }

  .level-card {
    width: 100%;
    max-height: calc(100vh - 32px);
    overflow: auto;
  }

  .achievement-card {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
  }

  .achievement-item-row,
  .achievement-recipe-row {
    grid-template-columns: 1fr;
  }

  .level-bag-preview {
    display: none;
  }
}
