:root {
  color-scheme: light;
  --ink: #fff8e8;
  --muted: #eadfbe;
  --leaf: #243222;
  --leaf-bright: #cfab59;
  --gold: #efc766;
  --water: #e0b56b;
  --wood: #8a6840;
  --wood-dark: #2b2015;
  --panel: rgba(54, 70, 45, 0.58);
  --panel-strong: rgba(33, 42, 28, 0.82);
  --line: rgba(244, 209, 122, 0.38);
  --shadow: 0 24px 60px rgba(18, 20, 12, 0.24);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(18, 31, 24, 0.44), rgba(33, 53, 35, 0.18) 48%, rgba(255, 244, 214, 0.04)),
    url("assets/adventure-background-traveler.png") center / cover fixed;
}

.leaf-shadow-layer {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 8% 8%, rgba(20, 28, 18, 0.16) 0 8%, transparent 18%),
    radial-gradient(ellipse at 18% 18%, rgba(242, 196, 91, 0.2) 0 7%, transparent 17%),
    radial-gradient(ellipse at 72% 12%, rgba(114, 92, 44, 0.12) 0 8%, transparent 20%),
    radial-gradient(ellipse at 82% 34%, rgba(255, 223, 145, 0.15) 0 7%, transparent 18%),
    linear-gradient(110deg, transparent 0 24%, rgba(255, 231, 168, 0.11) 38%, transparent 54%);
  background-size: 140% 140%, 125% 125%, 150% 150%, 130% 130%, 160% 160%;
  mix-blend-mode: soft-light;
  opacity: 0.52;
  animation: leafDapple 12s ease-in-out infinite alternate;
}

.ambient-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 38% 58%, rgba(242, 196, 91, 0.16), transparent 24%),
    linear-gradient(105deg, transparent 20%, rgba(255, 231, 168, 0.1) 43%, transparent 66%);
  mix-blend-mode: soft-light;
  opacity: 0.58;
  animation: ambientDrift 18s ease-in-out infinite alternate;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 48px 0;
}

.hero {
  max-width: 650px;
  padding: 24px 0 34px;
}

.site-emblem {
  width: clamp(72px, 10vw, 118px);
  height: auto;
  display: block;
  margin-bottom: 18px;
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.34));
  animation: emblemGlow 4.8s ease-in-out infinite;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.bilingual {
  max-width: 100%;
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.15;
  vertical-align: middle;
}

.en-line {
  color: rgba(207, 194, 160, 0.82);
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.01em;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(2.3rem, 7vw, 5.7rem);
  line-height: 0.98;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

h1 .bilingual {
  gap: 10px;
  line-height: 0.98;
}

h1 .en-line {
  color: rgba(255, 248, 223, 0.78);
  font-size: 0.24em;
  line-height: 1.15;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

.intro {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.75;
}

.intro .bilingual {
  gap: 4px;
}

.backpack-hotspot {
  position: fixed;
  left: var(--backpack-x, 0px);
  top: var(--backpack-y, 0px);
  z-index: 2;
  width: var(--backpack-w, 86px);
  height: var(--backpack-h, 112px);
  border: 2px solid rgba(244, 199, 93, 0);
  border-radius: 34% 38% 32% 36%;
  color: transparent;
  background: rgba(244, 199, 93, 0.02);
  cursor: pointer;
  animation: backpackPulse 3.8s ease-in-out infinite;
}

.backpack-hotspot > .bilingual {
  position: absolute;
  left: 50%;
  bottom: -52px;
  transform: translateX(-50%);
  white-space: nowrap;
  border-radius: 999px;
  padding: 7px 12px;
  color: #14100a;
  background: var(--gold);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  font-size: 0.82rem;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
}

.backpack-hotspot > .bilingual {
  align-items: center;
}

.backpack-hotspot > .bilingual .en-line {
  color: rgba(20, 16, 10, 0.72);
}

.backpack-hotspot:hover,
.backpack-hotspot:focus-visible {
  border-color: rgba(244, 199, 93, 0.85);
  background: rgba(244, 199, 93, 0.12);
  box-shadow: 0 0 0 6px rgba(244, 199, 93, 0.13);
  outline: none;
  animation-play-state: paused;
}

.backpack-hotspot:hover > .bilingual,
.backpack-hotspot:focus-visible > .bilingual {
  opacity: 1;
}

.site-footer {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 3;
  transform: translateX(-50%);
  font-size: 0.78rem;
}

.site-footer a {
  display: inline-flex;
  border: 1px solid rgba(242, 196, 91, 0.24);
  border-radius: 999px;
  padding: 6px 12px;
  color: rgba(255, 248, 223, 0.9);
  background: rgba(48, 62, 40, 0.34);
  text-decoration: none;
  backdrop-filter: blur(10px);
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--gold);
  border-color: rgba(242, 196, 91, 0.5);
  outline: none;
}

.backpack-overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 15, 0.28);
  backdrop-filter: blur(10px);
  animation: overlayFade 180ms ease-out;
}

.backpack-overlay[hidden] {
  display: none;
}

.backpack-dialog {
  position: relative;
  width: min(1180px, 100%);
  max-height: min(860px, calc(100vh - 48px));
  overflow: auto;
  border: 2px solid rgba(244, 199, 93, 0.54);
  border-radius: 8px;
  padding: 22px;
  background:
    radial-gradient(circle at 18% 8%, rgba(242, 196, 91, 0.12), transparent 26%),
    linear-gradient(145deg, rgba(64, 79, 51, 0.88), rgba(28, 35, 24, 0.9));
  box-shadow: var(--shadow);
  animation: backpackOpen 260ms cubic-bezier(0.18, 0.88, 0.28, 1.08);
  transform-origin: 76% 82%;
}

.backpack-title-row {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-right: 42px;
}

.backpack-title-row .eyebrow {
  margin-bottom: 6px;
}

.backpack-title-row h2 {
  margin-bottom: 0;
  font-size: 1.75rem;
}

.title-with-count {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.count-badge {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 220, 126, 0.35);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--muted);
  background: rgba(255, 248, 223, 0.14);
  box-shadow: inset 0 0 0 1px rgba(35, 37, 23, 0.08);
  font-size: 0.88rem;
  font-weight: 900;
}

.count-badge .bilingual {
  align-items: center;
}

.permission-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.88rem;
}

.permission-panel > span {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 248, 223, 0.22);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 248, 223, 0.08);
}

body.visitor-mode .owner-only,
body.visitor-mode .delete-button {
  display: none;
}

body.visitor-mode .workspace {
  grid-template-columns: 1fr;
}

body.visitor-mode .backpack-dialog {
  width: min(1040px, 100%);
}

body.visitor-mode .archive-panel {
  width: min(100%, 880px);
  justify-self: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 410px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.file-form,
.archive-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.file-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 12px;
}

.form-row {
  display: grid;
  gap: 8px;
}

label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 248, 223, 0.28);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 248, 223, 0.1);
  outline: none;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(244, 199, 93, 0.18);
}

.primary-button,
.filter-chip,
.delete-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  min-height: 56px;
  border-radius: 8px;
  color: #14100a;
  background: linear-gradient(135deg, #ffdf7c, var(--gold) 58%, #b9852e);
  font-weight: 900;
}

.primary-button .bilingual,
.secondary-button .bilingual,
.danger-button .bilingual,
.download-button .bilingual,
.filter-chip .bilingual,
.type-badge .bilingual,
.artifact-name .bilingual {
  align-items: center;
  text-align: center;
}

.primary-button .en-line,
.download-button .en-line,
.filter-chip.active .en-line {
  color: rgba(20, 16, 10, 0.72);
}

.archive-panel {
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
}

.inventory-controls {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.search-input {
  max-width: 280px;
  flex: 0 0 min(280px, 38%);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0;
}

.filter-chip {
  min-height: 46px;
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 248, 223, 0.14);
}

.filter-chip.active {
  color: #14100a;
  background: var(--gold);
  font-weight: 900;
}

.inventory-grid {
  width: fit-content;
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(6, minmax(78px, 116px));
  grid-auto-rows: minmax(96px, 112px);
  justify-content: center;
  margin-inline: auto;
  gap: 9px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.inventory-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}

.pager-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 220, 126, 0.48);
  border-radius: 50%;
  color: var(--ink);
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 248, 223, 0.3), transparent 38%),
    linear-gradient(145deg, rgba(111, 85, 52, 0.88), rgba(55, 48, 28, 0.88));
  box-shadow:
    inset 0 0 0 2px rgba(42, 35, 21, 0.12),
    0 8px 18px rgba(36, 30, 17, 0.18);
  cursor: pointer;
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1;
}

.pager-button:hover,
.pager-button:focus-visible {
  border-color: var(--gold);
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.22),
    0 0 0 4px rgba(244, 199, 93, 0.13),
    0 10px 22px rgba(0, 0, 0, 0.32);
  outline: none;
}

.pager-button:disabled {
  cursor: default;
  opacity: 0.38;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2);
}

#pageStatus {
  min-width: 68px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.inventory-slot {
  position: relative;
  aspect-ratio: auto;
  min-height: 0;
  display: grid;
  align-items: center;
  justify-items: center;
  align-content: center;
  gap: 5px;
  border: 1px solid rgba(255, 220, 126, 0.36);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 229, 152, 0.14), transparent 48%),
    linear-gradient(145deg, rgba(92, 84, 54, 0.54), rgba(45, 58, 34, 0.48));
  box-shadow:
    inset 0 0 0 1px rgba(53, 50, 31, 0.16),
    inset 0 12px 22px rgba(255, 248, 223, 0.05),
    0 8px 18px rgba(36, 31, 18, 0.08);
  cursor: pointer;
  text-align: center;
  overflow: hidden;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.inventory-slot::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255, 248, 223, 0.12);
  border-radius: 5px;
  pointer-events: none;
}

.inventory-slot::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 248, 223, 0.1), transparent 32%),
    linear-gradient(315deg, rgba(46, 41, 25, 0.08), transparent 45%);
  opacity: 0.7;
  pointer-events: none;
}

.item-slot:hover,
.item-slot:focus-visible {
  transform: translateY(-4px) scale(1.025);
  border-color: rgba(244, 199, 93, 0.7);
  filter: saturate(1.12);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.36),
    inset 0 12px 22px rgba(255, 248, 223, 0.04),
    0 10px 22px rgba(244, 199, 93, 0.15);
  outline: none;
}

.item-slot:hover .item-preview,
.item-slot:focus-visible .item-preview {
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.28),
    0 0 18px rgba(244, 199, 93, 0.42);
}

.empty-slot {
  overflow: hidden;
  cursor: default;
  opacity: 0.74;
}

.item-slot.just-added {
  animation: itemArrive 720ms ease-out;
  border-color: rgba(244, 199, 93, 0.82);
}

.type-badge {
  border-radius: 999px;
  padding: 6px 10px;
  color: #14100a;
  background: var(--water);
  font-size: 0.82rem;
  font-weight: 900;
}

.type-badge .en-line {
  color: rgba(20, 16, 10, 0.7);
}

.delete-button {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.34);
  font-size: 1rem;
  line-height: 1;
}

.item-preview,
.detail-icon {
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #14100a;
  background: linear-gradient(135deg, #fff3b8, #f2c45b 58%, #b9852e);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  font-weight: 950;
}

.item-preview {
  position: relative;
  z-index: 1;
  width: min(54%, 46px);
  aspect-ratio: 1;
  overflow: hidden;
  font-size: clamp(0.62rem, 1.35vw, 1rem);
}

.item-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.inventory-slot h3 {
  position: relative;
  z-index: 1;
  width: 100%;
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.18;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.artifact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
  margin: 18px 0 14px;
}

.artifact-slot {
  min-height: 118px;
  display: grid;
  place-items: center;
  gap: 8px;
  border: 2px solid rgba(255, 220, 126, 0.46);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 32%, rgba(255, 248, 223, 0.22), transparent 46%),
    linear-gradient(145deg, rgba(101, 77, 46, 0.86), rgba(47, 58, 34, 0.82));
  box-shadow: inset 0 0 0 2px rgba(63, 54, 31, 0.14);
  cursor: pointer;
  text-align: center;
  overflow-wrap: anywhere;
}

.artifact-slot:hover,
.artifact-slot:focus-visible {
  border-color: var(--gold);
  outline: none;
}

.artifact-slot[hidden] {
  display: none;
}

.artifact-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #14100a;
  background: linear-gradient(135deg, #fff3b8, #f2c45b 58%, #b9852e);
  font-size: 0.72rem;
  font-weight: 950;
}

.artifact-name {
  width: 100%;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.25;
}

#detailNote {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

time {
  color: rgba(255, 248, 223, 0.55);
  font-size: 0.78rem;
}

.detail-overlay,
.preview-overlay,
.confirm-overlay,
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 15, 0.42);
  backdrop-filter: blur(12px);
}

.detail-overlay[hidden],
.preview-overlay[hidden],
.confirm-overlay[hidden],
.auth-overlay[hidden] {
  display: none;
}

.detail-dialog,
.preview-dialog,
.confirm-dialog,
.auth-dialog {
  position: relative;
  width: min(520px, 100%);
  border: 2px solid rgba(244, 199, 93, 0.54);
  border-radius: 8px;
  padding: 26px;
  background:
    radial-gradient(circle at 16% 10%, rgba(242, 196, 91, 0.14), transparent 28%),
    linear-gradient(145deg, rgba(67, 81, 53, 0.92), rgba(32, 40, 27, 0.94)),
    repeating-linear-gradient(90deg, rgba(122, 81, 41, 0.07) 0 20px, transparent 20px 40px);
  box-shadow: var(--shadow);
}

.preview-dialog {
  width: min(760px, 100%);
  animation: itemPreviewOpen 220ms cubic-bezier(0.18, 0.88, 0.28, 1.08);
  transform-origin: var(--preview-origin-x, 50%) var(--preview-origin-y, 50%);
}

.confirm-dialog h2 {
  margin-bottom: 12px;
  font-size: 1.45rem;
}

.confirm-dialog p {
  margin-bottom: 20px;
  color: var(--muted);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.auth-dialog {
  width: min(460px, 100%);
}

.auth-emblem {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  margin-bottom: 14px;
  color: #14100a;
  background: linear-gradient(135deg, #fff3b8, #f2c45b 58%, #b9852e);
  box-shadow: 0 0 24px rgba(244, 199, 93, 0.24);
  font-weight: 950;
}

.auth-emblem .bilingual {
  align-items: center;
}

.auth-emblem .en-line {
  color: rgba(20, 16, 10, 0.72);
  font-size: 0.52em;
}

.auth-dialog h2 {
  margin-bottom: 10px;
  font-size: 1.55rem;
}

.auth-dialog p {
  color: var(--muted);
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.auth-message {
  min-height: 22px;
  margin: 0;
  color: var(--gold);
  font-size: 0.9rem;
}

.auth-message.error {
  color: #ffb1a8;
}

.auth-submit {
  padding: 0 16px;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.secondary-button,
.danger-button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  padding: 6px 16px;
  cursor: pointer;
  font-weight: 900;
}

.secondary-button {
  color: var(--ink);
  background: rgba(255, 232, 161, 0.24);
}

.danger-button {
  color: #fff8df;
  background: #b73535;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(43, 53, 35, 0.48);
  cursor: pointer;
  font-size: 1.35rem;
}

.detail-icon {
  width: 66px;
  height: 66px;
  margin-bottom: 14px;
  font-size: 1.5rem;
}

.detail-dialog .type-badge {
  display: inline-block;
  margin-bottom: 12px;
}

.detail-dialog h2 {
  margin-bottom: 12px;
  font-size: 1.7rem;
  overflow-wrap: anywhere;
}

.preview-dialog h2 {
  margin: 0 42px 16px 0;
  font-size: 1.45rem;
  overflow-wrap: anywhere;
}

.preview-stage {
  min-height: 280px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 220, 126, 0.32);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 248, 223, 0.08);
}

.preview-stage img,
.preview-stage iframe,
.preview-stage video {
  width: 100%;
  max-height: 62vh;
  border: 0;
  border-radius: 8px;
  object-fit: contain;
}

.preview-stage audio {
  width: min(100%, 520px);
}

.preview-stage iframe {
  min-height: 56vh;
  background: white;
}

.preview-stage pre {
  width: 100%;
  max-height: 56vh;
  margin: 0;
  overflow: auto;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.preview-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  text-align: center;
}

.download-button {
  width: fit-content;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  margin-top: 14px;
  border-radius: 8px;
  padding: 6px 14px;
  color: #14100a;
  background: var(--gold);
  font-weight: 900;
  text-decoration: none;
}

@keyframes backpackPulse {
  0%,
  72%,
  100% {
    border-color: rgba(244, 199, 93, 0);
    box-shadow: 0 0 0 0 rgba(244, 199, 93, 0);
    background: rgba(244, 199, 93, 0.02);
  }

  82% {
    border-color: rgba(244, 199, 93, 0.72);
    box-shadow: 0 0 0 8px rgba(244, 199, 93, 0.12), 0 0 24px rgba(244, 199, 93, 0.18);
    background: rgba(244, 199, 93, 0.1);
  }
}

@keyframes overlayFade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes backpackOpen {
  from {
    opacity: 0;
    transform: translate(72px, 72px) scale(0.82);
  }

  to {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

@keyframes ambientDrift {
  from {
    opacity: 0.42;
    transform: translate3d(-1.5%, -0.5%, 0) scale(1);
  }

  to {
    opacity: 0.72;
    transform: translate3d(1.5%, 0.75%, 0) scale(1.025);
  }
}

@keyframes leafDapple {
  0% {
    opacity: 0.48;
    background-position: 0% 0%, 8% 6%, 70% 12%, 84% 32%, 0% 0%;
  }

  50% {
    opacity: 0.68;
    background-position: 5% 3%, 12% 9%, 66% 15%, 78% 36%, 12% 0%;
  }

  100% {
    opacity: 0.54;
    background-position: 10% 4%, 16% 5%, 62% 10%, 72% 30%, 22% 0%;
  }
}

@keyframes emptySlotGlimmer {
  0%,
  58%,
  100% {
    transform: translateX(-130%);
    opacity: 0;
  }

  72% {
    transform: translateX(130%);
    opacity: 1;
  }
}

@keyframes itemPreviewOpen {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.92);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes itemArrive {
  0% {
    transform: translateY(-12px) scale(0.9);
    box-shadow:
      inset 0 0 0 2px rgba(0, 0, 0, 0.25),
      0 0 0 0 rgba(244, 199, 93, 0);
  }

  45% {
    transform: translateY(0) scale(1.06);
    box-shadow:
      inset 0 0 0 2px rgba(0, 0, 0, 0.25),
      0 0 0 7px rgba(244, 199, 93, 0.18),
      0 0 28px rgba(244, 199, 93, 0.34);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes emblemGlow {
  0%,
  100% {
    filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.34));
    transform: translateY(0);
  }

  50% {
    filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.34)) drop-shadow(0 0 18px rgba(244, 199, 93, 0.28));
    transform: translateY(-2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 820px) {
  body {
    background-attachment: scroll;
    background-position: center, right center;
  }

  .app-shell {
    width: min(100% - 24px, 620px);
    padding: 26px 0;
  }

  .backpack-overlay {
    padding: 10px;
  }

  .backpack-dialog {
    max-height: calc(100vh - 20px);
    padding: 14px;
  }

  .workspace,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .backpack-title-row {
    flex-direction: column;
  }

  .permission-panel {
    justify-content: flex-start;
  }

  .inventory-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .search-input {
    max-width: none;
    flex-basis: auto;
  }

  .inventory-grid {
    width: 100%;
    grid-template-columns: repeat(4, minmax(58px, 1fr));
    grid-auto-rows: minmax(78px, 92px);
    gap: 7px;
  }

  .inventory-slot {
    padding: 5px;
  }
}
