:root {
  --bg0: #1a2332;
  --bg1: #243447;
  --sand: #f3e6c8;
  --wood: #c48a4a;
  --yellow: #f6d34a;
  --cheek: #e85d4c;
  --ink: #1e2430;
  --paper: #f7f1e6;
  --accent: #3d8bfd;
  --ok: #3ecf8e;
  --shadow: rgba(10, 16, 28, 0.35);
  --radius: 18px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", "Consolas", "Sarasa Mono SC", monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--paper);
  background:
    radial-gradient(1200px 600px at 10% -10%, #3a4f6a 0%, transparent 55%),
    radial-gradient(900px 500px at 110% 10%, #5a3d1a 0%, transparent 45%),
    linear-gradient(165deg, var(--bg0), var(--bg1));
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  background: rgba(255,255,255,.08);
  color: inherit;
  transition: transform .15s ease, background .15s ease;
}
button:hover { background: rgba(255,255,255,.14); transform: translateY(-1px); }
button:active { transform: translateY(1px) scale(.98); }
button.primary {
  background: linear-gradient(135deg, var(--yellow), #ffb347);
  color: var(--ink);
  font-weight: 700;
}
button.ghost {
  border: 1px solid rgba(255,255,255,.2);
  background: transparent;
}
kbd {
  font-family: var(--mono);
  font-size: .85em;
  padding: .1em .4em;
  border-radius: 6px;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.15);
}

.app {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
  padding-bottom: max(2.5rem, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.brand { display: flex; align-items: center; gap: .85rem; }
.brand-mark {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--yellow), #ff9f1a);
  color: var(--ink);
  font-size: 1.4rem;
  box-shadow: 0 8px 24px rgba(246, 211, 74, .25);
}
.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: .02em;
}
.brand p {
  margin: .15rem 0 0;
  opacity: .7;
  font-size: .85rem;
}
.top-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.stage {
  background: linear-gradient(180deg, #8eb8d8 0%, #c9dff0 45%, #e8d7b8 100%);
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  box-shadow: 0 20px 50px var(--shadow);
  border: 1px solid rgba(255,255,255,.2);
  display: flex;
  flex-direction: column;
}
.room {
  position: relative;
  min-height: 300px;
  padding: 1.25rem 1rem 1.5rem;
  overflow: hidden;
  flex: 1;
}
.window-light {
  position: absolute;
  inset: 0 auto auto 12%;
  width: 42%;
  height: 55%;
  background: linear-gradient(180deg, rgba(255,255,255,.45), transparent);
  clip-path: polygon(10% 0, 100% 0, 80% 100%, 0 100%);
  pointer-events: none;
}
.desk {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 38%;
  background:
    linear-gradient(180deg, #d9a66a, var(--wood) 30%, #9a6430);
  box-shadow: inset 0 8px 0 rgba(255,255,255,.15);
}

.fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 7;
}
.bg-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  background:
    radial-gradient(ellipse 80% 55% at 50% 35%, rgba(255, 236, 140, .0), transparent 70%);
}
.bg-fx::before,
.bg-fx::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
}
.bg-fx::before {
  background:
    linear-gradient(180deg, rgba(255, 245, 180, .55), transparent 42%),
    radial-gradient(circle at 20% 30%, rgba(255, 220, 80, .45), transparent 35%),
    radial-gradient(circle at 80% 20%, rgba(120, 200, 255, .35), transparent 40%);
}
.bg-fx::after {
  background:
    repeating-linear-gradient(
      115deg,
      transparent 0 14px,
      rgba(255, 255, 255, .08) 14px 16px
    );
  mix-blend-mode: screen;
}

.skill-banner {
  position: absolute;
  left: 50%;
  top: 12%;
  right: auto;
  transform: translateX(-50%);
  z-index: 8;
  padding: .4rem .85rem;
  border-radius: 999px;
  background: rgba(20, 24, 32, .88);
  border: 1px solid rgba(246, 211, 74, .55);
  color: #ffe9a8;
  font-weight: 800;
  letter-spacing: .08em;
  font-size: .88rem;
  text-shadow: 0 0 12px rgba(246, 211, 74, .45);
  pointer-events: none;
  max-width: none;
  white-space: nowrap;
}
.skill-banner[hidden] { display: none !important; }

.room.casting {
  animation: roomShake .55s ease;
}
.room.casting .bg-fx {
  animation: bgPulse .7s ease;
}
.room.casting-dash .bg-fx::before {
  animation: dashSky .65s ease;
}
.room.casting-dash .bg-fx::after {
  animation: dashStreaks .55s ease;
}
.room.casting-bolt .bg-fx::before {
  animation: singleBoltSky .75s ease;
}
.room.casting-thunder .bg-fx::before {
  animation: stormFlash 1.15s ease;
}
.room.casting-thunder .bg-fx::after {
  animation: stormRain 1.1s linear;
}
.room.casting-volt .bg-fx::before {
  animation: voltChargeSky 1.2s ease;
}
.room.casting-volt .bg-fx::after {
  animation: dashStreaks .9s ease .35s both;
}
.room.casting-slash .bg-fx::before {
  animation: metalGlint .55s ease;
}
.room.casting .desk {
  animation: deskBounce .55s ease;
}
.room.casting-thunder {
  animation: roomShakeHard .95s ease;
}
.room.casting-bolt {
  animation: roomShake .55s ease;
}
.room.casting-volt .window-light {
  animation: windowBurst 1.1s ease;
}

@keyframes roomShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 1px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, 2px); }
  80% { transform: translate(2px, -1px); }
}
@keyframes roomShakeHard {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-5px, 2px); }
  22% { transform: translate(5px, -3px); }
  35% { transform: translate(-4px, 3px); }
  48% { transform: translate(4px, -2px); }
  62% { transform: translate(-3px, 2px); }
  78% { transform: translate(3px, -1px); }
}
@keyframes bgPulse {
  0% { opacity: 0; }
  15% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes dashSky {
  0% { opacity: 0; transform: translateX(-8%); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateX(10%); }
}
@keyframes dashStreaks {
  0% { opacity: 0; transform: translateX(-20%); }
  30% { opacity: .9; }
  100% { opacity: 0; transform: translateX(30%); }
}
@keyframes singleBoltSky {
  0%, 100% { opacity: 0; }
  12% { opacity: 1; }
  28% { opacity: .2; }
  40% { opacity: .95; }
  70% { opacity: .25; }
}
@keyframes stormFlash {
  0%, 100% { opacity: 0; }
  6% { opacity: 1; }
  12% { opacity: .1; }
  20% { opacity: .95; }
  30% { opacity: .15; }
  42% { opacity: 1; }
  55% { opacity: .2; }
  68% { opacity: .85; }
  82% { opacity: .25; }
}
@keyframes stormRain {
  0% { opacity: 0; background-position: 0 0; }
  15% { opacity: .65; }
  100% { opacity: 0; background-position: 50px 110px; }
}
@keyframes voltChargeSky {
  0% { opacity: 0; filter: brightness(1); }
  25% { opacity: .7; filter: brightness(1.3); }
  55% { opacity: .45; }
  70% { opacity: 1; filter: brightness(1.7); }
  100% { opacity: 0; }
}
@keyframes metalGlint {
  0% { opacity: 0; filter: grayscale(.2); }
  30% { opacity: .55; filter: brightness(1.4) saturate(.4); }
  100% { opacity: 0; }
}
@keyframes deskBounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(3px); }
  55% { transform: translateY(-2px); }
}
@keyframes windowBurst {
  0%, 100% { opacity: 1; filter: brightness(1); }
  20% { opacity: 1; filter: brightness(1.8) saturate(1.4); }
  50% { filter: brightness(1.25); }
}
.pet.casting-dash {
  animation: dashSlide .55s ease;
}
.pet.casting-tail {
  animation: ironTailWhip .75s ease;
  transform-origin: 50% 70%;
}
.pet.casting-volt-rush {
  animation: voltRush 1.15s ease;
  filter: drop-shadow(0 0 12px #ffe566);
}
.pet.casting-struck {
  animation: struckFlash .7s ease;
}
@keyframes dashSlide {
  0% { transform: translateX(-50%); }
  35% { transform: translateX(calc(-50% + 16px)); }
  70% { transform: translateX(calc(-50% - 12px)); }
  100% { transform: translateX(-50%); }
}
@keyframes ironTailWhip {
  0% { transform: translateX(-50%) rotate(0deg) scale(1); filter: brightness(1); }
  22% { transform: translateX(-50%) rotate(-28deg) scale(1.06); filter: brightness(1.35) saturate(.45); }
  48% { transform: translateX(calc(-50% + 18px)) rotate(38deg) scale(1.1); filter: brightness(1.7) contrast(1.15); }
  70% { transform: translateX(calc(-50% - 8px)) rotate(-12deg); }
  100% { transform: translateX(-50%) rotate(0deg) scale(1); filter: brightness(1); }
}
@keyframes voltRush {
  0% { transform: translateX(-50%) scale(1); filter: drop-shadow(0 0 0 transparent); }
  18% { transform: translateX(-50%) scale(1.12); filter: drop-shadow(0 0 18px #ffe566); }
  42% { transform: translateX(calc(-50% + 72px)) scale(1.18); filter: drop-shadow(-18px 0 22px #fff59a); }
  58% { transform: translateX(calc(-50% - 86px)) scale(1.22); filter: drop-shadow(22px 0 28px #fff8c8); }
  78% { transform: translateX(calc(-50% + 28px)) scale(1.08); }
  100% { transform: translateX(-50%) scale(1); filter: drop-shadow(0 0 0 transparent); }
}
@keyframes struckFlash {
  0%, 100% { transform: translateX(-50%); filter: brightness(1); }
  15% { transform: translateX(-50%) scale(1.08); filter: brightness(1.8); }
  40% { transform: translateX(calc(-50% + 4px)); filter: brightness(1.35); }
  65% { transform: translateX(calc(-50% - 3px)); filter: brightness(1.55); }
}

.skills-block {
  margin-top: 1rem;
  padding-top: .85rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.skills-hint {
  font-size: .78rem;
  opacity: .55;
}
.skill-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
  margin-top: .65rem;
}
.skill-card {
  display: grid;
  gap: .3rem;
  padding: .75rem;
  border-radius: 12px;
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.06);
  text-align: left;
}
.skill-card.unlocked {
  border-color: rgba(246, 211, 74, .28);
  background: linear-gradient(160deg, rgba(246,211,74,.1), rgba(0,0,0,.18));
}
.skill-card.locked { opacity: .55; }
.skill-card.cooling { opacity: .7; }
.skill-card strong {
  font-size: .92rem;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.skill-card .meta {
  font-size: .75rem;
  opacity: .65;
  line-height: 1.35;
}
.skill-card button {
  justify-self: start;
  margin-top: .25rem;
  padding: .35rem .75rem;
  font-size: .8rem;
  background: linear-gradient(135deg, #ffe27a, #ffb347);
  color: var(--ink);
  font-weight: 700;
}
.skill-card button:disabled {
  background: rgba(255,255,255,.08);
  color: inherit;
  font-weight: 500;
  opacity: .7;
  cursor: not-allowed;
}

.pet {
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 108px;
  height: 118px;
  transform: translateX(-50%);
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  z-index: 5;
}
.pet-shadow {
  position: absolute;
  left: 50%; bottom: 2px;
  width: 58px; height: 12px;
  transform: translateX(-50%);
  background: rgba(0,0,0,.18);
  border-radius: 50%;
  filter: blur(2px);
}
.pet-body {
  position: relative;
  width: 100%; height: 100%;
  transform-origin: 50% 90%;
}
.pet-canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.18));
}
.pet:focus-visible .pet-body {
  filter: drop-shadow(0 0 10px rgba(246,211,74,.8));
}

.mood-happy .pet-canvas { animation: bounce .45s ease; }
.mood-zap .pet-canvas { animation: zapshake .5s ease; }
.mood-sleep .pet-canvas { animation: sleepbob 2.8s ease-in-out infinite; }
.mood-celebrate .pet-canvas { animation: bounce .5s ease; }
.mood-hungry .pet-canvas { filter: saturate(1.15) drop-shadow(0 8px 12px rgba(0,0,0,.18)); }

@keyframes bounce {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-18px) scale(1.05); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes zapshake {
  0%, 100% { transform: translate(0) rotate(0); }
  20% { transform: translate(-4px, -2px) rotate(-4deg); }
  40% { transform: translate(5px, 1px) rotate(5deg); }
  60% { transform: translate(-3px, 2px) rotate(-3deg); }
  80% { transform: translate(3px, -1px) rotate(2deg); }
}
@keyframes sleepbob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(3px) rotate(2deg); }
}

.spark {
  position: absolute;
  right: 8%; top: 18%;
  font-size: 1.6rem;
  opacity: 0;
  pointer-events: none;
  transform: scale(.4);
  transition: opacity .2s ease, transform .2s ease;
}
.spark.show {
  opacity: 1;
  transform: scale(1) translate(6px, -10px);
}

.float-text {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  font-weight: 800;
  color: #fff8d6;
  text-shadow: 0 2px 8px rgba(0,0,0,.35);
  opacity: 0;
  pointer-events: none;
  z-index: 7;
  font-size: .85rem;
}
.float-text.show {
  animation: floatup 900ms ease forwards;
}
@keyframes floatup {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -36px); }
}

.speech {
  position: absolute;
  left: calc(50% + 58px);
  bottom: calc(18% + 96px);
  right: auto;
  top: auto;
  transform: none;
  max-width: min(200px, 42%);
  margin: 0;
  padding: .5rem .75rem;
  background: rgba(255,255,255,.95);
  color: var(--ink);
  border-radius: 14px 14px 14px 4px;
  font-size: .86rem;
  line-height: 1.4;
  box-shadow: 0 10px 24px rgba(0,0,0,.14);
  text-align: left;
  z-index: 6;
  pointer-events: none;
}
.speech::after {
  display: block;
  content: "";
  position: absolute;
  left: 10px;
  bottom: -7px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 7px 0 0;
  border-color: rgba(255,255,255,.95) transparent transparent transparent;
  transform: none;
}

.panel {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(8px);
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
}
.stat {
  padding: .75rem .7rem;
  border-radius: 14px;
  background: rgba(0,0,0,.18);
}
.stat .label {
  display: block;
  font-size: .75rem;
  opacity: .65;
  margin-bottom: .25rem;
}
.stat strong { font-size: 1.15rem; }

.bond {
  margin-bottom: 1rem;
  padding: .85rem .9rem;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(246,211,74,.12), rgba(61,139,253,.1));
  border: 1px solid rgba(246,211,74,.2);
}
.bond-head {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  font-size: .9rem;
  margin-bottom: .55rem;
}
.bond-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.28);
  overflow: hidden;
}
.bond-track i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f6d34a, #ff8a3d);
  transition: width .35s ease;
}
.bond-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1rem;
  margin-top: .7rem;
  font-size: .82rem;
  opacity: .9;
}
.bond-meta strong { color: var(--yellow); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-top: 1rem;
}
.actions button {
  background: rgba(255,255,255,.1);
}
button.compact {
  padding: .35rem .75rem;
  font-size: .82rem;
}
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .75rem;
}
.panel-title-row h2,
.shop h3,
.inventory h3 {
  margin: 0;
  font-size: 1rem;
}
.milestone-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .55rem;
}
.milestone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .7rem .8rem;
  border-radius: 12px;
  background: rgba(0,0,0,.18);
  font-size: .88rem;
}
.milestone .left { display: grid; gap: .15rem; }
.milestone .req { opacity: .6; font-size: .78rem; }
.milestone.locked { opacity: .55; }
.milestone.claimed { opacity: .7; }
.milestone button {
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--yellow), #ffb347);
  color: var(--ink);
  font-weight: 700;
  padding: .4rem .8rem;
}
.milestone button:disabled {
  background: rgba(255,255,255,.08);
  color: inherit;
  font-weight: 500;
  opacity: .7;
  cursor: default;
}

.shop {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
  margin-top: .65rem;
}
.shop-item {
  display: grid;
  gap: .35rem;
  padding: .75rem;
  border-radius: 12px;
  background: rgba(0,0,0,.18);
  text-align: left;
}
.shop-item strong { font-size: .92rem; }
.shop-item span { font-size: .75rem; opacity: .65; line-height: 1.35; }
.shop-item button {
  justify-self: start;
  margin-top: .2rem;
  background: rgba(255,255,255,.1);
  padding: .35rem .7rem;
  font-size: .8rem;
}
.shop-item button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.shop-hint {
  margin: .7rem 0 0;
  font-size: .78rem;
  opacity: .55;
}

.inventory { margin-top: 1rem; }
.inv-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .55rem;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .3rem .55rem;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  font-size: .78rem;
}
.tag.plate { border: 1px solid rgba(61,139,253,.45); }
.tag.badge { border: 1px solid rgba(246,211,74,.45); }
.muted { opacity: .55; font-size: .82rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%) translateY(20px);
  padding: .65rem 1rem;
  border-radius: 999px;
  background: rgba(20,24,32,.92);
  border: 1px solid rgba(246,211,74,.35);
  color: #fff;
  font-size: .88rem;
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: .25s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tips {
  margin: 1rem 0 0;
  font-size: .82rem;
  opacity: .65;
  line-height: 1.5;
}
.credit {
  margin: .55rem 0 0;
  font-size: .75rem;
  opacity: .55;
  line-height: 1.45;
}
.credit a { color: var(--yellow); }

/* Boss Key */
.boss-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: var(--mono);
}
.boss-screen[hidden] { display: none !important; }
.boss-titlebar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .45rem .8rem;
  background: #323233;
  font-size: .8rem;
}
.boss-dots { display: flex; gap: 6px; }
.boss-dots i {
  width: 10px; height: 10px; border-radius: 50%;
  background: #555;
  display: block;
}
.boss-dots i:nth-child(1) { background: #ff5f56; }
.boss-dots i:nth-child(2) { background: #ffbd2e; }
.boss-dots i:nth-child(3) { background: #27c93f; }
.boss-body { flex: 1; display: flex; min-height: 0; }
.boss-sidebar {
  width: 180px;
  background: #252526;
  padding: .75rem .4rem;
  font-size: .82rem;
  border-right: 1px solid #111;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.boss-file {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  color: #ddd;
  background: transparent;
  cursor: pointer;
  padding: .35rem .6rem;
  border-radius: 4px;
  opacity: .75;
  font: inherit;
}
.boss-file:hover {
  background: #2a2d2e;
  opacity: 1;
}
.boss-file.active {
  background: #37373d;
  opacity: 1;
}
.boss-file:focus-visible {
  outline: 1px solid #007fd4;
  outline-offset: -1px;
}
.boss-code {
  margin: 0;
  flex: 1;
  padding: 1rem 1.2rem;
  overflow: auto;
  font-size: .9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  tab-size: 2;
}
.boss-status {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .3rem .8rem;
  background: #007acc;
  color: #fff;
  font-size: .75rem;
}
.boss-hint { margin-left: auto; opacity: .9; }

body.boss-mode .app { visibility: hidden; }

/* HUD — top chips + one detail line (no sidebar scroll) */
.hud {
  position: absolute;
  left: .65rem;
  right: .65rem;
  top: .55rem;
  z-index: 6;
  display: grid;
  gap: .35rem;
  pointer-events: none;
}
.status-bubbles {
  position: static;
  left: auto;
  top: auto;
  right: auto;
  bottom: auto;
  width: auto;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  overflow: visible;
  pointer-events: none;
}
.status-bubble {
  pointer-events: auto;
  position: relative;
  border: 0;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  background: rgba(255,255,255,.9);
  border-radius: 999px;
  padding: .28rem .55rem;
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: .28rem;
  font-size: .76rem;
  line-height: 1;
  text-align: left;
  transition: background .15s ease, transform .15s ease;
}
.status-bubble:hover,
.status-bubble:focus-visible,
.status-bubble.open {
  background: #fff;
  transform: translateY(-1px);
  z-index: 8;
}
.status-bubble .row {
  display: inline-flex;
  align-items: center;
  gap: .28rem;
  min-width: 0;
}
.status-bubble .ico { font-size: .88rem; flex: 0 0 auto; }
.status-bubble .short {
  font-weight: 700;
  max-width: 4.8em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-detail {
  pointer-events: none;
  min-height: 0;
  max-width: min(360px, 100%);
  padding: .4rem .65rem;
  border-radius: 10px;
  background: rgba(20, 24, 32, .88);
  color: #f5f5f5;
  font-size: .78rem;
  line-height: 1.4;
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
}
.status-detail[hidden] { display: none !important; }
.status-detail strong {
  color: #ffe27a;
  margin-right: .35rem;
}

.feed-tip {
  margin: .65rem 0 0;
  font-size: .8rem;
  opacity: .6;
}

/* reward reveal — side card, pet stays visible */
.reward-reveal[hidden] { display: none !important; }
.reward-reveal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  pointer-events: auto;
}
.reward-reveal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 20, .18);
}
.reward-card {
  position: relative;
  z-index: 1;
  width: min(280px, 86vw);
  text-align: center;
  padding: 1.25rem 1.1rem 1rem;
  border-radius: 20px;
  background: rgba(18, 22, 32, .9);
  border: 1px solid rgba(246, 211, 74, .35);
  box-shadow: 0 20px 48px rgba(0, 0, 0, .35);
  color: #fff;
  animation: rewardCardIn .35s ease;
}
@keyframes rewardCardIn {
  from { opacity: 0; transform: translateX(18px) scale(.96); }
  to { opacity: 1; transform: none; }
}
.reward-stage {
  height: 96px;
  display: grid;
  place-items: center;
  margin-bottom: .35rem;
}
.reward-prop {
  font-size: 3.2rem;
  line-height: 1;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .35));
}
.reward-reveal.kind-blind .reward-prop {
  animation: blindShake .55s ease-in-out 2;
}
.reward-reveal.kind-blind.is-open .reward-prop {
  animation: prizePop .55s cubic-bezier(.2, 1.4, .3, 1) both;
}
.reward-reveal.kind-badge .reward-prop,
.reward-reveal.kind-plate .reward-prop,
.reward-reveal.kind-loot .reward-prop {
  animation: prizePop .55s cubic-bezier(.2, 1.4, .3, 1) both;
}
@keyframes blindShake {
  0%, 100% { transform: rotate(0) translateY(0); }
  20% { transform: rotate(-12deg) translateY(-2px); }
  40% { transform: rotate(12deg) translateY(1px); }
  60% { transform: rotate(-8deg) translateY(-3px); }
  80% { transform: rotate(8deg); }
}
@keyframes prizePop {
  0% { transform: scale(.2) rotate(-20deg); opacity: 0; }
  60% { transform: scale(1.18) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.reward-label {
  margin: 0;
  font-size: .78rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .65;
  color: #ffe27a;
}
.reward-title {
  margin: .35rem 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
}
.reward-hint {
  margin: .7rem 0 0;
  font-size: .75rem;
  opacity: .5;
}

/* modals */
.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 20, .55);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  width: min(440px, 100%);
  max-height: min(82vh, 720px);
  overflow: auto;
  border-radius: 18px;
  background: linear-gradient(165deg, #243447, #1a2332);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
  padding: 1rem 1rem 1.15rem;
  color: var(--paper);
}
.modal-card-wide { width: min(560px, 100%); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .35rem;
}
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  background: rgba(255,255,255,.08);
}
.modal-desc {
  margin: 0 0 .85rem;
  font-size: .82rem;
  opacity: .65;
}
.shop-tabs {
  display: flex;
  gap: .4rem;
  margin-bottom: .85rem;
}
.shop-tab {
  flex: 1;
  border-radius: 999px;
  padding: .45rem .6rem;
  background: rgba(255,255,255,.06);
  font-size: .85rem;
}
.shop-tab.active {
  background: linear-gradient(135deg, var(--yellow), #ffb347);
  color: var(--ink);
  font-weight: 700;
}
.shop-wallet {
  margin-bottom: .65rem;
  font-size: .88rem;
  opacity: .9;
}
.shop-wallet strong { color: var(--yellow); }

body.modal-open { overflow: hidden; }

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .shop-grid,
  .skill-grid { grid-template-columns: 1fr; }
  .room { min-height: 280px; }
  .pet { width: 96px; height: 104px; bottom: 16%; }
  .status-bubble .short { max-width: 3.6em; }
  .skill-banner { top: 10%; font-size: .78rem; }
  .speech {
    left: calc(50% + 42px);
    bottom: calc(16% + 88px);
    max-width: min(160px, 46%);
    font-size: .8rem;
  }
  .reward-reveal {
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 1.5rem;
  }
  .brand h1 { font-size: 1.15rem; }
  .boss-sidebar { display: none; }
  .top-actions { gap: .35rem; }
  .top-actions .ghost { padding: .45rem .7rem; font-size: .82rem; }
}

/* Browser: full UI. Installed PWA (?pet=1): pet only, no room */
.pet-dock {
  display: none !important;
}

html.pet-only,
html.pet-only body,
body.pet-only {
  background: transparent !important;
  background-image: none !important;
  min-height: 100%;
  overflow: hidden;
  color: #fff;
}

html.pet-only .app,
body.pet-only .app {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent !important;
}

html.pet-only .topbar,
html.pet-only .panel,
html.pet-only .window-light,
html.pet-only .desk,
html.pet-only .hud,
body.pet-only .topbar,
body.pet-only .panel,
body.pet-only .window-light,
body.pet-only .desk,
body.pet-only .hud {
  display: none !important;
}

html.pet-only .stage,
body.pet-only .stage {
  width: min(320px, 100vw);
  background: transparent !important;
  background-image: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
}

html.pet-only .room,
body.pet-only .room {
  min-height: 220px;
  padding: .5rem;
  background: transparent !important;
  overflow: visible !important;
}

html.pet-only .bg-fx,
body.pet-only .bg-fx {
  opacity: 0;
  pointer-events: none;
}

html.pet-only .room.casting .bg-fx,
body.pet-only .room.casting .bg-fx {
  animation: bgPulse .7s ease;
}

html.pet-only .pet,
body.pet-only .pet {
  bottom: 18%;
  width: 120px;
  height: 130px;
}

html.pet-only .speech,
body.pet-only .speech {
  background: rgba(255, 255, 255, .94);
  color: #1e2430;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .2);
}

html.pet-only .pet-dock,
body.pet-only .pet-dock {
  display: flex !important;
  position: fixed;
  right: .75rem;
  bottom: .75rem;
  gap: .35rem;
  z-index: 40;
  padding: .3rem;
  border-radius: 999px;
  background: rgba(20, 24, 32, .55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, .12);
}

html.pet-only .pet-dock button,
body.pet-only .pet-dock button {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  font-size: 1rem;
}

html.pet-only .pet-dock button:hover,
body.pet-only .pet-dock button:hover {
  background: rgba(246, 211, 74, .35);
}

html.pet-only.boss-mode .pet-dock,
body.pet-only.boss-mode .pet-dock,
body.pet-only.boss-mode .pet-dock {
  display: none !important;
}

html.pet-only #btn-install,
body.pet-only #btn-install {
  display: none !important;
}

/* Electron frameless: drag the pet / bubble (transparent pixels don't receive mouse) */
html.pet-only.electron-pet,
html.pet-only.electron-pet body,
body.pet-only.electron-pet {
  background: transparent !important;
  user-select: none;
}
html.pet-only.electron-pet .pet,
body.pet-only.electron-pet .pet {
  cursor: grab;
}
html.pet-only.electron-pet .pet:active,
body.pet-only.electron-pet .pet:active {
  cursor: grabbing;
}
html.pet-only.electron-pet .speech,
body.pet-only.electron-pet .speech {
  cursor: grab;
  pointer-events: auto;
}
