:root {
  --bg-0: #0f172a;
  --bg-1: #1a2634;
  --panel: rgba(15, 23, 42, 0.65);
  --panel-soft: rgba(15, 23, 42, 0.45);
  --line: rgba(56, 189, 248, 0.55);
  --line-dim: rgba(34, 211, 238, 0.28);
  --cyan: #38bdf8;
  --cyan-2: #22d3ee;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --danger: #fb7185;
  --ok: #4ade80;
  --gold: #fbbf24;
  --loot: #a78bfa;
  --shadow: 0 12px 40px rgba(2, 8, 23, 0.45);
  --radius: 14px;
  --font: "Inter", system-ui, sans-serif;
  --pixel: "Press Start 2P", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-0);
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.pixel {
  font-family: var(--pixel);
  letter-spacing: 0.04em;
}

.muted {
  color: var(--muted);
  font-size: 0.75rem;
}

/* —— World backdrop —— */
.world {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.72), rgba(15, 23, 42, 0.88)),
    url("assets/scene-bg.jpg") center / cover no-repeat;
}

.sky {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(18px) saturate(0.9);
  background:
    radial-gradient(ellipse 80% 50% at 70% 10%, rgba(56, 189, 248, 0.1), transparent 60%),
    radial-gradient(ellipse 60% 40% at 20% 30%, rgba(34, 211, 238, 0.06), transparent 55%);
}

.cityscape,
.wet-ground {
  display: none;
}

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(2, 6, 16, 0.72) 100%);
}

.rain {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.rain span {
  position: absolute;
  top: -10%;
  width: 1px;
  height: 14vh;
  background: linear-gradient(180deg, transparent, rgba(186, 230, 253, 0.35));
  animation: fall linear infinite;
  opacity: 0.55;
}

@keyframes fall {
  to {
    transform: translateY(120vh);
  }
}

@keyframes windows {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 0.55;
  }
}

/* —— Glass —— */
.glass {
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 0.5px solid var(--line);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(148, 163, 184, 0.08);
  border-radius: var(--radius);
}

.glass-soft {
  background: var(--panel-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 0.5px solid var(--line-dim);
  border-radius: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border: 0.5px solid var(--line);
  border-radius: 4px;
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tag--gold {
  color: var(--gold);
  border-color: rgba(251, 191, 36, 0.45);
}

.tag--loot {
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.5);
}

/* —— App shell —— */
.app {
  position: relative;
  z-index: 1;
  height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem 1.25rem 0.75rem;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.85rem;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1.2fr auto auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.75rem 1rem;
  animation: rise 0.7s ease both;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.logo-mark {
  color: var(--cyan-2);
  font-size: 1.35rem;
  line-height: 1;
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.45);
  animation: pulse 2.8s ease-in-out infinite;
}

.brand {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.1;
}

.brand-sub {
  margin: 0.15rem 0 0;
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.18em;
}

.event-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  min-width: 0;
  padding: 0.35rem 0.65rem;
  border-left: 0.5px solid var(--line-dim);
  border-right: 0.5px solid var(--line-dim);
}

.event-text {
  font-weight: 600;
  font-size: 0.92rem;
}

.countdown {
  color: var(--cyan-2);
  font-size: 0.58rem;
  padding: 0.35rem 0.5rem;
  border: 0.5px solid var(--line-dim);
  border-radius: 6px;
  background: rgba(8, 47, 73, 0.35);
}

.env-panel {
  display: grid;
  gap: 0.2rem;
  font-size: 0.78rem;
}

.env-row {
  display: flex;
  gap: 0.5rem;
  white-space: nowrap;
}

.env-row .muted {
  min-width: 2rem;
}

.status-dot::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 0.35rem;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  vertical-align: middle;
}

.achievement {
  display: grid;
  gap: 0.3rem;
  text-align: left;
  padding: 0.55rem 0.75rem;
  max-width: 220px;
  transition: border-color 0.2s, transform 0.2s;
}

.achievement:hover {
  border-color: rgba(251, 191, 36, 0.55);
  transform: translateY(-1px);
}

.achievement__text {
  font-size: 0.82rem;
  font-weight: 500;
}

/* —— Stage —— */
.stage {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 360px);
  gap: 1rem;
  min-height: 0;
}

.scene {
  position: relative;
  min-height: 0;
  border-radius: calc(var(--radius) + 2px);
  border: 0.5px solid var(--line-dim);
  overflow: hidden;
  animation: rise 0.85s ease both 0.08s;
  background: #0a1524;
}

/* —— Scene photo backdrop —— */
.scene__art {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.scene__photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  filter: saturate(1.05) contrast(1.05) brightness(0.92);
  transform: scale(1.02);
}

.scene__grade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(8, 15, 28, 0.35) 0%, transparent 28%, transparent 55%, rgba(8, 15, 28, 0.55) 100%),
    radial-gradient(ellipse at center, transparent 40%, rgba(2, 6, 16, 0.55) 100%);
}

.scene__rain {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0.55;
}

.scene__rain span {
  position: absolute;
  top: -12%;
  width: 1px;
  height: 12%;
  background: linear-gradient(180deg, transparent, rgba(186, 230, 253, 0.5));
  animation: fall linear infinite;
}

.scene__fog {
  position: absolute;
  inset: auto 0 0 0;
  height: 28%;
  background: linear-gradient(180deg, transparent, rgba(15, 23, 42, 0.45));
}

/* —— NPC photo portraits —— */
.npc {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 120px;
}

.npc__portrait {
  width: 112px;
  height: 148px;
  object-fit: cover;
  object-position: center top;
  border-radius: 12px;
  border: 0.5px solid rgba(56, 189, 248, 0.35);
  box-shadow:
    0 14px 28px rgba(2, 8, 23, 0.55),
    0 0 0 1px rgba(15, 23, 42, 0.4);
  background: #0a1524;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
}

.npc__portrait--dim {
  opacity: 0.82;
  filter: saturate(0.85);
}

.npc:hover .npc__portrait,
.npc:focus-within .npc__portrait {
  transform: translateY(-4px) scale(1.03);
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow:
    0 18px 36px rgba(2, 8, 23, 0.6),
    0 0 20px rgba(34, 211, 238, 0.18);
}

.npc[data-npc="colleague"] .npc__portrait {
  animation: idle 2.8s ease-in-out infinite;
}

.npc[data-npc="passerby"] .npc__portrait {
  animation: walkBob 2.2s ease-in-out infinite;
}

.npc__label {
  display: grid;
  gap: 0.15rem;
  padding: 0.4rem 0.6rem;
  min-width: 84px;
  text-align: center;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  z-index: 2;
  margin-top: -1.1rem;
}

.npc__label:hover,
.npc:focus-within .npc__label {
  border-color: var(--line);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(2, 8, 23, 0.35);
}

.npc__name {
  font-size: 0.82rem;
  font-weight: 600;
}

.npc__name.hostile {
  color: var(--danger);
}

.npc__name.safe {
  color: var(--ok);
}

.npc__name.muted-name {
  color: var(--muted);
}

.npc__meta {
  font-size: 0.58rem;
  color: var(--muted);
}

.npc__meta.pixel {
  font-size: 0.48rem;
  color: var(--cyan);
}

.npc__bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 200px;
  padding: 0.55rem 0.7rem;
  font-size: 0.78rem;
  line-height: 1.4;
  z-index: 5;
  animation: pop 0.25s ease;
}

.npc__bubble[hidden] {
  display: none;
}

.quest-mark {
  position: absolute;
  left: 50%;
  top: -0.55rem;
  transform: translateX(-50%);
  color: var(--gold);
  font-weight: 800;
  font-size: 1.45rem;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.55);
  animation: bob 1.4s ease-in-out infinite;
  z-index: 3;
}

.loot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  z-index: 3;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.loot__img {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border-radius: 12px;
  border: 0.5px solid rgba(251, 191, 36, 0.45);
  box-shadow: 0 10px 24px rgba(2, 8, 23, 0.5);
  mix-blend-mode: lighten;
  position: relative;
  z-index: 1;
  transition: transform 0.2s ease;
}

.loot:hover .loot__img {
  transform: translateY(-3px) scale(1.04);
}

.loot__glow {
  display: block;
  width: 90px;
  height: 28px;
  margin-top: -18px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(167, 139, 250, 0.55), transparent 70%);
  filter: blur(1px);
  animation: lootPulse 1.8s ease-in-out infinite;
}

.loot__label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
  transition: transform 0.2s, border-color 0.2s;
}

.loot:hover .loot__label {
  transform: translateY(-2px);
  border-color: rgba(167, 139, 250, 0.7);
}

.loot.is-claimed {
  opacity: 0.45;
  pointer-events: none;
}

.loot.is-claimed .loot__glow {
  animation: none;
  opacity: 0.3;
}

.loot.is-claimed .loot__img {
  filter: grayscale(0.85);
  mix-blend-mode: normal;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  z-index: 10;
  animation: pop 0.25s ease;
}

.toast[hidden] {
  display: none;
}

/* —— HUD —— */
.hud {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  padding: 1rem;
  min-height: 0;
  overflow: auto;
  animation: rise 0.9s ease both 0.14s;
}

.hud__head {
  display: grid;
  gap: 0.75rem;
  padding-bottom: 0.85rem;
  border-bottom: 0.5px solid var(--line-dim);
}

.title-tag {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.player-title {
  margin: 0.2rem 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.level-block {
  display: grid;
  gap: 0.4rem;
}

.level {
  color: var(--cyan);
  font-size: 0.72rem;
}

.exp {
  position: relative;
  height: 16px;
  border: 0.5px solid var(--line-dim);
  border-radius: 999px;
  background: rgba(2, 8, 23, 0.45);
  overflow: hidden;
}

.exp__fill {
  height: 100%;
  background: linear-gradient(90deg, #0284c7, var(--cyan-2));
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.35);
  transition: width 0.4s ease;
}

.exp__text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.42rem;
  color: #f8fafc;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.gold {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: var(--gold);
}

.gold__icon {
  font-size: 0.95rem;
}

.gold__unit {
  color: var(--muted);
  font-size: 0.55rem;
}

.hud__vitals {
  display: grid;
  gap: 0.85rem;
}

.mood {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.mood__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.65rem;
  border: 0.5px solid var(--line-dim);
  border-radius: 999px;
  background: rgba(2, 8, 23, 0.35);
  transition: border-color 0.2s;
}

.mood__btn:hover {
  border-color: var(--line);
}

.mood__label {
  font-weight: 600;
  font-size: 0.9rem;
}

.mood__icon {
  font-size: 1rem;
  transition: transform 0.25s;
}

.mood.is-bad .mood__icon {
  transform: scale(1.1);
}

.rings {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem;
  align-items: center;
}

.ring {
  position: relative;
  width: 84px;
  height: 84px;
}

.ring__svg {
  width: 84px;
  height: 84px;
  transform: rotate(-90deg);
}

.ring__track {
  fill: none;
  stroke: rgba(148, 163, 184, 0.18);
  stroke-width: 6;
}

.ring__value {
  fill: none;
  stroke: var(--cyan-2);
  stroke-width: 6;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.45));
  transition: stroke-dashoffset 0.45s ease;
}

.ring__meta {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 0.15rem;
}

.ring__meta .pixel {
  font-size: 0.55rem;
  color: var(--cyan);
}

.hp {
  display: grid;
  gap: 0.35rem;
}

.hp__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.hp__label .pixel {
  font-size: 0.48rem;
}

.hp__bar {
  height: 12px;
  border: 0.5px solid rgba(251, 113, 133, 0.35);
  border-radius: 999px;
  background: rgba(2, 8, 23, 0.45);
  overflow: hidden;
}

.hp__fill {
  height: 100%;
  background: linear-gradient(90deg, #be123c, var(--danger));
  box-shadow: 0 0 10px rgba(251, 113, 133, 0.35);
  transition: width 0.4s ease;
}

.section-label {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.skill-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.skill {
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem 0.4rem;
  border: 0.5px solid var(--line-dim);
  border-radius: 10px;
  background: rgba(2, 8, 23, 0.35);
  text-align: center;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.skill:hover {
  border-color: var(--line);
  background: rgba(8, 47, 73, 0.35);
}

.skill:active {
  transform: scale(0.97);
}

.skill.is-active {
  border-color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.2);
}

.skill__name {
  font-size: 0.85rem;
  font-weight: 600;
}

.skill__lv {
  font-size: 0.42rem;
  color: var(--cyan-2);
}

.buff-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.buff {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 0.5px solid var(--line-dim);
  font-size: 0.8rem;
  background: rgba(2, 8, 23, 0.28);
}

.buff em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.72rem;
}

.buff__tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.buff--pos .buff__tag {
  color: var(--ok);
  border: 0.5px solid rgba(74, 222, 128, 0.4);
}

.buff--neg .buff__tag {
  color: var(--danger);
  border: 0.5px solid rgba(251, 113, 133, 0.4);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.btn {
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  border: 0.5px solid var(--line-dim);
  background: rgba(2, 8, 23, 0.4);
  font-weight: 600;
  font-size: 0.86rem;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.btn:hover {
  border-color: var(--line);
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  border-color: rgba(56, 189, 248, 0.55);
  background: linear-gradient(180deg, rgba(14, 116, 144, 0.45), rgba(8, 47, 73, 0.55));
  color: #e0f2fe;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.25rem 0.15rem;
  font-size: 0.72rem;
  animation: rise 1s ease both 0.2s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-5px);
  }
}

@keyframes lootPulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.75;
  }
  50% {
    opacity: 1;
  }
}

@keyframes neonFlicker {
  0%,
  90%,
  100% {
    opacity: 1;
  }
  92% {
    opacity: 0.45;
  }
  94% {
    opacity: 1;
  }
  96% {
    opacity: 0.6;
  }
}

@keyframes idle {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes walkBob {
  0%,
  100% {
    transform: translateX(0) translateY(0);
  }
  50% {
    transform: translateX(4px) translateY(-2px);
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
    max-width: none;
  }

  .topbar {
    grid-template-columns: 1fr 1fr;
  }

  .event-banner {
    grid-column: 1 / -1;
    border: none;
    padding: 0.5rem 0 0;
    border-top: 0.5px solid var(--line-dim);
  }

  .stage {
    grid-template-columns: 1fr;
  }

  .scene {
    min-height: 420px;
  }

  .footer {
    flex-direction: column;
    gap: 0.25rem;
  }
}

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .achievement {
    max-width: none;
  }

  .skill-grid {
    grid-template-columns: 1fr;
  }

  .rings {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .npc__bubble {
    max-width: 150px;
  }
}
