*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ocean: #0171C9;
  --brown:       #7a4f1a;
  --brown-dark:  #5a3810;
  --brown-deep:  #4a2f08;
  --gold:        #f5c842;
  --font-ui: 'Rubik', sans-serif;
  --font-hebrew: 'Rubik', sans-serif;
  --text-small: 0.9rem;
  --text-body: 1rem;
  --text-large: 1.25rem;
  --text-heading: 1.75rem;
  /* Global card-size constants — single source of truth for all mini-games */
  --card-w:    155px;
  --card-gap:  10px;
  --card-font: 1.2rem;
}

body {
  font-family: var(--font-ui);
  font-size: var(--text-body);
  background: #f5f0e8;
  color: #1a1a1a;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.australia-view,
.region-view,
.opening-view,
.reward-view,
.puzzle-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ─── Map shared ──────────────────────────────────────────── */

.map-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: #7a4f1a;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.map-title-text {
  font-size: var(--text-heading);
}

.btn-reset {
  background: none;
  border: 1.5px solid rgba(255,255,255,0.45);
  border-radius: 6px;
  color: #fff;
  padding: 0.3rem 0.75rem;
  font: inherit;
  font-size: var(--text-small);
  cursor: pointer;
  opacity: 0.9;
}

.btn-reset:hover { opacity: 1; }

.map-container {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--ocean);
}

.map-inner {
  position: relative;
  container-type: inline-size;  /* enables cqw sizing for hotspot children */
  /* CSS fallback: ResizeObserver overrides via inline style to exact 16:9 px.
     Fallback covers the first paint; max-height omitted to avoid the stretch bug. */
  width: 100%;
  aspect-ratio: 16 / 9;
}

.map-img {
  display: block;
  width: 100%;
  height: 100%;
}

.map-container--contain-backdrop {
  position: relative;
  overflow: hidden;
}

.map-container--contain-backdrop .map-inner {
  z-index: 1;
}

.map-inner--contain-backdrop .map-img {
  position: relative;
  z-index: 1;
  object-fit: contain;
  object-position: center center;
}

.map-img-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  filter: blur(18px) brightness(0.72) saturate(1.12);
  transform: scale(1.06);
}

.map-inner--contain-backdrop .hotspot {
  z-index: 2;
}

.australia-view .map-inner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.15);
  pointer-events: none;
  z-index: 1;
}

.australia-view .hotspot {
  z-index: 2;
}

/* ─── Letterbox variants ──────────────────────────────────── */

.map-container.lb-flat     { background: var(--ocean); }
.map-container.lb-vignette { background: radial-gradient(ellipse 90% 90% at center, #0378d4 0%, #0156ab 50%, #012558 100%); }
.map-container.lb-deep     { background: linear-gradient(180deg, #012558 0%, var(--ocean) 35%, var(--ocean) 65%, #012558 100%); }

/* ─── Hotspots ────────────────────────────────────────────── */

.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  padding: clamp(0.1rem, calc(0.25rem * var(--map-w, 1000) / 1000), 0.35rem)
           clamp(0.3rem, calc(0.65rem * var(--map-w, 1000) / 1000), 0.85rem);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  white-space: nowrap;
  font-family: inherit;
  border: 2px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hotspot-label {
  font-size: clamp(0.55rem, calc(1rem * var(--map-w, 1000) / 1000), 1.4rem);
  line-height: 1.25;
}

.hotspot-sublabel {
  font-size: clamp(0.4rem, calc(0.7rem * var(--map-w, 1000) / 1000), 1rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0.85;
  text-transform: uppercase;
}

.australia-view .hotspot-label,
.australia-view .hotspot-sublabel,
.opening-hotspot .hotspot-label,
.opening-hotspot .hotspot-sublabel {
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
}

.australia-view .hotspot,
.opening-hotspot {
  max-width: 42cqw;
}

.australia-view .hotspot-label,
.opening-hotspot .hotspot-label {
  font-family: var(--font-hebrew);
  font-weight: 600;
}

.australia-view .hotspot-sublabel,
.opening-hotspot .hotspot-sublabel {
  text-align: center;
  white-space: normal;
}

.hotspot--active {
  background: #fff;
  border-color: #7a4f1a;
  color: #4a2f08;
  opacity: 0.9;
}

.hotspot--active:hover {
  transform: translate(-50%, -50%) scale(1.06);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}

.hotspot--locked {
  background: rgba(255,255,255,0.55);
  border-color: #bbb;
  color: #999;
  cursor: default;
  opacity: 0.5;
  box-shadow: none;
  pointer-events: none;
}

.hotspot--earned {
  background: #f5c842;
  border-color: #b8920a;
  color: #2d1a00;
  box-shadow: 0 2px 14px rgba(200,148,0,0.55);
}

.hotspot--complete {
  background: #3a9a5c;
  border-color: #28774a;
  color: #fff;
}

.hotspot.hotspot--img {
  background: none;
  border-color: transparent;
  padding: 0;
  box-shadow: none;
}
.hotspot.hotspot--img:hover {
  transform: translate(-50%, -50%);
  box-shadow: none;
}
.hotspot.hotspot--img img {
  display: block;
  pointer-events: none;
}

/* ─── Progress strip ─────────────────────────────────────── */

.progress-strip {
  display: flex;
  justify-content: center;
  gap: clamp(0.25rem, 1.2vw, 0.5rem);
  padding: 0.65rem 0.75rem;
  background: #5a3810;
  flex-shrink: 0;
  direction: rtl;
}

.progress-cell {
  width: clamp(2rem, 9vw, 2.75rem);
  height: clamp(2rem, 9vw, 2.75rem);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  font-family: var(--font-hebrew);
  font-size: clamp(1.3rem, 5vw, 1.7rem);
  font-weight: 600;
}

.progress-cell.earned {
  background: #f5c842;
  color: #2d1a00;
  box-shadow: 0 1px 6px rgba(200,148,0,0.45);
  text-shadow: 0 1px 3px rgba(200,148,0,0.5);
}

.progress-cell.pending {
  background: transparent;
  color: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.12);
}

/* ─── Reward view ─────────────────────────────────────────── */

@keyframes letter-pop {
  0%   { transform: scale(0.1) rotate(-12deg); opacity: 0; }
  65%  { transform: scale(1.3)  rotate(4deg);  opacity: 1; }
  100% { transform: scale(1.0)  rotate(0deg);  opacity: 1; }
}

.reward-view {
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  background: #160e04;
  cursor: pointer;
  user-select: none;
}

.reward-letter {
  font-family: var(--font-hebrew);
  font-size: 8rem;
  line-height: 1;
  color: #f5c842;
  text-shadow: 0 4px 40px rgba(245,200,66,0.55);
  animation: letter-pop 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.reward-region-name {
  font-size: var(--text-large);
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.04em;
}

.reward-view .progress-strip {
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
}

.reward-hint {
  font-size: var(--text-small);
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 0.5rem;
}

/* ─── Opening sequence ────────────────────────────────────── */

/* Dark letterbox + background during the title card; reverts when view unmounts */
.opening-view .map-container {
  background: #040f1e;
}

.opening-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Flex content centres over the continent, shifted left 5% from image centre */
  padding: 8% 19% 12% 9%;
  background: rgba(4,16,32,0.88);
  border: 0;
  width: 100%;
  color: #fff;
  font-family: var(--font-ui);
  cursor: pointer;
}

.opening-overlay:disabled {
  opacity: 1;
}

.opening-content {
  position: relative;
  top: -5%;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.opening-hotspot {
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.85);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}

.opening-hotspot--visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.opening-hotspot--visible.hotspot--active {
  opacity: 0.9;
}

.opening-word,
.opening-subtitle {
  font-weight: 600;
  line-height: 1.25;
}

.opening-word {
  font-family: var(--font-hebrew);
  font-size: clamp(3.5rem, 9vw, 6.5rem);
  direction: rtl;
  text-shadow: 0 2px 20px rgba(0,0,0,0.7);
}

.opening-subtitle {
  font-size: clamp(1.5rem, 4vw, 3rem);
  color: #fff;
  margin-top: 0.25rem;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.85; }
  50%       { opacity: 1; }
}

.opening-start-hint {
  margin-top: 1.25rem;
  color: rgba(255,255,255,0.85);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity 0.2s ease;
  animation: hint-pulse 1.8s ease-in-out infinite;
}

.scatter-letter {
  position: absolute;
  z-index: 2;
  display: inline-block;
  isolation: isolate;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-family: var(--font-hebrew);
  color: #fff;
  text-shadow: 0 1px 10px rgba(0,0,0,0.9);
  pointer-events: none;
}

.scatter-letter::after,
.scatter-letter::before {
  content: '';
  position: absolute;
  right: 60%;
  top: 50%;
  z-index: 0;
  width: clamp(2rem, 5vw, 4rem);
  transform: translateY(-50%) rotate(var(--travel-angle, 0deg));
  transform-origin: 100% 50%;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
}

.scatter-letter::after {
  height: 0.16rem;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(245,200,66,0.12) 35%, rgba(255,235,160,0.55));
  filter: blur(0.6px);
}

.scatter-letter::before {
  height: 0.7rem;
  background:
    radial-gradient(circle, rgba(255,255,255,0.65) 0 1px, transparent 1.5px) 18% 45% / 5px 5px no-repeat,
    radial-gradient(circle, rgba(245,200,66,0.58) 0 1.2px, transparent 1.8px) 48% 20% / 6px 6px no-repeat,
    radial-gradient(circle, rgba(255,235,160,0.48) 0 1px, transparent 1.5px) 72% 72% / 5px 5px no-repeat;
}

@keyframes letter-spark {
  0%   { filter: drop-shadow(0 0 8px rgba(255,229,128,0.9)); }
  30%  { filter: drop-shadow(0 0 24px rgba(255,229,128,1)) drop-shadow(0 0 14px rgba(255,255,255,0.8)); }
  100% { filter: none; }
}

.scatter-letter--spark {
  animation: letter-spark var(--flight-duration, 900ms) ease-out var(--flight-delay, 0ms) forwards;
}

@keyframes comet-tail {
  0%, 8% { opacity: 0; }
  20%    { opacity: 0.5; }
  72%    { opacity: 0.34; }
  100%   { opacity: 0; }
}

@keyframes comet-glitter {
  0%, 12% { opacity: 0; }
  28%     { opacity: 0.48; }
  48%     { opacity: 0.2; }
  68%     { opacity: 0.42; }
  100%    { opacity: 0; }
}

.scatter-letter--comet::after {
  animation: comet-tail var(--flight-duration, 900ms) ease-out var(--flight-delay, 0ms) both;
}

.scatter-letter--comet::before {
  animation: comet-glitter var(--flight-duration, 900ms) linear var(--flight-delay, 0ms) both;
}

/* ─── Sub-map header ──────────────────────────────────────── */

.submap-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: #7a4f1a;
  color: #fff;
}

.submap-title {
  font-size: var(--text-large);
  font-weight: 600;
}

/* ─── Shared buttons ──────────────────────────────────────── */

.btn-back {
  background: none;
  border: 1.5px solid #ccc;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: var(--text-small);
  font-family: inherit;
  color: inherit;
}

.btn-back--dark {
  border-color: rgba(255,255,255,0.45);
  color: #fff;
}

/* ─── Puzzle view ─────────────────────────────────────────── */

.puzzle-view {
  width: 100%;
}

.puzzle-name {
  font-size: var(--text-heading);
  margin: 1rem 0 0.5rem;
}

.puzzle-mechanic {
  color: #666;
  font-size: var(--text-small);
  margin-bottom: 2rem;
}

.puzzle-placeholder {
  border: 2px dashed #ccc;
  border-radius: 12px;
  padding: 4rem 2rem;
  text-align: center;
  color: #aaa;
  font-size: 1.2rem;
  margin-bottom: 2rem;
}

.btn-complete {
  background: #3a9a5c;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
}

/* ─── Location view (from first slice — orphaned but kept) ── */

.location-view {
  max-width: 540px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

.location-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.location-title { flex: 1; font-size: 1.3rem; }

.btn-nikud {
  background: none;
  border: 1.5px solid #7a4f1a;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  color: #4a2f08;
}

.word-list { display: flex; flex-direction: column; gap: 1.25rem; }

.word-row {
  text-align: center;
  padding: 1.25rem 1rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.word-hebrew {
  font-family: var(--font-hebrew);
  font-size: 3rem;
  direction: rtl;
  unicode-bidi: isolate;
  line-height: 1.6;
  margin-bottom: 0.4rem;
}

.word-translit { font-style: italic; color: #666; margin-bottom: 0.2rem; }
.word-english  { font-weight: 600; font-size: 1rem; }

/* ─── Find-the-Set game ───────────────────────────────────── */

.fts-root {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.fts-status {
  font-size: 1.1rem;
  color: #666;
  letter-spacing: 0.03em;
}

.fts-grid {
  display: grid;
  grid-template-columns: repeat(4, var(--card-w));
  gap: var(--card-gap);
}

.fts-tile {
  min-width: 0;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  border: 2.5px solid #ddd;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  font-family: var(--font-ui);
  font-size: var(--card-font);
  font-weight: 500;
  color: #3a3326;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
  user-select: none;
  line-height: 1.35;
  overflow-wrap: normal;
  word-break: keep-all;
  hyphens: none;
}

.fts-tile--hebrew {
  font-family: var(--font-hebrew);
  font-size: calc(var(--card-font) * 1.18);
  direction: rtl;
  unicode-bidi: isolate;
  line-height: 1.6;
}

.fts-tile--english {
  text-transform: capitalize;
}

.fts-tile--translit {
  font-style: italic;
}

.hebrew {
  font-family: var(--font-hebrew);
}


.fts-tile.fts-tile--selected {
  border-color: #4a7ab5;
  background: #dce8f5;
  transform: scale(1.05);
}

.fts-tile.fts-tile--cleared {
  background: #b8c8b8;
  border-color: #6a8a6a;
  color: #4a6a4a;
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
  transform: none;
}

@keyframes fts-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.fts-tile.fts-tile--wrong {
  animation: fts-shake 0.45s ease;
  border-color: #c0392b;
  background: #fde8e6;
}

@media (max-width: 700px) {
  .fts-grid {
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
  }
}

@media (max-width: 480px) {
  .fts-grid {
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .puzzle-name { font-size: 1.1rem; }
  .ui-screen-header { padding: 0.35rem 0.5rem; margin-bottom: 0.5rem; }
}

@media (max-width: 400px) {
  .fts-grid    { grid-template-columns: repeat(2, 1fr); width: 100%; }
  .memory-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Find-the-Set: instructions gate ────────────────────── */

.fts-instructions {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem 1rem;
}

.fts-instr-text {
  font-size: 1.2rem;
  text-align: center;
  color: #555;
  line-height: 1.5;
  max-width: 20rem;
}

.fts-start-btn { /* visual from .ui-btn.ui-btn--primary */ }

.fts-start-btn:hover { background: #c8bcae; }

/* ─── Concept reveal beat (shared component) ─────────────── */

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

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

.fts-reveal-stage {
  width: 100%;
  min-height: 120px;
  display: flex;
  align-items: center;
}

.cr-card {
  width: 100%;
  background: #fdf3e0;
  border: 2px solid #e8c04a;
  border-radius: 18px;
  padding: 1.5rem 2.25rem;
  display: flex;
  align-items: center;
  gap: 1.875rem;
  cursor: pointer;
  animation: cr-in 0.2s ease forwards;
}

.cr-card--out {
  animation: cr-out 0.3s ease forwards;
}

.cr-img {
  width: 7.5rem;
  height: 7.5rem;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 12px;
}

.cr-translit {
  width: 7.5rem;
  height: 7.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-style: italic;
  font-weight: 500;
  font-size: 1.35rem;
  color: #3a3326;
  flex-shrink: 0;
  background: #f0e8d0;
  border-radius: 12px;
  text-align: center;
  padding: 0.375rem;
}

.cr-text {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.cr-hebrew {
  font-family: var(--font-hebrew);
  font-size: 3rem;
  font-weight: 500;
  direction: rtl;
  color: #3a3326;
  line-height: 1.2;
}

.cr-english {
  font-size: 1.5rem;
  font-weight: 500;
  color: #3a3326;
  text-transform: capitalize;
}

@media (prefers-reduced-motion: reduce) {
  .cr-card, .cr-card--out { animation-duration: 0.001ms; }
}

/* ─── MEMORY game ────────────────────────────────────────── */

.memory-root {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  min-height: 0;
}

.memory-instructions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
}

.memory-instr-text {
  max-width: 22rem;
  color: #4a2f08;
  font-size: 1rem;
  line-height: 1.35;
  text-align: center;
}

.memory-start-btn {
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 1.4rem;
  background: #7a4f1a;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
}

.memory-start-btn:hover { background: #5c3a12; }

.memory-status {
  color: #666;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
  width: 100%;
}

.memory-card {
  min-width: 0;
  aspect-ratio: 4 / 5;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 700px;
}

.memory-card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.35s ease;
  transform-style: preserve-3d;
}

.memory-card--flipped .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card-back,
.memory-card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid #d8c7ad;
  border-radius: 10px;
  backface-visibility: hidden;
  box-shadow: 0 2px 5px rgba(74,47,8,0.16);
}

.memory-card-back {
  background: #7a4f1a;
  color: rgba(255,255,255,0.9);
  font-size: 2rem;
  font-weight: 700;
}

.memory-card-face {
  padding: 0.4rem;
  transform: rotateY(180deg);
  background: #fff;
}

.memory-card-hebrew {
  color: #3a3326;
  font-weight: 500;
  direction: rtl;
  font-family: var(--font-hebrew);
  font-size: clamp(1.25rem, 3.5vw, 1.7rem);
  line-height: 1.6;
  unicode-bidi: isolate;
}

.memory-card-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.memory-card--matched {
  pointer-events: none;
}

.memory-card--matched.memory-card--flipped {
  opacity: 0.68;
}

.memory-card--matched:not(.memory-card--flipped) {
  opacity: 0.16;
}

.memory-card--wrong {
  animation: fts-shake 0.45s ease;
}

.memory-card--wrong .memory-card-face {
  border-color: #c0392b;
  background: #fde8e6;
}

/* ─── Minimal-pair teaching beat ─────────────────────────── */

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

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

.mpb-card {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 2px solid #e8c04a;
  border-radius: 12px;
  background: #fff8df;
  animation: mpb-in 0.2s ease forwards;
}

.mpb-card--out {
  animation: mpb-out 0.3s ease forwards;
}

.mpb-prompt {
  margin-bottom: 0.55rem;
  color: #7a4f1a;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.mpb-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.mpb-word {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.65);
  transition: background 0.15s, box-shadow 0.15s;
}

.mpb-word--playing {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(232,192,74,0.65);
}

.mpb-hebrew {
  color: #4a2f08;
  direction: rtl;
  font-family: var(--font-hebrew);
  font-size: 1.45rem;
  line-height: 1.3;
  text-align: right;
}

.mpb-equals {
  color: #b8920a;
  font-weight: 700;
}

.mpb-english {
  color: #4a2f08;
  font-size: 0.9rem;
  font-weight: 700;
}

.mpb-contrast {
  margin-top: 0.55rem;
  color: #76552d;
  font-size: 0.85rem;
  text-align: center;
}

@media (max-width: 480px) {
  .memory-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .mpb-comparison {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .memory-card-inner { transition-duration: 0.001ms; }
  .mpb-card, .mpb-card--out { animation-duration: 0.001ms; }
  .scatter-letter--spark { animation: none; }
  .scatter-letter--comet::before,
  .scatter-letter--comet::after { animation: none; opacity: 0; }
  .opening-start-hint { animation: none; }
}

/* ─── Shared flat-cartoon chrome ──────────────────────────── */

.ui-screen {
  background: #ece4d6;
  border: 3px solid #6b5d4f;
  border-radius: 14px;
  box-shadow: 2px 4px 0 #c0b4a4;
}

.ui-screen-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: #9e8e7e;
  border-radius: 8px;
  color: #fff;
  font-weight: 600;
  margin-bottom: 1rem;
}

.ui-btn {
  border: 2.5px solid #6b5d4f;
  border-radius: 8px;
  background: #d8cfc4;
  color: #2e251e;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  box-shadow: 0 4px 0 #8a7a6a;
  transition: transform 0.1s, box-shadow 0.1s;
}

.ui-btn:hover { background: #c8bcae; }

.ui-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #8a7a6a;
}

.ui-btn--back {
  font-size: var(--text-small);
  padding: 0.3rem 0.65rem;
  margin-left: auto;
  flex-shrink: 0;
}

.ui-btn--primary {
  padding: 0.75rem 2rem;
  font-size: 1rem;
}

.ui-panel {
  background: #ece4d6;
  border: 2px solid #b8a898;
  border-radius: 10px;
}

.ui-hud {
  background: #e8ddd0;
  border: 2px solid #9e8e7e;
  border-radius: 999px;
  padding: 0.2rem 0.9rem;
  color: #4a3f35;
}

/* .ui-grid — semantic hook, layout inherited from .fts-grid / .memory-grid */

.ui-slot {
  background: #cfc8bd;
  border: 2.5px solid #6b5d4f;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.22);
}

/* ─── 3-zone play layout ──────────────────────────────────── */

/* standalone (memory / stub) — centered, capped width */
.puzzle-screen {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1.25rem;
  overflow-y: auto;
}

/* inside play-zone (match3) — fixed width, art slots fill the rest */
.fts-play-zone > .puzzle-screen {
  flex: 0 0 700px;
  max-width: none;
  margin: 0;
}

.fts-play-zone {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  min-height: 0;
}

.art-slot {
  flex: 1;
  min-width: 0;
  background-color: #ece4d6;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 2px solid #b8a898;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.art-slot-label {
  color: rgba(107, 93, 79, 0.28);
  font-size: 0.75rem;
  text-align: center;
  padding: 0.5rem;
  user-select: none;
  pointer-events: none;
  writing-mode: vertical-rl;
}

@media (max-width: 959px) {
  .art-slot { display: none; }
  .fts-play-zone > .puzzle-screen { flex: 1; width: 100%; }
}
