/* =============================================================
   MEUUS — Styles matching Figma High-Fidelity Prototype
   Tokens → Base → Components → Screens → Animations
   ============================================================= */

/* ---------- Design Tokens (from Figma) ----------------------- */
:root {
  --surface:             #FBF8F4;
  --surface-container:   #FAF3E5;
  --surface-dim:         #E0D9CC;
  --on-surface:          #1E1B13;
  --on-surface-variant:  #49454F;
  --outline-variant:     #CBC4CF;
  --primary:             #68548D;
  --on-primary:          #FFFFFF;
  --secondary:           #904A49;
  --secondary-container: #FFDAD8;
  --on-secondary-container: #733333;

  /* Chat bubble palette — user matches their picked avatar; partner is fixed */
  --user-bubble:         #F2D8A8;
  --on-user-bubble:      #2A2243;
  --partner-bubble:      #D2B8F0;
  --on-partner-bubble:   #2A2243;

  --font-display: "Playfair Display", Georgia, serif;
  --font-body:    "Roboto", system-ui, -apple-system, sans-serif;

  --radius-full: 1000px;
  --radius-sm:   8px;
  --radius-md:   16px;
  --radius-lg:   24px;

  --shadow-soft: 0px 0px 28px -14px rgba(0, 0, 0, 0.25);

  --ease-out:  cubic-bezier(0.22, 0.9, 0.3, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:  140ms;
  --dur-med:   250ms;
  --dur-slow:  400ms;
}

/* ---------- Reset & Base ------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

/* Clip horizontal overflow on the document so the slide-in/out screen
   transition (translateX ±40px) never produces a momentary horizontal
   scrollbar. The flashing scrollbar was also stealing vertical viewport
   space briefly, causing the layout to jerk as content re-centered. */
html, body {
  overflow-x: clip;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--on-surface);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: contain;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; color: inherit; border: 0; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ---------- App Shell ---------------------------------------- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  /* Belt-and-braces: also clip the app container so the translated
     screen during transitions can't paint outside it. */
  overflow-x: clip;
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 36px 18px;
  background: var(--surface);
  position: relative;
}

.screen.is-active {
  display: flex;
}

.screen.is-entering {
  animation: screenSlideIn var(--dur-slow) var(--ease-out) forwards;
}

.screen.is-leaving {
  animation: screenSlideOut 350ms var(--ease-out) forwards;
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* ---------- Screen Layout ------------------------------------ */
.screen__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 11px;
  padding: 0 0 24px;
  flex-shrink: 0;
}

.screen__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 24px 0;
  overflow-y: auto;
  /* Explicitly clip horizontally. Without this, `overflow-y: auto` causes
     the browser to compute `overflow-x` as `auto` as well, which makes a
     horizontal scrollbar flash whenever a child briefly grows past the
     content area (e.g. the avatar hover/pop scale animation on screen 2).
     Using `clip` instead of `hidden` avoids creating a second scroll
     container that would interfere with the y-axis scroll. */
  overflow-x: clip;
}

.screen__content--centered {
  justify-content: center;
  gap: 36px;
}

.screen__footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  padding-top: 16px;
}

/* ---------- Typography --------------------------------------- */
.heading-lg {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 32px;
  line-height: 40px;
  letter-spacing: 0;
  color: var(--on-surface);
  text-align: center;
}

.heading-md {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  line-height: 36px;
  letter-spacing: 0;
  color: var(--on-surface);
  text-align: center;
}

.body-text {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 16px;
  line-height: 24px;
  letter-spacing: 0.5px;
  color: var(--on-surface-variant);
  text-align: center;
}

.body-text-sm {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
  color: var(--on-surface-variant);
  text-align: center;
}

.text-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 376px;
  padding: 0 15px;
}

/* ---------- Buttons ------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
  transition: transform var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  user-select: none;
  white-space: nowrap;
}

.btn--filled {
  background: var(--primary);
  color: var(--on-primary);
  padding: 16px 24px;
  font-size: 16px;
  min-width: 130px;
}

.btn--filled:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(104, 84, 141, 0.3);
}

.btn--filled:active {
  transform: translateY(0);
}

.btn--filled:disabled {
  background: var(--outline-variant);
  color: rgba(255, 255, 255, 0.7);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn--text {
  color: var(--primary);
  padding: 16px 24px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
}

.btn--text:hover {
  background: rgba(104, 84, 141, 0.08);
}

.btn--sm {
  padding: 14px 10px;
}

/* Icon button (back arrow) */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  color: var(--on-surface);
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease-out);
}

.btn-icon:hover {
  background: rgba(30, 27, 19, 0.08);
}

/* ---------- Progress Dots ------------------------------------ */
.progress-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 1;
  justify-content: center;
}

.progress-dot {
  width: 48px;
  height: 12px;
  border-radius: var(--radius-full);
  transition: background var(--dur-med) var(--ease-out);
}

.progress-dot--complete {
  background: var(--primary);
}

.progress-dot--incomplete {
  background: var(--secondary-container);
}

/* ---------- Input -------------------------------------------- */
.input-wrapper {
  width: 100%;
  max-width: 323px;
}

.input-pill {
  width: 100%;
  padding: 16px 24px;
  border-radius: var(--radius-full);
  background: #FFFFFF;
  border: 1px solid var(--surface-dim);
  box-shadow: var(--shadow-soft);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 24px;
  letter-spacing: 0.5px;
  color: var(--on-surface);
  outline: none;
  text-align: left;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.input-pill::placeholder {
  color: var(--outline-variant);
}

.input-pill:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--primary);
}

.input-pill.is-invalid,
.input-pill.is-invalid:focus {
  border-color: var(--secondary);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--secondary);
}

.input-error {
  margin-top: 8px;
  padding: 0 24px;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 18px;
  color: var(--secondary);
  text-align: left;
}

/* ---------- Elevated Label ----------------------------------- */
.elevated-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: var(--radius-full);
  background: var(--surface-container);
  border: 1px solid var(--surface-dim);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  color: var(--primary);
}

/* ---------- Avatar Grid -------------------------------------- */
.avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
}

.avatar-section__label {
  display: flex;
  justify-content: center;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, 100px);
  gap: 8px 8px;
  justify-content: center;
  /* Pad the grid so the hover (scale 1.04) and selection-pop (scale 1.08)
     animations on the corner avatars have breathing room before reaching
     the `.screen__content` overflow boundary. Without this, parents shrink
     to fit the grid exactly and the scaled circles get visually clipped. */
  padding: 8px;
}

.avatar-btn {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-full);
  overflow: hidden;
  padding: 0;
  border: 6px solid transparent;
  transition: transform var(--dur-med) var(--ease-back),
              border-color var(--dur-fast) var(--ease-out);
}

.avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-btn:hover {
  transform: scale(1.04);
}

.avatar-btn.is-selected {
  border-color: var(--primary);
  transform: scale(1.0);
}

.avatar-btn.is-selecting {
  animation: avatarPop var(--dur-med) var(--ease-back);
}

/* ---------- Option Pills (single-col list items) ------------- */
.option-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 376px;
}

.option-pill {
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: var(--radius-full);
  background: var(--surface-container);
  border: 1px solid var(--surface-dim);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 24px;
  letter-spacing: 0.5px;
  color: var(--on-surface);
  text-align: center;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.option-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.option-pill.is-selected {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  transform: scale(1.0);
}

/* ---------- Option Grid (2-col for screen 6) ----------------- */
.option-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 376px;
}

.option-grid__row {
  display: flex;
  gap: 12px;
}

.option-pill--half {
  flex: 1;
  min-width: 0;
}

/* ---------- Welcome Art --------------------------------------- */
.welcome-art {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 304px;
}

.welcome-art__img {
  max-height: 222px;
  object-fit: contain;
}

.welcome-art--sm {
  max-width: 244px;
}

.welcome-art--sm .welcome-art__img {
  max-height: 200px;
}

.welcome-art--logo {
  max-width: 240px;
}

.welcome-art--logo .welcome-art__img {
  width: 100%;
  max-height: 240px;
  height: auto;
}

/* ---------- Screen 1 Welcome — entrance animation ------------ */
.screen[data-screen="1"] .welcome-art__img {
  opacity: 0;
  transform: scale(0.95);
  animation: welcomeArtIn 500ms var(--ease-out) 100ms forwards;
}

.screen[data-screen="1"] .text-block .heading-lg {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeSlideUp 400ms var(--ease-out) 250ms forwards;
}

.screen[data-screen="1"] .text-block .body-text {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeSlideUp 400ms var(--ease-out) 330ms forwards;
}

.screen[data-screen="1"] .screen__footer .btn--filled {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeSlideUp 400ms var(--ease-out) 410ms forwards;
}

.screen[data-screen="1"] .screen__footer .btn--text {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeSlideUp 400ms var(--ease-out) 490ms forwards;
}

/* ---------- Code Display (Screen 8) -------------------------- */
.code-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 376px;
}

.code-display__field {
  width: 100%;
  padding: 21px 4px;
  border: 2px solid var(--outline-variant);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.code-display__field span {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 45px;
  line-height: 52px;
  letter-spacing: 0;
  color: var(--on-surface-variant);
  text-align: center;
}

.code-display__actions {
  display: flex;
  gap: 2px;
  border-radius: var(--radius-md);
  overflow: hidden;
  width: 259px;
}

.btn-segment {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  min-width: 48px;
  min-height: 48px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  border-radius: var(--radius-lg);
  transition: background var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.btn-segment--primary {
  background: var(--secondary);
  color: var(--on-primary);
}

.btn-segment--primary:hover {
  filter: brightness(1.1);
}

.btn-segment--secondary {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

.btn-segment--secondary:hover {
  filter: brightness(0.95);
}

.code-display__status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--on-surface-variant);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease-out);
}

.code-display__status.is-visible {
  opacity: 1;
}

/* ---------- Loading Spinner ---------------------------------- */
.loading-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--outline-variant);
  border-top-color: var(--primary);
  animation: spin 1200ms linear infinite;
}

/* ---------- Paired Avatar (Screen 9) ------------------------- */
.paired-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
}

.paired-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Pack Selection (Screen 11) ----------------------- */
.pack-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 376px;
  padding: 4px 0;
}

.pack-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface-container);
  border: 1px solid var(--surface-dim);
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  width: 100%;
  transform-origin: center;
  transition: transform var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.pack-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.pack-card:active {
  transform: scale(0.985);
}

.pack-card.is-selecting {
  animation: packCardPop var(--dur-med) var(--ease-back);
}

.pack-card__art {
  display: block;
  width: 104px;
  flex-shrink: 0;
  line-height: 0;
}

.pack-card__art img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: contain;
}

.pack-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  align-self: stretch;
  padding: 6px 0;
}

.pack-card__title {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 16px;
  line-height: 22px;
  letter-spacing: 0.15px;
  color: var(--on-surface);
}

.pack-card__desc {
  display: block;
  margin-top: 4px;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
  color: #49454E;
}

.pack-card__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.4px;
  color: #49454E;
}

.pack-card__dot {
  line-height: 1;
}

@keyframes packCardPop {
  0%   { transform: scale(1.0); }
  40%  { transform: scale(0.97); }
  100% { transform: scale(1.0); }
}

@media (max-width: 380px) {
  .pack-card {
    padding: 10px 12px;
    gap: 12px;
  }
  .pack-card__art {
    width: 92px;
  }
}

/* ---------- Screen Header — back-only variant --------------- */
.screen__header--back-only {
  justify-content: flex-start;
  padding: 0;
}

/* ---------- Pack Info (Screen 12) ---------------------------- */
.screen[data-screen="12"] {
  padding-top: 20px;
  padding-bottom: 24px;
}

.screen[data-screen="12"] .screen__content {
  gap: 16px;
  padding: 8px 0 8px;
}

.screen[data-screen="12"] .screen__footer {
  padding-top: 8px;
}

.pack-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 376px;
}

.pack-info__art {
  display: flex;
  justify-content: center;
  width: 100%;
}

.pack-info__art img {
  display: block;
  width: 144px;
  height: 180px;
  object-fit: contain;
}

.pack-info__details {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 4px;
}

.pack-info__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
  color: var(--on-surface-variant);
}

.pack-info__dot {
  line-height: 1;
}

/* ---------- How it works card (Screen 12) ------------------- */
.howto-card {
  width: 100%;
  background: var(--surface-container);
  border: 1px solid var(--surface-dim);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.howto-card__title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  line-height: 24px;
  letter-spacing: 0.15px;
  color: #49454E;
  margin: 0;
}

.howto-card__list {
  list-style: decimal;
  padding-left: 21px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
  color: #49454E;
}

.howto-card__list li {
  padding-left: 4px;
}

/* ---------- Before we start (Screen 13) --------------------- */
.before-art {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 304px;
}

.before-art__img {
  max-height: 240px;
  object-fit: contain;
}

/* ---------- Game screens (14, 15, 16) ----------------------- */
.screen--game {
  padding: 36px 18px 24px;
}

/* Game screens don't need scroll, and overflow:visible lets the card
   drop-shadow render without being clipped by the content container. */
.screen--game .screen__content,
.screen--game .game-content {
  overflow: visible;
}

.game-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 4px;
  flex-shrink: 0;
}

.game-nav__close,
.game-nav__heart {
  color: var(--on-surface);
}

.game-nav__heart {
  color: var(--primary);
}

.game-nav__heart.is-saved .heart-svg {
  fill: var(--primary);
  stroke: var(--primary);
}

.game-nav__heart.is-saving {
  animation: heartPop var(--dur-med) var(--ease-back);
}

.game-nav__spacer {
  display: inline-block;
  width: 48px;
  height: 48px;
}

.card-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: #EBDCFF;
  color: var(--primary);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.game-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
  padding: 16px 0;
}

/* ---------- Draw card (Screen 14) --------------------------- */
.draw-card {
  display: block;
  width: 300px;
  max-width: 80vw;
  aspect-ratio: 2 / 3;
  padding: 0;
  border-radius: 28px;
  background: transparent;
  cursor: pointer;
  position: relative;
  transform-origin: center;
  transition: transform var(--dur-fast) var(--ease-out);
}

/* Two fanned-out copies of the card peek from behind the top card on
   hover, like a real deck. They share the top card's image via the
   --draw-card-img custom property (set in JS when the pack changes). */
.draw-card::before,
.draw-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: var(--draw-card-img, none);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.06))
          drop-shadow(0 14px 28px rgba(0, 0, 0, 0.08));
  opacity: 0;
  transform-origin: 50% 60%;
  transform: rotate(0deg) translateX(0);
  transition: transform 280ms var(--ease-out),
              opacity 220ms var(--ease-out);
  /* pointer-events: auto so a click on the rotated peek-out corners
     (which extend outside the button's geometric rect) still counts
     as clicking the deck — the event bubbles to the host button. */
  pointer-events: auto;
  z-index: 0;
}

.draw-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.06))
          drop-shadow(0 16px 32px rgba(0, 0, 0, 0.10));
}

.draw-card:hover::before {
  opacity: 1;
  transform: rotate(-5deg) translateX(-6px);
}

.draw-card:hover::after {
  opacity: 1;
  transform: rotate(5deg) translateX(6px);
}

.draw-card:active {
  transform: scale(0.98);
}

.draw-card.is-flipping {
  animation: cardFlip 420ms var(--ease-out) forwards;
}

/* Hide the fanned cards during the flip so they don't peek through. */
.draw-card.is-flipping::before,
.draw-card.is-flipping::after {
  opacity: 0;
  transition: none;
}

@keyframes cardFlip {
  0%   { transform: rotateY(0); }
  50%  { transform: rotateY(90deg); }
  100% { transform: rotateY(180deg); opacity: 0; }
}

/* ---------- Elevated pill button (game screens) ------------- */
.btn-elevated {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 10px 16px;
  border-radius: var(--radius-full);
  background: var(--surface-container);
  border: 1px solid var(--surface-dim);
  color: var(--primary);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.1px;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.btn-elevated:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.btn-elevated:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-elevated:disabled {
  cursor: default;
  opacity: 0.85;
}

/* ---------- Prompt card (Screen 15) ------------------------- */
.prompt-card {
  display: flex;
  flex-direction: column;
  width: 300px;
  max-width: 80vw;
  height: 450px;
  max-height: 64vh;
  padding: 24px;
  background: var(--surface-container);
  border: 1px solid var(--surface-dim);
  border-radius: 28px;
  box-shadow: 0px 0px 36px -14px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.prompt-card__text {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
  line-height: 28px;
  letter-spacing: 0;
  color: var(--on-surface-variant);
  margin: 0;
  text-align: left;
}

.prompt-card.is-revealing {
  animation: promptReveal 420ms var(--ease-out);
}

@keyframes promptReveal {
  0%   { opacity: 0; transform: rotateY(-90deg); }
  100% { opacity: 1; transform: rotateY(0); }
}

/* ---------- Prompt actions (Screen 15 footer) --------------- */
.prompt-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.btn-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--on-primary);
  cursor: pointer;
  box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3),
              0px 1px 3px 1px rgba(0, 0, 0, 0.15);
  transition: transform var(--dur-fast) var(--ease-out),
              filter var(--dur-fast) var(--ease-out);
}

.btn-circle:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-circle:active {
  transform: scale(0.96);
}

/* ---------- Compact prompt + emotion grid (Screen 16) ------- */
.game-content--emotions {
  justify-content: flex-start;
  gap: 24px;
  padding-top: 24px;
}

.prompt-card--compact {
  width: 100%;
  max-width: 376px;
  height: auto;
  min-height: 60px;
  padding: 16px 20px;
  flex-direction: row;
  align-items: center;
  border-radius: 20px;
}

.prompt-card--compact .prompt-card__text {
  font-size: 18px;
  line-height: 24px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.emotion-prompt {
  align-self: center;
}

.emotion-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, auto);
  justify-items: center;
  align-items: center;
  width: 100%;
  max-width: 376px;
  margin-top: 4px;
  row-gap: 8px;
}

.emotion-btn {
  width: 110px;
  height: 110px;
  padding: 0;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--dur-med) var(--ease-back);
}

.emotion-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.emotion-btn:hover {
  transform: scale(1.06);
}

.emotion-btn:active,
.emotion-btn.is-selected {
  transform: scale(1.1);
}

.emotion-btn.is-selecting {
  animation: emotionPop 360ms var(--ease-back);
}

.emotion-btn--top    { grid-column: 2; grid-row: 1; }
.emotion-btn--left   { grid-column: 1; grid-row: 2; }
.emotion-btn--center { grid-column: 2; grid-row: 2; }
.emotion-btn--right  { grid-column: 3; grid-row: 2; }
.emotion-btn--bottom { grid-column: 2; grid-row: 3; }

@keyframes emotionPop {
  0%   { transform: scale(1.0); }
  40%  { transform: scale(1.16); }
  100% { transform: scale(1.1); }
}

@keyframes heartPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ---------- Screen 17 — Response card ----------------------- */
.game-content--response {
  justify-content: flex-start;
  gap: 18px;
  padding-top: 12px;
}

/* Make the compact-mode prompt tappable + show transition state. */
.prompt-card--toggle {
  width: 100%;
  max-width: 376px;
  height: auto;
  min-height: 60px;
  padding: 16px 20px;
  flex-direction: row;
  align-items: center;
  border-radius: 20px;
  text-align: left;
  cursor: pointer;
  transition: max-width var(--dur-med) var(--ease-out),
              padding var(--dur-med) var(--ease-out),
              border-radius var(--dur-med) var(--ease-out);
}

.prompt-card--toggle .prompt-card__text {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 24px;
  color: var(--on-surface);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  flex: 1;
  transition: font-size var(--dur-med) var(--ease-out),
              line-height var(--dur-med) var(--ease-out);
}

.prompt-card--toggle.is-expanded {
  position: fixed;
  z-index: 60;
  top: 88px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  max-width: 80vw;
  height: 450px;
  max-height: 64vh;
  padding: 24px;
  border-radius: 28px;
  flex-direction: column;
  align-items: stretch;
  cursor: zoom-out;
  animation: promptExpandIn var(--dur-med) var(--ease-out);
}

.prompt-card--toggle.is-expanded .prompt-card__text {
  font-size: 24px;
  line-height: 32px;
  display: block;
  -webkit-line-clamp: unset;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

@keyframes promptExpandIn {
  from { transform: translateX(-50%) scaleY(0.4); opacity: 0.5; transform-origin: top center; }
  to   { transform: translateX(-50%) scaleY(1); opacity: 1; }
}

/* Backdrop scrim + blur for the rest of the screen when expanded */
.prompt-expand-scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(251, 248, 244, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: scrimIn var(--dur-med) var(--ease-out);
  cursor: zoom-out;
}

.prompt-expand-scrim[hidden] { display: none; }

/* Response actions row — Scroll for options + arrow circle */
.response-actions {
  margin-top: 4px;
}

/* Sub-emotion bar — center-anchored carousel with morphing slots */
.subemo-bar {
  position: relative;
  width: 100%;
  max-width: 376px;
  height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  user-select: none;
  touch-action: pan-y;
}

.subemo-track {
  position: relative;
  width: 324px;
  height: 120px;
  flex-shrink: 0;
}

/* Each circle is absolutely-positioned by data-slot. CSS transitions on
   width/height/top/left/font-size produce the "liquid morph" effect. */
.subemo {
  position: absolute;
  border-radius: 50%;
  background: var(--subemo-grad, linear-gradient(180deg, #FFBB00 0%, #F8771B 100%));
  color: var(--on-primary);
  font-family: var(--font-body);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-align: center;
  cursor: pointer;
  transition: width 480ms cubic-bezier(0.34, 1.5, 0.52, 1),
              height 480ms cubic-bezier(0.34, 1.5, 0.52, 1),
              top 480ms cubic-bezier(0.34, 1.5, 0.52, 1),
              left 480ms cubic-bezier(0.34, 1.5, 0.52, 1),
              opacity 280ms var(--ease-out),
              filter 320ms var(--ease-out);
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, 0.35);
}

.subemo[data-slot="-2"] {
  left: 0; top: 45px;
  width: 30px; height: 30px;
  font-size: 0;
}

.subemo[data-slot="-1"] {
  left: 36px; top: 30px;
  width: 60px; height: 60px;
  font-size: 0;
}

.subemo[data-slot="0"],
.subemo--lg {
  left: 102px; top: 0;
  width: 120px; height: 120px;
  font-size: 16px;
  letter-spacing: 0.15px;
  z-index: 2;
}

.subemo[data-slot="1"] {
  left: 228px; top: 30px;
  width: 60px; height: 60px;
  font-size: 0;
}

.subemo[data-slot="2"] {
  left: 294px; top: 45px;
  width: 30px; height: 30px;
  font-size: 0;
}

/* Liquid wobble while transitioning between slots */
.subemo.is-shifting {
  filter: blur(0.5px) saturate(1.05);
}

.subemo__label {
  display: block;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-weight: 500;
  pointer-events: none;
}

/* Per-emotion gradients applied via data-emotion attribute on the bar */
.subemo-bar[data-emotion="anger"]   .subemo { --subemo-grad: linear-gradient(180deg, #F03A47 0%, #C2185B 100%); }
.subemo-bar[data-emotion="joy"]     .subemo { --subemo-grad: linear-gradient(180deg, #FFBB00 0%, #F8771B 100%); }
.subemo-bar[data-emotion="sadness"] .subemo { --subemo-grad: linear-gradient(180deg, #4DD0E1 0%, #1E88E5 100%); }
.subemo-bar[data-emotion="disgust"] .subemo { --subemo-grad: linear-gradient(180deg, #66BB6A 0%, #2E7D32 100%); }
.subemo-bar[data-emotion="fear"]    .subemo { --subemo-grad: linear-gradient(180deg, #B86DDB 0%, #6F3596 100%); }

/* Response card — same proportions as prompt card on screen 15 */
.response-card {
  width: 300px;
  max-width: 80vw;
  height: 450px;
  max-height: 64vh;
  margin: 6px auto 0;
  padding: 24px;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
}

.response-card .prompt-card__text {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 28px;
  color: var(--on-surface-variant);
  margin: 0;
  text-align: left;
}

.response-card.is-cycling .prompt-card__text {
  animation: responseSwap 380ms var(--ease-out);
}

@keyframes responseSwap {
  0%   { opacity: 1; transform: translateY(0); }
  35%  { opacity: 0; transform: translateY(-8px); }
  50%  { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* When the prompt is expanded, blur and disable the rest of the screen
   so the focus stays on the full-prompt overlay. Covers all game-loop
   screens that use the truncated-prompt toggle (16, 17, 18). */
.screen--game.is-prompt-expanded .response-actions,
.screen--game.is-prompt-expanded .subemo-bar,
.screen--game.is-prompt-expanded .response-card,
.screen--game.is-prompt-expanded .chat-feed,
.screen--game.is-prompt-expanded .chat-composer,
.screen--game.is-prompt-expanded .emotion-prompt,
.screen--game.is-prompt-expanded .emotion-grid {
  filter: blur(8px);
  pointer-events: none;
  transition: filter var(--dur-med) var(--ease-out);
}

/* ---------- Screen 18 — Chat space -------------------------- */
.game-content--chat {
  justify-content: flex-start;
  align-items: center;
  gap: 16px;
  padding: 12px 0 0;
  width: 100%;
}

.game-content--chat #chatPromptToggle {
  flex-shrink: 0;
}

.chat-feed {
  flex: 1 1 auto;
  width: 100%;
  max-width: 376px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 4px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  scrollbar-width: thin;
}

.chat-message {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 100%;
  animation: chatMessageIn 320ms var(--ease-out);
}

@keyframes chatMessageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-message--partner {
  align-self: flex-start;
  flex-direction: row;
}

.chat-message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-message--user .chat-avatar    { background: var(--user-bubble); }
.chat-message--partner .chat-avatar { background: var(--partner-bubble); }

.chat-bubble {
  padding: 12px 18px;
  border-radius: 22px;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 15px;
  line-height: 22px;
  letter-spacing: 0.15px;
  max-width: calc(100% - 70px);
  word-wrap: break-word;
}

.chat-message--partner .chat-bubble {
  background: var(--partner-bubble);
  color: var(--on-partner-bubble);
  border-bottom-left-radius: 8px;
}

.chat-message--user .chat-bubble {
  background: var(--user-bubble);
  color: var(--on-user-bubble);
  border-bottom-right-radius: 8px;
}

/* Three-dot typing indicator */
.chat-bubble--typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 18px 20px;
}

.chat-bubble--typing .typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  animation: typingDot 1.3s infinite ease-in-out both;
}

.chat-bubble--typing .typing-dot:nth-child(2) { animation-delay: 0.18s; }
.chat-bubble--typing .typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingDot {
  0%, 70%, 100% { transform: translateY(0);   opacity: 0.4; }
  35%           { transform: translateY(-4px); opacity: 0.95; }
}

/* Chat composer (input + send/next + waiting state) */
.chat-composer {
  width: 100%;
  max-width: 376px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  flex-shrink: 0;
  padding-bottom: 6px;
}

.chat-input {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--surface-dim);
  border-radius: var(--radius-full);
  padding: 4px 6px 4px 22px;
  height: 56px;
  box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.06);
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.chat-input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(104, 84, 141, 0.15);
}

.chat-input input {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--on-surface);
  height: 100%;
  outline: none;
  min-width: 0;
}

.chat-input input::placeholder { color: var(--outline-variant); }

.chat-input__image-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--on-surface-variant);
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.chat-input__image-btn:hover  { background: rgba(30, 27, 19, 0.06); }
.chat-input__image-btn:active { background: rgba(30, 27, 19, 0.12); transform: scale(0.96); }

.chat-action-row {
  display: flex;
  justify-content: center;
}

#chatNextBtn {
  padding: 12px 32px;
  letter-spacing: 0.4px;
}

/* Waiting-for-partner badge */
.chat-waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.25px;
  color: var(--on-surface-variant);
  padding: 4px 0;
}

.chat-waiting[hidden] { display: none; }

.chat-waiting__badge {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-waiting__pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  animation: chatWaitingPulse 1.4s ease-in-out infinite;
}

@keyframes chatWaitingPulse {
  0%, 100% { transform: scale(0.65); opacity: 0.55; }
  50%      { transform: scale(1.15); opacity: 1; }
}

/* When in waiting state, fade the input + button row */
.chat-composer.is-locked .chat-input,
.chat-composer.is-locked .chat-action-row {
  opacity: 0.55;
  pointer-events: none;
}

/* ---------- Screens 19–24 — Core-emotion intro flow --------- */
.emo-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
  width: 100%;
  max-width: 376px;
}

.intro-emotions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2.4vw, 14px);
  width: 100%;
  flex-wrap: nowrap;
  padding: 0 4px;
}

.intro-emotions__item {
  display: inline-flex;
  width: 60px;
  height: 60px;
  flex-shrink: 0;
}

.intro-emotions__item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Per-emotion meet card layout (screens 20–24) */
.emo-meet {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 376px;
  padding: 0 12px;
}

.emo-meet__art {
  width: 240px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emo-meet__art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.emo-meet__card {
  width: 100%;
  background: var(--surface-container);
  border: 1px solid var(--surface-dim);
  border-radius: var(--radius-md);
  padding: 16px 22px;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 22px;
  letter-spacing: 0.2px;
  color: var(--on-surface-variant);
  text-align: center;
  margin: 0;
}

/* Footer "Meet [next]" pill+arrow combo — sits flush with no gap */
.emo-advance {
  gap: 0;
}

/* Subtle entrance for each emotion card */
.screen[data-screen="22"] .emo-meet__art,
.screen[data-screen="23"] .emo-meet__art,
.screen[data-screen="24"] .emo-meet__art,
.screen[data-screen="25"] .emo-meet__art,
.screen[data-screen="26"] .emo-meet__art {
  animation: emoArtPop 480ms var(--ease-back) 80ms both;
}

/* ---------- Screen 19 — Pack demo complete ----------------- */
.demo-complete {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
  width: 100%;
  max-width: 376px;
  padding: 0 12px;
}

.demo-complete__art {
  width: 100%;
  max-width: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: demoCompleteArtIn 500ms var(--ease-out) 80ms both;
}

.demo-complete__art img {
  width: 100%;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}

.demo-complete__title {
  animation: demoCompleteTitleIn 540ms var(--ease-out) 180ms both;
}

@keyframes demoCompleteArtIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes demoCompleteTitleIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes emoArtPop {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- Screen 20 — Money Type result ------------------- */
.money-type {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 376px;
  padding: 0 4px;
}

.money-type__art {
  width: 100%;
  max-width: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: moneyTypeArtIn 500ms var(--ease-out) 80ms both;
}

.money-type__art img {
  width: 100%;
  height: auto;
  max-height: 240px;
  object-fit: contain;
  pointer-events: none;
}

.money-type__title {
  text-align: center;
  margin: 0;
  animation: moneyTypeTitleIn 520ms var(--ease-out) 180ms both;
}

.money-type__intro {
  text-align: center;
  max-width: 320px;
  margin: 0;
  animation: moneyTypeTitleIn 520ms var(--ease-out) 260ms both;
}

.money-type__card {
  width: 100%;
  background: var(--surface-container);
  border: 1px solid var(--surface-dim);
  border-radius: var(--radius-md);
  padding: 16px 22px;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 22px;
  letter-spacing: 0.2px;
  color: var(--on-surface-variant);
  text-align: center;
  margin: 4px 0 0;
  animation: moneyTypeCardIn 540ms var(--ease-out) 340ms both;
}

@keyframes moneyTypeArtIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes moneyTypeTitleIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes moneyTypeCardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Exit confirmation dialog ------------------------ */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.dialog[hidden] { display: none; }

.dialog__scrim {
  position: absolute;
  inset: 0;
  background: rgba(30, 27, 19, 0.45);
  animation: scrimIn var(--dur-med) var(--ease-out);
}

.dialog__panel {
  position: relative;
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--surface-dim);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  animation: dialogIn var(--dur-med) var(--ease-back);
}

.dialog__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  line-height: 28px;
  color: var(--on-surface);
  margin: 0 0 8px;
}

.dialog__body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
  color: var(--on-surface-variant);
  margin: 0 0 16px;
}

.dialog__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.btn--filled-sm {
  padding: 10px 18px;
  font-size: 14px;
  min-width: 0;
}

@keyframes scrimIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes dialogIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Notification Art (Screen 10) --------------------- */
.notification-art {
  display: flex;
  justify-content: center;
  width: 100%;
}

.notification-art__img {
  max-height: 254px;
  object-fit: contain;
}

/* ---------- Toast -------------------------------------------- */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--on-surface);
  color: var(--on-primary);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: transform 300ms var(--ease-out), opacity 200ms ease;
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.is-hiding {
  transform: translateX(-50%) translateY(100px);
  opacity: 0;
  transition: transform 200ms ease-in, opacity 200ms ease-in;
}

/* ---------- Animations --------------------------------------- */
@keyframes screenSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes screenSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-40px); }
}

@keyframes welcomeArtIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1.0); }
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes avatarPop {
  0%   { transform: scale(1.0); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1.0); }
}

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

/* ---------- Responsive --------------------------------------- */
@media (max-width: 412px) {
  .avatar-grid {
    grid-template-columns: repeat(3, 90px);
  }
  .avatar-btn {
    width: 90px;
    height: 90px;
  }
  .code-display__field span {
    font-size: 36px;
    line-height: 44px;
  }
}

/* ---------- Desktop / wider viewports ----------------------- */
@media (min-width: 600px) {
  .screen {
    padding: 56px 40px;
    max-width: none;
  }

  /* Keep header/nav, content, and footer aligned in a centered column,
     but let the screen background fill the entire viewport.
     `width: 100%` is required: these elements are flex children of
     `.screen` (a column flex container). Setting both auto margins
     normally collapses a flex item down to its intrinsic content size
     — which is why the back-only header on screen 12 was shrinking to
     the back button's 48 px width and getting centered. With explicit
     `width: 100%` plus `max-width`, the items reliably size to the
     capped column and the auto margins center the column itself. */
  .screen__header,
  .screen__content,
  .screen__footer,
  .game-nav,
  .pack-info,
  .text-block,
  .option-list,
  .option-grid,
  .pack-list,
  .code-display,
  .input-wrapper,
  .avatar-section {
    width: 100%;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
  }

  /* Pack-info content stays narrower for comfortable reading. */
  .screen[data-screen="12"] .screen__content,
  .screen[data-screen="13"] .screen__content {
    max-width: 480px;
  }

  /* Game screens — give the card extra breathing room so its
     drop-shadow renders without clipping at the column edges. */
  .screen--game .screen__content,
  .screen--game .game-content,
  .screen--game .screen__footer,
  .screen--game .game-nav {
    max-width: 540px;
  }

  /* Don't restrict the welcome art container any further than it
     already is on mobile — but center it within the wider viewport. */
  .welcome-art,
  .before-art,
  .notification-art {
    margin-left: auto;
    margin-right: auto;
  }
}

@media (min-width: 1024px) {
  .screen {
    padding: 72px 48px;
  }
  .screen__header,
  .screen__content,
  .screen__footer,
  .game-nav,
  .pack-info,
  .text-block,
  .option-list,
  .option-grid,
  .pack-list,
  .code-display,
  .input-wrapper,
  .avatar-section,
  .screen--game .screen__content,
  .screen--game .game-content,
  .screen--game .screen__footer,
  .screen--game .game-nav {
    width: 100%;
    max-width: 580px;
  }
}

/* ---------- Screen 27 — Home (dashboard) -------------------- */
.screen--home {
  padding: 0;
  background: var(--surface);
  flex-direction: row;
  align-items: stretch;
}

.home-sidenav {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
  width: 96px;
  padding: 24px 8px;
  background: var(--surface-container);
  border-right: 1px solid var(--surface-dim);
}

.home-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100dvh;
  position: relative;
}

.home-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 18px 8px;
  flex-shrink: 0;
}

.home-topbar__group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.home-topbar__btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--on-surface);
  position: relative;
  transition: background var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.home-topbar__btn:hover { background: rgba(30, 27, 19, 0.06); }
.home-topbar__btn:active { transform: scale(0.94); }

.home-topbar__dot {
  position: absolute;
  top: 10px;
  right: 11px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--secondary);
  border: 2px solid var(--surface);
  box-sizing: content-box;
}

.home-topbar__cal-wrap,
.home-topbar__notif-wrap {
  position: relative;
}

/* Calendar dropdown */
.home-calendar {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  min-width: 280px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--surface-dim);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  animation: dropdownIn var(--dur-med) var(--ease-out);
}

.home-calendar[hidden] { display: none; }

.home-calendar__head {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.home-calendar__month {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--on-surface);
}

.home-calendar__week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.home-calendar__day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  background: transparent;
  transition: background var(--dur-fast) var(--ease-out);
}

.home-calendar__day:hover { background: var(--surface-container); }

.home-calendar__day-name {
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--on-surface-variant);
  text-transform: uppercase;
}

.home-calendar__day-num {
  font-size: 15px;
  font-weight: 500;
  color: var(--on-surface);
}

.home-calendar__day.is-today {
  background: var(--primary);
}
.home-calendar__day.is-today .home-calendar__day-name,
.home-calendar__day.is-today .home-calendar__day-num {
  color: var(--on-primary);
}

/* Notifications dropdown */
.home-notifs {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: min(340px, calc(100vw - 36px));
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--surface-dim);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  animation: dropdownIn var(--dur-med) var(--ease-out);
}

.home-notifs[hidden] { display: none; }

.home-notifs__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--on-surface);
  margin-bottom: 10px;
}

.home-notifs__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-notif {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 4px;
}

.home-notif__dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  background: var(--surface-dim);
}

.home-notif__dot--purple { background: var(--primary); }

.home-notif__text {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 20px;
  color: var(--on-surface);
  margin: 0;
}

.home-notif__time {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--on-surface-variant);
  letter-spacing: 0.4px;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Main content */
.home-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 8px 18px 96px;
  overflow-y: auto;
}

.home-greeting {
  text-align: left;
  font-size: 28px;
  line-height: 36px;
  width: 100%;
  margin-top: 4px;
}

.home-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.home-section__label {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
  color: var(--on-surface);
  margin: 0;
}

.home-section__title {
  text-align: left;
  font-size: 26px;
  line-height: 34px;
  margin: 0;
}

.home-section__sub {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.25px;
  color: var(--on-surface-variant);
  margin: 0;
}

.home-pack-card {
  max-width: none;
}

/* Insight cards rail */
.insight-rail {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 0 8px;
  margin: 0 -18px;
  padding-left: 18px;
  padding-right: 18px;
}
.insight-rail::-webkit-scrollbar { display: none; }

.insight-card {
  flex: 0 0 calc(60% - 6px);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 16px 12px;
  background: var(--surface-container);
  border: 1px solid var(--surface-dim);
  border-radius: var(--radius-md);
  text-align: left;
  min-height: 200px;
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.insight-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.insight-card:active { transform: scale(0.985); }

.insight-card__title {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 28px;
  color: var(--on-surface);
}

.insight-card__art {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 0;
}

.insight-card__art img {
  width: 100%;
  max-width: 160px;
  height: auto;
  object-fit: contain;
}

.home-show-all {
  align-self: flex-start;
  padding: 8px 0 0;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.1px;
  color: var(--primary);
  background: none;
  border: 0;
  cursor: pointer;
}

.home-show-all:hover { text-decoration: underline; }

/* Bottom nav (mobile) */
.home-bottomnav {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 4px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface-container);
  border-top: 1px solid var(--surface-dim);
  flex-shrink: 0;
  z-index: 5;
}

.home-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  color: var(--on-surface-variant);
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.home-nav__item:hover {
  background: rgba(104, 84, 141, 0.08);
  color: var(--on-surface);
}

.home-nav__item.is-active {
  background: var(--primary);
  color: var(--on-primary);
}

.home-nav__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.home-nav__label {
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.4px;
  line-height: 14px;
}

/* Desktop layout */
@media (min-width: 900px) {
  .screen--home {
    padding: 0;
  }

  .home-sidenav {
    display: flex;
  }

  .home-bottomnav {
    display: none;
  }

  .home-topbar {
    padding: 28px 40px 8px;
  }

  .home-content {
    padding: 16px 40px 48px;
    gap: 32px;
    max-width: 1100px;
  }

  .home-greeting {
    font-size: 32px;
    line-height: 40px;
  }

  .home-pack-card {
    max-width: 720px;
  }

  .home-pack-card .pack-card__art {
    width: 140px;
  }

  .insight-rail {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin: 0;
    padding: 4px 0 4px;
    overflow: visible;
    max-width: 720px;
  }

  .insight-card {
    flex: none;
    min-height: 220px;
  }

  .insight-card__art img {
    max-width: 180px;
  }
}

@media (min-width: 1200px) {
  .home-content {
    padding-left: 56px;
    padding-right: 56px;
  }
  .home-topbar {
    padding-left: 56px;
    padding-right: 56px;
  }
}

/* ---------- Reduced motion ----------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
