:root {
  color-scheme: light;
  --ink: #121417;
  --soft-ink: #313941;
  --muted: #69727d;
  --faint: #89939f;
  --paper: rgba(255, 255, 255, 0.78);
  --glass: rgba(255, 255, 255, 0.58);
  --line: rgba(18, 20, 23, 0.1);
  --line-strong: rgba(18, 20, 23, 0.16);
  --teal: #1f9c92;
  --mint: #66dec9;
  --blue: #4f8fff;
  --indigo: #7877ff;
  --rose: #ff7d8e;
  --amber: #f6c85f;
  --green: #72c35f;
  --shadow: 0 24px 70px rgba(44, 54, 62, 0.16);
  --tight-shadow: 0 12px 34px rgba(44, 54, 62, 0.12);
  --radius: 8px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family:
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Display",
    "SF Pro Text",
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 16% 12%, rgba(102, 222, 201, 0.34), transparent 30%),
    radial-gradient(circle at 84% 18%, rgba(255, 125, 142, 0.24), transparent 28%),
    radial-gradient(circle at 52% 94%, rgba(246, 200, 95, 0.26), transparent 32%),
    linear-gradient(145deg, #fbfcff, #eff7f4 48%, #fff4ec);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.34) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 78%);
}

button {
  font: inherit;
}

.app-shell {
  width: min(1220px, calc(100% - 28px));
  min-height: calc(100vh - 28px);
  margin: 14px auto;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 14px;
}

.world-panel,
.control-panel,
.tab-view {
  min-width: 0;
}

.world-panel {
  display: grid;
  grid-template-rows: auto auto minmax(420px, 1fr) auto;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.38));
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(28px) saturate(1.35);
}

.control-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.daily-panel,
.tabbar,
.stats-panel,
.trait-panel,
.quest-panel,
.inventory-panel,
.log-panel,
.game-card {
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--tight-shadow);
  backdrop-filter: blur(26px) saturate(1.28);
}

.topbar,
.section-head,
.xp-copy,
.stat-copy,
.resource-line,
.upgrade-top,
.achievement-top,
.game-top,
.game-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  min-height: 58px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.section-head {
  padding: 16px 16px 0;
}

.section-head.compact {
  padding-bottom: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.1rem, 5vw, 4.9rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.2;
}

h3 {
  margin-bottom: 4px;
  font-size: 0.98rem;
  line-height: 1.12;
}

.icon-button,
.tab-button,
.primary-button,
.text-button,
.action-card,
.expedition-card,
.upgrade-card,
.catch-target,
.echo-board button {
  min-height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    transform 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    background 0.18s var(--ease),
    opacity 0.18s var(--ease);
}

.icon-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(18, 20, 23, 0.1);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 9px 24px rgba(18, 20, 23, 0.08);
}

.hud-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.hud-item {
  min-height: 74px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 12px 26px rgba(44, 54, 62, 0.08);
}

.hud-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
}

.hud-item strong {
  font-size: 1.25rem;
  line-height: 1;
}

.scene {
  position: relative;
  min-height: 420px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(233, 248, 255, 0.96), rgba(241, 255, 243, 0.74) 55%, rgba(255, 241, 228, 0.92)),
    #edf9f7;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.scene-depth {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.light-beam {
  position: absolute;
  width: 48%;
  height: 140%;
  top: -25%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), transparent);
  opacity: 0.34;
  transform: rotate(18deg);
}

.beam-one {
  left: 4%;
}

.beam-two {
  right: -15%;
  opacity: 0.25;
  transform: rotate(-18deg);
}

.orbital {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62%;
  aspect-ratio: 1;
  border: 1px solid rgba(31, 156, 146, 0.16);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
}

.orbital-two {
  width: 78%;
  border-color: rgba(120, 119, 255, 0.13);
  transform: translate(-50%, -50%) rotate(18deg);
}

.habitat {
  position: absolute;
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  transition:
    opacity 0.35s var(--ease),
    transform 0.35s var(--ease);
}

.habitat.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.habitat-nest {
  left: 50%;
  bottom: 26px;
  width: min(58%, 390px);
  height: 76px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.72), transparent 58%),
    linear-gradient(90deg, rgba(246, 200, 95, 0.38), rgba(255, 125, 142, 0.22), rgba(102, 222, 201, 0.32));
  filter: blur(0.2px);
  transform: translateX(-50%);
}

.habitat-mobile {
  top: 16px;
  right: 18%;
  width: 80px;
  height: 96px;
}

.habitat-mobile::before,
.habitat-mobile::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: 68px;
  background: rgba(18, 20, 23, 0.16);
}

.habitat-mobile::after {
  top: 58px;
  left: 34%;
  width: 44px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--rose));
  box-shadow: 30px 16px 0 rgba(102, 222, 201, 0.82);
}

.habitat-fountain {
  right: 8%;
  bottom: 18%;
  width: 70px;
  height: 100px;
  border-radius: 34px 34px 16px 16px;
  background: linear-gradient(180deg, rgba(79, 143, 255, 0.16), rgba(79, 143, 255, 0.54));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.64);
}

.habitat-garden {
  left: 8%;
  bottom: 18%;
  width: 96px;
  height: 80px;
}

.habitat-garden::before,
.habitat-garden::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 54px;
  height: 54px;
  border-radius: 54px 54px 6px 54px;
  background: linear-gradient(135deg, var(--green), var(--mint));
}

.habitat-garden::after {
  left: 38px;
  width: 44px;
  height: 44px;
  border-radius: 44px 44px 44px 6px;
  background: linear-gradient(135deg, var(--rose), var(--amber));
}

.creature {
  width: min(72%, 450px);
  max-height: 78%;
  z-index: 2;
  --creature-scale: 1;
  transform-origin: center bottom;
  animation: breathe 3.4s var(--ease) infinite;
}

.body {
  fill: url(#bodyGradient);
}

.belly {
  fill: url(#bellyGradient);
}

.wing,
.crest,
.foot {
  fill: url(#wingGradient);
}

.wing {
  opacity: 0.9;
  transform-box: fill-box;
  transform-origin: center;
}

.lower {
  opacity: 0.48;
}

.wing-left {
  animation: wingLeft 3.4s var(--ease) infinite;
}

.wing-right {
  animation: wingRight 3.4s var(--ease) infinite;
}

.eye {
  fill: var(--ink);
}

.sparkle-eye {
  fill: #fff9cf;
}

.cheek {
  fill: rgba(255, 125, 142, 0.34);
}

.smile {
  fill: none;
  stroke: var(--ink);
  stroke-width: 8;
  stroke-linecap: round;
}

.scene.is-sleepy .eye {
  transform: scaleY(0.18);
  transform-origin: center;
}

.scene.is-hungry .smile {
  transform: translateY(6px) scaleY(-0.75);
  transform-origin: center;
}

.scene.is-excited .creature {
  animation-duration: 1.1s;
}

.spark-button {
  position: absolute;
  z-index: 5;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  color: #382700;
  background: linear-gradient(135deg, #ffe98f, #f6c85f);
  box-shadow: 0 14px 28px rgba(130, 90, 0, 0.2);
  cursor: pointer;
  animation: pop 0.9s var(--ease) infinite alternate;
}

.spark-button span {
  display: block;
  font-size: 1.65rem;
  font-weight: 900;
}

.hidden {
  display: none;
}

.mood-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.64);
}

.mood-card p {
  margin: 0;
  color: var(--soft-ink);
  font-weight: 760;
  line-height: 1.35;
}

.xp-wrap {
  display: grid;
  gap: 8px;
}

.xp-copy span,
.stat-copy span,
.resource-line span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
}

.xp-track,
.stat-track,
.trait-track,
.mini-track {
  height: 11px;
  border-radius: 999px;
  background: rgba(18, 20, 23, 0.09);
  overflow: hidden;
}

.xp-track span,
.stat-track span,
.trait-track span,
.mini-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  transition: width 0.35s var(--ease);
}

.xp-track span {
  background: linear-gradient(90deg, var(--teal), var(--amber), var(--rose), var(--indigo));
}

.daily-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
}

.daily-panel.is-done {
  opacity: 0.86;
}

.primary-button {
  border: 0;
  padding: 0 16px;
  color: white;
  background: linear-gradient(135deg, #17191d, #2c343b);
  font-weight: 820;
  box-shadow: 0 12px 26px rgba(18, 20, 23, 0.18);
}

.primary-button:hover,
.action-card:hover,
.expedition-card:hover,
.upgrade-card:hover,
.tab-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.action-card:disabled,
.expedition-card:disabled,
.upgrade-card:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 6px;
}

.tab-button {
  border: 0;
  min-height: 42px;
  color: var(--muted);
  background: transparent;
  font-size: 0.88rem;
  font-weight: 820;
}

.tab-button.active {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 18px rgba(44, 54, 62, 0.12);
}

.tab-view {
  display: none;
  gap: 12px;
}

.tab-view.active {
  display: grid;
}

.stats-panel {
  overflow: hidden;
}

.stat-row {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.stat-row:last-child {
  border-bottom: 0;
}

[data-stat="belly"] .stat-track span {
  background: var(--green);
}

[data-stat="joy"] .stat-track span {
  background: var(--rose);
}

[data-stat="energy"] .stat-track span {
  background: var(--blue);
}

[data-stat="shine"] .stat-track span {
  background: var(--mint);
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action-card,
.expedition-card,
.upgrade-card,
.achievement-item,
.collection-item {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 10px 24px rgba(44, 54, 62, 0.08);
}

.action-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 82px;
  padding: 11px;
  color: var(--ink);
  text-align: left;
}

.action-card.wide {
  grid-column: 1 / -1;
}

.action-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: white;
  background: linear-gradient(135deg, var(--teal), var(--indigo));
  font-weight: 900;
}

.action-card strong,
.action-card small {
  display: block;
  min-width: 0;
}

.action-card strong {
  margin-bottom: 3px;
  font-size: 0.96rem;
}

.action-card small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
  line-height: 1.25;
}

.trait-panel {
  overflow: hidden;
}

.trait-list {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.trait-item {
  display: grid;
  gap: 7px;
}

.trait-name {
  display: flex;
  justify-content: space-between;
  color: var(--soft-ink);
  font-size: 0.88rem;
  font-weight: 800;
}

.trait-track span {
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--indigo));
}

.expedition-list,
.upgrade-list,
.achievement-list {
  display: grid;
  gap: 10px;
}

.expedition-card,
.upgrade-card {
  width: 100%;
  display: grid;
  gap: 10px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
}

.expedition-meta,
.cost-row,
.reward-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--soft-ink);
  background: rgba(255, 255, 255, 0.62);
  font-size: 0.76rem;
  font-weight: 800;
}

.pill.good {
  color: #245914;
  background: rgba(114, 195, 95, 0.18);
}

.pill.locked {
  color: #6d2a34;
  background: rgba(255, 125, 142, 0.16);
}

.quest-panel,
.log-panel {
  overflow: hidden;
}

.section-head > span,
#bondValue,
#collectionCount {
  padding: 7px 9px;
  border-radius: 999px;
  color: #5c4106;
  background: rgba(246, 200, 95, 0.2);
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.quest-list,
#logList {
  list-style: none;
  margin: 0;
  padding: 10px 16px 16px;
}

.quest-list {
  display: grid;
  gap: 8px;
}

.quest-item {
  display: grid;
  grid-template-columns: 27px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.54);
}

.quest-check {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: rgba(18, 20, 23, 0.24);
  font-weight: 900;
}

.quest-item.done .quest-check {
  background: var(--green);
}

.quest-name {
  font-weight: 800;
}

.quest-progress {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 820;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 16px 16px;
}

.resource-chip {
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.58);
}

.resource-chip span {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 780;
}

.resource-chip strong {
  font-size: 1.1rem;
}

.upgrade-card.is-max {
  background: rgba(114, 195, 95, 0.14);
}

.upgrade-copy p,
.expedition-card p,
.achievement-item p,
.collection-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.35;
}

.mini-track {
  height: 8px;
}

.mini-track span {
  background: linear-gradient(90deg, var(--amber), var(--rose));
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.collection-item {
  min-height: 108px;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px;
  border-radius: var(--radius);
}

.collection-item.locked {
  opacity: 0.48;
  filter: grayscale(0.75);
}

.collection-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: linear-gradient(135deg, var(--indigo), var(--rose));
  font-weight: 900;
}

.achievement-list {
  padding-bottom: 4px;
}

.achievement-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius);
}

.achievement-top strong {
  font-size: 0.94rem;
}

.achievement-item.claimed {
  background: rgba(114, 195, 95, 0.14);
}

.game-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
}

.game-score {
  min-width: 72px;
  display: grid;
  justify-items: end;
  gap: 2px;
}

.game-score strong {
  font-size: 1.55rem;
  line-height: 1;
}

.game-score span,
.game-bottom p,
.catch-stage p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 780;
}

.catch-stage {
  position: relative;
  min-height: 238px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.88), transparent 24%),
    radial-gradient(circle at 78% 76%, rgba(120, 119, 255, 0.2), transparent 28%),
    linear-gradient(145deg, rgba(102, 222, 201, 0.18), rgba(255, 125, 142, 0.14), rgba(246, 200, 95, 0.18));
}

.catch-stage p {
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 1;
}

.catch-target {
  position: absolute;
  z-index: 3;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  color: #3c2b00;
  background: linear-gradient(135deg, #fff2a6, var(--amber));
  box-shadow:
    0 18px 34px rgba(125, 83, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  font-size: 1.55rem;
  font-weight: 900;
}

.catch-target:active,
.echo-board button:active {
  transform: scale(0.94);
}

.game-start {
  width: 100%;
}

.echo-board {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.echo-board button {
  min-height: 96px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  color: white;
  background: linear-gradient(135deg, var(--teal), var(--indigo));
  box-shadow: 0 12px 26px rgba(44, 54, 62, 0.14);
  font-size: 1.8rem;
  font-weight: 900;
}

.echo-board button:nth-child(2) {
  background: linear-gradient(135deg, var(--rose), var(--amber));
}

.echo-board button:nth-child(3) {
  background: linear-gradient(135deg, var(--blue), var(--mint));
}

.echo-board button:nth-child(4) {
  background: linear-gradient(135deg, #222833, var(--indigo));
}

.echo-board button.is-lit {
  transform: translateY(-2px) scale(1.03);
  filter: brightness(1.16) saturate(1.2);
  box-shadow: 0 18px 38px rgba(44, 54, 62, 0.22);
}

.echo-board.is-locked button {
  pointer-events: none;
  opacity: 0.78;
}

.text-button {
  border: 1px solid var(--line);
  padding: 0 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
  font-weight: 820;
}

#logList {
  display: grid;
  gap: 8px;
  max-height: 190px;
  overflow: auto;
}

#logList li {
  color: var(--soft-ink);
  font-size: 0.87rem;
  line-height: 1.35;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 20;
  width: min(380px, calc(100% - 28px));
  padding: 12px 14px;
  border-radius: 16px;
  color: white;
  background: rgba(18, 20, 23, 0.92);
  box-shadow: 0 18px 45px rgba(18, 20, 23, 0.26);
  text-align: center;
  font-weight: 820;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition:
    opacity 0.2s var(--ease),
    transform 0.2s var(--ease);
  backdrop-filter: blur(18px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.level-dialog {
  width: min(420px, calc(100% - 32px));
  border: 0;
  border-radius: 22px;
  padding: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.level-dialog::backdrop {
  background: rgba(18, 20, 23, 0.42);
}

.level-dialog form {
  display: grid;
  gap: 14px;
  padding: 24px;
}

.level-dialog p {
  margin-bottom: 0;
  color: var(--muted);
}

@keyframes breathe {
  0%,
  100% {
    transform: translateY(2px) scale(var(--creature-scale));
  }
  50% {
    transform: translateY(-9px) scale(calc(var(--creature-scale) * 1.026));
  }
}

@keyframes wingLeft {
  50% {
    transform: rotate(-6deg) translateX(-3px);
  }
}

@keyframes wingRight {
  50% {
    transform: rotate(6deg) translateX(3px);
  }
}

@keyframes pop {
  to {
    transform: scale(1.08) rotate(5deg);
  }
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 18px, 620px);
    grid-template-columns: 1fr;
  }

  .world-panel {
    grid-template-rows: auto auto minmax(340px, 50vh) auto;
    padding: 12px;
  }

  .scene {
    min-height: 340px;
  }
}

@media (max-width: 520px) {
  body {
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .app-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    gap: 8px;
  }

  .world-panel {
    grid-template-rows: auto auto minmax(292px, 39vh) auto;
    gap: 10px;
    padding: 12px 12px 10px;
    border-radius: 0 0 24px 24px;
  }

  .daily-panel,
  .tabbar,
  .stats-panel,
  .trait-panel,
  .quest-panel,
  .inventory-panel,
  .log-panel {
    margin-inline: 10px;
    border-radius: 18px;
  }

  .topbar {
    align-items: flex-start;
  }

  .hud-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 7px;
  }

  .hud-item {
    min-height: 62px;
    padding: 10px;
  }

  .scene {
    min-height: 292px;
    border-radius: 22px;
  }

  .creature {
    width: min(78%, 370px);
  }

  .mood-card {
    padding: 12px;
    border-radius: 18px;
  }

  .mood-card p {
    font-size: 0.92rem;
  }

  .daily-panel {
    grid-template-columns: 1fr;
  }

  .tabbar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 15;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin: 0;
    padding: 7px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 18px 48px rgba(18, 20, 23, 0.22);
  }

  .tab-button {
    min-height: 40px;
    font-size: 0.72rem;
  }

  .actions-grid,
  .collection-grid {
    grid-template-columns: 1fr;
    margin-inline: 10px;
  }

  .expedition-list,
  .upgrade-list,
  .achievement-list,
  .game-card {
    margin-inline: 10px;
  }

  .inventory-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .catch-stage {
    min-height: 230px;
  }

  .echo-board button {
    min-height: 86px;
    font-size: 1.55rem;
  }

  h1 {
    font-size: clamp(2.15rem, 11vw, 3.2rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
