:root{color-scheme:dark;--gold:#f3c85b;--purple:#9b4bf4;--panel:#10071b;--muted:#b8a9c4}*{box-sizing:border-box}html,body{margin:0;min-width:320px;min-height:100%;background:#07030d;color:#fff;font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}body{min-height:100vh;background:radial-gradient(circle at 72% 8%,rgba(132,43,217,.28),transparent 35%),radial-gradient(circle at 12% 88%,rgba(239,185,63,.09),transparent 29%),#07030d;overflow-x:hidden}.memory-shell{width:min(1180px,100%);min-height:100vh;margin:auto;padding:12px 18px 22px}.memory-topbar{display:grid;grid-template-columns:48px minmax(220px,1fr) auto 48px;align-items:center;gap:12px}.memory-title{width:min(500px,60vw);max-height:104px;object-fit:contain;object-position:left center;filter:drop-shadow(0 10px 24px rgba(126,31,210,.35))}.icon-button{width:44px;height:44px;border:1px solid rgba(223,179,79,.3);border-radius:12px;color:#f6dc91;background:rgba(20,9,33,.9);font-weight:1000;font-size:20px}.icon-button:disabled{opacity:.35}.run-meta{display:grid;justify-items:end}.run-meta b{color:#ead9f4}.run-meta span{color:#9b89a8;font-size:11px}.memory-hud{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;margin:5px 0 12px}.memory-hud>div{min-height:82px;display:grid;align-content:end;justify-items:center;padding:8px 10px 11px;background-position:center;background-repeat:no-repeat;background-size:100% 100%}.memory-hud span{color:#9c8aa8;font-size:8px;font-weight:1000;letter-spacing:.12em;text-transform:uppercase}.memory-hud b{color:#ffe49a;font-family:"Courier New",monospace;font-size:clamp(17px,2.2vw,25px);text-shadow:0 0 14px rgba(247,193,61,.32)}.board-wrap{position:relative;min-height:540px;display:grid;place-items:center;padding:14px;border:1px solid rgba(198,139,246,.18);border-radius:24px;background:linear-gradient(145deg,rgba(22,10,37,.94),rgba(7,3,13,.98));box-shadow:0 28px 85px rgba(0,0,0,.48),inset 0 0 50px rgba(106,35,184,.08);overflow:hidden}.board-wrap:before{content:"";position:absolute;inset:0;opacity:.18;background-image:linear-gradient(rgba(152,78,229,.2) 1px,transparent 1px),linear-gradient(90deg,rgba(152,78,229,.2) 1px,transparent 1px);background-size:62px 62px;mask-image:linear-gradient(to bottom,transparent,#000 24%,#000 80%,transparent)}.memory-board{position:relative;z-index:2;width:min(100%,860px);display:grid;grid-template-columns:repeat(var(--columns),minmax(0,1fr));gap:10px}.memory-board.hard{width:min(100%,1050px);gap:8px}.memory-card{position:relative;aspect-ratio:3/4;border:0;background:transparent;padding:0;perspective:900px;cursor:pointer}.card-inner{position:absolute;inset:0;transform-style:preserve-3d;transition:transform .42s cubic-bezier(.2,.72,.2,1)}.memory-card.is-open .card-inner{transform:rotateY(180deg)}.card-back,.card-front{position:absolute;inset:0;display:grid;place-items:center;border-radius:12px;overflow:hidden;backface-visibility:hidden;box-shadow:0 12px 24px rgba(0,0,0,.42)}.card-back{border:1px solid rgba(247,197,72,.7);background:#160925}.card-back img{width:100%;height:100%;object-fit:cover}.card-front{transform:rotateY(180deg);background:#f7f3ec;border:1px solid rgba(255,255,255,.9)}.card-front img{width:100%;height:100%;object-fit:contain}.memory-card.is-matched{animation:matchedPulse .55s ease}.memory-card.is-matched .card-front{box-shadow:0 0 0 2px rgba(244,198,72,.88),0 0 28px rgba(244,198,72,.55)}.memory-card:focus-visible{outline:3px solid #c777ff;outline-offset:3px}.ready-overlay,.pause-overlay{position:absolute;z-index:8;inset:0;display:grid;place-content:center;justify-items:center;text-align:center;padding:25px;background:rgba(6,2,11,.78);backdrop-filter:blur(10px)}.ready-overlay img{width:min(220px,42vw);max-height:190px;object-fit:contain}.ready-overlay h1,.pause-overlay h2{margin:5px 0 8px;font-family:Georgia,"Times New Roman",serif;font-size:clamp(34px,5vw,58px)}.ready-overlay p{margin:0 0 18px;color:var(--muted)}.pause-overlay img{position:absolute;width:250px;opacity:.34}.pause-overlay h2,.pause-overlay button{position:relative}.primary,.secondary,.text-button{border-radius:12px;font-weight:900}.primary{padding:12px 22px;border:1px solid rgba(255,255,255,.2);color:#fff;background:linear-gradient(135deg,#9c58f5,#5c24ad);box-shadow:0 12px 28px rgba(91,34,173,.34)}.secondary{padding:12px 22px;border:1px solid rgba(238,190,70,.3);color:#f6e5b0;background:rgba(30,13,48,.95)}.text-button{padding:8px 0;border:0;color:#d3b4f1;background:transparent}.memory-footer{display:flex;align-items:center;gap:18px;padding:12px 4px;color:#8f7d9b;font-size:11px}.memory-footer span:nth-child(2){margin-left:auto}.result-overlay{position:fixed;z-index:50;inset:0;display:grid;place-items:center;padding:18px;background:rgba(4,2,8,.86);backdrop-filter:blur(12px)}.result-card{position:relative;width:min(570px,100%);padding:38px 34px 28px;text-align:center;border:1px solid rgba(239,190,72,.38);border-radius:25px;background:linear-gradient(145deg,#211037,#0b0513);box-shadow:0 35px 100px #000}.result-plaque{width:min(100%,450px);height:90px;object-fit:contain;margin:0 auto}.result-emblem{width:120px;height:120px;object-fit:contain;margin:0 auto 4px;filter:drop-shadow(0 12px 25px rgba(0,0,0,.45))}.result-kicker{color:#dfbdff;font-size:10px;font-weight:1000;letter-spacing:.17em}.result-card h2{margin:7px 0 4px;font-family:Georgia,"Times New Roman",serif;font-size:36px}.result-card p{color:#c7b8cf}.result-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:20px 0}.result-stats div{padding:12px;border:1px solid rgba(255,255,255,.07);border-radius:12px;background:rgba(255,255,255,.025)}.result-stats small{display:block;color:#8f7d9a;font-size:8px}.result-stats b{display:block;margin-top:4px;color:#ffe095}.result-actions{display:flex;justify-content:center;gap:9px}.authority-note{display:block;margin-top:14px;color:#796a82}.embedded .memory-shell{min-height:100dvh}@keyframes matchedPulse{50%{transform:scale(1.06);filter:brightness(1.25)}}@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}@media(max-width:760px){.memory-shell{padding:8px}.memory-topbar{grid-template-columns:42px 1fr 42px}.run-meta{display:none}.memory-title{width:min(420px,68vw)}.memory-hud{grid-template-columns:repeat(4,1fr);gap:4px}.memory-hud .best-visor{display:none}.memory-hud>div{min-height:64px;padding-bottom:8px}.board-wrap{min-height:calc(100dvh - 190px);padding:8px;border-radius:16px}.memory-board{gap:6px}.memory-board.hard{gap:4px}.card-back,.card-front{border-radius:8px}.memory-footer{padding:8px;font-size:9px}.result-card{padding:25px 16px}.result-actions{flex-direction:column}}@media(max-width:420px){.memory-hud span{display:none}.memory-hud b{font-size:16px}.memory-topbar{gap:6px}.icon-button{width:38px;height:38px}.memory-board{gap:4px}.board-wrap{min-height:calc(100dvh - 165px)}}
/* v0.6.0 weekly campaign */
.memory-board.campaign-large{width:min(100%,1040px);gap:6px}.weekly-authority{margin:12px 0;padding:12px;border:1px solid rgba(184,126,242,.22);border-radius:12px;background:rgba(255,255,255,.03)}.weekly-authority strong{display:block;color:#dec0fa;font-size:10px;letter-spacing:.1em}.weekly-authority p{margin:5px 0;color:#a99ab4;font-size:10px}.weekly-authority span{display:block;color:#f3d780;font-size:11px;font-weight:900}.weekly-authority.accepted{border-color:rgba(84,213,144,.35)}.weekly-authority.accepted strong{color:#7fe0aa}.weekly-authority.rejected{border-color:rgba(255,111,111,.36)}.weekly-authority.rejected strong{color:#ff9999}.result-actions button:disabled{opacity:.45;cursor:not-allowed}@media(max-width:760px){.memory-board.campaign-large{gap:3px}.memory-board.campaign-large .card-back,.memory-board.campaign-large .card-front{border-radius:5px}}@media(max-width:420px){.memory-board.campaign-large{gap:2px}}

/* v0.6.1 — result/overlay escape-path fix.
   The victory card used to extend below compact portrait viewports while its
   fixed backdrop could not scroll, trapping the player on the result screen. */
.ready-overlay,
.pause-overlay,
.result-overlay{
  overflow-y:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}

/* v0.6.5 — one tap card activation */
.memory-card{touch-action:manipulation;-webkit-tap-highlight-color:transparent;user-select:none}
.ready-overlay,
.pause-overlay{place-content:safe center}
.result-overlay{
  align-items:start;
  padding:
    max(12px,env(safe-area-inset-top))
    max(12px,env(safe-area-inset-right))
    max(12px,env(safe-area-inset-bottom))
    max(12px,env(safe-area-inset-left));
}
.result-card{
  max-height:calc(100dvh - 24px);
  margin:auto;
  overflow-y:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
  -webkit-overflow-scrolling:touch;
}
@media(max-width:760px){
  .result-card{max-height:calc(100dvh - 20px);padding:22px 14px 12px}
  .result-plaque{height:72px}
  .result-emblem{width:92px;height:92px}
  .result-card h2{font-size:31px;line-height:1.05}
  .result-card p{margin:8px 0}
  .result-stats{margin:13px 0}
  .weekly-authority{margin:9px 0;padding:10px}
  .result-actions{
    position:sticky;
    z-index:3;
    bottom:0;
    gap:7px;
    padding:11px 0 max(2px,env(safe-area-inset-bottom));
    background:linear-gradient(180deg,transparent 0,#0b0513 18px);
  }
  .result-actions button{min-height:44px}
}
@media(max-width:390px) and (max-height:700px){
  .result-card{padding:15px 12px 10px}
  .result-plaque{height:57px}
  .result-emblem{width:72px;height:72px;margin-bottom:0}
  .result-kicker{font-size:8px}
  .result-card h2{margin:4px 0 2px;font-size:27px}
  .result-card p{font-size:13px}
  .result-stats{gap:5px;margin:9px 0}
  .result-stats div{padding:8px 5px}
  .weekly-authority{font-size:10px}
  .authority-note{margin-top:8px}
}

/* v0.6.2 — desktop/web fit rescue.
   Only applies to embedded desktop play, preserving the mobile portrait tuning. */
@media (min-width:901px){
  html.embedded,
  html.embedded body{
    height:100%;
    overflow:hidden;
  }
  .embedded .memory-shell{
    width:100%;
    height:100dvh;
    min-height:0;
    padding:8px 12px 10px;
    display:grid;
    grid-template-rows:auto auto minmax(0,1fr) auto;
    overflow:hidden;
  }
  .embedded .memory-topbar{
    grid-template-columns:42px minmax(190px,1fr) auto 42px;
    gap:8px;
  }
  .embedded .memory-title{
    max-height:58px;
    width:min(360px,42vw);
  }
  .embedded .icon-button{
    width:38px;
    height:38px;
    border-radius:10px;
    font-size:17px;
  }
  .embedded .memory-hud{
    margin:4px 0 7px;
    gap:6px;
  }
  .embedded .memory-hud>div{
    min-height:56px;
    padding:5px 8px 7px;
  }
  .embedded .memory-hud b{
    font-size:clamp(15px,1.45vw,20px);
  }
  .embedded .board-wrap{
    min-height:0;
    height:100%;
    padding:8px;
    border-radius:18px;
  }
  .embedded .memory-board{
    width:min(100%, calc((100dvh - 190px) * 1.12), 760px);
    max-height:100%;
    gap:6px;
  }
  .embedded .memory-board.hard,
  .embedded .memory-board.campaign-large{
    width:min(100%, calc((100dvh - 190px) * 1.45), 900px);
    gap:5px;
  }
  .embedded .card-back,
  .embedded .card-front{
    border-radius:8px;
  }
  .embedded .memory-footer{
    padding:7px 3px 0;
  }
}

@media (min-width:901px) and (max-height:760px){
  .embedded .memory-title{max-height:46px}
  .embedded .memory-hud>div{min-height:48px}
  .embedded .memory-hud span{display:none}
  .embedded .memory-board{
    width:min(100%, calc((100dvh - 165px) * 1.08), 700px);
    gap:5px;
  }
  .embedded .memory-board.hard,
  .embedded .memory-board.campaign-large{
    width:min(100%, calc((100dvh - 165px) * 1.42), 820px);
    gap:4px;
  }
  .embedded .memory-footer{font-size:10px}
}

/* v0.6.4 — PC full-board fit.
   Scale from available height + row count so the whole board is visible. */
@media (min-width:901px){
  .embedded .memory-shell{
    padding:6px 10px 8px;
  }
  .embedded .memory-topbar{
    min-height:42px;
  }
  .embedded .memory-title{
    max-height:44px;
    width:min(300px,32vw);
  }
  .embedded .run-meta span{
    font-size:10px;
  }
  .embedded .memory-hud{
    margin:2px 0 5px;
  }
  .embedded .memory-hud>div{
    min-height:42px;
    padding:3px 7px 5px;
  }
  .embedded .memory-hud span{
    font-size:7px;
  }
  .embedded .memory-hud b{
    font-size:clamp(14px,1.2vw,18px);
  }
  .embedded .board-wrap{
    padding:6px;
  }
  .embedded .memory-board,
  .embedded .memory-board.hard,
  .embedded .memory-board.campaign-large{
    --fit-gap:clamp(3px,.45vw,7px);
    gap:var(--fit-gap);
    width:min(
      100%,
      1120px,
      calc((100dvh - 168px - (var(--rows,4) - 1) * var(--fit-gap)) * var(--columns,4) / var(--rows,4) * .75)
    );
  }
  .embedded .card-back,
  .embedded .card-front{
    border-radius:7px;
  }
  .embedded .memory-footer{
    padding:5px 3px 0;
    font-size:10px;
  }
}

@media (min-width:901px) and (max-height:760px){
  .embedded .memory-board,
  .embedded .memory-board.hard,
  .embedded .memory-board.campaign-large{
    width:min(
      100%,
      1040px,
      calc((100dvh - 132px - (var(--rows,4) - 1) * var(--fit-gap)) * var(--columns,4) / var(--rows,4) * .75)
    );
  }
}
