/* Pares duo: the setup fills its own grid, not the former narrow sidebar. */
#memory-game{--font-ui:system-ui,-apple-system,"Segoe UI",sans-serif}
#memory-game.is-lobby .memory-arena{grid-template-columns:minmax(0,680px);grid-template-areas:'lobby';width:min(100%,740px);margin-inline:auto;justify-content:center;padding:clamp(12px,3vw,30px);background:radial-gradient(ellipse at 50% 0,#12607155,transparent 65%),#071c2d}
#memory-game.is-lobby .memory-lobby{box-sizing:border-box;grid-template-columns:1fr;gap:20px;padding:clamp(16px,3vw,28px);border-color:#30748a;background:#092537cc;border-radius:24px;box-shadow:none}
#memory-game .memory-lobby-art{display:flex;justify-content:center;align-items:center;gap:12px;height:105px;pointer-events:none}
#memory-game .memory-lobby-art img{width:75px;height:90px;object-fit:contain;filter:drop-shadow(0 6px 4px #0004);transform:rotate(-12deg)}
#memory-game .memory-lobby-art img:nth-child(2){width:100px;height:110px;transform:translateY(-4px)}
#memory-game .memory-lobby-art img:nth-child(3){transform:rotate(12deg)}
#memory-game.is-lobby .memory-lobby-copy{text-align:center;gap:8px}
#memory-game.is-lobby .memory-lobby-copy strong{font:850 clamp(24px,4vw,32px)/1.15 var(--font-ui)}
#memory-game.is-lobby .memory-lobby-copy small{display:block;font:400 14px/1.5 var(--font-ui);color:#b2d2dc;max-width:390px;margin-inline:auto}
#memory-game.is-lobby .memory-mode-choice{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:5px;border:1px solid #285060;border-radius:16px;background:#031825;grid-column:1}
#memory-game.is-lobby .memory-mode-choice button{min-height:48px;padding:10px 8px;border-radius:11px;border:0;font:750 14px/1.2 var(--font-ui);background:transparent;color:#b2d3df;box-shadow:none}
#memory-game.is-lobby .memory-mode-choice button.active{background:#77dfda;color:#062b34}
#memory-game.is-lobby .memory-settings-panel{grid-column:1;gap:16px}
#memory-game.is-lobby .memory-player-count{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;min-width:0}
#memory-game.is-lobby .memory-player-count button{min-height:46px;font:750 14px/1.2 var(--font-ui);box-shadow:none}
#memory-game.is-lobby .memory-player-names{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;grid-column:1}
#memory-game.is-lobby .memory-player-names:has(label:only-child){grid-template-columns:1fr}
#memory-game.is-lobby .memory-player-names label{grid-template-columns:32px minmax(0,1fr);gap:8px;min-width:0}
#memory-game.is-lobby .memory-player-names input{height:48px;font:650 15px/1.2 var(--font-ui);width:100%;box-sizing:border-box}
#memory-game.is-lobby .memory-start-button{width:100%;min-height:52px;font:850 16px/1.2 var(--font-ui);border-radius:14px}
#memory-game.is-lobby .memory-friend-picker{grid-template-columns:1fr;max-height:170px;scrollbar-width:thin;scrollbar-color:#498e99 transparent}
#memory-game.is-lobby .memory-friend-choice{min-height:48px;padding:10px 12px}#memory-game.is-lobby .memory-friend-choice strong{font-size:14px}
#memory-game.is-lobby .memory-online-settings>p{font-size:14px;line-height:1.5}
#memory-game.is-lobby .memory-online-actions{grid-template-columns:1fr 1fr}#memory-game.is-lobby .memory-online-actions button,#memory-game.is-lobby .memory-room-actions button{min-height:46px;font-size:13px}
#memory-game.is-playing .memory-scoreboard,#memory-game.is-finished .memory-scoreboard{--memory-players:2;gap:10px}
#memory-game .memory-player-score{transition:border-color .18s,background-color .18s}.memory-player-score.active{position:relative}
#memory-game .memory-card{touch-action:manipulation;will-change:auto}#memory-game .memory-card:focus-visible{outline:3px solid #ffdf8a;outline-offset:2px}
#memory-game .memory-player-score>strong{font-size:13px}#memory-game .memory-player-score>b{font-size:12px}
@media(max-width:520px){#memory-game.is-lobby .memory-arena{padding:10px}#memory-game.is-lobby .memory-lobby{gap:15px;padding:16px}#memory-game.is-lobby .memory-player-names{grid-template-columns:1fr}#memory-game.is-lobby .memory-lobby-art{height:86px}#memory-game .memory-lobby-art img{height:72px;width:60px}#memory-game .memory-lobby-art img:nth-child(2){height:88px;width:80px}}
@media(max-height:500px) and (min-width:600px){#memory-game.is-lobby .memory-lobby{grid-template-columns:1fr 1fr;align-items:start;gap:14px}#memory-game.is-lobby .memory-lobby-art{display:none}#memory-game.is-lobby .memory-lobby-copy{grid-column:1;grid-row:1;text-align:left}#memory-game.is-lobby .memory-mode-choice{grid-column:1;grid-row:2}#memory-game.is-lobby .memory-settings-panel{grid-column:2;grid-row:1 / 4}#memory-game.is-lobby .memory-player-names{grid-template-columns:1fr}}
@media(prefers-reduced-motion:reduce){#memory-game .memory-card,#memory-game .memory-card-art,#memory-game .memory-player-score{animation:none!important;transition:none!important}}

/* During a match, the viewport belongs to the cards, not the setup sidebar. */
body.game-screen-active[data-arcade-screen="memory-game"] .app-shell:has(#memory-game:is(.is-playing,.is-finished)){
  padding:max(6px,env(safe-area-inset-top)) max(6px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left));
}
body.game-screen-active #memory-game:is(.is-playing,.is-finished){min-height:0;overflow:hidden}
body.game-screen-active #memory-game:is(.is-playing,.is-finished) .memory-game-header{
  display:grid;grid-template-columns:44px minmax(0,1fr) auto;align-items:center;
  width:100%;max-width:none;gap:8px;margin:0 0 6px;flex-wrap:nowrap;
}
#memory-game:is(.is-playing,.is-finished) .memory-game-header>div{min-width:0}
body.game-screen-active #memory-game:is(.is-playing,.is-finished) .memory-game-header h1{
  font:850 clamp(16px,2.4vw,28px)/1.1 var(--font-ui);letter-spacing:-.035em;
  color:#eaf8ff;word-break:normal;overflow-wrap:normal;
}
#memory-game:is(.is-playing,.is-finished) .memory-game-header .game-menu-trigger{
  width:44px;height:44px;min-width:44px;margin:0;padding:5px;border-radius:12px;
}
#memory-game:is(.is-playing,.is-finished) .memory-game-header .game-stats{
  display:flex;width:auto;margin:0;gap:5px;align-self:center;flex-wrap:nowrap;
}
body.game-screen-active #memory-game:is(.is-playing,.is-finished) .memory-game-header :is(.level-box,.score-box){
  min-width:54px;padding:5px 7px;border-radius:10px;flex:none;background:#163347;
}
#memory-game:is(.is-playing,.is-finished) .game-stats span{color:#abc7d5;font-size:9px;letter-spacing:.06em}
#memory-game:is(.is-playing,.is-finished) .game-stats strong{color:#79e4d7;font-size:16px;line-height:1.15;font-variant-numeric:tabular-nums}
body.game-screen-active #memory-game:is(.is-playing,.is-finished) .memory-arena{
  flex:1;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto;
  grid-template-areas:'scores' 'board' 'message';align-items:stretch;align-content:stretch;
  width:100%;max-width:none;min-height:0;min-width:0;margin:0;gap:6px;padding:7px;border-radius:18px;
}
#memory-game:is(.is-playing,.is-finished) .memory-scoreboard{gap:6px;align-items:stretch}
#memory-game:is(.is-playing,.is-finished) .memory-player-score{
  grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:7px;
  min-height:36px;padding:5px 10px;border-radius:10px;
}
#memory-game:is(.is-playing,.is-finished) .memory-player-score>span{grid-row:auto;display:block;font-size:10px}
#memory-game:is(.is-playing,.is-finished) .memory-player-score>strong{grid-column:auto;text-align:left;font-size:13px}
#memory-game:is(.is-playing,.is-finished) .memory-player-score>b{grid-column:auto;text-align:right;font-size:12px;white-space:nowrap}
/* Keep instructions available to assistive technology without a redundant row. */
#memory-game:is(.is-playing,.is-finished) #memory-instruction{
  position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;
  clip-path:inset(50%);white-space:nowrap;
}
#memory-game:is(.is-playing,.is-finished) #restart-memory{display:none}
body.game-screen-active #memory-game:is(.is-playing,.is-finished) .memory-board{
  grid-template-columns:repeat(var(--memory-columns,5),minmax(0,1fr));
  grid-template-rows:repeat(var(--memory-rows,6),minmax(0,1fr));
  width:100%;height:100%;max-width:none;min-width:0;min-height:0;align-self:stretch;justify-self:stretch;
  gap:clamp(5px,.65vw,9px);padding:6px;border-radius:13px;
}
#memory-game:is(.is-playing,.is-finished) .memory-card{
  width:100%;height:100%;min-height:0;aspect-ratio:auto;padding:0;
  background-size:contain;background-repeat:no-repeat;border-radius:clamp(7px,.8vw,12px);
}
#memory-game:is(.is-playing,.is-finished) .game-message{
  min-height:18px;margin:0;font:650 12px/1.35 var(--font-ui);align-self:center;
  overflow-wrap:break-word;word-break:normal;
}
@media(max-width:360px){
  #memory-game:is(.is-playing,.is-finished) .memory-player-score{gap:4px;padding:5px 6px}
  #memory-game:is(.is-playing,.is-finished) .memory-player-score>span{display:none}
  #memory-game:is(.is-playing,.is-finished) .memory-player-score{grid-template-columns:minmax(0,1fr) auto}
  #memory-game:is(.is-playing,.is-finished) .memory-player-score>strong{font-size:12px}
}

/* O Último Par. O placar e os créditos rolam dentro do cartão. */
#memory-finale {
  --par-gap:clamp(6px,2vh,16px);
  --par-top:max(var(--par-gap),env(safe-area-inset-top,0px));
  --par-right:max(var(--par-gap),env(safe-area-inset-right,0px));
  --par-bottom:max(var(--par-gap),env(safe-area-inset-bottom,0px));
  --par-left:max(var(--par-gap),env(safe-area-inset-left,0px));
  position:fixed; inset:var(--par-top) var(--par-right) var(--par-bottom) var(--par-left); margin:auto; padding:0;
  width:min(980px,calc(100% - var(--par-left) - var(--par-right))); max-width:none;
  max-height:calc(100dvh - var(--par-top) - var(--par-bottom)); overflow:hidden;
  color:#f8f3df; background:#153e3d; border:1px solid #84bdab; border-radius:20px;
  box-shadow:0 24px 75px #020f18ba; font-family:system-ui,sans-serif; text-align:left;
}
#memory-finale[open] { display:grid; grid-template: minmax(0,1fr) / minmax(0,1.05fr) minmax(0,1fr); }
#memory-finale::backdrop { background:#031925e6; }
.memory-finale-art { position:relative; min-height:325px; min-width:0; overflow:hidden; margin:0; background:#33716a; }
.memory-finale-art img { position:absolute; display:block; inset:0; width:100%; height:100%; object-fit:cover; object-position:center; }
.memory-finale-panel {
  display:grid; grid-template-rows:minmax(0,1fr) auto; min-width:0; min-height:0;
  gap:10px; padding:clamp(12px,3vw,32px);
  background:radial-gradient(ellipse at top left,#2e6657 0%,#204542 55%,#153738 100%);
}
.memory-finale-scroll { overflow:auto; min-width:0; min-height:0; padding:2px 4px; touch-action:pan-y; overscroll-behavior:contain; }
#memory-finale .memory-finale-kicker { color:#b8edc9; margin:0 0 8px; font-size:.69rem; font-weight:850; letter-spacing:.13em; }
#memory-finale #memory-finale-title { margin:0 0 8px; color:#fff1cc; font:700 clamp(1.52rem,3.6vw,2.85rem)/1.04 Georgia,serif; letter-spacing:-.03em; text-wrap:balance; }
#memory-finale #memory-finale-summary { margin:0 0 10px; color:#edfbef; font-size:.88rem; overflow-wrap:anywhere; }
#memory-finale-players { margin:0; padding:2px 10px; list-style:none; border:1px solid #94cbac80; border-radius:8px; background:#102e2fe0; }
#memory-finale-players li { min-height:31px; display:flex; justify-content:space-between; gap:6px; align-items:center; color:#e3f6e8; font-size:.82rem; }
#memory-finale-players li+li { border-top:1px solid #9cdbb23b; }
#memory-finale-players li span { overflow-wrap:anywhere; }
#memory-finale-players li strong { flex:none; color:#ffdda6; }
#memory-finale #memory-finale-score { margin:7px 0 0; color:#ffdfaa; font-size:.8rem; font-weight:800; }
#memory-finale-credits { margin-top:9px; border-top:1px solid #a8d4a966; color:#e2f3dc; font-size:.74rem; }
#memory-finale-credits summary { min-height:44px; display:list-item; align-content:center; cursor:pointer; font-weight:800; }
#memory-finale-credits dl { display:grid; gap:3px; margin:0 0 6px; }
#memory-finale-credits dl div { display:flex; flex-wrap:wrap; justify-content:space-between; gap:0 6px; }
#memory-finale-credits dd { margin:0; color:#fff1ce; }
#memory-finale #memory-finale-credits p { margin:0 0 3px; color:#ffdeaa; font:italic .91rem/1.24 Georgia,serif; }
.memory-finale-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px; padding-inline:4px; }
#memory-finale .memory-finale-actions button { min-height:44px; min-width:0; margin:0; padding:5px 7px; border:1px solid #a1c9b1; border-radius:8px; color:#f2f9e7; background:#31534b; box-shadow:none; font:750 .8rem/1.17 system-ui,sans-serif; white-space:normal; overflow-wrap:anywhere; }
#memory-finale #memory-finale-replay:not(:disabled) { color:#263a33; background:#ffda9f; border-color:#ffe4b7; }
#memory-finale #memory-finale-replay:disabled { color:#daeae0; background:#253d39; opacity:1; }
#memory-finale-board,#memory-finale-replay-status { grid-column:1/-1; }
#memory-finale #memory-finale-replay-status { margin:0; font-size:.73rem; color:#e5f2df; }
#memory-show-finale { position:fixed; right:max(10px,env(safe-area-inset-right)); bottom:max(10px,env(safe-area-inset-bottom)); z-index:22; min-height:44px; }
#memory-finale :focus-visible,#memory-show-finale:focus-visible { outline:2px solid #ffdd9d; outline-offset:2px; }
@media(max-width:620px) and (orientation:portrait) {
  #memory-finale[open] { grid-template:auto minmax(0,1fr) / minmax(0,1fr); }
  .memory-finale-art { height:clamp(105px,27dvh,209px); min-height:0; }
  .memory-finale-panel { gap:7px; }
}
@media(max-height:510px) and (orientation:landscape) {
  #memory-finale[open] { grid-template-columns:minmax(0,.86fr) minmax(0,1fr); }
  .memory-finale-art { min-height:0; }
  .memory-finale-panel { padding:8px; gap:4px; }
  #memory-finale #memory-finale-title { font-size:1.63rem; margin-bottom:5px; }
}
@media(max-height:300px) and (orientation:landscape) {
  #memory-finale[open] { grid-template-columns:minmax(0,1fr); }
  .memory-finale-art,#memory-finale .memory-finale-kicker { display:none; }
  .memory-finale-panel { padding:5px; }
  #memory-finale #memory-finale-title { font-size:1.18rem; margin-bottom:4px; }
}
