*,*::before,*::after{box-sizing:border-box}
:root{padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}
body{margin:0;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
img{max-width:100%}
[hidden]{display:none!important}

/* Fredoka (SIL OFL, see fonts/OFL.txt), bundled so the app works offline */
@font-face{font-family:"Fredoka";font-style:normal;font-weight:500 700;font-display:swap;src:url(fonts/fredoka-latin-ext.woff2) format("woff2");
  unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C4,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:"Fredoka";font-style:normal;font-weight:500 700;font-display:swap;src:url(fonts/fredoka-latin.woff2) format("woff2");
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}

/* Layout: one bright playground column — rainbow title, mode picker cards, candy sticker tiles, chunky 3D buttons.
   Deliberately one sunny look in every theme (a kids' game), so every color is set explicitly. */
:root{
  --sky1:#7FD3FF; --sky2:#B9F0FF; --ink:#2B2D6E; --white:#FFFFFF; --soft:#5D61A0;
  --red:#FF5C6C; --orange:#FF9F43; --yellow:#FFD23F; --green:#2ED47A; --blue:#4D8DFF; --purple:#A66BFF; --pink:#FF7AC6;
  --font:"Fredoka","Baloo 2","Comic Sans MS","Chalkboard SE",system-ui,sans-serif;
  color-scheme:light;
  --gap:14px; /* on :root so the overlay dialogs (outside .wrap) get it too */
}
/* The whole game always fits the screen: the page never scrolls, the tile board takes whatever space is left. */
html{height:100%;height:100dvh;overflow:hidden;overscroll-behavior:none}
body{height:100%;overflow:hidden;display:flex;flex-direction:column;
  color:var(--ink);font-family:var(--font);font-size:1.0625rem;
  padding-block:12px;padding-inline:max(16px,env(safe-area-inset-left,0px)) max(16px,env(safe-area-inset-right,0px));
  background:
    radial-gradient(circle at 12% 18%,rgba(255,255,255,.75) 0 38px,transparent 39px),
    radial-gradient(circle at 18% 16%,rgba(255,255,255,.75) 0 30px,transparent 31px),
    radial-gradient(circle at 86% 9%,rgba(255,255,255,.7) 0 34px,transparent 35px),
    radial-gradient(circle at 92% 11%,rgba(255,255,255,.7) 0 26px,transparent 27px),
    radial-gradient(circle at 80% 88%,rgba(255,255,255,.55) 0 44px,transparent 45px),
    linear-gradient(180deg,var(--sky1),var(--sky2));
  background-attachment:fixed;background-color:var(--sky2)}
.wrap{flex:1;min-height:0;width:100%;max-width:540px;margin:0 auto;display:flex;flex-direction:column;gap:var(--gap)}
#screen{flex:1;min-height:0;display:flex;flex-direction:column;padding-bottom:8px}
header,footer{flex:none}

header{display:flex;align-items:center;justify-content:space-between;gap:10px}
.logo{display:flex;align-items:center;gap:6px;min-width:0}
.mascot{font-size:2.6rem;line-height:1;animation:hop 1.6s ease-in-out infinite;display:inline-block}
@keyframes hop{0%,100%{transform:translateY(0) rotate(-6deg)}50%{transform:translateY(-8px) rotate(6deg)}}
h1{margin:0;font-weight:700;font-size:2.4rem;line-height:1;letter-spacing:1px;text-shadow:0 3px 0 var(--white);white-space:nowrap}
h1 span{display:inline-block;-webkit-text-stroke:2px var(--ink);paint-order:stroke fill}
h1 span:nth-child(7n+1){color:var(--red);transform:rotate(-6deg)}
h1 span:nth-child(7n+2){color:var(--orange);transform:translateY(-3px)}
h1 span:nth-child(7n+3){color:var(--yellow);transform:rotate(5deg)}
h1 span:nth-child(7n+4){color:var(--green)}
h1 span:nth-child(7n+5){color:var(--blue);transform:rotate(-4deg)}
h1 span:nth-child(7n+6){color:var(--purple);transform:translateY(-2px)}
h1 span:nth-child(7n){color:var(--pink);transform:rotate(6deg)}
h1 .gap{width:.3em}
.hdr-right{display:flex;gap:8px;align-items:center;flex:none}
.iconbtn{all:unset;cursor:pointer;font-size:1.3rem;width:42px;height:42px;display:grid;place-items:center;border-radius:50%;
  background:var(--white);border:3px solid var(--ink);box-shadow:0 3px 0 var(--ink);box-sizing:border-box}
.iconbtn:active{transform:translateY(2px);box-shadow:0 1px 0 var(--ink)}
.iconbtn:focus-visible{outline:3px solid var(--purple);outline-offset:3px}

.card{background:var(--white);border:4px solid var(--ink);border-radius:28px;padding:18px;
  box-shadow:0 8px 0 var(--ink);display:flex;flex-direction:column;gap:var(--gap);
  flex:0 1 auto;min-height:0;max-height:100%;overflow-y:auto;overscroll-behavior:contain}
.card.play{flex:1 1 auto}
/* split cards: a .side column next to a .board (tiles or map). Stacked in portrait, side by side in landscape. */
.split > .side{display:contents}
.split > .side > .actions{order:2}
.split > .board,.split > .mapside > *{order:1}
.split > .mapside{display:contents}
.tag{margin:0;text-align:center;font-weight:700;font-size:.95rem;color:var(--soft);font-variant-numeric:tabular-nums}
.prompt{font-weight:700;font-size:1.6rem;line-height:1.25;margin:0;text-align:center;text-wrap:balance}
.target{display:inline-block;background:var(--yellow);border:3px solid var(--ink);border-radius:14px;
  padding:0 9px;margin:2px;transform:rotate(-3deg);animation:wiggle 2s ease-in-out infinite}
@keyframes wiggle{0%,100%{transform:rotate(-3deg)}50%{transform:rotate(3deg) scale(1.06)}}

/* mode picker: one row per game on phones, two columns on tablets, three in landscape */
.modes{display:grid;grid-template-columns:1fr;gap:12px}
.mode{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:12px;padding:10px 14px;min-width:0;
  border:4px solid var(--ink);border-radius:22px;background:var(--c);box-shadow:0 6px 0 var(--ink);transition:transform .1s, box-shadow .1s}
.mode:hover{transform:translateY(-2px)}
.mode:active{transform:translateY(4px);box-shadow:0 2px 0 var(--ink)}
.mode:focus-visible{outline:4px solid var(--purple);outline-offset:3px}
.mode .me{font-size:2.3rem;line-height:1;flex:none}
.mode .mt{flex:1;min-width:0}
.mode b{font-size:1.25rem;display:block;line-height:1.1}
.mode small{font-size:.9rem;display:block;line-height:1.2;color:var(--ink);opacity:.8}
.mode .ml{font-weight:700;font-size:.82rem;background:var(--white);border:2px solid var(--ink);border-radius:999px;
  padding:2px 10px;align-self:flex-start;font-variant-numeric:tabular-nums;white-space:nowrap}
.mode.mix{background:linear-gradient(110deg,#FFB3BA,#FFD6A5,#FDFFB6,#CAFFBF,#9BF6FF,#BDB2FF)}
.mode .pills{display:flex;flex-direction:column;align-items:flex-end;gap:4px;flex:none}
@media (min-width:600px){.modes{grid-template-columns:1fr 1fr}.mode.mix,.mode.wide{grid-column:1/-1}}

/* timer */
.timer{display:flex;align-items:center;gap:12px;position:relative}
.ring{--p:1;--rc:var(--green);flex:none;width:62px;height:62px;border-radius:50%;border:3px solid var(--ink);
  background:conic-gradient(var(--rc) calc(var(--p) * 360deg),#E6EAF7 0);display:grid;place-items:center;box-shadow:0 4px 0 var(--ink)}
.ring span{width:42px;height:42px;border-radius:50%;background:var(--white);border:2.5px solid var(--ink);display:grid;place-items:center;
  font-weight:700;font-size:1.45rem;font-variant-numeric:tabular-nums}
.ring.low{--rc:var(--orange)}
.track{flex:1;min-width:0;height:24px;border:3px solid var(--ink);border-radius:999px;
  background:repeating-linear-gradient(-45deg,#E6EAF7 0 10px,#F2F4FB 10px 20px)}
.bar{position:relative;height:100%;width:100%;border-radius:999px;transition:width .1s linear;
  background:linear-gradient(90deg,var(--purple),var(--blue),var(--green),var(--yellow))}
.bar.low{background:linear-gradient(90deg,var(--yellow),var(--orange))}
.fire{position:absolute;right:-14px;top:50%;transform:translateY(-55%);font-size:1.5rem;line-height:1;animation:twinkle 1.6s ease-in-out infinite}
@keyframes twinkle{0%,100%{transform:translateY(-55%) rotate(0)}50%{transform:translateY(-55%) rotate(20deg) scale(1.1)}}
.face{flex:none;font-size:2.2rem;line-height:1}
.bonus{position:absolute;left:6px;top:-10px;font-weight:700;font-size:1.6rem;color:var(--green);
  -webkit-text-stroke:2px var(--ink);paint-order:stroke fill;pointer-events:none;animation:floatup .9s ease-out forwards}
@keyframes floatup{0%{transform:translateY(0) scale(.6);opacity:0}25%{transform:translateY(-8px) scale(1.2);opacity:1}100%{transform:translateY(-38px);opacity:0}}
.study{height:14px;border:3px solid var(--ink);border-radius:999px;overflow:hidden;background:#E6EAF7}
.study i{display:block;height:100%;width:100%;background:var(--purple);transition-property:width;transition-timing-function:linear}

.stars{display:flex;justify-content:center;gap:4px;flex-wrap:wrap;min-height:32px}
.star{width:30px;height:30px;display:grid;place-items:center;font-size:1.4rem;line-height:1;filter:grayscale(1) opacity(.35)}
.star.on{filter:none;animation:boing .45s}
@keyframes boing{0%{transform:scale(.4)}60%{transform:scale(1.35)}100%{transform:scale(1)}}

/* tiles: the board is a size container, the square grid is as big as fits inside it */
.board{display:grid;place-items:center}
.grid{display:grid;gap:10px;width:100%}
.grid.g3{grid-template-columns:repeat(3,1fr)}
.grid.g4{grid-template-columns:repeat(4,1fr);gap:8px}
.grid.g5{grid-template-columns:repeat(5,1fr);gap:7px}
.grid.g6{grid-template-columns:repeat(6,1fr);gap:6px}
.tile{all:unset;box-sizing:border-box;aspect-ratio:1;display:grid;place-items:center;position:relative;cursor:pointer;min-width:0;
  border-radius:22px;border:4px solid var(--ink);box-shadow:0 6px 0 var(--ink);background:var(--c);
  font-size:clamp(2.1rem,11vw,3.4rem);line-height:1;-webkit-tap-highlight-color:transparent;
  animation:popin .4s cubic-bezier(.3,1.6,.5,1) backwards;animation-delay:calc(var(--i) * 15ms);
  transition:transform .12s, box-shadow .12s}
.g4 .tile{border-radius:18px;border-width:3px;box-shadow:0 5px 0 var(--ink);font-size:clamp(1.7rem,8.5vw,2.6rem)}
.g5 .tile{border-radius:14px;border-width:3px;box-shadow:0 4px 0 var(--ink);font-size:clamp(1.4rem,7vw,2.2rem)}
.g6 .tile{border-radius:11px;border-width:2.5px;box-shadow:0 3px 0 var(--ink);font-size:clamp(1.15rem,5.8vw,1.85rem)}
@keyframes popin{from{transform:scale(0) rotate(-20deg)}to{transform:scale(1)}}
.tile.word{font-weight:700;text-align:center;padding:4px;line-height:1.05;color:var(--ink);overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
.g3 .tile.word{font-size:clamp(1.15rem,6vw,1.75rem)}
.g4 .tile.word{font-size:clamp(.9rem,4.4vw,1.3rem)}
.g5 .tile.word{font-size:clamp(.7rem,3.2vw,1rem);padding:3px}
.g6 .tile.word{font-size:clamp(.6rem,2.7vw,.88rem);padding:2px}
.g3 .tile.word.long{font-size:clamp(.95rem,4.6vw,1.35rem)}
.g4 .tile.word.long{font-size:clamp(.72rem,3.4vw,1.05rem)}
.tile:hover{transform:translateY(-3px)}
.tile:active{transform:translateY(4px);box-shadow:0 2px 0 var(--ink)}
.tile:focus-visible{outline:4px solid var(--purple);outline-offset:3px}
.grid.hide .tile{filter:blur(9px)}
.tile.picked{background:var(--yellow);animation:yay .5s}
.tile.picked::after{content:"⭐";position:absolute;top:-12px;right:-10px;font-size:1.6rem;line-height:1;
  filter:drop-shadow(0 2px 0 var(--ink));animation:boing .45s}
.g5 .tile.picked::after,.g6 .tile.picked::after{font-size:1.05rem;top:-8px;right:-6px}
@keyframes yay{0%{transform:scale(1)}40%{transform:scale(1.15) rotate(-6deg)}70%{transform:scale(.95) rotate(4deg)}100%{transform:scale(1)}}
.tile.wrong{background:#FFD6A5;animation:wobble .5s}
@keyframes wobble{25%{transform:rotate(-4deg)}75%{transform:rotate(4deg)}}
.tile.answer{background:#CAFFBF;outline:4px dashed var(--green);outline-offset:-9px;animation:pulse .8s ease-in-out infinite}
.tile.down{background:var(--purple);animation:flip .35s}
.tile.down .v{visibility:hidden}
.tile.down::before{content:"?";position:absolute;color:var(--white);font-weight:700;font-size:.9em;-webkit-text-stroke:2px var(--ink);paint-order:stroke fill}
@keyframes flip{0%{transform:rotateY(0)}50%{transform:rotateY(90deg)}100%{transform:rotateY(0)}}

/* buttons */
.btn{all:unset;box-sizing:border-box;text-align:center;cursor:pointer;font-weight:700;font-size:1.6rem;
  padding:12px 34px;border:4px solid var(--ink);border-radius:999px;background:var(--green);color:var(--white);
  box-shadow:0 7px 0 var(--ink);text-shadow:0 2px 0 rgba(0,0,0,.2);transition:transform .1s, box-shadow .1s}
.btn:active{transform:translateY(5px);box-shadow:0 2px 0 var(--ink)}
.btn:focus-visible{outline:4px solid var(--purple);outline-offset:4px}
.btn[disabled]{background:#D9DEEE;color:#8C93B8;cursor:not-allowed;text-shadow:none}
.btn.ready{animation:pulse 1s ease-in-out infinite}
@keyframes pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.07)}}
.btn.pink{background:var(--pink)}
.btn.plain{font-size:1.15rem;padding:7px 22px;background:var(--white);color:var(--ink);text-shadow:none;box-shadow:0 4px 0 var(--ink);border-width:3px}
.actions{display:flex;flex-direction:column;align-items:center;gap:10px}
.hint{color:var(--soft);font-weight:600;font-size:1.1rem;margin:0;min-height:1.4em;text-align:center;text-wrap:balance}

.congrats{font-weight:700;font-size:2rem;line-height:1.15;margin:0;text-align:center;text-wrap:balance}
.congrats b{color:var(--purple)}
.trophy{font-size:4rem;line-height:1;text-align:center;animation:hop 1.2s ease-in-out infinite}
.levelup{margin:0;text-align:center;font-weight:700;font-size:1.15rem;background:var(--yellow);border:3px solid var(--ink);
  border-radius:18px;padding:10px 14px;animation:boing .6s}
.maplabel{font-weight:700;font-size:1.05rem;color:var(--soft);margin:0;text-align:center}
.mapside{flex-direction:column;gap:8px;min-height:0}
.mapbox{position:relative;width:100%;max-width:360px;max-height:236px;min-height:104px;flex:0 1 auto;margin:0 auto;overflow-y:auto;overscroll-behavior:contain;
  padding:12px 10px 18px;border:3px solid var(--ink);border-radius:20px;background:#F2F4FB}
.map{display:grid;grid-template-columns:repeat(5,1fr);gap:16px 10px;width:100%}
.cell{all:unset;box-sizing:border-box;aspect-ratio:1;display:grid;place-items:center;position:relative;border-radius:50%;
  border:3px solid var(--ink);font-weight:700;font-size:1.4rem;font-variant-numeric:tabular-nums;background:#E6EAF7;color:#8C93B8}
.cell.open{cursor:pointer;color:var(--ink);background:var(--white);box-shadow:0 3px 0 var(--ink)}
.cell.open:hover{transform:translateY(-2px)}
.cell:focus-visible{outline:3px solid var(--purple);outline-offset:2px}
.cell.done{background:var(--yellow)}
.cell .cs{position:absolute;bottom:-9px;left:50%;transform:translateX(-50%);font-size:.6rem;line-height:1;font-style:normal;white-space:nowrap;letter-spacing:-1px}
.cell .cs b,.rating .off{filter:grayscale(1) opacity(.35);font-weight:inherit}
.rating{margin:0;text-align:center;font-size:2.6rem;line-height:1}
.rating span{display:inline-block;animation:boing .5s backwards}
.rating span:nth-child(2){animation-delay:.15s}
.rating span:nth-child(3){animation-delay:.3s}
.homehead{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:8px 12px}
.brag{margin:0;align-self:center;text-align:center;font-weight:700;font-size:1.05rem;background:#FFF3C4;
  border:3px solid var(--ink);border-radius:999px;padding:6px 16px}
.cell.now{background:var(--pink);color:var(--white);animation:pulse 1.1s ease-in-out infinite}
.cell.locked::before{content:"🔒";position:absolute;font-size:.75rem;bottom:-6px;right:-4px}

.overlay{position:fixed;inset:0;background:rgba(43,45,110,.45);display:grid;place-items:center;padding:16px;z-index:5}
.overlay .card{max-width:370px;align-items:center;animation:popin .35s cubic-bezier(.3,1.6,.5,1)}
.overlay .card .btn{flex:none}
.go{position:fixed;inset:0;display:grid;place-items:center;z-index:7;pointer-events:none}
.goN{font-weight:700;font-size:9rem;line-height:1;color:var(--yellow);-webkit-text-stroke:6px var(--ink);paint-order:stroke fill;
  text-shadow:0 10px 0 var(--ink);animation:countpop .7s cubic-bezier(.3,1.6,.5,1)}
.goN.goGo{color:var(--green);font-size:7rem}
@keyframes countpop{0%{transform:scale(.2) rotate(-15deg);opacity:0}30%{transform:scale(1.2);opacity:1}100%{transform:scale(1)}}
canvas#confetti{position:fixed;inset:0;pointer-events:none;z-index:6}
footer{color:var(--ink);font-size:.9rem;text-align:center;opacity:.7}
footer{display:flex;flex-wrap:wrap;justify-content:center;gap:4px 18px}
footer button{all:unset;cursor:pointer;text-decoration:underline}
#install{font-weight:700}
.steps{margin:0;padding-left:1.4em;display:flex;flex-direction:column;gap:8px;font-weight:600;font-size:1.05rem;line-height:1.3;text-align:left}
.steps .key{display:inline-block;font-size:1.1em}
footer button:focus-visible{outline:2px solid var(--purple)}
#ver{font-size:.8em;opacity:.8;align-self:center}
@media (max-width:420px){h1{font-size:1.9rem}.mascot{font-size:2rem}.prompt{font-size:1.35rem}.mode b{font-size:1.1rem}}

/* tile and word sizes follow the board, not the window */
@supports (width:1cqmin){
  .board{flex:1 1 0;min-height:96px;container-type:size}
  .board .grid{--s:min(100cqw - 6px,100cqh - 18px);width:var(--s)}
  .g3 .tile{font-size:calc(var(--s) * .15)}
  .g4 .tile{font-size:calc(var(--s) * .115)}
  .g5 .tile{font-size:calc(var(--s) * .092)}
  .g6 .tile{font-size:calc(var(--s) * .076)}
  .g3 .tile.word{font-size:calc(var(--s) * .075)}
  .g4 .tile.word{font-size:calc(var(--s) * .058)}
  .g5 .tile.word{font-size:calc(var(--s) * .045)}
  .g6 .tile.word{font-size:calc(var(--s) * .037)}
  .g3 .tile.word.long{font-size:calc(var(--s) * .058)}
  .g4 .tile.word.long{font-size:calc(var(--s) * .046)}
}


/* both pills on one line beside the name; they stack again only if there isn't room */
.mode .mt{flex:1 0 auto}
@media (max-aspect-ratio:5/4){.mode b{white-space:nowrap}}
.mode .pills{flex:0 1 auto;flex-direction:row;flex-wrap:wrap;justify-content:flex-end}
/* very narrow phones: the pills stack, so keep them small */
@media (max-width:359px){.modes .mode{padding:3px 10px;gap:8px}.modes .mode .me{font-size:1.6rem}.modes .mode .pills{gap:2px}.modes .mode .ml{font-size:.68rem;line-height:1.15;padding:0 6px}}
/* very short landscape */
@media (max-height:420px) and (min-aspect-ratio:5/4){.modes .mode{padding:4px 8px;gap:4px 8px}.modes .mode .me{font-size:1.5rem}}

/* shorter screens: tighten spacing so it all still fits */
@media (max-height:960px){.mode small{display:none}}
@media (max-height:880px){
  .modes{gap:10px}.mode{padding:8px 14px}.homehint{font-size:.95rem}
  .mode .ml{font-size:.75rem;padding:1px 8px}
  .stars{min-height:26px}.star{width:24px;height:24px;font-size:1.15rem}
  .play .actions{flex-direction:row;flex-wrap:wrap;justify-content:center;gap:12px}
  .play .actions .hint{flex:1 1 0;min-width:5em;text-align:left}
  .play .actions .btn{flex:none}
}
@media (max-height:760px){
  .mapbox{min-height:72px}
  .tag{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .brag{padding:3px 12px;font-size:.95rem}
  :root{--gap:10px}
  .card{padding:14px;border-radius:24px}
  .mode{padding:5px 12px;border-width:3px;box-shadow:0 5px 0 var(--ink)}
  .homehint{display:none}
  .mode .me{font-size:1.9rem}
  .mode .ml{padding:1px 8px}
  .ring{width:50px;height:50px}.ring span{width:34px;height:34px;font-size:1.2rem}
  .btn{font-size:1.35rem;padding:9px 28px;box-shadow:0 5px 0 var(--ink)}
  .trophy{font-size:3rem}.congrats{font-size:1.6rem}.rating{font-size:2rem}
}
@media (max-height:620px){
  :root{--gap:8px}
  body{padding-block:8px}
  h1{font-size:1.6rem}.mascot{font-size:1.7rem}.iconbtn{width:36px;height:36px;font-size:1.1rem}
  .card{padding:12px;border-width:3px;box-shadow:0 5px 0 var(--ink)}
  .prompt{font-size:1.2rem}.tag{font-size:.8rem}
  .modes{gap:8px}
  .mode{padding:5px 10px}
  .mode .pills{gap:3px}
  .mode .ml{font-size:.72rem;border-width:1.5px}
  .brag{font-size:.85rem;padding:2px 10px}
  .mode b{font-size:1.05rem}
  .ring{width:42px;height:42px}.ring span{width:28px;height:28px;font-size:1rem}.face{font-size:1.7rem}.track{height:18px}
  .stars{min-height:22px}.star{width:22px;height:22px;font-size:1.05rem}
  .hint{font-size:.95rem}
  .btn{font-size:1.2rem;padding:7px 24px}
  .btn.plain{font-size:1rem;padding:5px 16px}
  .trophy{font-size:2.4rem}.congrats{font-size:1.35rem}.rating{font-size:1.7rem}
  .levelup{font-size:1rem;padding:6px 10px}
}

/* landscape: the side column sits next to a square board */
@media (min-aspect-ratio:5/4){
  .wrap{max-width:1100px}
  .card.split{flex-direction:row;column-gap:20px}
  /* safe center: if the column is taller than the card, overflow goes down (scrollable), not up off the top */
  .split > .side{display:flex;flex-direction:column;justify-content:center;justify-content:safe center;gap:var(--gap);flex:1 1 0;min-width:0}
  .split > .board{flex:0 1 auto;height:100%;aspect-ratio:1;min-width:0}
  .split > .mapside{display:flex;flex:1 1 0;min-width:0;justify-content:center;justify-content:safe center}
  .split > .mapside .mapbox{flex:0 1 auto;max-height:none}
  .modes{grid-template-columns:repeat(4,1fr)}
  .mode.mix,.mode.wide,.mode.themes{grid-column:auto}
  .mode{display:grid;grid-template-columns:auto minmax(0,1fr);gap:6px 10px}
  .mode .pills{grid-column:1/-1;flex-direction:row;flex-wrap:wrap;align-items:flex-start}
}
/* tablets (portrait and landscape): everything scales with the screen, menus fill it with big tap targets */
@media (min-width:700px) and (min-height:700px){
  html{font-size:clamp(17px,2.1vmin,24px)}
  .wrap{--gap:.9rem;max-width:48rem}
  .iconbtn{width:2.7rem;height:2.7rem}
  .card{padding:1.15rem;border-radius:1.75rem}
  .card.menu{flex:1 1 auto}
  .card.menu .modes{flex:1 1 auto;grid-auto-rows:1fr;gap:.9rem}
  .mode{padding:.7rem 1rem;border-radius:1.4rem}
  .mode{display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-rows:1fr auto;align-items:center;column-gap:.9rem;row-gap:.4rem}
  .mode .me{font-size:3rem;grid-row:1/-1}
  .mode .mt{align-self:end}
  .mode .pills{flex-direction:row;flex-wrap:wrap;align-items:flex-start;align-self:start;justify-content:flex-start}
  .mode b{font-size:1.4rem}
  .mode small{display:block;font-size:.95rem}
  .ring{width:3.9rem;height:3.9rem}.ring span{width:2.65rem;height:2.65rem;font-size:1.45rem}
  .track{height:1.5rem}
  .stars{min-height:2rem}.star{width:1.9rem;height:1.9rem;font-size:1.4rem}
  .grid{gap:.75rem}.grid.g4{gap:.6rem}.grid.g5{gap:.5rem}.grid.g6{gap:.45rem}
  .tile{border-radius:1.4rem}.g4 .tile{border-radius:1.15rem}.g5 .tile{border-radius:.9rem}.g6 .tile{border-radius:.75rem}
  .btn{font-size:1.6rem;padding:.75rem 2.2rem}
  .btn.plain{font-size:1.15rem;padding:.45rem 1.4rem}
  .hint{font-size:1.1rem}
  .mapbox{max-width:24rem;max-height:16rem;padding:.8rem .7rem 1.2rem}
  .map{gap:1rem .65rem}
  .cell .cs{font-size:.65rem;bottom:-.6rem}
  .overlay .card{max-width:30rem}
  footer{font-size:1rem}
}
/* landscape tablets: a wider column, and the side panel keeps a readable width next to the board */
@media (min-width:700px) and (min-height:700px) and (min-aspect-ratio:5/4){
  .wrap{max-width:80rem}
  .split > .side{min-width:min(36%,22rem)}
  .split > .board{flex:0 1 auto}
  .play .actions{flex-direction:column;align-items:stretch;text-align:center}
  .play .actions .hint{flex:none;text-align:center}
  .play .actions .btn{align-self:center}
  .modes{grid-template-columns:repeat(3,1fr)}
  .mode .pills{grid-column:2}
  .mode.themes{grid-column:1/-1}
  .split > .mapside .mapbox{max-width:26rem}
}
@media (max-height:620px) and (max-aspect-ratio:5/4){.play .tag{display:none}}
@media (max-height:420px){.split .actions{gap:6px}.trophy{font-size:1.5rem}.congrats{font-size:1.2rem}.rating{font-size:1.4rem}}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
