.game-header {
  position: absolute;
  z-index: 30;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(180deg, rgb(255 249 242 / 86%), rgb(255 249 242 / 16%), transparent);
}

.game-header:not([hidden]) { animation: formal-ui-enter 320ms var(--ease) both; }

.audio-toggle {
  position: absolute;
  z-index: 45;
  top: max(16px, env(safe-area-inset-top));
  right: 18px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 58%);
  border-radius: 50%;
  background: rgb(255 249 242 / 82%);
  box-shadow: 0 8px 22px rgb(73 52 44 / 14%);
  color: var(--primary-strong);
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.audio-toggle span { font-size: 20px; transform: translateX(-1px); }
.audio-toggle::after {
  position: absolute;
  width: 2px;
  height: 24px;
  border-radius: 2px;
  background: currentcolor;
  content: "";
  opacity: 0;
  transform: rotate(-42deg) scaleY(.4);
  transition: opacity 160ms ease, transform 160ms var(--ease);
}
.audio-toggle[aria-pressed="false"]::after { opacity: .82; transform: rotate(-42deg) scaleY(1); }
.audio-toggle:focus-visible { outline: 3px solid rgb(179 107 100 / 36%); outline-offset: 3px; }
.audio-toggle:disabled { cursor: not-allowed; opacity: .4; }

.brand-lockup {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border: 1px solid rgb(126 93 76 / 15%);
  border-radius: 14px;
  background: rgb(255 249 242 / 88%);
  box-shadow: 0 6px 18px rgb(73 52 44 / 9%);
  backdrop-filter: blur(10px);
}

.brand-lockup strong {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.2;
  white-space: nowrap;
}

@keyframes formal-ui-enter {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 52px;
}

.stage {
  position: relative;
  z-index: 10;
  height: 100%;
  overflow: hidden auto;
  padding: calc(max(66px, env(safe-area-inset-top) + 52px)) 16px calc(104px + env(safe-area-inset-bottom));
  scrollbar-width: none;
}

.stage::-webkit-scrollbar { display: none; }

.stage--encounter {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-top: max(40px, env(safe-area-inset-top) + 24px);
  padding-bottom: max(30px, env(safe-area-inset-bottom) + 20px);
}

.story-card {
  align-self: stretch;
  padding: 18px 20px;
  border: 1px solid rgb(255 255 255 / 62%);
  border-radius: 24px;
  background: linear-gradient(145deg, rgb(255 250 242 / 90%), rgb(247 231 217 / 82%));
  color: var(--ink);
  box-shadow: 0 16px 38px rgb(73 48 40 / 16%);
  backdrop-filter: blur(14px);
}

.story-card h1 {
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: clamp(26px, 8vw, 38px);
  letter-spacing: 0.12em;
}

.story-card p { margin-bottom: 0; color: var(--ink-soft); font-size: var(--text-sm); line-height: var(--line-relaxed); }

.encounter-zone {
  display: grid;
  min-height: 42vh;
  place-items: end center;
  touch-action: none;
}

.encounter-cat { width: min(72vw, 315px); max-height: 42vh; object-fit: contain; filter: drop-shadow(0 18px 18px rgb(39 29 50 / 28%)); animation: breathe 7s ease-in-out infinite; }

.encounter-bottom {
  display: grid;
  gap: 12px;
}

.naming-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 9px;
  border-radius: 20px;
  background: rgb(255 249 242 / 90%);
  box-shadow: var(--shadow);
}

.naming-form input,
.adoption-form input,
.adoption-form textarea,
.adoption-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgb(255 255 255 / 72%);
  color: var(--ink);
}

.naming-form input { min-width: 0; padding: 0 14px; border: 0; background: transparent; }
.naming-form .primary-button { min-height: 46px; padding: 0 18px; }

.home-layout,
.nurture-layout {
  display: flex;
  min-height: calc(100dvh - 174px);
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
}

.cat-stage {
  position: relative;
  display: grid;
  min-height: 340px;
  place-items: end center;
  touch-action: none;
}

.cat-stage::after {
  position: absolute;
  right: 16%;
  bottom: 4%;
  left: 16%;
  height: 20px;
  border-radius: 50%;
  background: rgb(80 56 43 / 17%);
  filter: blur(8px);
  content: "";
}

.cat-stage > img {
  position: relative;
  z-index: 2;
  width: min(76vw, 325px);
  max-height: 340px;
  object-fit: contain;
  filter: drop-shadow(0 18px 18px rgb(71 46 37 / 22%));
  animation: breathe 7s ease-in-out infinite;
}

.cat-stage.is-purring > img { transform: rotate(-1deg) scale(1.025); }

.scene-note {
  position: absolute;
  z-index: 6;
  bottom: 18px;
  left: 18px;
  max-width: calc(100% - 36px);
}

.scene-note > summary {
  width: max-content;
  padding: 8px 12px;
  border: 1px solid rgb(255 255 255 / 62%);
  border-radius: 999px;
  background: rgb(255 249 242 / 90%);
  box-shadow: 0 8px 20px rgb(73 47 40 / 13%);
  color: var(--ink);
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: 900;
  list-style: none;
}
.scene-note > summary::-webkit-details-marker { display: none; }
.scene-note > summary::before { margin-right: 7px; color: var(--rose-ink); content: "◌"; }
.scene-note > summary::after { margin-left: 8px; color: var(--ink-soft); content: "+"; font-size: 15px; }
.scene-note[open] > summary::after { content: "−"; }
.scene-note > summary:focus-visible { outline: 3px solid rgb(231 183 104 / 56%); outline-offset: 3px; }
.scene-note[open] { width: min(232px, calc(100% - 36px)); }
.scene-note:not([open]) > .cat-caption { display: none; }

.scene-note .cat-caption {
  margin: 8px 0 0;
  padding: 11px 13px;
  border: 1px solid rgb(255 255 255 / 62%);
  border-left: 3px solid rgb(177 103 96 / 82%);
  border-radius: 12px;
  background: rgb(255 249 242 / 92%);
  box-shadow: 0 10px 24px rgb(73 47 40 / 13%);
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: var(--line-normal);
}

.care-panel,
.progress-panel,
.bond-banner {
  padding: 16px;
}

.care-panel header,
.progress-panel header,
.bond-banner header,
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.care-panel h2,
.progress-panel h2,
.bond-banner h2,
.sheet-header h2 { margin-bottom: 4px; font-size: var(--text-lg); }

.care-panel p,
.progress-panel p,
.bond-banner p { margin-bottom: 0; color: var(--ink-soft); font-size: var(--text-sm); line-height: var(--line-normal); }

.progress-panel header > div { min-width: 0; }
.progress-panel header > strong {
  flex: 0 0 auto;
  align-self: flex-start;
  padding: 5px 8px;
  border-radius: 10px;
  background: rgb(255 249 242 / 72%);
  font-size: 13px;
  white-space: nowrap;
}

.progress-track {
  height: 8px;
  margin: 12px 0 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(89 69 63 / 10%);
}

.progress-track i {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sage), var(--honey), var(--rose));
  transition: width 300ms var(--ease);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.bond-actions { grid-template-columns: repeat(2, 1fr); }

.chip-button {
  min-height: 50px;
  padding: 8px 6px;
  border: 1px solid rgb(89 69 63 / 10%);
  border-radius: 15px;
  background: rgb(255 255 255 / 64%);
  font-size: 12px;
  font-weight: 750;
}

.chip-button.is-selected { border-color: var(--rose); background: #fff0eb; color: var(--rose-ink); }

.ceremony-layout {
  display: flex;
  min-height: calc(100dvh - 175px);
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  text-align: center;
}

.ceremony-copy {
  padding: 18px 22px;
  color: #fffaf2;
  text-shadow: 0 3px 15px rgb(44 28 35 / 56%);
}
.ceremony-copy h1 { margin-bottom: 8px; font-family: var(--font-display); font-size: 30px; }
.ceremony-copy p { margin-bottom: 0; font-size: var(--text-sm); line-height: var(--line-relaxed); }

.reveal-grid,
.adoption-grid,
.compendium-grid,
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.kitten-card,
.breed-card,
.friend-card {
  position: relative;
  overflow: hidden;
  padding: 12px;
  border: 1px solid rgb(255 255 255 / 58%);
  border-radius: 22px;
  background: rgb(255 249 242 / 86%);
  box-shadow: 0 10px 28px rgb(65 43 38 / 14%);
}

.kitten-card.is-new { animation: reveal-in 600ms var(--ease) both; }
.kitten-card img, .breed-card img { width: 100%; height: 132px; object-fit: contain; }
.kitten-card h3, .breed-card h3 { margin: 8px 0 4px; font-size: var(--text-md); }
.kitten-card p, .breed-card p { margin-bottom: 0; color: var(--ink-soft); font-size: var(--text-xs); line-height: var(--line-normal); }

.trait-seal {
  display: inline-flex;
  margin-top: 7px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f7e6c9;
  color: #8a6139;
  font-size: var(--text-xs);
  font-weight: 800;
}

.adoption-form { display: grid; gap: 12px; }
.adoption-form label { display: grid; gap: 6px; font-size: 12px; font-weight: 750; }
.adoption-form input, .adoption-form textarea, .adoption-form select { min-height: 42px; padding: 10px 12px; }
.adoption-form textarea { min-height: 70px; resize: vertical; }

.sheet {
  min-height: calc(100dvh - 176px);
  padding: 16px;
  animation: reveal-in 300ms var(--ease) both;
}

.sheet-header { margin-bottom: 14px; }
.sheet-kicker { color: var(--rose-ink); font-size: var(--text-xs); font-weight: 900; letter-spacing: 0.1em; }

.tree-canvas {
  position: relative;
  min-height: max(470px, calc(var(--generation-count, 3) * 116px));
  overflow: hidden;
  border-radius: 20px;
  background: linear-gradient(180deg, #ede7f2, #fff7ed);
}

.genealogy-sheet .sheet-header p { max-width: 620px; margin: 5px 0 0; color: var(--ink-soft); font-size: var(--text-sm); line-height: var(--line-normal); }
.tree-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: -2px 0 10px; color: var(--ink-soft); font-size: var(--text-xs); }
.tree-legend span { display: inline-flex; align-items: center; gap: 7px; }
.tree-legend__line { width: 28px; height: 1px; background: var(--edge-parent); }
.tree-legend__home { width: 12px; height: 12px; border: 2px solid var(--sage); border-radius: 4px; background: rgb(255 249 242 / 82%); }
.tree-scroll { max-height: 420px; overflow: auto; border-radius: 20px; scrollbar-color: var(--edge-muted) transparent; }
.tree-generation-band { position: absolute; z-index: 0; right: 22px; left: 22px; top: var(--y); height: 1px; border-top: 1px dashed rgb(89 69 63 / 11%); color: var(--ink-soft); font-size: var(--text-xs); }
.tree-generation-band > span { position: sticky; top: -10px; left: 8px; padding: 1px 7px; border-radius: 6px; background: rgb(255 249 242 / 92%); }
.tree-lines { pointer-events: none; position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.tree-lines path, .tree-lines line { fill: none; stroke: var(--edge-parent); stroke-width: var(--edge-width); stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.tree-lines .is-bond { stroke: var(--edge-bond); stroke-dasharray: 4 4; }
.tree-junction { fill: var(--paper); stroke: var(--edge-parent); stroke-width: var(--edge-width); }
.tree-node {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 96px;
  transform: translate(-50%, -50%);
  padding: 6px 5px;
  border: 1px solid rgb(255 255 255 / 58%);
  border-radius: var(--radius-md);
  background: rgb(255 249 242 / 82%);
  box-shadow: 0 8px 18px rgb(75 51 44 / 12%);
  text-align: center;
}
.tree-node--home { border-color: rgb(120 135 111 / 45%); box-shadow: 0 0 0 4px rgb(168 181 154 / 16%), 0 8px 18px rgb(75 51 44 / 12%); }
.tree-node img { width: 62px; height: 62px; margin: 0 auto 5px; object-fit: contain; border-radius: 50%; background: rgb(255 255 255 / 76%); }
.tree-node b, .tree-node small { display: block; }
.tree-node b { font-size: var(--text-sm); }
.tree-node small { color: var(--ink-soft); font-size: var(--text-xs); line-height: var(--line-tight); }

.postcard {
  position: relative;
  min-height: 250px;
  overflow: hidden;
  padding: 14px;
  border: 8px solid white;
  border-radius: 6px;
  background: linear-gradient(145deg, #f7e8de, #efe6c9);
  box-shadow: 0 10px 25px rgb(76 47 42 / 16%);
}
.postcard::after { position: absolute; right: 10px; bottom: 8px; color: rgb(185 109 105 / 34%); font-size: 44px; content: "⌁"; }
.postcard img { width: 100%; height: 125px; object-fit: contain; filter: drop-shadow(0 8px 8px rgb(76 48 42 / 15%)); }
.postcard h3 { margin: 8px 0 4px; font-family: var(--font-display); }
.postcard p { position: relative; z-index: 1; margin-bottom: 12px; color: var(--ink-soft); font-size: var(--text-xs); line-height: var(--line-normal); }
.postcard .soft-button { position: relative; z-index: 2; min-height: var(--control-sm); padding: 0 12px; border-radius: var(--radius-sm); font-size: var(--text-xs); }

.postcard-preview {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #f6e8dc;
  text-align: center;
}
.postcard-preview header { display: flex; align-items: center; justify-content: space-between; text-align: left; }
.postcard-preview h3 { margin: 2px 0 0; }
.postcard-preview img { width: min(100%, 230px); max-height: 360px; margin: 12px auto; object-fit: contain; box-shadow: 0 12px 30px rgb(76 47 42 / 16%); }
.postcard-preview .postcard-download { width: min(100%, 230px); min-height: var(--control-sm); margin: 0 auto; text-decoration: none; }

.candidate-list { display: grid; gap: 10px; }
.candidate {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
}
.candidate img { width: 66px; height: 66px; object-fit: contain; }
.candidate p { margin: 3px 0 0; color: var(--ink-soft); font-size: var(--text-xs); line-height: var(--line-normal); }
.similarity { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 50%; background: #f2e7dc; font-size: var(--text-xs); font-weight: 900; }
.candidate.is-blocked { opacity: 0.66; }

.bottom-nav {
  position: absolute;
  z-index: 40;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: 68px;
  padding: 7px;
  border: 1px solid rgb(255 255 255 / 62%);
  border-radius: 24px;
  background: rgb(255 249 242 / 88%);
  box-shadow: 0 14px 34px rgb(64 42 38 / 22%);
  backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  place-items: center;
  gap: 2px;
  border-radius: 17px;
  background: transparent;
  color: var(--ink-soft);
  font-size: var(--text-xs);
  font-weight: 750;
}
.nav-item span { font-size: 19px; line-height: 1; }
.nav-item.is-active { background: #f7e7e1; color: var(--rose-ink); }

.toast {
  pointer-events: none;
  position: absolute;
  z-index: 80;
  top: 72px;
  right: auto;
  bottom: auto;
  left: 50%;
  width: max-content;
  max-width: 360px;
  padding: 9px 13px;
  transform: translate(-50%, -10px);
  border-radius: 15px;
  background: rgb(73 59 64 / 92%);
  color: white;
  font-size: var(--text-xs);
  text-align: center;
  opacity: 0;
  transition: 220ms var(--ease);
}
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

.pet-particle {
  pointer-events: none;
  position: absolute;
  z-index: 75;
  left: var(--x);
  top: var(--y);
  color: #fff2d1;
  font-size: 22px;
  filter: drop-shadow(0 3px 5px rgb(104 61 53 / 28%));
  animation: float-up 780ms var(--ease) forwards;
}



/* Four small reward stops turn intimacy into tangible keepsakes without adding another management panel. */
.intimacy-loop {
  margin-top: 11px;
  padding: 10px 10px 11px;
  border: 1px solid rgb(130 92 72 / 15%);
  border-radius: 17px;
  background: linear-gradient(155deg, rgb(255 251 243 / 94%), rgb(239 223 201 / 66%));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 72%);
}

.intimacy-loop > header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.intimacy-loop > header div { display: grid; gap: 1px; min-width: 0; }
.intimacy-loop > header span {
  color: var(--rose-ink);
  font-size: var(--text-xs);
  font-weight: 900;
  letter-spacing: .1em;
}
.intimacy-loop > header b {
  overflow: hidden;
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.intimacy-loop ol {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.intimacy-loop ol::before {
  position: absolute;
  z-index: 0;
  top: 12px;
  right: 8%;
  left: 8%;
  height: 1px;
  background: linear-gradient(90deg, rgb(168 181 154 / 28%), rgb(231 183 104 / 72%), rgb(217 138 134 / 46%));
  content: "";
}

.intimacy-reward {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 0;
  min-height: 126px;
  grid-template-rows: 25px 42px auto 38px;
  justify-items: center;
  padding: 3px 3px 5px;
  border: 1px solid rgb(126 93 76 / 11%);
  border-radius: 12px;
  background: rgb(255 252 246 / 72%);
  text-align: center;
}

.intimacy-reward > span {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid rgb(126 93 76 / 18%);
  border-radius: 50%;
  background: #fffaf2;
  color: var(--ink-soft);
  font-size: var(--text-xs);
  font-weight: 900;
}
.intimacy-reward img { width: 42px; height: 38px; object-fit: contain; filter: drop-shadow(0 4px 4px rgb(77 51 41 / 14%)); }
.intimacy-reward b {
  overflow: hidden;
  max-width: 100%;
  align-self: center;
  font-size: var(--text-xs);
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.intimacy-reward small {
  display: -webkit-box;
  overflow: hidden;
  align-self: center;
  color: var(--ink-soft);
  font-size: var(--text-xs);
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.intimacy-reward.is-locked { color: rgb(89 69 63 / 58%); }
.intimacy-reward.is-locked img { filter: grayscale(1) sepia(.25) opacity(.34); }
.intimacy-reward.is-family-unlocked {
  border-color: rgb(120 135 111 / 32%);
  background: rgb(236 242 228 / 82%);
}
.intimacy-reward.is-family-unlocked > span { border-color: rgb(120 135 111 / 42%); color: #64725d; }
.intimacy-reward.is-claimed {
  border-color: rgb(218 157 90 / 44%);
  background: linear-gradient(160deg, #fff9e8, #f7dfbd);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 68%), 0 4px 10px rgb(125 82 49 / 10%);
}
.intimacy-reward.is-claimed::after {
  position: absolute;
  top: -5px;
  right: -3px;
  color: #c48643;
  content: "✦";
  font-size: 13px;
  filter: drop-shadow(0 2px 2px rgb(111 70 38 / 16%));
}
.intimacy-reward.is-claimed > span { border-color: transparent; background: var(--primary-strong); color: white; }
.intimacy-reward.is-claimed img { transform: translateY(-1px) scale(1.04); }

/* Home keeps the four milestones visible, while their repeated explanations stay in the compendium. */
.home-layout .intimacy-reward {
  min-height: 88px;
  grid-template-rows: 25px 42px auto;
}
.home-layout .intimacy-reward small { display: none; }

.home-layout > .progress-panel,
.home-layout > .bond-banner { max-height: 100%; overflow: auto; scrollbar-width: thin; }
.panel-primary { width: 100%; margin-top: 11px; }

.toast {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid rgb(255 230 179 / 24%);
  box-shadow: 0 14px 34px rgb(64 42 38 / 22%);
}
.toast::before { color: #f7d58f; content: "✦"; font-size: 17px; }
