:root {
  --pink: #ff8fc7;
  --hot: #ff5fa2;
  --purple: #9f7bff;
  --lav: #e6d9ff;
  --teal: #3fd0c9;
  --maroon: #8b2b4a;
  --ink: #4a2040;
  --cream: #fff7fb;
  --gold: #ffd86b;
  --font: 'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2a1650; }
body {
  font-family: var(--font); color: var(--ink);
  position: fixed; inset: 0;
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font-family: inherit; color: inherit; border: none; cursor: pointer; touch-action: manipulation; }
#app { position: absolute; inset: 0; }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; display: none; overflow: hidden; }
.screen.active { display: block; }
canvas { display: block; touch-action: none; }
#world-canvas, #sanct-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- buttons ---------- */
.btn {
  font-size: 18px; font-weight: 700; padding: 12px 22px; border-radius: 999px;
  background: #fff; box-shadow: 0 4px 0 var(--maroon), 0 6px 16px rgba(74, 32, 64, .25);
  border: 3px solid var(--maroon); transition: transform .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--maroon); }
.btn.primary { background: linear-gradient(180deg, #ffa8d4, var(--hot)); color: #fff; text-shadow: 0 2px 0 rgba(139, 43, 74, .5); }
.btn.secondary { background: linear-gradient(180deg, #c3f6f2, #7fe0d6); }
.btn.danger { background: #ffd0d8; }
.btn.huge { font-size: 28px; padding: 16px 48px; }
.btn:disabled { opacity: .6; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; font-size: 22px; background: #fffffff0;
  border: 3px solid var(--maroon); box-shadow: 0 3px 0 var(--maroon); flex: none;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--maroon); }
.pill {
  background: #fffffff0; border: 3px solid var(--maroon); border-radius: 999px; padding: 6px 12px;
  font-weight: 700; font-size: 16px; white-space: nowrap; box-shadow: 0 3px 0 var(--maroon);
}
.pill.grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: center; }

.topbar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 5;
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 10px) 8px calc(var(--safe-l) + 10px);
  display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: nowrap;
}
.hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 8px calc(var(--safe-r) + 10px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 10px);
  display: flex; gap: 8px; align-items: center; justify-content: space-between; pointer-events: none;
}
.hud-bottom > * { pointer-events: auto; }
.comp-pill {
  display: flex; align-items: center; gap: 4px; background: #fffffff0; border: 3px solid var(--maroon);
  border-radius: 999px; padding: 2px 12px 2px 2px; box-shadow: 0 3px 0 var(--maroon); font-weight: 700; font-size: 14px;
}
.comp-pill img { width: 46px; height: 46px; border-radius: 50%; background: var(--lav); }

/* ---------- title ---------- */
#screen-title {
  background: radial-gradient(ellipse at 50% 30%, #ffe3f3 0%, #ffb3dc 35%, #b48cff 75%, #6d3fd6 100%);
  display: none; flex-direction: column; align-items: center; justify-content: space-evenly;
  padding: calc(var(--safe-t) + 10px) 16px calc(var(--safe-b) + 16px);
}
#screen-title.active { display: flex; }
.title-sparkles { position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(2px 2px at 20% 30%, #fff, transparent), radial-gradient(3px 3px at 80% 20%, #fff, transparent),
    radial-gradient(2px 2px at 60% 70%, #fff, transparent), radial-gradient(3px 3px at 30% 80%, #fff, transparent),
    radial-gradient(2px 2px at 90% 60%, #fff, transparent), radial-gradient(2px 2px at 10% 55%, #fff, transparent);
  animation: twinkle 2.5s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .4 } to { opacity: 1 } }
.game-title { margin: 0; text-align: center; line-height: .95; z-index: 1; }
.game-title span { display: block; font-size: clamp(26px, 7vw, 40px); color: #fff; text-shadow: 0 3px 0 var(--maroon), 0 0 12px #ff5fa2; }
.game-title .big {
  font-size: clamp(40px, 12vw, 72px);
  background: linear-gradient(90deg, #fff 0%, #fff3a6 30%, #ffffff 50%, #c3f6f2 70%, #fff 100%); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2px var(--maroon); text-shadow: none; filter: drop-shadow(0 4px 0 var(--maroon));
  animation: shimmer 3s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.title-sofie { max-height: 52vh; max-width: 80vw; z-index: 1; filter: drop-shadow(0 10px 20px rgba(74, 32, 64, .4)); animation: floaty 3s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translateY(-10px) rotate(-1deg); } }
#title-play { z-index: 1; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.mute-corner { position: absolute; top: calc(var(--safe-t) + 10px); right: calc(var(--safe-r) + 10px); z-index: 2; }
@media (orientation: landscape) and (max-height: 500px) {
  #screen-title { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 4px 24px; }
  .title-sofie { max-height: 78vh; order: -1; }
  .game-title { width: 50%; }
  #title-play { position: absolute; bottom: calc(var(--safe-b) + 18px); right: calc(var(--safe-r) + 30px); }
}

/* ---------- map ---------- */
#screen-map { background: linear-gradient(160deg, #b48cff, #ff8fc7 60%, #ffc6e1); }
.map-parchment {
  position: absolute; left: calc(var(--safe-l) + 10px); right: calc(var(--safe-r) + 10px);
  top: calc(var(--safe-t) + 66px); bottom: calc(var(--safe-b) + 84px);
  border-radius: 24px; border: 4px solid var(--maroon);
  background:
    radial-gradient(ellipse at 30% 25%, rgba(63, 208, 201, .35), transparent 40%),
    radial-gradient(ellipse at 75% 70%, rgba(180, 140, 255, .35), transparent 40%),
    radial-gradient(ellipse at 50% 50%, #fff6df, #f6dfb8);
  box-shadow: inset 0 0 40px rgba(139, 43, 74, .25), 0 6px 0 var(--maroon);
  overflow: hidden;
}
.map-title { position: absolute; top: 8px; left: 0; right: 0; text-align: center; font-weight: 700; font-size: 20px; color: var(--maroon); }
#map-lands { position: absolute; inset: 34px 8px 8px 8px; }
.map-path { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-path path { fill: none; stroke: var(--maroon); stroke-width: 3; stroke-dasharray: 2 8; stroke-linecap: round; opacity: .55; }
.land-node {
  position: absolute; transform: translate(-50%, -50%); background: none; display: flex; flex-direction: column; align-items: center;
  width: 120px; padding: 0; z-index: 2;
}
.land-bubble {
  width: 72px; height: 72px; border-radius: 50%; font-size: 38px; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff, var(--c)); border: 4px solid var(--maroon); box-shadow: 0 4px 0 var(--maroon), 0 0 0 6px #ffffff88;
  animation: bob 2.4s ease-in-out infinite;
}
.land-node:nth-child(odd) .land-bubble { animation-delay: -1.2s; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.land-node.restored .land-bubble { box-shadow: 0 4px 0 var(--maroon), 0 0 0 6px #fff3a6, 0 0 24px 8px #ffe066; }
.land-node.locked .land-bubble { background: #d9cfe6; filter: grayscale(.6); animation: none; }
.land-label { margin-top: 6px; font-weight: 700; font-size: 14px; background: #fff; border: 2px solid var(--maroon); border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.land-prog { font-size: 12px; font-weight: 600; color: var(--maroon); background: #ffffffcc; border-radius: 8px; padding: 0 6px; margin-top: 2px; white-space: nowrap; }
.map-sofie { position: absolute; right: -10px; bottom: -6px; height: 34%; max-height: 220px; pointer-events: none; filter: drop-shadow(0 4px 8px rgba(74, 32, 64, .3)); z-index: 1; }
.bottombar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 10px;
  padding: 8px calc(var(--safe-r) + 10px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 10px);
}
.btn.nav { display: flex; flex-direction: column; align-items: center; font-size: 24px; padding: 6px 14px; border-radius: 18px; flex: 1; max-width: 150px; }
.btn.nav span { font-size: 13px; }
#screen-map .topbar { justify-content: center; }
@media (orientation: landscape) and (max-height: 500px) {
  .map-parchment { top: calc(var(--safe-t) + 60px); bottom: calc(var(--safe-b) + 8px); right: calc(var(--safe-r) + 120px); }
  .bottombar { left: auto; top: calc(var(--safe-t) + 60px); flex-direction: column; justify-content: flex-start; width: calc(var(--safe-r) + 120px); padding: 0 calc(var(--safe-r) + 10px) 0 6px; }
  .btn.nav { flex: none; }
  .land-bubble { width: 56px; height: 56px; font-size: 30px; }
  .land-label { font-size: 12px; }
  .map-sofie { height: 60%; }
}

/* ---------- dialog ---------- */
#dialog {
  position: fixed; inset: 0; z-index: 50; display: none; align-items: flex-end; justify-content: center;
  background: linear-gradient(transparent 40%, rgba(42, 22, 80, .45));
  padding: 0 calc(var(--safe-r) + 10px) calc(var(--safe-b) + 14px) calc(var(--safe-l) + 10px);
}
#dialog.show { display: flex; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0 } }
.dialog-card {
  width: 100%; max-width: 640px; background: var(--cream); border: 4px solid var(--maroon); border-radius: 24px;
  display: flex; gap: 10px; align-items: flex-end; padding: 12px; box-shadow: 0 6px 0 var(--maroon); position: relative;
  animation: popin .25s cubic-bezier(.3, 1.6, .5, 1);
}
.dialog-card.right { flex-direction: row-reverse; }
@keyframes popin { from { transform: translateY(30px) scale(.9); opacity: 0; } }
.portrait { width: 96px; height: 96px; flex: none; border-radius: 20px; border: 3px solid var(--maroon); background: radial-gradient(circle, #fff, var(--lav)); object-fit: contain; margin-top: -40px; }
.portrait.sofie { background: radial-gradient(circle, #fff, #ffc6e1); object-fit: cover; }
.portrait.narrator { display: grid; place-items: center; font-size: 52px; background: radial-gradient(circle, #fff6df, #f6dfb8); }
.dialog-body { flex: 1; min-width: 0; }
.dialog-name { display: inline-block; background: var(--hot); color: #fff; font-weight: 700; border-radius: 10px; padding: 1px 10px; font-size: 15px; border: 2px solid var(--maroon); }
.dialog-text { font-size: 19px; line-height: 1.3; margin: 6px 0 2px; font-weight: 500; }
.dialog-next { text-align: right; font-size: 13px; color: var(--maroon); opacity: .7; animation: pulse 1.2s infinite; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 70px); transform: translate(-50%, -20px); z-index: 80;
  background: var(--maroon); color: #fff; font-weight: 600; padding: 10px 18px; border-radius: 16px; max-width: 90vw; text-align: center;
  opacity: 0; transition: all .25s; pointer-events: none; font-size: 16px;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- confetti ---------- */
.confetti { position: fixed; z-index: 90; pointer-events: none; animation: burst 1.3s ease-out forwards; text-shadow: 0 0 4px #fff; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }
body.portal-flash::after { content: ''; position: fixed; inset: 0; z-index: 99; pointer-events: none; background: radial-gradient(circle, #fff, #ff8fc7aa, #9f7bff00); animation: flash .7s ease-out forwards; }
@keyframes flash { from { opacity: 1; transform: scale(.2); } to { opacity: 0; transform: scale(2); } }

/* ---------- modal ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(42, 22, 80, .5); display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .2s; }
.modal-wrap.show { opacity: 1; }
.modal-card { position: relative; background: var(--cream); border: 4px solid var(--maroon); border-radius: 24px; padding: 18px; width: 100%; max-width: 420px; max-height: 92%; overflow: auto; box-shadow: 0 6px 0 var(--maroon); }
.modal-x { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 2px solid var(--maroon); font-size: 16px; }
.choose { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.choose-img { width: 140px; height: 140px; }
.choose-text { font-size: 19px; margin: 0; font-weight: 600; }
.choose-btns { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.settings { display: flex; flex-direction: column; gap: 12px; }
.settings h3, .card h3 { margin: 0; text-align: center; }
.powers { background: #fff; border-radius: 14px; padding: 8px 12px; border: 2px dashed var(--pink); font-size: 15px; }
.powers h4 { margin: 0 0 4px; }
.tiny { font-size: 13px; text-align: center; opacity: .8; margin: 0; }

/* ---------- book ---------- */
.overlay-full {
  position: fixed; inset: 0; z-index: 40; display: none; flex-direction: column;
  background: linear-gradient(170deg, #ffe3f3, #e6d9ff 60%, #c3f6f2);
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 10px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 10px);
}
.overlay-full.show { display: flex; animation: fadein .2s; }
.book-head { display: flex; align-items: center; gap: 8px; }
.book-title { flex: 1; font-size: 24px; font-weight: 700; color: var(--maroon); }
#book-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.book-tabs { display: flex; gap: 6px; margin: 10px 0; overflow-x: auto; }
.book-tab { flex: 1; min-width: 58px; padding: 6px 4px; border-radius: 14px; background: #fff; border: 3px solid var(--maroon); font-size: 22px; display: flex; flex-direction: column; align-items: center; }
.book-tab span { font-size: 12px; font-weight: 700; }
.book-tab.active { background: var(--c); color: #fff; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); }
.book-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; align-content: start; padding: 4px 2px 20px; }
.book-card { position: relative; background: #ffffffaa; border: 3px dashed #b9a6d6; border-radius: 18px; padding: 4px; display: flex; flex-direction: column; align-items: center; }
.book-card img { width: 100%; aspect-ratio: 1; }
.book-card.found { background: #fff; border: 3px solid var(--maroon); box-shadow: 0 3px 0 var(--maroon); }
.book-card.rare.found { background: linear-gradient(160deg, #fff, #fff3a6, #ffd6ea); }
.book-card.comp { box-shadow: 0 0 0 4px var(--gold), 0 3px 0 var(--maroon); }
.book-name { font-size: 12px; font-weight: 700; text-align: center; line-height: 1.1; min-height: 2.2em; }
.badge { position: absolute; top: 2px; right: 4px; font-size: 18px; }
.badge.comp { left: 4px; right: auto; }
.card { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.card-img { width: 200px; height: 200px; background: radial-gradient(circle, #fff, var(--lav)); border-radius: 24px; border: 3px solid var(--maroon); }
.card-nick { font-family: inherit; font-size: 22px; font-weight: 700; text-align: center; border: 2px dashed var(--pink); border-radius: 12px; padding: 4px 8px; width: 90%; color: var(--maroon); background: #fff; -webkit-user-select: text; user-select: text; }
.card-species { font-size: 14px; opacity: .8; margin-top: -4px; }
.card-facts { background: #fff; border-radius: 14px; padding: 8px 12px; width: 100%; font-size: 15px; display: flex; flex-direction: column; gap: 4px; }
.card-fact { font-style: italic; color: var(--maroon); }
.card-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.paint-parts { display: flex; gap: 6px; }
.paint-part { background: #fff; border: 2px solid var(--maroon); border-radius: 12px; padding: 4px 10px; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.paint-part.active { background: var(--pink); color: #fff; }
.paint-part .sw { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--maroon); }
.paint-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 6px; width: 100%; }
.paint-sw { aspect-ratio: 1; border-radius: 50%; border: 3px solid var(--maroon); }

/* ---------- sanctuary ---------- */
#shop {
  position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 72px); z-index: 6; display: none;
  padding: 0 calc(var(--safe-r) + 10px) 0 calc(var(--safe-l) + 10px);
}
#shop.show { display: block; animation: popin .2s; }
.shop-items { display: flex; gap: 8px; overflow-x: auto; padding: 8px; background: #fffffff0; border: 3px solid var(--maroon); border-radius: 20px; box-shadow: 0 4px 0 var(--maroon); }
.shop-item { flex: none; width: 84px; background: #fff; border: 2px solid #e3d3f0; border-radius: 14px; padding: 4px; display: flex; flex-direction: column; align-items: center; font-size: 12px; font-weight: 600; }
.shop-item img { width: 60px; height: 60px; }
.shop-item .big { font-size: 40px; height: 60px; display: grid; place-items: center; }
.shop-item b { color: var(--maroon); }
.shop-item.active { border-color: var(--hot); background: #ffe3f3; box-shadow: 0 0 0 3px var(--pink); }
.shop-item.poor { opacity: .45; }
.hint { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 68px); z-index: 5; background: var(--maroon); color: #fff; padding: 6px 14px; border-radius: 14px; font-weight: 600; font-size: 15px; max-width: 90%; text-align: center; }
.hint:empty { display: none; }

/* ---------- minigames ---------- */
#game { z-index: 45; background: linear-gradient(170deg, #ffb3dc, #b48cff 55%, #6d3fd6); color: var(--ink); }
.g-header { display: flex; align-items: center; gap: 8px; background: var(--cream); border: 3px solid var(--maroon); border-radius: 20px; padding: 6px 8px; box-shadow: 0 4px 0 var(--maroon); }
.g-portrait { width: 56px; height: 56px; flex: none; }
.g-titles { flex: 1; min-width: 0; }
.g-title { font-weight: 700; font-size: 19px; color: var(--maroon); }
.g-instr { font-size: 14px; line-height: 1.2; }
.g-x { width: 40px; height: 40px; border-radius: 50%; background: #fff; border: 2px solid var(--maroon); font-size: 16px; flex: none; }
.g-status { text-align: center; color: #fff; font-weight: 700; font-size: 18px; margin: 8px 0; text-shadow: 0 2px 0 var(--maroon); min-height: 24px; }
.g-stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 20px; background: rgba(255, 255, 255, .15); border: 3px dashed rgba(255, 255, 255, .6); overflow: hidden; }
.g-canvas { position: absolute; inset: 0; }
.g-banner { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(255, 247, 251, .92); font-size: 28px; font-weight: 700; color: var(--maroon); text-align: center; padding: 20px; animation: fadein .2s; }
.g-banner.win { background: rgba(255, 247, 251, .8); font-size: 34px; }
.g-sub { font-size: 16px; font-weight: 500; }

.mem-grid { display: grid; gap: 10px; width: min(100%, 440px); padding: 12px; }
.mem-card { aspect-ratio: 3/4; background: none; perspective: 600px; padding: 0; max-height: 18vh; }
.mem-inner { position: relative; width: 100%; height: 100%; transition: transform .35s; transform-style: preserve-3d; }
.mem-card.flip .mem-inner { transform: rotateY(180deg); }
.mem-back, .mem-front { position: absolute; inset: 0; border-radius: 14px; border: 3px solid var(--maroon); display: grid; place-items: center; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 3px 0 var(--maroon); }
.mem-back { background: repeating-linear-gradient(45deg, var(--pink), var(--pink) 8px, #ffb3dc 8px, #ffb3dc 16px); color: #fff; font-size: 26px; }
.mem-front { background: #fff; font-size: clamp(26px, 8vw, 40px); transform: rotateY(180deg); }
.mem-card.done .mem-front { background: #fff3a6; animation: pulse .5s 2; }

.simon { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: min(84%, 340px); aspect-ratio: 1; }
.simon-pad { border-radius: 28px; background: var(--c); border: 4px solid var(--maroon); font-size: 54px; color: #fff; opacity: .65; box-shadow: 0 5px 0 var(--maroon); transition: all .08s; }
.simon-pad.lit { opacity: 1; transform: scale(1.06); box-shadow: 0 0 30px 10px #fff, 0 5px 0 var(--maroon); }

.treat-scene { position: relative; display: flex; align-items: center; justify-content: center; }
.treat-pet { width: min(48vw, 200px); height: min(48vw, 200px); }
.treat-bubble { position: absolute; top: -10px; right: -50px; width: 80px; height: 80px; border-radius: 50%; background: #fff; border: 3px solid var(--maroon); display: grid; place-items: center; font-size: 44px; opacity: 0; transition: opacity .2s; }
.treat-bubble.show { opacity: 1; }
.treat-opts { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; padding: 0 10px; }
.treat-btn { width: 70px; height: 70px; font-size: 40px; border-radius: 18px; background: #fff; border: 3px solid var(--maroon); box-shadow: 0 3px 0 var(--maroon); }
.treat-btn.right { background: #b4f0c0; }
.treat-btn.wrong { background: #ffd0d8; opacity: .5; }

.slide-wrap { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
.slide-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: min(80vw, 46vh, 330px); aspect-ratio: 1; background: var(--maroon); border: 4px solid var(--maroon); border-radius: 14px; overflow: hidden; }
.slide-tile { background-color: #fff; border-radius: 6px; padding: 0; }
.slide-tile.empty { background: rgba(255, 255, 255, .25); }
.slide-board.solved { gap: 0; box-shadow: 0 0 30px 10px #fff3a6; }
.slide-side { display: flex; flex-direction: column; align-items: center; color: #fff; font-weight: 700; }
.slide-preview { width: 90px; height: 90px; background: #fff; border-radius: 14px; border: 3px solid var(--maroon); }

@media (orientation: landscape) and (max-height: 500px) {
  #game { flex-direction: column; }
  .g-instr { display: none; }
  .g-status { margin: 4px 0; }
  .mem-grid { grid-template-columns: repeat(6, 1fr) !important; width: min(100%, 600px); }
  .mem-card { max-height: 30vh; }
  .simon { width: auto; height: 90%; }
  .dialog-text { font-size: 17px; }
  .portrait { width: 76px; height: 76px; }
}
