:root {
    color-scheme: dark;
    --memory-bg: #151020;
    --memory-panel: #21172e;
    --memory-border: #51405e;
    --memory-text: #fff5e8;
    --memory-muted: #cbbdd5;
    --memory-gold: #f3bf75;
    --memory-accent: #4d2b61;
    --memory-green: #a9e0bd;
    font-family: system-ui, "Segoe UI", Tahoma, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

.memory-page {
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    background:
        radial-gradient(ellipse at 18% 12%, var(--memory-glow, #342047) 0%, transparent 52%),
        radial-gradient(ellipse at 86% 84%, var(--memory-panel) 0%, transparent 38%),
        var(--memory-bg);
    color: var(--memory-text);
}

.memory-page[data-memory-world="ocean"] {
    --memory-bg: #081521;
    --memory-panel: #112e42;
    --memory-border: #3d6475;
    --memory-glow: #1a495e;
    --memory-board-bg: #0e2334;
    --memory-card-light: #236677;
    --memory-card-dark: #183c56;
    --memory-card-edge: #6e9eae;
    --memory-gold: #a1eedd;
    --memory-accent: #225464;
    --memory-muted: #c1dce4;
}
.memory-page[data-memory-world="garden"] {
    --memory-bg: #101d18;
    --memory-panel: #253628;
    --memory-border: #507151;
    --memory-glow: #335336;
    --memory-board-bg: #18291f;
    --memory-card-light: #4b734a;
    --memory-card-dark: #2c4b36;
    --memory-card-edge: #87a682;
    --memory-gold: #d1efaa;
    --memory-accent: #385d3f;
    --memory-muted: #ceddcb;
}
.memory-page[data-memory-world="workshop"] {
    --memory-bg: #21150f;
    --memory-panel: #3f2b20;
    --memory-border: #88634d;
    --memory-glow: #55382b;
    --memory-board-bg: #2d2018;
    --memory-card-light: #81563d;
    --memory-card-dark: #513624;
    --memory-card-edge: #bd9373;
    --memory-gold: #ffd1a3;
    --memory-accent: #744e36;
    --memory-muted: #e6d0bd;
}
.memory-page[data-memory-world="space"] {
    --memory-bg: #0c1026;
    --memory-panel: #1e2856;
    --memory-border: #535f91;
    --memory-glow: #33366d;
    --memory-board-bg: #161d40;
    --memory-card-light: #494d8f;
    --memory-card-dark: #313963;
    --memory-card-edge: #868fbc;
    --memory-gold: #d1ccff;
    --memory-accent: #414a76;
    --memory-muted: #d2d5ed;
}

.memory-page :is(button, a) {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.memory-page :is(button, a):focus-visible {
    outline: 3px solid #ffce91;
    outline-offset: 3px;
}

.memory-page button { font: inherit; cursor: pointer; }
.memory-page button:disabled { cursor: default; }
.memory-page a { color: inherit; text-decoration: none; }

.memory-top {
    border-bottom: 1px solid #a68ab52d;
    background: #15101ed9;
}

.memory-nav {
    width: min(1180px, calc(100% - 48px));
    margin-inline: auto;
    min-height: 65px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.memory-nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-inline-start: auto;
}

.memory-nav :is(a, button) {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 9px;
    font-size: .86rem;
    font-weight: 650;
}

.memory-nav-actions :is(a, button) {
    border: 1px solid var(--memory-border);
    background: #241b30;
}

.memory-nav-actions button { color: var(--memory-text); min-width: 44px; font-size: 1.17rem; }
.memory-nav button[aria-pressed="false"] span { text-decoration: line-through; }
.memory-library span { color: var(--memory-gold); font-size: 1.12rem; }

.memory-layout {
    width: min(1180px, calc(100% - 48px));
    margin: clamp(24px, 5vw, 68px) auto 34px;
    display: grid;
    grid-template-columns: minmax(260px, .82fr) minmax(0, 1.18fr);
    grid-template-areas: "intro board" "settings board" "help board";
    align-items: start;
    align-content: start;
    grid-template-rows: auto auto 1fr;
    gap: 22px clamp(22px, 4vw, 55px);
}

.memory-intro { grid-area: intro; min-width: 0; }
.memory-intro h1 {
    max-width: 11em;
    margin: 0;
    font: 700 clamp(2.6rem, 5vw, 5rem)/.99 Georgia, serif;
    letter-spacing: -.044em;
    text-wrap: balance;
}
[dir="rtl"] .memory-intro h1 {
    max-width: 14em;
    font-family: Tahoma, "Segoe UI", sans-serif;
    font-size: clamp(2.2rem, 3.9vw, 3.72rem);
    letter-spacing: -.016em;
    line-height: 1.22;
}
.memory-intro p {
    color: var(--memory-muted);
    max-width: 32em;
    margin: 14px 0 20px;
    line-height: 1.6;
}
.memory-cover {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1200 / 630;
    object-fit: cover;
    border: 1px solid #c1976f58;
    border-radius: 17px;
    box-shadow: 0 16px 32px #0d091659;
}
.memory-world-panel {
    padding: 18px;
    border: 1px solid var(--memory-border);
    border-radius: 17px;
    background: linear-gradient(145deg, var(--memory-panel), var(--memory-bg));
    box-shadow: 0 16px 32px #0d091659;
}
.memory-world-panel h2 { margin: 0; color: var(--memory-gold); font-size: clamp(1.12rem, 2.35vw, 1.55rem); }
.memory-world-preview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.memory-world-preview img { width: 100%; aspect-ratio: 1; border: 1px solid var(--memory-border); border-radius: 10px; }

.memory-settings { grid-area: settings; display: grid; gap: 9px; }
.memory-daily, .memory-action, .memory-stage {
    min-height: 44px;
    padding: 7px 10px;
    border: 1px solid var(--memory-border);
    border-radius: 9px;
    background: #241a32;
    color: var(--memory-text);
    font-weight: 650;
}
.memory-settings button[aria-pressed="true"], .memory-stage-picker[data-active="true"] {
    border-color: var(--memory-gold);
    background: #543568;
    color: #ffddad;
    box-shadow: inset 0 0 0 1px #f3bf753b;
}
.memory-page[data-memory-world]:not([data-memory-world="classic"]) .memory-stage-picker[data-active="true"] {
    background: var(--memory-accent);
    color: var(--memory-text);
}
.memory-settings .memory-stage-picker { width: 100%; justify-content: space-between; }
.memory-stage-picker strong { font-variant-numeric: tabular-nums; }
.memory-shadow-picker { justify-content: flex-start; white-space: normal; }
.memory-daily {
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: start;
}
.memory-daily-mark { color: var(--memory-gold); font-size: 1.1rem; }
.memory-daily small { margin-inline-start: auto; color: var(--memory-muted); white-space: nowrap; }
.memory-settings #game-hearts-hud {
    position: static;
    background: #261b33;
    border: 1px solid var(--memory-border);
    border-radius: 9px;
    height: auto;
    min-height: 48px;
}
.memory-settings #hp-open {
    min-height: 44px;
    padding-inline: 14px;
    background: transparent;
    border: 0;
}
.memory-help { grid-area: help; display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; color: var(--memory-muted); font-size: .9rem; }
.memory-help a { display: inline-flex; align-items: center; min-height: 44px; gap: 8px; }
.memory-help a:hover { text-decoration: underline; }
.memory-help span { color: var(--memory-gold); }

.memory-workbench {
    grid-area: board;
    min-width: 0;
    border: 1px solid var(--memory-border);
    border-radius: 20px;
    padding: clamp(14px, 2.25vw, 27px);
    background: radial-gradient(ellipse at top, var(--memory-panel), transparent 70%), var(--memory-board-bg, #1c1428);
    box-shadow: 0 20px 55px #09060f6b;
}
.memory-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 15px;
    background: #1a1323;
    border: 1px solid var(--memory-border);
    border-radius: 10px;
}
.memory-stats > div { display: grid; gap: 3px; padding: 11px 4px; text-align: center; }
.memory-stats > div + div { border-inline-start: 1px solid var(--memory-border); }
.memory-stats span, .memory-best span { color: var(--memory-muted); font-size: .79rem; }
.memory-stats strong {
    font: 700 clamp(1.2rem, 2.3vw, 1.75rem)/1.1 Georgia, serif;
    font-variant-numeric: tabular-nums;
    color: #ffdcab;
}
.memory-stats .memory-urgent { color: #ff9ba8; }
.memory-board-position { margin: 0 0 8px; color: var(--memory-muted); text-align: center; font-size: .82rem; }
.memory-board {
    --memory-columns: 4;
    display: grid;
    grid-template-columns: repeat(var(--memory-columns), minmax(0, 1fr));
    width: min(100%, 510px);
    margin-inline: auto;
    gap: clamp(5px, 1.5vw, 12px);
    user-select: none;
    -webkit-user-select: none;
}
.memory-board[data-columns="2"] { --memory-columns: 2; width: min(100%, 255px); }
.memory-board[data-columns="3"] { --memory-columns: 3; width: min(100%, 385px); }
.memory-board[data-columns="6"] { --memory-columns: 6; width: min(100%, 570px); }
.memory-card {
    display: block;
    aspect-ratio: 1.12;
    min-width: 0;
    position: relative;
    background: transparent;
    border: 0;
    border-radius: 10px;
    padding: 0;
    perspective: 630px;
}
.memory-card-surface {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    transform-style: preserve-3d;
    transition: transform 170ms ease-out;
}
.memory-card[data-state="revealed"] .memory-card-surface,
.memory-card[data-state="matched"] .memory-card-surface { transform: rotateY(180deg); }
.memory-card[data-state="matched"] { cursor: default; }
.memory-card :is(.memory-card-back, .memory-card-front) {
    display: grid;
    place-items: center;
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    box-shadow: 0 3px 4px #0d09169c;
}
.memory-card-back {
    border: 1px solid var(--memory-card-edge, #9c76a2);
    color: var(--memory-gold);
    background:
        repeating-linear-gradient(135deg, transparent 0 5px, #ffe5c405 5px 6px),
        radial-gradient(ellipse, var(--memory-card-light, #6c437f), var(--memory-card-dark, #422951) 72%);
    font-size: clamp(.98rem, 3vw, 2.7rem);
    text-shadow: 0 2px 4px #201326;
}
.memory-card-back::before, .memory-card-back::after {
    position: absolute;
    content: "";
    pointer-events: none;
}
.memory-card-back::before {
    inset: 6%;
    border: 1px solid #e0b0787d;
    border-radius: 6px;
}
.memory-card-back::after {
    height: 47%;
    aspect-ratio: 1;
    border: 1px solid #e0b07870;
    border-radius: 32%;
    transform: rotate(45deg);
}
.memory-card-front {
    transform: rotateY(180deg);
    border: 2px solid #e4bd8b;
    background: #372442;
}
.memory-card-front img { width: 100%; height: 100%; object-fit: cover; }
.memory-card-front.memory-card-shadow { background: #102a40; }
.memory-card-shadow img { padding: 7%; object-fit: contain; }
.memory-card[data-state="matched"] .memory-card-front { border-color: #9bd8b0; }
.memory-card[data-state="matched"] .memory-card-front::after {
    content: "✓";
    position: absolute;
    inset-inline-end: 5%;
    inset-block-end: 5%;
    display: grid;
    place-items: center;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background: #153526;
    color: #bff4ce;
    font: 800 .84rem/1 system-ui, sans-serif;
}
.memory-message {
    display: grid;
    align-items: center;
    min-height: 40px;
    margin: 7px 0 1px;
    color: var(--memory-muted);
    text-align: center;
    font-size: .9rem;
    line-height: 1.4;
}
.memory-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--memory-border);
    padding-top: 10px;
}
.memory-best { display: grid; gap: 2px; }
.memory-best strong { color: var(--memory-text); font-size: .9rem; }
.memory-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    font-size: .88rem;
}
.memory-action span { color: var(--memory-gold); font-size: 1.08rem; }

.memory-dialog {
    width: min(410px, calc(100% - 24px));
    max-height: calc(100svh - 28px);
    text-align: center;
    padding: 26px;
    border: 1px solid #bb8c70;
    border-radius: 17px;
    box-shadow: 0 20px 65px #100919bb;
    background: #291c39;
    color: var(--memory-text);
}
.memory-dialog::backdrop { background: #100a18cf; }
.memory-result-mark { font-size: 2.3rem; line-height: 1; color: var(--memory-gold); }
.memory-dialog h2 { margin: 12px 0 8px; font-size: clamp(1.4rem, 6vw, 2rem); line-height: 1.17; }
.memory-dialog p { color: var(--memory-muted); margin: 7px 0; }
.memory-dialog .memory-record-note { color: var(--memory-green); }
.memory-dialog .memory-world-unlocked { color: var(--memory-gold); font-weight: 700; }
.memory-page .memory-stars, .memory-stage-stars { color: var(--memory-gold); direction: ltr; }
.memory-dialog .memory-stars { font: 750 1.75rem/1.15 system-ui, sans-serif; letter-spacing: 2px; }
.memory-dialog:has(#memory-result-stars:not([hidden])) .memory-result-mark { display: none; }
.memory-result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.memory-primary { background: var(--memory-gold); color: #281928; border-color: var(--memory-gold); }
.memory-stage-dialog { width: min(430px, calc(100% - 24px)); }
.memory-world-select {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    color: var(--memory-muted);
    text-align: start;
    font-size: .85rem;
}
.memory-world-select select {
    min-height: 44px;
    min-width: 0;
    flex: 1;
    padding-inline: 9px;
    border: 1px solid var(--memory-border);
    border-radius: 9px;
    background: var(--memory-panel);
    color: var(--memory-text);
    font: inherit;
}
.memory-world-select select:focus-visible { outline: 2px solid var(--memory-gold); outline-offset: 2px; }
.memory-stage-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin-top: 15px;
}
.memory-stage {
    display: grid;
    place-content: center;
    font-variant-numeric: tabular-nums;
}
.memory-stage:disabled { opacity: .52; }
.memory-stage[aria-current="step"] { background: var(--memory-accent); border-color: var(--memory-gold); }
.memory-stage-stars { font-size: .68rem; line-height: 1.1; white-space: nowrap; }
.memory-stage-stars:empty { display: none; }
.memory-stage-pages {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    margin-top: 11px;
}
.memory-stage-pages span { color: var(--memory-muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.memory-stage-pages button:disabled { opacity: .52; }
.memory-challenge-target {
    display: grid;
    justify-items: start;
    gap: 4px;
    margin-bottom: 12px;
    padding: 9px 12px;
    border: 1px solid var(--memory-border);
    border-radius: 10px;
    background: var(--memory-panel);
    color: var(--memory-muted);
    font-size: .88rem;
}
.memory-challenge-target strong { color: var(--memory-gold); }
.memory-challenge-target a { min-height: 38px; display: flex; align-items: center; text-decoration: underline; }
.memory-share { margin-top: 9px; }
.memory-link-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    text-align: start;
}
.memory-link-box label { grid-column: 1 / -1; font-size: .82rem; }
.memory-link-box input {
    min-width: 0;
    height: 44px;
    padding: 6px;
    border: 1px solid var(--memory-border);
    border-radius: 8px;
    background: var(--memory-bg);
    color: var(--memory-text);
}
#memory-share-status:empty { display: none; }
.memory-album { width: min(540px, calc(100% - 24px)); }
.memory-dialog .memory-album-progress { margin: 10px 0 6px; font-size: .83rem; text-align: start; }
.memory-album-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.memory-album-card {
    display: grid;
    align-content: start;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--memory-border);
    border-radius: 8px;
    background: var(--memory-panel);
}
.memory-album-card :is(img, span) { width: 100%; height: auto; aspect-ratio: 1; }
.memory-album-card span { display: grid; place-items: center; background: var(--memory-bg); color: var(--memory-border); }
.memory-album-card figcaption { padding: 4px 2px; overflow-wrap: anywhere; font-size: .68rem; line-height: 1.35; }

@media (hover: hover) {
    .memory-card[data-state="closed"]:hover .memory-card-back { filter: brightness(1.2); }
    .memory-stage:not(:disabled):hover, .memory-daily:hover,
    .memory-nav :is(a, button):hover, .memory-action:hover { filter: brightness(1.16); }
}

@media (max-width: 720px) {
    .memory-nav, .memory-layout { width: min(520px, calc(100% - 20px)); }
    .memory-nav { min-height: 51px; }
    .memory-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        grid-template-areas: "intro" "settings" "board" "help";
        gap: 9px;
        margin-block: 11px 12px;
    }
    .memory-intro h1, [dir="rtl"] .memory-intro h1 {
        max-width: none;
        font-size: clamp(1.48rem, 6vw, 2.5rem);
        letter-spacing: -.02em;
        line-height: 1.2;
    }
    .memory-intro p { margin: 5px 0 0; font-size: .82rem; line-height: 1.4; }
    .memory-cover { display: none; }
    .memory-world-panel { padding: 5px 0 0; border: 0; background: none; box-shadow: none; }
    .memory-world-panel h2 { font-size: .86rem; }
    .memory-world-preview { display: none; }
    .memory-settings { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1.03fr) minmax(0, .9fr); gap: 5px; }
    .memory-settings :is(.memory-stage-picker, .memory-daily, .memory-shadow-picker) { padding-inline: 5px; font-size: .76rem; }
    .memory-settings .memory-shadow-picker { justify-content: center; }
    .memory-daily { justify-content: center; gap: 4px; }
    .memory-daily-mark { font-size: .75rem; }
    .memory-daily small { display: none; }
    #memory-hearts-slot { grid-column: 1 / -1; }
    .memory-workbench { padding: 8px; border-radius: 12px; }
    .memory-stats { margin-bottom: 8px; }
    .memory-stats > div { padding: 6px 4px; }
    .memory-board { gap: 6px; width: min(100%, 380px); }
    .memory-board[data-columns="6"] { gap: 4px; width: min(100%, 405px); }
    .memory-card { border-radius: 7px; }
    .memory-card-back { font-size: clamp(.9rem, 4.7vw, 1.8rem); }
    .memory-board[data-columns="6"] .memory-card { aspect-ratio: 1; }
    .memory-message { min-height: 28px; margin-block: 5px 2px; font-size: .79rem; }
    .memory-foot { padding-top: 5px; }
    .memory-help { padding-inline: 3px; }
}

@media (min-width: 721px) and (max-height: 610px) {
    .memory-layout { margin-top: 13px; gap: 11px 20px; }
    .memory-nav { min-height: 48px; }
    .memory-intro h1, [dir="rtl"] .memory-intro h1 { font-size: clamp(1.65rem, 4vw, 2.6rem); }
    .memory-intro p { margin-block: 6px 8px; }
    .memory-cover { display: none; }
    .memory-world-panel { padding: 7px 0 0; border: 0; background: none; box-shadow: none; }
    .memory-world-preview { display: none; }
    .memory-workbench { padding: 9px; }
    .memory-board { width: min(100%, 340px, max(212px, calc((100svh - 175px) * 1.12))); }
    .memory-board[data-columns="2"] { width: min(100%, 180px); }
    .memory-board[data-columns="3"] { width: min(100%, 245px); }
    .memory-board[data-columns="6"] { width: min(100%, 460px, max(326px, calc((100svh - 175px) * 1.62))); }
    .memory-card { min-block-size: 44px; }
    .memory-stats { margin-bottom: 7px; }
    .memory-stats > div { padding: 4px; }
    .memory-message { min-height: 27px; margin-block: 3px; }
    .memory-foot { padding-top: 5px; }
}

@media (min-width: 721px) and (max-height: 510px) {
    .memory-stage-dialog { width: min(690px, calc(100% - 24px)); padding: 16px; }
    .memory-stage-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
    .memory-album { width: min(750px, calc(100% - 24px)); padding: 16px; }
    .memory-album-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

@media (max-width: 360px) {
    .memory-nav, .memory-layout { width: calc(100% - 16px); }
}

@media (prefers-reduced-motion: reduce) {
    .memory-card-surface { transition: none; }
}

html:has(body.memory-page) { overflow: hidden; overscroll-behavior: none; }
html body.memory-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}
.memory-top { flex: none; }
.memory-nav .memory-compact-account { display: none; }
.memory-layout {
    flex: 1;
    min-height: 0;
    margin-block: clamp(4px, 1.7dvh, 18px);
}
.memory-intro p { margin-block: 8px 12px; }
.memory-cover { max-height: 23dvh; }
.memory-world-preview img { max-height: 18dvh; object-fit: cover; }
.memory-workbench {
    align-self: stretch;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.memory-workbench > :not(.memory-board-space) { flex: none; }
.memory-board-space { flex: 1; min-height: 0; display: grid; place-items: center; }
.memory-workbench .memory-board { width: min(100%, var(--board-fit-width, 100%)); }
.memory-workbench .memory-card { block-size: var(--board-fit-height, 44px); min-block-size: 0; aspect-ratio: auto; }
.memory-dialog { max-height: calc(100dvh - 12px); overflow: hidden; }
.memory-help { gap: 3px 10px; }

@media (max-width: 720px) {
    .memory-layout { grid-template-rows: auto auto minmax(0, 1fr) auto; }
    .memory-intro p { display: none; }
    .memory-help :is(a, button) { min-height: 35px; padding-inline: 4px; font-size: .72rem; }
    .memory-challenge-target { display: flex; flex-wrap: wrap; gap: 0 8px; align-items: center; font-size: .73rem; margin-bottom: 5px; }
    .memory-challenge-target a { min-height: 32px; }
}

@media (max-height: 755px) {
    .memory-album { padding: 12px; }
    .memory-album h2 { margin-top: 2px; }
    .memory-album > p:not(.memory-album-progress) { display: none; }
    .memory-album .memory-album-card :is(img, span) { max-height: 14dvh; object-fit: cover; }
}

@media (orientation: landscape) and (max-height: 500px) {
    html body.memory-page { padding-block-start: env(safe-area-inset-top, 0px); }
    .memory-page #game-guest-bar { display: none; }
    .memory-nav .memory-compact-account { display: inline-flex; }
    .memory-nav { width: calc(100% - 20px); min-height: 42px; }
    .memory-nav :is(a, button) { min-height: 36px; padding-block: 3px; }
    .memory-layout {
        width: calc(100% - 20px);
        grid-template-columns: minmax(156px, .64fr) minmax(0, 1.36fr);
        grid-template-rows: auto auto minmax(0, 1fr);
        grid-template-areas: "intro board" "settings board" "help board";
        gap: 5px 10px;
    }
    .memory-settings { grid-template-columns: 1fr; gap: 4px; }
    .memory-settings :is(button, #game-hearts-hud) { min-height: 34px; }
    .memory-intro h1, [dir="rtl"] .memory-intro h1 { font-size: clamp(1.15rem, 3.3vw, 2rem); }
    .memory-intro p, .memory-cover, .memory-world-preview { display: none; }
    .memory-world-panel { padding-block: 3px; }
    .memory-world-panel h2 { font-size: .8rem; }
    .memory-help { align-self: start; gap: 1px 5px; }
    .memory-help :is(a, button) { min-height: 32px; font-size: .73rem; }
    .memory-workbench { padding: 6px 9px; }
    .memory-message { min-height: 23px; margin-block: 3px; }
    .memory-foot .memory-action { min-height: 36px; }
    .memory-dialog { padding: 10px 14px; }
    .memory-dialog h2 { font-size: 1.22rem; margin: 2px 0 4px; }
    .memory-dialog p { margin-block: 4px; }
    .memory-result-actions { margin-top: 7px; }
    .memory-stage-dialog > p { display: none; }
    .memory-world-select, .memory-stage-grid, .memory-stage-pages { margin-top: 5px; }
    .memory-dialog :is(.memory-action, .memory-stage, select, .memory-link-box input) { min-height: 36px; }
    .memory-dialog .memory-action, .memory-link-box input { height: auto; }
    .memory-share, .memory-link-box { margin-top: 5px; }
}
