@font-face {
  font-family: "LostSoulHand";
  src: url("../assets/fonts/lost-soul-hand.ttf?v=0.3.3-goalpanel-fix-1") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #261425;
  --paper: #fff1dd;
  --paper-soft: #f6d7bb;
  --night: #171323;
  --night-2: #251733;
  --plum: #4f2348;
  --moss: #6fa37a;
  --rose: #f07187;
  --gold: #ffd36a;
  --aqua: #77d9ca;
  --lilac: #b7a0ff;
  --shadow: rgba(24, 10, 24, 0.45);
  --panel: rgba(255, 239, 218, 0.92);
  --panel-dark: rgba(38, 20, 37, 0.84);
  --font-display: "LostSoulHand", "Comic Sans MS", "Comic Neue", "Trebuchet MS", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: #15121f;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  font-family: var(--font-display);
  color: var(--paper);
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 211, 106, 0.14), transparent 13rem),
    radial-gradient(circle at 88% 74%, rgba(119, 217, 202, 0.12), transparent 15rem),
    radial-gradient(circle at 50% -15%, rgba(240, 113, 135, 0.32), transparent 34rem),
    linear-gradient(180deg, #23162e 0%, #15121f 62%, #0d1119 100%);
}

img {
  max-width: 100%;
}

button {
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100vw, 560px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 16% 14%, rgba(255, 211, 106, 0.16), transparent 9rem),
    radial-gradient(circle at 80% 20%, rgba(119, 217, 202, 0.14), transparent 11rem),
    linear-gradient(180deg, rgba(46, 28, 55, 0.96), rgba(22, 17, 32, 0.98));
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
  isolation: isolate;
}

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen-active {
  display: flex;
  flex-direction: column;
}

.game-screen {
  padding:
    max(6px, env(safe-area-inset-top))
    env(safe-area-inset-right)
    max(6px, env(safe-area-inset-bottom))
    env(safe-area-inset-left);
}

.menu-screen {
  justify-content: start;
  gap: 16px;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 38%, rgba(148, 72, 255, 0.08), transparent 18rem),
    url("../assets/dashboard/dashboard_bg_main.png?v=0.3.3-goalpanel-fix-1"),
    radial-gradient(circle at 16% 14%, rgba(255, 211, 106, 0.16), transparent 9rem),
    radial-gradient(circle at 80% 20%, rgba(119, 217, 202, 0.14), transparent 11rem),
    linear-gradient(180deg, rgba(46, 28, 55, 0.96), rgba(22, 17, 32, 0.98));
  background-position: center, center, center, center, center, center;
  background-size: cover, cover, cover, auto, auto, cover;
  background-repeat: no-repeat;
}

.menu-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(12, 6, 30, 0.2) 0%, rgba(12, 6, 30, 0.34) 58%, rgba(8, 6, 18, 0.72) 100%),
    radial-gradient(circle at 50% 35%, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.38) 82%);
}

.dashboard-bg-img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

.mist {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.35;
  background:
    radial-gradient(ellipse at 25% 78%, rgba(255, 241, 221, 0.18), transparent 18rem),
    radial-gradient(ellipse at 72% 63%, rgba(183, 160, 255, 0.16), transparent 15rem);
  animation: mistDrift 8s ease-in-out infinite alternate;
}

.menu-top-actions {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.menu-icon-button {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--paper);
  background: transparent;
  box-shadow: none;
}

.menu-icon-img {
  width: 100%;
  height: 100%;
  max-width: none;
  display: block;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.28));
}

.title-mark {
  position: relative;
  z-index: 2;
  padding: clamp(54px, 9vh, 86px) 0 0;
}

.version-chip {
  position: absolute;
  top: max(15px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  z-index: 4;
  padding: 0;
  color: rgba(255, 241, 221, 0.68);
  font-weight: 900;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.title-kicker,
.eyebrow {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--gold);
  font-weight: 800;
}

.title-logo {
  display: block;
  width: min(86%, 390px);
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.42));
  animation: logoFloat 4.8s ease-in-out infinite;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  display: grid;
  gap: 2px;
  margin-top: 10px;
  color: var(--paper);
  font-size: clamp(3.2rem, 15vw, 5.4rem);
  line-height: 0.82;
  text-shadow: 0 5px 0 #602a54, 0 12px 24px rgba(0, 0, 0, 0.4);
}

h1 span:last-child {
  color: var(--gold);
  text-shadow: 0 5px 0 #7b3653, 0 12px 24px rgba(0, 0, 0, 0.4);
}

.landing-panel {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 16px;
  width: min(100%, 480px);
  margin: auto auto 18px;
  padding: 16px;
  border: 1px solid rgba(255, 241, 221, 0.18);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(22, 14, 34, 0.56), rgba(16, 11, 26, 0.7)),
    rgba(20, 12, 28, 0.48);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(5px);
}

.landing-panel p {
  max-width: 28rem;
  margin: 0;
  color: #f9d9c7;
  font-size: 1rem;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.title-charms {
  display: flex;
  gap: 8px;
  margin-top: -2px;
}

.charm {
  width: 46px;
  height: 46px;
  object-fit: contain;
  object-position: center;
  border-radius: 10px;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.32));
  animation: mascotBob 2.3s ease-in-out infinite;
}

.charm-soul {
  animation-delay: 0ms;
}

.charm-eye {
  animation-delay: 180ms;
}

.charm-flame {
  animation-delay: 360ms;
}

.menu-actions,
.result-actions {
  display: grid;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.menu-screen .menu-actions {
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 2px;
}

.menu-screen .primary-button,
.menu-screen .ghost-button {
  min-height: 50px;
  padding: 12px 10px;
}

.menu-screen .landing-art-button {
  min-height: 0;
  aspect-ratio: 512 / 180;
  padding: 0 34px 4px 36px;
  border: 0;
  border-radius: 10px;
  color: var(--paper);
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  box-shadow: none;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: clamp(1rem, 4.4vw, 1.16rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.58), 0 0 7px rgba(255, 241, 220, 0.24);
}

.menu-screen .landing-play-button {
  padding: 0 48px 8px 34px;
  color: #fff1dc;
  text-shadow: 0 2px 0 rgba(79, 28, 11, 0.86), 0 0 7px rgba(45, 17, 30, 0.34);
  background-image: url("../assets/ui/ui_button_primary_play.png?v=0.3.3-goalpanel-fix-1");
}

.menu-screen .landing-book-button {
  padding: 0 34px 4px 36px;
  color: #fff1dc;
  text-shadow: 0 2px 0 rgba(12, 8, 22, 0.82), 0 0 8px rgba(169, 109, 255, 0.26);
  background-image: url("../assets/ui/ui_button_primary_book.png?v=0.3.3-goalpanel-fix-1");
}

.primary-button,
.ghost-button,
.icon-button,
.menu-icon-button,
.level-node {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease;
}

.primary-button:active,
.ghost-button:active,
.icon-button:active,
.menu-icon-button:active,
.level-node:active,
.tile:active {
  transform: scale(0.97);
}

.primary-button,
.ghost-button {
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.24);
}

.primary-button {
  background: linear-gradient(180deg, #ffcf75, #ff8f7d);
  border: 1px solid rgba(255, 241, 221, 0.42);
}

.ghost-button {
  color: var(--paper);
  background: rgba(255, 241, 221, 0.13);
  border: 1px solid rgba(255, 241, 221, 0.22);
}

.primary-button:hover,
.ghost-button:hover,
.icon-button:hover,
.menu-icon-button:hover,
.level-node:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.muted-button {
  opacity: 0.58;
}

.top-bar,
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top-bar h2,
.hud strong,
.result-card h2 {
  color: var(--paper);
}

.icon-button {
  min-width: 58px;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--paper);
  background: rgba(255, 241, 221, 0.12);
  border: 1px solid rgba(255, 241, 221, 0.18);
}

.map-screen,
.collection-screen {
  gap: 22px;
}

.map-card {
  position: relative;
  min-height: 70vh;
  padding: 18px 10px 26px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 24% 20%, rgba(255, 211, 106, 0.17), transparent 8rem),
    radial-gradient(circle at 78% 72%, rgba(119, 217, 202, 0.14), transparent 10rem),
    rgba(255, 241, 221, 0.08);
  border: 1px solid rgba(255, 241, 221, 0.14);
}

.map-deco {
  position: absolute;
  pointer-events: none;
  opacity: 0.42;
}

.deco-torii {
  right: 20px;
  top: 18px;
  width: 58px;
  height: 38px;
  border-top: 8px solid var(--rose);
  border-left: 6px solid var(--rose);
  border-right: 6px solid var(--rose);
}

.deco-torii::before {
  content: "";
  position: absolute;
  left: -12px;
  right: -12px;
  top: -17px;
  height: 8px;
  border-radius: 999px;
  background: var(--gold);
}

.deco-lantern {
  left: 18px;
  bottom: 18px;
  width: 28px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffd36a, #f07187);
  box-shadow: 0 0 18px rgba(255, 211, 106, 0.38);
}

.map-label {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 18px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--paper-soft);
  text-align: center;
  background: rgba(38, 20, 37, 0.62);
  border: 1px solid rgba(255, 241, 221, 0.12);
}

.map-path {
  min-height: 56vh;
  display: grid;
  align-content: start;
  gap: 12px;
  position: relative;
  padding: 4px 0;
}

.map-path::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 3%;
  bottom: 3%;
  width: 10px;
  border-radius: 999px;
  background: repeating-linear-gradient(180deg, #ffd36a, #ffd36a 16px, #75486a 16px, #75486a 28px);
  opacity: 0.58;
  transform: translateX(-50%);
}

.map-node {
  width: min(86%, 360px);
  min-height: 74px;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  align-items: center;
  justify-self: start;
  padding: 10px;
  border: 1px solid rgba(255, 241, 221, 0.18);
  border-radius: 8px;
  color: var(--paper);
  background: rgba(38, 20, 37, 0.88);
  box-shadow: 0 9px 0 rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 1;
}

.map-node.side-right {
  justify-self: end;
}

.map-node:disabled {
  cursor: default;
}

.map-node-number {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  font-weight: 900;
  background: var(--paper);
  box-shadow: inset 0 -7px rgba(0, 0, 0, 0.14), 0 0 0 5px rgba(255, 241, 221, 0.1);
}

.map-node-copy {
  display: grid;
  gap: 3px;
}

.map-node-copy strong {
  font-size: 0.96rem;
}

.map-node-copy small {
  color: var(--paper-soft);
  font-size: 0.76rem;
  font-weight: 800;
}

.map-node-state {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--gold);
  font-size: 0.7rem;
  font-weight: 900;
}

.map-node.locked {
  opacity: 0.48;
  filter: grayscale(0.8);
}

.map-node.current {
  outline: 3px solid var(--gold);
}

.map-node.completed .map-node-number {
  background: linear-gradient(180deg, #d9fff9, #77d9ca);
  font-size: 0.72rem;
}

.area-card {
  width: min(78%, 330px);
  display: grid;
  gap: 3px;
  justify-self: center;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--paper);
  text-align: center;
  background: rgba(255, 241, 221, 0.1);
  border: 1px solid rgba(255, 241, 221, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  position: relative;
  z-index: 2;
}

.area-card strong {
  color: var(--gold);
}

.area-card small,
.area-deco {
  color: var(--paper-soft);
  font-weight: 800;
  font-size: 0.76rem;
}

.area-deco {
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.area-shrine .map-node-number { background: linear-gradient(180deg, #defbf6, #77d9ca); }
.area-bath .map-node-number { background: linear-gradient(180deg, #fff1dd, #f07187); }
.area-grove .map-node-number { background: linear-gradient(180deg, #d8f7cb, #6fa37a); }
.area-slurple .map-node-number { background: linear-gradient(180deg, #d89dff, #7b4bd6); color: var(--paper); }
.area-gate .map-node-number { background: linear-gradient(180deg, #ffd36a, #4f2348); color: var(--paper); }

.level-node {
  width: min(100%, 390px);
  margin-left: clamp(0px, 10vw, 46px);
  display: grid;
  grid-template-columns: 72px 1fr auto;
  grid-template-areas: "orb content badge";
  gap: 2px 14px;
  align-items: center;
  text-align: left;
  padding: 14px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.18);
}

.level-node:disabled {
  cursor: default;
}

.node-content {
  grid-area: content;
  display: grid;
  gap: 3px;
}

.node-content strong {
  font-size: 1.08rem;
}

.node-content small {
  color: #644b58;
  font-weight: 800;
}

.node-badge {
  grid-area: badge;
  align-self: center;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--gold);
  font-size: 0.75rem;
  font-weight: 900;
}

.locked-badge {
  background: #cdb7a1;
}

.node-orb {
  grid-area: orb;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  box-shadow: inset 0 -8px rgba(0, 0, 0, 0.16), 0 0 0 5px rgba(38, 20, 37, 0.18);
}

.shrine-orb {
  background: radial-gradient(circle at 35% 30%, #fff1dd 0 10%, #f07187 11% 52%, #6d315f 53%);
}

.bath-orb {
  background: radial-gradient(circle at 35% 30%, #fff1dd 0 10%, #77d9ca 11% 52%, #315363 53%);
}

.grove-orb {
  background: radial-gradient(circle at 35% 30%, #fff1dd 0 10%, #95d883 11% 52%, #31563e 53%);
}

.node-preview {
  opacity: 0.62;
}

.hud {
  position: sticky;
  top: 0;
  z-index: 4;
  gap: 5px;
  padding: 4px 0;
}

.hud-stat {
  width: 56px;
  min-width: 56px;
  min-height: 50px;
  padding: 7px 6px 6px;
  border-radius: 12px;
  color: var(--paper);
  text-align: center;
  background-color: var(--panel-dark);
  background-image: url("../assets/ui/square_panel_bg.png?v=0.3.3-goalpanel-fix-1");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  border: 0;
}

.hud-stat span {
  display: block;
  color: var(--paper-soft);
  font-size: 0.54rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hud-stat strong {
  font-size: 1rem;
  line-height: 1.05;
}

.hud-level-card {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 50px;
  display: grid;
  align-content: center;
  gap: 1px;
  padding: 8px 9px;
  border-radius: 12px;
  color: var(--paper);
  background:
    linear-gradient(180deg, rgba(255, 241, 221, 0.16), rgba(255, 241, 221, 0.04)),
    rgba(38, 20, 37, 0.82);
  border: 1px solid rgba(255, 241, 221, 0.16);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22);
}

.hud-level-card span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--paper-soft);
  font-size: 0.7rem;
  line-height: 1;
}

.hud-level-card strong {
  color: var(--gold);
  font-size: 1rem;
  line-height: 1;
}

.hud .icon-button {
  width: 50px;
  min-width: 50px;
  min-height: 50px;
  padding: 0;
  border: 0;
  color: var(--paper);
  background-color: var(--panel-dark);
  background-image: url("../assets/ui/square_panel_bg.png?v=0.3.3-goalpanel-fix-1");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

.goal-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
  margin: 3px 0 6px;
  padding: 3px 12px;
  border: 8px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  background-color: transparent;
  background-image: none;
  border-image-source: url("../assets/ui/goal_panel.png?v=0.3.3-goalpanel-fix-1");
  border-image-slice: 42 fill;
  border-image-width: 8px;
  border-image-repeat: stretch;
  box-shadow: none;
}

.goal-panel .eyebrow {
  color: #9b3c58;
}

.goal-panel p {
  font-weight: 900;
}

.goal-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.goal-copy h2 {
  display: none;
  color: var(--ink);
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.05;
}

.goal-panel .eyebrow {
  display: none;
}

.goal-panel .summon-pill {
  display: none;
}

.goal-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.goal-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 2px 7px 2px 4px;
  border-radius: 999px;
  background: transparent;
  font-size: 0.82rem;
  line-height: 1;
  font-weight: 900;
}

.strip-label {
  color: #7a364e;
  font-size: 0.64rem;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.goal-chip strong {
  color: var(--plum);
}

.goal-done {
  filter: saturate(1.08) brightness(1.03);
}

.yokai-hint {
  display: none;
  margin-top: 8px;
  color: #644b58;
  font-size: 0.82rem;
  font-weight: 800;
}

.yokai-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.yokai-progress-title {
  display: none;
}

.yokai-progress-items {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
  align-items: center;
}

.yokai-progress-row {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  min-height: 30px;
  padding: 2px 7px 2px 4px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1;
  font-weight: 900;
}

.ui-target-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.ui-target-icon img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  display: block;
}

.mini-tile {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.mini-tile svg {
  width: 74%;
  height: 74%;
}

.tile-art-wrap {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.tile-art-img,
.tile-art-fallback,
.tile-art-fallback svg {
  width: 100%;
  height: 100%;
}

.tile-art-img {
  position: absolute;
  inset: 0;
  object-fit: contain;
  object-position: center;
  z-index: 2;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.18));
}

.tile-art-fallback {
  display: none;
  place-items: center;
  z-index: 1;
  border-radius: inherit;
  background: var(--tile-bg);
  box-shadow: inset 0 -4px rgba(0, 0, 0, 0.15);
}

.tile-art-loaded .tile-art-fallback {
  display: none;
}

.tile-art-missing .tile-art-fallback {
  display: grid;
}

.mini-special {
  width: 34px;
  min-height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink);
  background: var(--gold);
  font-size: 0.66rem;
  font-weight: 900;
}

.summon-pill {
  flex: 0 0 auto;
  min-width: 66px;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--ink);
  text-align: center;
  font-weight: 900;
  background: linear-gradient(180deg, #d9fff9, #77d9ca);
  box-shadow: inset 0 -4px rgba(0, 0, 0, 0.12);
}

.game-stage {
  display: grid;
  width: 100%;
  margin-inline: 0;
  gap: 1px;
  justify-items: center;
  position: relative;
}

.board-frame {
  width: min(100%, 560px, calc(100vh - 150px));
  width: min(100%, 560px, calc(100dvh - 150px));
  max-width: 100%;
  min-width: 280px;
  position: relative;
  padding: 0;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 241, 221, 0.24), rgba(255, 241, 221, 0.04)),
    rgba(10, 12, 20, 0.5);
  border: 1px solid rgba(255, 241, 221, 0.18);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.28);
}

.board {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  padding: 0;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 241, 221, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 241, 221, 0.09) 1px, transparent 1px),
    rgba(10, 12, 20, 0.44);
  background-size: 20px 20px;
  border: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 241, 221, 0.03);
  touch-action: manipulation;
  isolation: isolate;
}

.tile {
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  border-radius: 10px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: visible;
  background: transparent;
  box-shadow: none;
  z-index: 1;
  transform-origin: center bottom;
  animation: tileDrop 230ms cubic-bezier(0.2, 0.85, 0.25, 1.32);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.tile svg {
  width: 74%;
  height: 74%;
  pointer-events: none;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.18));
}

.tile .tile-art-wrap {
  width: 100%;
  height: 100%;
}

.tile .tile-art-img {
  inset: -9%;
  width: 118%;
  height: 118%;
  max-width: none;
  max-height: none;
}

.tile .tile-art-fallback {
  box-shadow: inset 0 -7px rgba(0, 0, 0, 0.18), inset 0 3px rgba(255, 255, 255, 0.36), 0 4px 0 rgba(0, 0, 0, 0.18);
}

.tile-art-selected,
.tile-art-activated {
  opacity: 0;
}

.tile.tile-eye.tile-selected .tile-art-normal {
  opacity: 0;
}

.tile.tile-eye.tile-selected .tile-art-selected {
  opacity: 1;
}

.tile.tile-eye.tile-special .tile-art-normal,
.tile.tile-eye.tile-special .tile-art-selected {
  opacity: 0;
}

.tile.tile-eye.tile-special .tile-art-activated {
  opacity: 1;
}

.tile-selected {
  z-index: 30;
  outline: 3px solid var(--gold);
  outline-offset: -2px;
  transform: translateY(-3px) scale(1.04);
  filter: drop-shadow(0 0 10px rgba(255, 211, 106, 0.7));
}

.tile-pop {
  z-index: 24;
  animation: tilePop 230ms ease forwards;
}

.tile-invalid {
  z-index: 22;
  animation: invalidShake 220ms ease;
}

.tile-special::after {
  content: "";
  position: absolute;
  inset: 3px;
  z-index: 3;
  border-radius: 8px;
  border: 3px dashed rgba(255, 255, 255, 0.82);
  animation: spinGlow 2.2s linear infinite;
  pointer-events: none;
}

.tile-special::before {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: 50%;
  height: 7px;
  z-index: 4;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  transform: translateY(-50%);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.56);
  pointer-events: none;
}

.tile-soul { --tile-bg: linear-gradient(180deg, #defbf6, #77d9ca); }
.tile-skull { --tile-bg: linear-gradient(180deg, #fff1dd, #cdb7a1); }
.tile-flame { --tile-bg: linear-gradient(180deg, #ffd36a, #f07187); }
.tile-eye { --tile-bg: linear-gradient(180deg, #e7ddff, #b7a0ff); }
.tile-bone { --tile-bg: linear-gradient(180deg, #f8dfbf, #e4aa78); }
.tile-slurple { --tile-bg: linear-gradient(180deg, #d89dff, #7b4bd6); }

.combo-banner {
  min-height: 16px;
  color: var(--gold);
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.combo-banner.show {
  animation: comboPulse 520ms ease;
}

.score-pop-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.score-pop {
  position: absolute;
  left: 50%;
  top: 42%;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 900;
  background: var(--gold);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  animation: scoreFloat 760ms ease forwards;
}

.score-pop-chain {
  background: linear-gradient(180deg, #d9fff9, #77d9ca);
}

.meatbag-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(255, 241, 221, 0.1);
  border: 1px solid rgba(255, 241, 221, 0.15);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.meatbag-card p {
  color: #f9d9c7;
  font-size: 0.8rem;
  line-height: 1.15;
}

.game-screen .meatbag {
  width: 44px;
  height: 56px;
}

.game-screen .meatbag::before,
.game-screen .meatbag::after {
  bottom: -5px;
  width: 12px;
  height: 12px;
}

.game-screen .meatbag::before { left: 7px; }
.game-screen .meatbag::after { right: 7px; }

.game-screen .meatbag-eye {
  top: 18px;
  width: 7px;
  height: 9px;
}

.game-screen .left-eye { left: 13px; }
.game-screen .right-eye { right: 13px; }

.game-screen .meatbag-mouth {
  top: 33px;
  width: 15px;
  height: 7px;
}

.meatbag {
  width: 58px;
  height: 72px;
  flex: 0 0 auto;
  position: relative;
  border-radius: 44% 44% 38% 38%;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.48), transparent 0.5rem),
    linear-gradient(180deg, #ffb1a6, #d75d76);
  box-shadow: inset 0 -10px rgba(82, 24, 51, 0.24), 0 5px 0 rgba(0, 0, 0, 0.18);
}

.meatbag::before,
.meatbag::after {
  content: "";
  position: absolute;
  bottom: -7px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #d75d76;
}

.meatbag::before { left: 8px; }
.meatbag::after { right: 8px; }

.meatbag-eye {
  position: absolute;
  top: 24px;
  width: 8px;
  height: 10px;
  border-radius: 50%;
  background: #261425;
}

.left-eye { left: 18px; }
.right-eye { right: 18px; }

.meatbag-mouth {
  position: absolute;
  left: 50%;
  top: 43px;
  width: 18px;
  height: 8px;
  border: 2px solid #261425;
  border-top: 0;
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%);
}

.mascot-idle {
  animation: mascotBob 1.8s ease-in-out infinite;
}

.result-screen {
  justify-content: center;
}

.result-card {
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 22px;
  border-radius: 8px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 211, 106, 0.16), transparent 10rem),
    rgba(38, 20, 37, 0.92);
  border: 1px solid rgba(255, 241, 221, 0.17);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.34);
}

.result-win {
  border-color: rgba(255, 211, 106, 0.42);
}

.result-fail {
  border-color: rgba(183, 160, 255, 0.38);
}

.result-card .meatbag {
  width: 70px;
  height: 86px;
}

.result-card h2 {
  font-size: 2rem;
}

.result-card p {
  color: #f9d9c7;
}

.result-stats {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-stats span,
.unlock-notice,
.book-copy,
.yokai-card {
  border-radius: 8px;
  background: rgba(255, 241, 221, 0.1);
  border: 1px solid rgba(255, 241, 221, 0.15);
}

.result-stats span {
  padding: 12px;
  display: grid;
  gap: 2px;
  color: var(--paper-soft);
}

.result-stats strong {
  color: var(--gold);
}

.unlock-notice {
  width: 100%;
  min-height: 0;
  color: var(--gold);
  font-weight: 900;
}

.unlock-notice:not(:empty) {
  padding: 12px;
}

.book-copy {
  padding: 12px 14px;
  color: #f9d9c7;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.collection-list {
  display: grid;
  gap: 12px;
}

.yokai-card {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  position: relative;
  overflow: hidden;
}

.yokai-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 211, 106, 0.07), transparent 42%);
  pointer-events: none;
}

.yokai-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff1dd, #f07187);
  box-shadow: inset 0 -7px rgba(0, 0, 0, 0.17);
}

.yokai-icon svg {
  width: 74%;
  height: 74%;
}

.yokai-card h3 {
  margin: 0 0 4px;
  color: var(--paper);
}

.yokai-card p {
  color: #f9d9c7;
  font-size: 0.9rem;
}

.requirement-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.requirement-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 8px;
  align-items: center;
  position: relative;
  padding: 5px 6px;
  border-radius: 8px;
  overflow: hidden;
  color: var(--paper);
  background: rgba(255, 241, 221, 0.1);
  font-size: 0.78rem;
  font-weight: 900;
}

.requirement-row > * {
  position: relative;
  z-index: 1;
}

.requirement-row i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--progress);
  background: rgba(119, 217, 202, 0.28);
  z-index: 0;
}

.yokai-state {
  justify-self: start;
  margin-top: 8px;
  display: inline-block;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  background: var(--gold);
}

.locked {
  filter: grayscale(0.85);
  opacity: 0.64;
}

.settings-screen {
  gap: 22px;
}

.settings-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 241, 221, 0.1);
  border: 1px solid rgba(255, 241, 221, 0.16);
}

.setting-row {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-radius: 8px;
  color: var(--paper);
  background: rgba(38, 20, 37, 0.65);
  border: 1px solid rgba(255, 241, 221, 0.12);
}

.setting-row span {
  display: grid;
  gap: 4px;
}

.setting-row small,
.settings-note {
  color: var(--paper-soft);
}

.setting-row input {
  width: 42px;
  height: 24px;
  accent-color: var(--aqua);
}

.settings-note {
  text-align: center;
  font-size: 0.86rem;
}

@media (min-width: 720px) {
  .app-shell {
    min-height: min(100vh, 920px);
    min-height: min(100dvh, 920px);
  }

  .screen {
    min-height: min(100vh, 920px);
    min-height: min(100dvh, 920px);
  }
}

@media (max-width: 520px) {
  .app-shell {
    box-shadow: none;
  }
}

@media (max-width: 380px) {
  .screen {
    padding:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  .game-screen {
    padding:
      max(5px, env(safe-area-inset-top))
      env(safe-area-inset-right)
      max(5px, env(safe-area-inset-bottom))
      env(safe-area-inset-left);
  }

  .menu-screen {
    gap: 10px;
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .menu-top-actions {
    gap: 6px;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }

  .menu-icon-button {
    width: 52px;
    height: 52px;
  }

  .version-chip {
    top: max(10px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    font-size: 0.64rem;
  }

  .title-mark {
    padding-top: clamp(50px, 8vh, 70px);
  }

  .title-logo {
    width: min(90%, 340px);
  }

  .landing-panel {
    gap: 10px;
    padding: 13px;
    margin-bottom: 12px;
  }

  .landing-panel p {
    font-size: 0.92rem;
  }

  .menu-screen .landing-art-button {
    padding: 0 24px 3px 26px;
    font-size: 0.96rem;
  }

  .menu-screen .landing-play-button {
    padding: 0 34px 7px 24px;
  }

  .menu-screen .landing-book-button {
    padding: 0 24px 3px 26px;
  }

  .charm {
    width: 42px;
    height: 42px;
  }

  .hud-stat {
    width: 52px;
    min-width: 52px;
    min-height: 48px;
    padding: 7px 5px 5px;
  }

  .hud-level-card {
    min-height: 48px;
    padding: 7px 7px;
  }

  .hud-level-card span {
    font-size: 0.64rem;
  }

  .hud-level-card strong {
    font-size: 0.92rem;
  }

  .goal-panel {
    align-items: center;
    min-height: 50px;
    padding: 3px 10px;
    border-width: 8px;
    border-image-width: 8px;
  }

  .board {
    min-width: 0;
  }

  .board-frame {
    min-width: 0;
  }

  .level-node {
    grid-template-columns: 60px 1fr;
    grid-template-areas: "orb content" "orb badge";
    margin-left: 0;
  }

  .node-orb {
    width: 52px;
    height: 52px;
  }

  .map-node,
  .map-node.side-right {
    width: 100%;
    justify-self: stretch;
  }

  .area-card {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .game-screen {
    padding:
      max(5px, env(safe-area-inset-top))
      max(1px, env(safe-area-inset-right))
      max(5px, env(safe-area-inset-bottom))
      max(1px, env(safe-area-inset-left));
  }

  .game-stage {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    gap: 0;
  }

  .board-frame {
    width: min(100%, calc(100vw - 2px));
    max-width: min(100%, calc(100vw - 2px));
    min-width: 0;
    padding: 0;
  }

  .board {
    width: 100%;
    gap: 1px;
    padding: 0;
  }

  .tile {
    min-width: 0;
    padding: 0;
  }

  .tile .tile-art-wrap {
    width: 100%;
    height: 100%;
  }

  .tile .tile-art-img {
    inset: -9%;
    width: 118%;
    height: 118%;
    max-width: none;
    max-height: none;
    object-fit: contain;
  }
}

@keyframes tileDrop {
  0% { transform: translateY(-18px) scale(0.92, 1.06); }
  70% { transform: translateY(2px) scale(1.04, 0.96); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes tilePop {
  35% {
    opacity: 1;
    transform: scale(1.18) rotate(-6deg);
  }
  to {
    opacity: 0;
    transform: scale(0.18) rotate(12deg);
  }
}

@keyframes invalidShake {
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

@keyframes comboPulse {
  0% { transform: scale(0.85); opacity: 0; }
  35% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes mascotBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes mistDrift {
  from { transform: translateX(-10px); }
  to { transform: translateX(10px); }
}

@keyframes spinGlow {
  to { transform: rotate(360deg); }
}

@keyframes scoreFloat {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.8); }
  25% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(0.96); }
}
