:root {
  --ink:#383347; --muted:#70697b; --paper:#fffaf6; --panel:#fff; --line:#ede6df;
  --lavender:#dbc9f1; --lavender-outline:#bea8df; --mint:#a8dbb8;
  --shadow:0 3px 14px rgba(89,67,101,.055);
  --font-title:'League Spartan','Arial Rounded MT Bold',system-ui,sans-serif;
  --font-body:'Sniglet','Trebuchet MS',system-ui,sans-serif;
}
*,*::before,*::after{box-sizing:border-box}
html{background:transparent}
body{margin:0;min-width:260px;background:transparent;color:var(--ink);font-family:var(--font-body);-webkit-tap-highlight-color:transparent}
button{font:inherit}
button:focus-visible{outline:3px solid #6760a8;outline-offset:3px}
.game-shell{width:min(100%,1100px);margin:0 auto;background:radial-gradient(ellipse at 0% 44%,rgba(222,206,240,.23),transparent 27%),radial-gradient(ellipse at 100% 62%,rgba(191,226,207,.25),transparent 28%),var(--paper);padding:clamp(14px,3.3vw,30px);border-radius:22px;border:1px solid #f2e8df;box-shadow:var(--shadow)}
.game-header{text-align:center;margin:2px 0 20px}
.game-header h1{font-family:var(--font-title);font-weight:800;font-size:clamp(30px,5vw,43px);letter-spacing:-.045em;line-height:1.05;margin:0 0 7px;color:#5c4a79}
.game-header p{margin:0;font-size:clamp(14px,2.1vw,18px);color:#6a6172}
.scoreboard{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:clamp(8px,2vw,16px);margin-bottom:18px}
.stat{min-height:84px;padding:12px 10px 10px;display:flex;flex-direction:column;align-items:center;justify-content:center;border-radius:17px;border:1px solid rgba(86,70,90,.08);text-align:center}
.stat--score{background:#f8dce6}.stat--moves{background:#e4d9f5}.stat--time{background:#dcf0e4}
.stat__label{text-transform:uppercase;letter-spacing:.06em;font-size:12px;color:#726077}
.stat__value{font-size:clamp(22px,3.5vw,33px);color:#51465e;line-height:1.2;font-weight:800;font-variant-numeric:tabular-nums}
.progress{margin:0 4px 13px}.progress__row{display:flex;justify-content:space-between;gap:14px;align-items:center;color:#685e75;font-size:clamp(13px,2vw,16px);margin-bottom:8px}
.progress__track{height:11px;overflow:hidden;background:#eee5e8;border-radius:99px}
.progress__fill{width:0;height:100%;border-radius:99px;background:#90cba4;transition:width .4s ease}
.board-scene{position:relative;isolation:isolate;display:flex;justify-content:center;align-items:center}
.scene-animal{position:absolute;z-index:0;width:clamp(110px,15vw,180px);height:auto;pointer-events:none;user-select:none;object-fit:contain;filter:drop-shadow(0 4px 3px rgba(96,69,67,.045))}
.scene-animal--shirt{left:2.1%;top:19%;transform:rotate(-4deg)}
.scene-animal--dress{right:2.1%;top:14%;transform:rotate(4deg)}
.scene-animal--jacket{right:1.6%;bottom:3%;width:clamp(90px,11vw,125px);transform:rotate(2deg)}
.board-panel{position:relative;z-index:1;width:min(100%,706px);background:#fff;border:1px solid #efe7e6;padding:clamp(8px,2.3vw,20px);border-radius:20px}
.board{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:clamp(7px,1.7vw,14px);max-width:660px;margin:auto}
.memory-card{position:relative;width:100%;aspect-ratio:1/1;border:0;border-radius:13px;padding:0;background:transparent;cursor:pointer;touch-action:manipulation;perspective:800px;transition:transform .12s ease}
@media (hover:hover) and (pointer:fine){.memory-card:not(.is-flipped):not(.is-matched):hover{transform:translateY(-2px)}}
.memory-card__inner{display:block;position:relative;width:100%;height:100%;border-radius:13px;transform-style:preserve-3d;transition:transform .48s cubic-bezier(.22,.72,.2,1)}
.memory-card.is-flipped .memory-card__inner,.memory-card.is-matched .memory-card__inner{transform:rotateY(180deg)}
.memory-card__side{position:absolute;inset:0;border-radius:13px;display:flex;align-items:center;justify-content:center;overflow:hidden;backface-visibility:hidden;-webkit-backface-visibility:hidden}
.memory-card__cover{background:linear-gradient(150deg,#e7d9f7,#d9c5f0);border:2px solid #c8b1e1;box-shadow:0 3px 0 rgba(138,111,168,.12),inset 0 1px rgba(255,255,255,.65);color:#9880b6}
.memory-card__paw{width:40%;height:40%;max-width:62px;max-height:62px;opacity:.8}
.memory-card__answer{transform:rotateY(180deg);border:2px solid #e8dfeb;background:#fdfbfe;box-shadow:0 3px 0 rgba(98,78,109,.08)}
.memory-card__answer--word{background:#fff9f1;border-color:#f0e2cc}
.memory-card__answer img{width:94%;height:94%;object-fit:contain;display:block;pointer-events:none;user-select:none}
.memory-card__word{padding:4px;text-align:center;color:#584b6b;font-size:clamp(15px,3.3vw,29px);line-height:1.07;overflow-wrap:anywhere}
.memory-card.is-matched .memory-card__answer{background:#eef8ee;border-color:#a9d6b2;box-shadow:0 0 0 2px #d9efdd inset}
.memory-card.is-matched{cursor:default}
.memory-card.just-matched{animation:happy-match .55s ease}
@keyframes happy-match{0%{transform:scale(1)}42%{transform:scale(1.055)}100%{transform:scale(1)}}
.game-actions{display:flex;justify-content:space-between;gap:16px;align-items:center;margin-top:17px}
.action{display:inline-flex;align-items:center;justify-content:center;gap:9px;padding:11px 18px;border:1px solid #e4dce3;border-radius:99px;background:#fff;color:#655777;cursor:pointer;box-shadow:0 2px 5px rgba(64,51,72,.045);transition:background .15s,transform .15s}
.action:hover{background:#f6effa}.action:active{transform:scale(.97)}
.action--restart{background:#f7dfe8;border-color:#f2d0db}.action--restart:hover{background:#f3d1dc}
.ui-icon{width:19px;height:19px;flex:none}
.action[aria-pressed="false"] .sound-wave{display:none}
.best-record{text-align:center;font-size:13px;color:#8a8291;min-height:18px;margin:14px 0 0}
.sr-only{position:absolute;clip:rect(0,0,0,0);width:1px;height:1px;overflow:hidden;white-space:nowrap}
.modal[hidden]{display:none}
.modal{position:fixed;inset:0;z-index:99;background:rgba(49,42,62,.56);display:flex;justify-content:center;align-items:center;padding:15px;overflow:auto}
.win-card{width:min(100%,445px);background:#fffaf6;border-radius:24px;border:3px solid #fff;padding:clamp(18px,4vw,30px);text-align:center;box-shadow:0 18px 80px rgba(40,30,50,.25);animation:win-rise .3s ease both}
@keyframes win-rise{from{transform:translateY(14px) scale(.97);opacity:0}to{transform:none;opacity:1}}
.win-card__trophy{font-size:40px;line-height:1.2}
.win-card h2{font-family:var(--font-title);font-weight:800;color:#685187;font-size:clamp(28px,6vw,38px);letter-spacing:-.035em;margin:7px 0}
.win-card__intro{margin:5px 0 8px;color:#6b6270;font-size:16px}
.win-stars{font-size:36px;color:#f2b54c;letter-spacing:6px;text-shadow:0 1px 1px #c69551;margin:4px 0 18px}
.win-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.win-stats>div{border-radius:12px;background:#f2e9f6;padding:12px 4px;display:flex;flex-direction:column;gap:5px}
.win-stats>div:nth-child(2){background:#fce4eb}.win-stats>div:nth-child(3){background:#e3f3e9}
.win-stats span{color:#6e6675;font-size:12px;text-transform:uppercase}.win-stats strong{font-size:22px;color:#544760}
.win-bonus,.win-best{font-size:13px;color:#736b7c;margin:12px 0 0}
.play-again{background:#765d9a;border:0;border-radius:100px;color:white;margin-top:20px;padding:13px 28px;font-family:var(--font-body);font-size:17px;cursor:pointer}
.play-again:hover{background:#624984}
@media (max-width:520px){.game-shell{padding:12px 10px 15px;border-radius:15px}.game-header{margin:7px 0 15px}.game-header h1{font-size:30px}.scoreboard{gap:7px;margin-bottom:13px}.stat{border-radius:12px;min-height:62px;padding:9px 3px}.stat__label{font-size:10px}.stat__value{font-size:24px}.progress{margin:0 2px 10px}.board-panel{padding:8px;border-radius:14px}.board{gap:7px}.memory-card,.memory-card__inner,.memory-card__side{border-radius:9px}.memory-card__cover,.memory-card__answer{border-width:1.5px}.memory-card__word{font-size:clamp(13px,4vw,19px)}.game-actions{margin-top:13px}.action{padding:10px 12px;font-size:13px}.best-record{font-size:12px;margin-top:12px}}
@media (prefers-reduced-motion:reduce){*,*:before,*:after{transition-duration:.01ms!important;animation-duration:.01ms!important}}

/* Extra width lets the A0 animals peek out; the cards keep their proven size. */
@media (max-width:970px){
  .scene-animal{display:none}
  .board-panel{width:min(100%,706px)}
}
@media (min-width:971px){
  .game-shell{padding-top:31px;padding-bottom:24px}
  .board-scene{margin-top:3px}
}
/* On narrow embeds the card grid remains 4x4 with no horizontal overflow. */
@media (max-width:400px){
  .game-shell{padding-inline:8px}
  .board-panel{padding:7px}
  .board{gap:6px}
}


/* V5: Aligned record panels and bottom controls on desktop ONLY.
   All base and under-900px rules stay exactly as in the approved mobile game. */
.desktop-records{display:none}
@media (min-width:900px){
  .game-shell{
    display:grid;
    grid-template-columns:minmax(132px,158px) minmax(0,1fr) minmax(132px,158px);
    grid-template-areas:
      "heading heading heading"
      "progress progress progress"
      "records board scoreboard"
      "actions board scoreboard";
    grid-template-rows:auto auto auto 1fr;
    column-gap:clamp(12px,2vw,23px);
    row-gap:0;
    padding:clamp(16px,2.5vw,28px);
    width:min(100%,1100px);
    align-items:start;
  }
  .game-header{grid-area:heading;margin:0 0 15px}
  .progress{grid-area:progress;margin:0 1px 18px}
  .board-scene{grid-area:board;margin:0;min-width:0;align-self:start}
  .board-panel{width:min(100%,630px);padding:clamp(9px,1.35vw,15px);border-radius:18px}
  .board{gap:clamp(8px,1.2vw,12px)}
  .scoreboard{grid-area:scoreboard;grid-template-columns:minmax(0,1fr);
    align-content:start;gap:12px;margin:0;min-width:0;position:relative;z-index:2}
  .stat{height:105px;min-height:105px;border-radius:17px;padding:14px 6px}
  .stat__value{font-size:30px}
  .desktop-records{grid-area:records;display:grid;
    grid-template-rows:repeat(3,105px);align-content:start;gap:12px;
    margin:0;min-width:0;position:relative;z-index:2}
  .desktop-record{display:flex;flex-direction:column;align-items:center;justify-content:center;
    height:105px;min-height:105px;gap:6px;padding:12px 4px;background:#fff;
    border:1px solid #ede6eb;border-radius:17px;text-align:center}
  .desktop-record__label{font-size:12px;color:#74677c;text-transform:uppercase;
    letter-spacing:.035em}
  .desktop-record__value{font-size:28px;line-height:1.15;color:#57496b;
    font-family:var(--font-body);font-weight:800;font-variant-numeric:tabular-nums}
  .game-actions{grid-area:actions;display:flex;flex-direction:column;
    align-items:stretch;justify-content:flex-end;align-self:end;
    margin:18px 0 0;gap:12px;position:relative;z-index:2}
  .game-actions .action{width:100%;padding:13px 8px;white-space:nowrap}
  .best-record{display:none}
  .scene-animal{width:clamp(105px,12vw,140px)}
  .scene-animal--shirt{left:-58px;top:17%;transform:rotate(-4deg)}
  .scene-animal--dress{right:-58px;top:12%;transform:rotate(4deg)}
  .scene-animal--jacket{right:-55px;bottom:6%;width:clamp(80px,8vw,100px)}
}


/* One brief, lightweight confetti burst on the win screen.
   Positioned above the dialogue but never intercepts clicks or changes layout. */
.victory-confetti {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}
.win-card { position: relative; z-index: 2; }


/* =========================================================
   V6 typography: larger, easier-to-read game text.
   Preserve the approved title size, all card and panel dimensions,
   controls' box geometry, A0 artwork, and existing responsive layout.
   ========================================================= */
.game-header p {font-size:clamp(17px,2.4vw,22px)}
.progress__row {font-size:clamp(16px,2.35vw,20px)}
.memory-card__word {font-size:clamp(17px,3.65vw,31px)}
.best-record {font-size:15px}
/* Buttons remain the same dimensions; only their labels are gently enlarged. */
.action {font-size:17px;gap:7px}
/* Completion screen typography */
.win-card h2 {font-size:clamp(32px,6.5vw,42px)}
.win-card__intro {font-size:19px}
.win-stats span {font-size:15px}
.win-stats strong {font-size:29px}
.win-bonus,.win-best {font-size:16px}
.play-again {font-size:19px}
/* Mobile receives readable text without rearranging any boxes or controls. */
@media (max-width:520px) {
  .game-header p {font-size:16px}
  .progress__row {font-size:15px}
  .stat__label {font-size:12px}
  .stat__value {font-size:26px}
  .stat--time .stat__value {font-size:24px}
  .memory-card__word {font-size:clamp(15px,4.3vw,20px)}
  .action {font-size:13px;gap:9px}
  .best-record {font-size:14px}
  .win-card__intro {font-size:17px}
  .win-stats span {font-size:13px}
  .win-stats strong {font-size:clamp(21px,5.8vw,26px)}
  .win-bonus,.win-best {font-size:14px}
}
/* Desktop: visually strong statistics, kept within the 105px-tall panels. */
@media (min-width:900px) {
  .stat__label,.desktop-record__label {font-size:18px;letter-spacing:.025em;line-height:1.12}
  .stat__value,.desktop-record__value {font-size:52px;line-height:1.08}
  /* Time values have five characters and must not be clipped. */
  .stat--time .stat__value,
  .desktop-record:last-child .desktop-record__value {font-size:40px;white-space:nowrap}
  .game-actions .action {font-size:17px;gap:6px;white-space:nowrap;height:50px}
}

/* V7: refined, less bubbly numeric typography.
   Keep Sniglet on labels/body and League Spartan on the main title.
   Use League Spartan SemiBold for all actual score, time and move values.
   No size, layout, color, sound, or gameplay changes. */
.stat__value,
.desktop-record__value,
.win-stats strong {
  font-family: var(--font-title);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}


/* V8: reduce ONLY numeric readouts by 20% compared to V7.
   The title, labels, button sizes, card text, geometry and layout do not change. */
.stat__value { font-size: clamp(17.6px, 2.8vw, 26.4px); }
.win-stats strong { font-size: 23.2px; }
@media (max-width: 520px) {
  .stat__value { font-size: 20.8px; }
  .stat--time .stat__value { font-size: 19.2px; }
  .win-stats strong { font-size: clamp(16.8px, 4.64vw, 20.8px); }
}
@media (min-width: 900px) {
  .stat__value, .desktop-record__value { font-size: 41.6px; }
  .stat--time .stat__value,
  .desktop-record:last-child .desktop-record__value { font-size: 32px; }
}


/* V9: Decorative, softly coloured animal footprints following the two hand-marked
   paths in the open desktop margins. These are noninteractive, hidden on tablet
   and mobile, and do not affect the game's size, cards, or controls. */
.game-shell{position:relative;isolation:isolate}
.button-trail{display:none;pointer-events:none;user-select:none}
@media (min-width:900px){
  .button-trail{
    display:block;position:absolute;z-index:0;
    width:clamp(132px,14.4%,158px);
    pointer-events:none;
  }
  .button-trail--left{left:clamp(16px,2.5vw,28px);top:63%;height:17%}
  .button-trail--right{right:clamp(16px,2.5vw,28px);top:63%;height:28%}
  .button-step{
    display:block;position:absolute;
    width:clamp(24px,3vw,34px);height:clamp(24px,3vw,34px);
    -webkit-mask:url('./assets/decorative-buttons.svg') center/contain no-repeat;
    mask:url('./assets/decorative-buttons.svg') center/contain no-repeat;
    background-color:#c8b4d1;
    opacity:.55;
    transform-origin:center;
  }
  .button-trail--left .button-step:nth-child(1){left:62%;top:0%;transform:rotate(-34deg);opacity:.38}
  .button-trail--left .button-step:nth-child(2){left:42%;top:17%;transform:rotate(-25deg);background-color:#d4bcb3;opacity:.53}
  .button-trail--left .button-step:nth-child(3){left:51%;top:39%;transform:rotate(-32deg);opacity:.55}
  .button-trail--left .button-step:nth-child(4){left:25%;top:59%;transform:rotate(-23deg);background-color:#c1d8c8;opacity:.61}
  .button-trail--left .button-step:nth-child(5){left:15%;top:82%;transform:rotate(-30deg);opacity:.45}
  .button-trail--right .button-step:nth-child(1){left:12%;top:0%;transform:rotate(22deg);background-color:#c1d8c8;opacity:.38}
  .button-trail--right .button-step:nth-child(2){left:36%;top:16%;transform:rotate(27deg);opacity:.51}
  .button-trail--right .button-step:nth-child(3){left:27%;top:34%;transform:rotate(17deg);background-color:#d4bcb3;opacity:.53}
  .button-trail--right .button-step:nth-child(4){left:49%;top:49%;transform:rotate(25deg);opacity:.58}
  .button-trail--right .button-step:nth-child(5){left:40%;top:68%;transform:rotate(18deg);background-color:#c1d8c8;opacity:.48}
  .button-trail--right .button-step:nth-child(6){left:66%;top:83%;transform:rotate(28deg);opacity:.38}
}

/* V10: Muted pastel treatment ONLY for three peekaboo side animals.
   Full-color picture cards, board, layout, controls and mobile remain unchanged. */
.scene-animal {
  filter: saturate(.53) brightness(1.16) contrast(.88)
          drop-shadow(0 4px 3px rgba(96,69,67,.02));
  opacity: .73;
}

/* Food 1 decoration changes only: a warm cream base, soft food icons and muted
   fork/spoon trails. Gameplay, card size, touch layout, type and controls stay V10. */
.game-shell {
  background:radial-gradient(ellipse at 1% 42%,rgba(247,210,193,.22),transparent 28%),
             radial-gradient(ellipse at 100% 66%,rgba(203,235,217,.22),transparent 29%),
             var(--paper);
}
/* Decorative food illustrations are especially quiet so playing cards dominate. */
.scene-animal { filter:saturate(.48) brightness(1.12) contrast(.88);
                opacity:.70; }
@media(min-width:900px) {
  .scene-animal--shirt { left:-59px;top:15%;transform:rotate(-6deg);width:clamp(105px,12vw,140px); }
  .scene-animal--dress { right:-59px;top:14%;transform:rotate(6deg);width:clamp(105px,12vw,140px); }
  .scene-animal--jacket { right:-56px;bottom:3%;transform:rotate(3deg);width:clamp(82px,9vw,105px); }
  .button-trail .button-step{opacity:.33;}
}

/* Clothes 1: quiet matte A0 clothing peeking behind the board, not competing with cards. */
.scene-animal{opacity:.43;filter:saturate(.72)}
@media (min-width:900px){
 .scene-animal--shirt{left:-58px;top:17%;transform:rotate(-7deg)}
 .scene-animal--dress{right:-58px;top:12%;transform:rotate(6deg)}
 .scene-animal--jacket{right:-55px;bottom:6%;width:clamp(80px,8vw,100px);transform:rotate(2deg)}
}


/* Clothes background update — placement follows marked reference image.
   Only desktop decorative art changes; no card, audio, or scoring changes.
   Small-screen illustrations continue to be hidden as in the approved template. */
@media (min-width: 971px) {
  /* T-shirt: below the left-hand best results and control buttons. */
  .scene-animal--shirt {
    left: -68px;
    right: auto;
    top: auto;
    bottom: -6px;
    width: 116px;
    transform: rotate(-6deg);
  }
  /* Dress: lower on the right, next to the bottom half of the playing board. */
  .scene-animal--dress {
    right: -69px;
    left: auto;
    top: auto;
    bottom: 114px;
    width: 118px;
    transform: rotate(5deg);
  }
  /* Jacket: further down and outward at the lower-right. */
  .scene-animal--jacket {
    right: -138px;
    left: auto;
    top: auto;
    bottom: -3px;
    width: 90px;
    transform: rotate(2deg);
  }
}

/* Memory Match navigation: physically inside each game shell, not above the iframe.
   Preserve the finished game board, typography, and scoreboard dimensions. */
.game-shell{position:relative}
.memory-set-nav{position:absolute;z-index:5;top:clamp(12px,2.2vw,22px);left:clamp(12px,2.2vw,22px);right:clamp(12px,2.2vw,22px);display:flex;justify-content:space-between;align-items:center;gap:12px;pointer-events:none}
.memory-set-nav__back{pointer-events:auto;display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:37px;border:1px solid #eadfea;background:#f8f2fb;color:#675574;border-radius:999px;padding:8px 15px;cursor:pointer;font-family:var(--font-body);font-size:15px;line-height:1;white-space:nowrap}
.memory-set-nav__back:hover{background:#efe3f5}
.memory-set-nav__back:active{transform:scale(.98)}
.memory-set-nav__chevron{font-family:Arial,sans-serif;font-size:23px;line-height:12px;position:relative;top:-1px}
.memory-set-nav__name{font-family:var(--font-title);font-size:18px;font-weight:600;line-height:1.2;color:#6e6178;white-space:nowrap;text-align:right}
@media(max-width:680px){
  .memory-set-nav{position:relative;top:auto;left:auto;right:auto;margin:0 0 13px;min-width:0}
  .memory-set-nav__back{min-height:35px;padding:8px 12px;font-size:14px}
  .memory-set-nav__name{font-size:16px}
}
