.memory-page{background:#f5f6f2;--memory-green:#6ca987;--memory-text:#193e42;--memory-line:#e6e2d8;--memory-surface:#fffefa;color:var(--ink)}
.memory-page.dark{background:#181d20;--memory-green:#487b67;--memory-text:#f2f5f4;--memory-line:#343c3e;--memory-surface:#202729}
.memory-page .header-inner,.memory-layout{max-width:1800px;width:100%;margin:auto}
.memory-page .header-inner{padding:0 28px}
.memory-layout{display:grid;grid-template-columns:290px minmax(0,1fr);gap:22px;padding:20px 28px;min-width:0;flex:1;overflow:visible}
.memory-sidebar{display:flex;flex-direction:column;gap:14px;min-width:0;grid-column:auto;order:0}
.memory-intro{padding:0 8px}.memory-intro .eyebrow{font-size:10px;letter-spacing:2px;margin:0 0 4px}.memory-intro h1{font-size:29px;line-height:1.1;margin:0;color:var(--memory-text)}
.memory-panel{background:var(--memory-surface);border:1px solid var(--memory-line);border-radius:22px;padding:18px;box-shadow:0 8px 25px #3f433a0a;color:var(--memory-text)}
.memory-panel h2{font-size:19px;line-height:1.2;margin:0 0 13px;letter-spacing:-.4px}
.memory-options{display:flex;gap:7px}.memory-options button{flex:1;min-width:0;border:1px solid var(--memory-line);border-radius:12px;background:var(--surface);color:var(--memory-text);padding:12px 3px;font-size:13px;font-weight:600;white-space:nowrap}.memory-options button.selected{color:white;background:var(--memory-green);border-color:#629b7f;box-shadow:0 4px 10px #395d3c10}
.memory-page #memory-new{height:46px;margin-top:16px;font-size:17px;border-radius:13px;background:var(--memory-green);color:white;gap:8px}.memory-page #memory-new svg{width:20px;height:20px;fill:currentColor}
.memory-stats{display:flex;margin-top:12px}.memory-stats>div{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;gap:7px;border-right:1px solid var(--memory-line)}.memory-stats>div:last-child{border:0}.memory-stats span{font-size:29px;line-height:1;color:#40ab87}.memory-stats .clock{color:#ed9b26}.memory-stats strong{font-size:23px;font-variant-numeric:tabular-nums}.memory-stats small{font-size:11px;color:var(--muted)}
.memory-players{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:15px}.memory-player{display:flex;flex-direction:column;gap:6px;border:1px solid var(--memory-line);border-radius:11px;padding:10px;font-size:12px}.memory-player.active{border-color:#70ab8d;background:#6ca98722}.memory-player strong{font-size:13px}
#memory-result h2{font-size:17px;margin:0}#memory-result p:empty{display:none}#memory-result p{font-size:13px;margin:9px 0 0}
.memory-surface{min-width:0;min-height:0;position:relative;display:grid;place-items:center;background:var(--memory-surface);border:1px solid var(--memory-line);border-radius:26px;padding:20px;box-shadow:0 8px 25px #3f433a08}
#memory-board{--columns:4;--rows:4;--gap:12px;--board-width:600px;display:grid;grid-template-columns:repeat(var(--columns),minmax(0,1fr));gap:var(--gap);width:min(100%,var(--board-width));margin:auto}
.memory-card{position:relative;width:100%;aspect-ratio:1;border:0;padding:0;background:transparent;border-radius:10px;perspective:800px;transition:opacity .2s;touch-action:manipulation}
.memory-card .card-inner{position:absolute;inset:0;transform-style:preserve-3d;transition:transform .23s ease-in-out;border-radius:inherit;box-shadow:0 5px 12px #122c252b}
.memory-card .card-face{position:absolute;inset:0;display:block;width:100%;height:100%;object-fit:cover;backface-visibility:hidden;border:2px solid #ffffffe0;border-radius:inherit;pointer-events:none}
.memory-card .front{transform:rotateY(180deg)}.memory-card.revealed .card-inner{transform:rotateY(180deg)}.memory-card.matched .front{border:3px solid #69dfb7;box-shadow:0 0 12px #64d6a933}.memory-card.gone{opacity:0;pointer-events:none}.memory-card:disabled{opacity:1}.memory-card.gone:disabled{opacity:0}
.memory-page #portrait{width:min(680px,calc(100vw - 28px));max-width:680px;max-height:calc(100dvh - 32px);overflow:auto;border:1px solid var(--memory-line);border-radius:25px;padding:25px;background:var(--memory-surface);color:var(--memory-text)}
.portrait-heading{display:flex;align-items:center;justify-content:space-between;gap:15px;margin-bottom:20px}.portrait-heading span,.portrait-contribution>span{font-size:11px;letter-spacing:2px;font-weight:700;color:#479b7c}.portrait-heading button{border:0;background:transparent;color:inherit;padding:6px;font-weight:600}.portrait-top{display:grid;grid-template-columns:210px 1fr;gap:22px;align-items:start}.portrait-top img{width:100%;max-height:240px;object-fit:contain;border-radius:16px}.portrait-top h2{font-size:28px;line-height:1.15;margin:4px 0 12px}.portrait-top p{color:var(--muted);font-size:16px;margin:10px 0}.portrait-top strong{font-size:15px}#portrait h3{font-size:19px;margin:20px 0 8px}#portrait-biography{font-size:15px;line-height:1.6;margin:0 0 15px}.portrait-contribution{background:#6ca9871f;padding:16px;border-radius:14px}.portrait-contribution p{font-size:15px;font-weight:600;line-height:1.5;margin:8px 0 0}.memory-page dialog::backdrop{background:#10272490;backdrop-filter:blur(3px)}.memory-page #dialog{max-height:85dvh;overflow:auto}.memory-page #dialog-body p{line-height:1.55}
@media(min-width:1000px){.memory-page{height:100dvh;min-height:760px;display:grid;grid-template-rows:66px minmax(0,1fr) auto}.memory-page header{height:66px}.memory-layout{height:100%;min-height:0}.memory-page footer{padding-top:9px;padding-bottom:9px}.memory-surface{height:100%}}
@media(min-width:1000px) and (max-height:850px){.memory-page{min-height:690px}.memory-sidebar{gap:9px}.memory-panel{padding:12px 15px;border-radius:18px}.memory-panel h2{font-size:17px;margin-bottom:9px}.memory-options button{padding:9px 2px}.memory-page #memory-new{height:39px;margin-top:10px}.memory-stats{margin-top:7px}.memory-stats span{font-size:23px}.memory-stats strong{font-size:20px}.memory-stats>div{gap:4px}.memory-players{margin-bottom:9px}.memory-player{padding:7px;gap:4px}.memory-intro h1{font-size:25px}}
@media(max-width:999px){.memory-layout{display:flex;flex-direction:column;padding:16px;gap:15px}.memory-sidebar{display:grid;grid-template-columns:1fr 1fr;gap:10px}.memory-intro{grid-column:1/-1}.memory-level,.memory-statistics{align-self:stretch}.memory-surface{padding:16px}#memory-result{grid-column:1/-1}.memory-page .header-inner{padding:0 18px}}
@media(max-width:520px){.memory-layout{padding:10px;gap:10px}.memory-panel{padding:12px;border-radius:16px}.memory-panel h2{font-size:16px;margin-bottom:10px}.memory-options{gap:4px}.memory-options button{font-size:11px;padding:11px 2px;border-radius:9px}.memory-level{grid-column:1/-1;display:grid;grid-template-columns:1fr 1fr;gap:8px 12px}.memory-level h2{grid-column:1;margin:0}.memory-level .memory-options{grid-column:1}.memory-page #memory-new{grid-column:2;grid-row:1/3;margin:0;align-self:center;height:44px;font-size:15px}.memory-statistics{grid-column:1/-1}.memory-statistics h2{margin-bottom:5px}.memory-players{margin:8px 0}.memory-player{padding:8px;flex-direction:row;flex-wrap:wrap;gap:5px 10px}.memory-player strong{flex-basis:100%}.memory-stats span{display:none}.memory-stats strong{font-size:20px}.memory-stats>div{gap:3px}.memory-surface{padding:10px;border-radius:18px}.memory-card{border-radius:7px}.memory-card .card-face{border-width:1.5px}.portrait-top{grid-template-columns:110px 1fr;gap:14px}.portrait-top h2{font-size:22px}.portrait-top p{font-size:14px}.memory-page #portrait{padding:18px}}
@media(prefers-reduced-motion:reduce){.memory-card,.memory-card .card-inner{transition:none}}

.memory-dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:22px}.memory-dialog-actions button{border:1px solid var(--line);border-radius:10px;padding:12px 18px;background:var(--tile);color:var(--ink)}.memory-dialog-actions #accept{background:#4a7d66;color:#fff;border-color:#4a7d66}

/* Additional elements have no desktop layout boxes. */
.memory-mobile-bar{display:none}.memory-level-row{display:contents}
#memory-settings-dialog{background:var(--memory-surface);color:var(--memory-text);border-color:var(--memory-line);max-height:85dvh;overflow:auto}
.mobile-settings-heading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:18px}.mobile-settings-heading h2{margin:0;font-size:22px}.mobile-settings-heading button{border:0;background:none;color:inherit;font-size:28px;padding:4px 8px}.mobile-settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 0;border-top:1px solid var(--memory-line);font-size:15px}.mobile-settings-row button,.mobile-settings-links button,.mobile-settings-links a{border:1px solid var(--memory-line);background:var(--memory-surface);color:inherit;border-radius:10px;padding:10px 16px;font-weight:600}.mobile-settings-row button.selected,#memory-mobile-sound[aria-pressed=true]{background:var(--memory-green);color:white}.mobile-theme-options{display:flex;gap:6px}.mobile-settings-links{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:12px}.mobile-settings-links a{text-align:center;text-decoration:none;font-size:13px}
@media(max-width:600px){
 .memory-page{--memory-green:#4a7d66;--memory-text:#193e42;--memory-line:#d7dfd9;--memory-surface:#f4f6f1;background:#edf1ec;min-width:0;min-height:100svh;color:var(--memory-text);-webkit-text-size-adjust:100%}
 .memory-page.dark{--memory-text:#f3f4f3;--memory-line:#303637;--memory-surface:#1d2224;background:#141819;--muted:#a3a9a8}
 .memory-page>header{display:none}
 .memory-page .memory-mobile-bar{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;flex:none;min-height:64px;padding:8px max(12px,env(safe-area-inset-right)) 8px max(12px,env(safe-area-inset-left));border-bottom:1px solid var(--memory-line);background:var(--memory-surface);color:var(--memory-text)}
 .dark .memory-mobile-bar{background:#191e20}
 .memory-mobile-bar h1{font-size:20px;line-height:1.2;font-weight:700;letter-spacing:0;margin:0}
 .memory-back{display:inline-flex;align-items:center;gap:5px;width:max-content;min-height:44px;color:inherit;text-decoration:none;font-size:17px}.memory-back svg{width:17px;height:24px;fill:none;stroke:currentColor;stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round}
 #memory-settings{justify-self:end;display:grid;place-items:center;width:44px;height:44px;border:0;padding:8px;background:none;color:inherit}#memory-settings svg{width:28px;height:28px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
 .memory-page .memory-layout{display:flex;flex-direction:column;gap:8px;padding:12px max(11px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(11px,env(safe-area-inset-left));min-width:0;width:100%;margin:0;flex:1}
 .memory-sidebar,.memory-page .memory-level{display:contents}
 .memory-sidebar>.memory-panel:nth-child(1){order:1}.memory-sidebar>.memory-panel:nth-child(2){order:2}
 .memory-sidebar>.memory-panel:nth-child(-n+2),.memory-level-row{display:grid;grid-template-columns:76px minmax(0,1fr);align-items:center;gap:2px;min-width:0;padding:4px 8px 4px 9px;min-height:48px;background:var(--memory-surface);border:1px solid var(--memory-line);border-radius:16px;box-shadow:none}
 .memory-level-row{order:3}
 .memory-desktop-label{display:none}
 .memory-page .memory-panel h2,.memory-level-row h2{font-size:13px;line-height:1.3;letter-spacing:0;margin:0;font-weight:600;white-space:nowrap}
 .memory-page .memory-options{display:flex;gap:5px;min-width:0;grid-column:auto;grid-row:auto}
 .memory-page .memory-options button{min-width:0;min-height:38px;padding:6px 2px;border-radius:11px;border:1px solid var(--memory-line);background:transparent;font-size:13px;line-height:1.2;font-weight:600;white-space:nowrap;color:var(--memory-text)}
 .memory-page .memory-options button.selected{background:var(--memory-green);border-color:#729f89;color:#fff;box-shadow:inset 0 0 0 1px #ffffff10}
 .memory-page #memory-new{display:flex;align-items:center;justify-content:center;flex:none;order:4;grid-column:auto;grid-row:auto;align-self:stretch;width:100%;height:48px;min-height:48px;margin:0;border:1px solid #729f89;border-radius:18px;background:var(--memory-green);color:#fff;font-size:17px;font-weight:700;gap:8px;padding:0 12px;box-shadow:0 7px 18px #00000016}
 .memory-page #memory-new svg{width:18px;height:18px}
 .memory-page .memory-surface{order:5;display:block;flex:none;min-width:0;width:100%;padding:8px;margin:clamp(16px,4svh,42px) 0 clamp(16px,4svh,42px);border:1px solid var(--memory-line);border-radius:28px;background:var(--memory-surface);box-shadow:none;height:auto}
 .memory-page #memory-board{width:100%;--columns:4;gap:8px;grid-template-columns:repeat(4,minmax(0,1fr));margin:0;min-width:0}
 .memory-page .memory-card{border-radius:11px;min-width:0;aspect-ratio:1}
 .memory-page .memory-card .card-inner{-webkit-transform-style:preserve-3d;transform-style:preserve-3d;box-shadow:none}
 .memory-page .memory-card .card-face{-webkit-backface-visibility:hidden;backface-visibility:hidden;border:1px solid #e1e6d8;border-radius:inherit}
 .memory-page .memory-card.matched .front{border:2px solid #69dfb7}
 .memory-page .memory-statistics{order:6;display:flex;flex-direction:column;grid-column:auto;flex:none;padding:6px 8px;background:var(--memory-surface);border:1px solid var(--memory-line);border-radius:17px;box-shadow:none;min-width:0}
 .memory-statistics>h2{display:none}
 .memory-page .memory-stats{margin:0;min-height:42px;display:flex}
 .memory-page .memory-stats>div{display:grid;grid-template-columns:auto auto;grid-template-rows:auto auto;align-content:center;justify-content:center;align-items:center;gap:3px 6px;padding:2px 4px;border-right:1px solid var(--memory-line)}
 .memory-page .memory-stats>div:last-child{border:0}
 .memory-page .memory-stats span{display:block;grid-column:1;grid-row:1;font-size:22px;line-height:1;color:#40ab87}
 .memory-page .memory-stats .clock{color:#ed9b26}
 .memory-page .memory-stats strong{grid-column:2;grid-row:1;font-size:20px;line-height:1.15;white-space:nowrap;letter-spacing:0}
 .memory-page .memory-stats small{grid-column:1/-1;grid-row:2;font-size:11px;line-height:1.3;white-space:nowrap;color:var(--muted)}
 .memory-page .memory-players{margin:0 0 8px;gap:6px}.memory-page .memory-player{padding:8px;font-size:11px}.memory-page .memory-player strong{font-size:12px}
 .memory-page #memory-result{order:7;padding:14px;border-radius:17px;grid-column:auto}
 .memory-page #memory-loading{font-size:14px;text-align:center;margin:12px 0}
 .memory-page #memory-settings-dialog{width:calc(100% - 28px);max-width:420px;padding:20px;border-radius:22px}
 .memory-page #portrait{max-height:calc(100dvh - 28px);max-width:calc(100vw - 28px)}
 .memory-page .portrait-top{grid-template-columns:minmax(80px,100px) minmax(0,1fr)}
 .memory-page .portrait-top h2{white-space:normal;overflow-wrap:anywhere}
 .memory-page .memory-dialog-actions button{padding:11px 13px;font-size:14px;min-height:44px}
}
@media(max-width:360px){.memory-page .memory-options button{font-size:11px}.memory-sidebar>.memory-panel:nth-child(-n+2),.memory-level-row{grid-template-columns:64px minmax(0,1fr)}.memory-page .memory-stats strong{font-size:18px}.memory-page .memory-stats span{font-size:19px}}

/* Keep every phone level and the statistics inside Safari's visible viewport. */
@media(max-width:600px){
 .memory-page{height:var(--memory-viewport-height,100dvh);min-height:0}
 .memory-page .memory-layout{flex:1;min-height:0}
 .memory-page .memory-surface{flex:1;min-height:0;height:auto;display:grid;place-items:center;margin-top:clamp(8px,2dvh,24px);margin-bottom:clamp(8px,2dvh,24px)}
 .memory-page #memory-board{grid-template-columns:repeat(var(--columns),minmax(0,1fr));gap:var(--gap);width:min(100%,var(--board-width));margin:auto}
 .memory-page .memory-card{border-radius:clamp(5px,2vw,11px)}
 .memory-page .memory-statistics{flex-shrink:0}
}
@media(max-width:600px) and (max-height:700px){
 .memory-page .memory-mobile-bar{min-height:52px;padding-top:4px;padding-bottom:4px}
 .memory-page .memory-layout{gap:6px;padding-top:8px;padding-bottom:max(12px,env(safe-area-inset-bottom))}
 .memory-sidebar>.memory-panel:nth-child(-n+2),.memory-level-row{min-height:40px;padding-top:3px;padding-bottom:3px}
 .memory-page .memory-options button{min-height:32px}
 .memory-page #memory-new{height:40px;min-height:40px}
 .memory-page .memory-surface{margin-top:8px;margin-bottom:8px;padding:6px;border-radius:22px}
 .memory-page .memory-statistics{padding:4px 8px}.memory-page .memory-stats{min-height:38px}
 .memory-page .memory-players{margin-bottom:4px}.memory-page .memory-player{padding:4px 6px;gap:3px 8px}
}
