/* The board owns the desktop canvas; the same game stays compact on phones. */
@media(min-width:761px){
  .app-shell{max-width:1060px;padding-inline:32px}
  .header{height:72px}
  .play-area{padding:18px 26px 20px;border-radius:30px}
  .game-toolbar{margin-bottom:10px}
  .puzzle-meta{min-height:39px;margin-bottom:10px}
  .modes button{font-size:11px;padding:8px 16px}
  h2{font-size:21px;line-height:1.3;margin-top:4px}
  .puzzle-label{display:block;font-size:9px;line-height:12px}
  .board{--tile-size:min(76px,calc((100cqh - 35px) / 6));gap:7px}
  .board-row{gap:7px}
  .tile{font-size:min(36px,calc(var(--tile-size) * .55));border-radius:min(12px,calc(var(--tile-size) * .18))}
  .keyboard{gap:7px}
  .key-row{gap:5px}
  .key{height:45px;max-width:52px;font-size:16px;border-radius:9px}
  .key.wide{font-size:10px;max-width:84px}
  .keyboard.mn{--letter-gap:5px}
  .keyboard.mn .keyboard-actions .key{height:40px;font-size:12px;min-width:58px}
  .keyboard.mn .keyboard-actions [data-key=Enter]{min-width:104px}
  .keyboard.mn .keyboard-actions .game-message{font-size:10px}
  .game-message{font-size:11px}
  .legend{margin-top:17px;font-size:8px;gap:20px}
}
@media(max-width:760px){
  .app-shell{padding:0 17px;max-width:500px}
  .header{height:65px}
  .brand{font-size:25px;gap:7px}
  .brand-mark{width:31px;height:31px;border-radius:10px}
  .header-right{gap:5px}
  .languages{padding:3px;border-radius:10px}
  .languages button{padding:7px;font-size:9px}
  .header-divider{margin:0 1px}
  .icon-button{width:29px;height:31px;border-radius:10px}
  .icon-button svg{width:17px;height:17px}
  .main{display:flex;padding:15px 0 12px;min-height:0}
  .play-area{max-width:440px;max-height:none;padding:0;background:transparent;border:0;border-radius:0;box-shadow:none}
  .game-toolbar{margin-bottom:15px;min-height:36px}
  .modes{background:#ece5fa;border-radius:12px}
  .modes button{padding:8px 15px;font-size:10px}
  .puzzle-meta{margin:0 2px 14px;min-height:43px}
  .puzzle-label{font-size:8px;letter-spacing:1.4px}
  h2{font-size:18px;margin-top:5px}
  .board{--tile-size:min(59px,calc((100cqh - 30px) / 6));gap:6px}
  .board-row{gap:6px}
  .tile{font-size:25px;border-radius:9px;background:#ffffff80;border-color:#e2d8ef}
  .game-message{min-height:34px;font-size:9px}
  .keyboard{gap:6px}
  .key-row{gap:4px}
  .key{height:44px;max-width:40px;font-size:20px;border-radius:7px;background:#e9e2f5;box-shadow:0 3px 0 #d8cde9}
  .key.wide{font-size:11px;max-width:61px}
  .keyboard.mn .key{font-size:19px;height:44px}
  .keyboard.mn .key.wide{font-size:11px}
  .legend{font-size:clamp(11px,3vw,12px);gap:12px;margin-top:12px;line-height:1.35}
}
@media(max-width:760px) and (max-height:780px){
  .header{height:57px}
  .main{padding-top:11px;padding-bottom:9px}
  .game-toolbar{margin-bottom:10px;min-height:33px}
  .modes button{padding:7px 14px}
  .puzzle-meta{margin-bottom:10px;min-height:39px}
  h2{font-size:16px}
  .board{--tile-size:min(53px,calc((100cqh - 25px) / 6));gap:5px}
  .board-row{gap:5px}
  .tile{font-size:23px;border-radius:8px}
  .game-message{min-height:29px}
  .keyboard .key,.keyboard.mn .key{height:37px}
  .legend{margin-top:10px}
}
@media(max-width:760px) and (max-height:650px){
  .header{height:47px}
  .main{padding:7px 0}
  .game-toolbar{min-height:30px;margin-bottom:8px}
  .modes{padding:3px}
  .modes button{padding:6px 13px}
  .puzzle-meta{margin-bottom:8px;min-height:35px}
  .puzzle-label{display:block;font-size:7px;line-height:9px}
  h2{font-size:15px;line-height:19px;margin-top:4px}
  .board{--tile-size:min(46px,calc((100cqh - 20px) / 6));gap:4px}
  .board-row{gap:4px}
  .tile{font-size:21px;border-radius:7px}
  .game-message{min-height:25px;font-size:8px}
  .keyboard{gap:5px}
  .keyboard .key,.keyboard.mn .key{height:32px}
  .legend{margin-top:8px}
}
@media(max-width:370px){
  .app-shell{padding-inline:10px}
  .header-right{gap:3px}
  .header-divider{display:none}
  .brand{font-size:23px;gap:6px}
  .brand-mark{width:29px;height:29px}
  .languages button{padding-inline:6px}
  .key-row{gap:3px}
  .key{font-size:18px}
  .keyboard.mn{--letter-gap:3px}.keyboard.mn .key{font-size:17px}
  .legend{gap:8px}
}
@media(min-width:761px) and (max-height:840px){
  .header{height:63px}
  .main{padding-block:12px}
  .play-area{padding:15px 18px}
  .game-toolbar{margin-bottom:9px}
  .puzzle-meta{margin-bottom:10px}
  .key{height:38px}
  .keyboard.mn .keyboard-actions .key{height:36px}
  .game-message{min-height:27px}
  .legend{margin-top:14px}
}
@media(min-width:761px) and (max-height:650px){.legend{display:none}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}.confetti{display:none}}

@media(max-width:760px){
  .keyboard.mn .keyboard-actions .key{height:38px;font-size:11px}
  .keyboard.mn .keyboard-actions .game-message{font-size:8px}
  .keyboard.mn .keyboard-actions .game-message button{font-size:9px;padding:4px 0}
}
@media(max-width:760px) and (max-height:650px){
  .keyboard-actions{gap:7px;margin-top:2px}
  .keyboard.mn .keyboard-actions .key{height:34px;min-width:45px;padding-inline:11px;font-size:10px}
  .keyboard.mn .keyboard-actions [data-key=Enter]{min-width:76px}
}

/* Tile text must shrink with the board inside shorter safe-area viewports. */
@media(max-width:760px){.tile{font-size:min(25px,calc(var(--tile-size) * .55));border-radius:min(9px,calc(var(--tile-size) * .17))}}

/* A rotated phone needs two columns so readable keys do not consume the board. */
@media(orientation:landscape) and (min-width:480px) and (max-height:500px) and (max-width:950px){
  .app-shell{max-width:900px;padding-inline:12px}
  .header{height:43px}
  .brand{font-size:23px}.brand-mark{width:29px;height:29px}
  .main{padding:7px 0}
  .play-area{display:grid;grid-template-columns:minmax(0,1fr) minmax(300px,1.5fr);grid-template-rows:auto auto minmax(0,1fr) auto auto;column-gap:16px;row-gap:4px;max-width:none;padding:0;border:0;background:none;box-shadow:none}
  .board-wrap{grid-column:1;grid-row:1 / -1;margin:0}
  .play-area:has(>.keyboard.mn) .board-wrap{margin:0}
  .board{--tile-size:min(48px,calc((100cqh - 20px) / 6),calc((100cqw - 16px) / 5));gap:4px}.board-row{gap:4px}
  .tile{font-size:calc(var(--tile-size) * .55);border-radius:min(8px,calc(var(--tile-size) * .17))}
  .game-toolbar{grid-column:2;grid-row:1;min-height:27px;margin:0}
  .modes{padding:3px}.modes button{font-size:10px;padding:5px 11px}
  .puzzle-meta{grid-column:2;grid-row:2;min-height:25px;margin:0}
  .puzzle-label{display:none}h2{font-size:15px;line-height:19px;margin:0}
  .play-area>.feedback-slot{grid-column:2;grid-row:3}
  .play-area>.feedback-slot .game-message{min-height:16px;font-size:10px}
  .keyboard{grid-column:2;grid-row:4;gap:5px}
  .keyboard .key,.keyboard.mn .key{height:34px;font-size:18px}
  .keyboard .key.wide{font-size:11px}
  .keyboard.mn{--letter-gap:3px}
  .keyboard-actions{margin-top:1px;gap:7px}
  .keyboard.mn .keyboard-actions .key{height:32px;min-width:45px;font-size:11px;padding-inline:10px}
  .keyboard.mn .keyboard-actions [data-key=Enter]{min-width:76px}
  .legend{grid-column:2;grid-row:5;display:flex;font-size:11px;line-height:1.35;margin:3px 0 0;gap:8px}
  .race-active .play-area{row-gap:2px}
  .race-active .race-players{margin-top:3px}
  .race-active .race-player{padding:5px 6px}
  .race-active .race-progress{margin-top:4px}
  #race-panel{grid-column:2;grid-row:1 / 3;margin:0}
  #race-result{grid-column:2;grid-row:3;margin:0}
}
