/* Play page layout (index.html): one card —
   Daily | Practice as underlined tabs (the same as the tournament's Today | Hall of fame),
   the board, the hint line (New word in Practice), the keyboard and the legend. The tools —
   records, daily challenge, word language, play with friends — live in the header
   (src/play-tools.css), away from the keys. */
.game-toolbar{gap:10px}
.play-area .game-toolbar>.modes{flex:1;display:flex;gap:6px;padding:0;border-radius:0;background:transparent;border-bottom:1px solid #e7def6}
.play-area .modes button{flex:1;min-width:0;min-height:44px;margin-bottom:-1px;padding:8px 10px;border:0;border-bottom:3px solid transparent;border-radius:12px 12px 0 0;background:transparent;box-shadow:none;color:#6d5885;font:800 14px/1.3 Manrope,'Segoe UI',sans-serif;letter-spacing:-.2px;white-space:nowrap;cursor:pointer;touch-action:manipulation;transition:color .18s,border-color .18s,background .18s}
.play-area .modes button:hover:not(:disabled){color:#5b2fbf;background:#f6f1ff}
.play-area .modes button.active{color:#5b2fbf;border-bottom-color:var(--purple);background:transparent;box-shadow:none}
.play-area .modes button:focus-visible{outline:3px solid #bca3ff;outline-offset:-3px}
#word-language{display:flex;align-items:stretch;gap:6px;min-width:0}
.word-language-picker{display:flex;min-width:0}
#word-language .language-picker{min-height:46px;padding:5px 10px 5px 5px;gap:8px;border-radius:14px}
#word-language .language-mark{width:32px;height:32px;font-size:17px}
#word-language .language-picker-copy strong{font-size:14px}
.word-language-leave{min-height:40px;padding:6px 10px;border-radius:11px;background:#f3eefb;color:#5d3abd;font-size:12px;font-weight:800;white-space:nowrap}

  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;border:0;border-radius:12px;background:transparent;box-shadow:none;
  color:#5a4672;font:800 11px/1.25 Manrope,'Segoe UI',sans-serif;letter-spacing:0;text-decoration:none;transform:none;cursor:pointer}
/* Records: the trophy over "rank · points" (labels stay in the button's accessible name). */
/* Challenge: the target over today's progress. */
/* Word language: its letter over its name. */
/* Play with friends: the icon over its name. */

/* Practice: New word takes the hint's place on the line above the keys (between Check and Delete on
   the Mongolian keyboard); a word notice still shows over it. */
.next-word{display:inline-flex;align-items:center;justify-content:center;gap:5px;min-height:32px;padding:5px 12px;border:1px solid #dccdfa;border-radius:11px;background:#f6f1ff;color:#5b2fbf;font:800 12px/1.2 Manrope,'Segoe UI',sans-serif;white-space:nowrap;cursor:pointer}
.next-word-icon{font-size:15px;line-height:1}
.feedback-slot{display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:nowrap}
.feedback-slot>*{min-width:0}
.feedback-slot.has-new-word .game-message{display:none}
.feedback-slot:has(.word-feedback.visible) #new-game{visibility:hidden}
.keyboard-actions .next-word{min-height:30px;padding:4px 9px;font-size:11px}
/* On the Mongolian keyboard the line sits between Check and Delete: one row, compact buttons. */
.keyboard.mn .keyboard-actions .feedback-slot{display:flex;flex-direction:row;align-items:center;justify-content:center;gap:6px}
.keyboard.mn .keyboard-actions .feedback-slot .game-message button{font-size:10px;padding:4px 0;white-space:nowrap}
.keyboard.mn .keyboard-actions .next-word{padding:4px 7px;font-size:10px;gap:4px}

/* In a friends' room the Daily | Practice tabs step aside; the header keeps every tool (records,
   challenge, the room's word language, invite) and adds the room's chat and Leave. */
.race-active .game-toolbar{display:none!important}

/* Board: tiles also fit the width, so six Korean columns never overflow a phone. */
.board{--cols:5;--tile:min(var(--tile-size),calc((100cqw - (var(--cols) - 1) * 7px) / var(--cols)))}
.board .tile{width:var(--tile);height:var(--tile)}
.board[data-cells="6"] .tile{font-size:min(26px,calc(var(--tile) * .5))}
.board[data-cells="6"],.keyboard.ko,.word-preview,.answer-word,.help-example,.korean-example{font-family:Manrope,"Malgun Gothic","Apple SD Gothic Neo","Noto Sans KR",sans-serif}

/* Korean keyboard: 10 / 9 + Shift / Enter + 7 + Delete. */
.keyboard.ko .key-row{gap:4px}
.keyboard.ko .key{font-size:17px;font-weight:700}
.keyboard.ko .key.wide{flex:1.5;font-size:9px}
.keyboard.ko .key.enter{flex:2.3;max-width:90px;background:var(--purple);color:#fff;box-shadow:0 3px 0 var(--purple-dark);letter-spacing:0}
/* English keyboard: the menu is always Mongolian, so Enter reads "ШАЛГАХ" (wider than "ENTER");
   a little more room keeps it unclipped on 320 px phones. */
.keyboard.en .key.enter{flex:2;letter-spacing:0}
.key.shift.active{background:#cdb6ff;color:#4b26b0;box-shadow:0 3px 0 #b39be6}
.key.shift.active svg{fill:currentColor}

/* Japanese: Manrope has no kana, so Japanese fonts follow it; lang="ja" on the board, keys,
   typed word and answer gives kana and kanji their Japanese shapes. */
.board:lang(ja),.keyboard.ja,.word-preview:lang(ja),.answer-word:lang(ja),.help-example:lang(ja),.korean-example:lang(ja){font-family:Manrope,"Hiragino Sans","Hiragino Kaku Gothic ProN","Yu Gothic","Meiryo","Noto Sans JP",sans-serif}
/* Japanese keyboard: two full pages of the gojūon chart (every row fills the width: ten
   columns on page 1, six on page 2), then 「゛゜小 | ー | ШАЛГАХ | ⌫」. Six rows, so each row is
   a little lower. */
.keyboard.ja{--kana-gap:4px;--kana-key:36px;gap:5px}
.keyboard.ja .key-row{gap:var(--kana-gap)}
.keyboard.ja .key-row>.key{flex:1 1 0;min-width:0;max-width:none;height:var(--kana-key)}
.keyboard.ja .key{font-size:18px;font-weight:700}
.keyboard.ja .kana-actions>.key{flex:1 1 0;font-size:11px}
.keyboard.ja .kana-actions>.key.enter{flex:1.5;background:var(--purple);color:#fff;box-shadow:0 3px 0 var(--purple-dark);letter-spacing:0}
/* #keyboard: above the phone-wide key sizes in input-profile.css (an id selector). */
#keyboard.ja .kana-actions>.key.shift{font-size:18px;letter-spacing:1px}
#keyboard.ja .kana-actions>.key.kana-letter{font-size:var(--kana-font,18px)}
@media(min-width:761px){.keyboard.ja{--kana-key:40px}}
@media(min-width:761px) and (max-height:840px){.keyboard.ja{--kana-key:34px}}
@media(max-width:760px){.keyboard.ja{--kana-key:37px}}
@media(max-width:760px) and (max-height:780px){.keyboard.ja{--kana-key:32px;gap:4px}}
@media(max-width:760px) and (max-height:650px){.keyboard.ja{--kana-key:28px;--kana-gap:3px;--kana-font:16px;gap:3px}.keyboard.ja .key{font-size:16px}}
@media(max-width:370px){.keyboard.ja{--kana-gap:3px;--kana-font:16px}.keyboard.ja .key{font-size:16px}}
@media(orientation:landscape) and (min-width:480px) and (max-height:500px) and (max-width:950px){.keyboard.ja{--kana-key:26px;gap:3px}}

/* Chinese: Manrope has no Han, so Simplified Chinese fonts follow it; lang="zh-Hans" on the
   board, keys, typed word, answer and examples gives the characters their mainland shapes. */
.board:lang(zh),.keyboard.zh,.word-preview:lang(zh),.answer-word:lang(zh),.help-example:lang(zh),.korean-example:lang(zh){font-family:Manrope,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","Noto Sans SC",sans-serif}
/* Chinese keyboard: the word's own 20 keys in four rows of five (the Han character over its
   pinyin), then 「ШАЛГАХ | ⌫」. Five rows of tall keys: every key is a 44 px touch target. */
.keyboard.zh{--han-key:52px;--han-gap:6px;gap:var(--han-gap)}
.keyboard.zh .key-row{gap:var(--han-gap)}
#keyboard.zh .key.han-key{flex:1 1 0;min-width:0;max-width:none;height:var(--han-key);min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;padding:0 2px;font-size:22px}
.keyboard.zh .key-char{font-size:1em;line-height:1.05;font-weight:700}
.keyboard.zh .key-pinyin{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font:600 11px/1.15 Manrope,"Segoe UI",Arial,sans-serif;letter-spacing:0;text-transform:none;opacity:.78}
.keyboard.zh .key.han-key.is-blank{background:#f1ecf9;box-shadow:none}
#keyboard.zh .han-actions>.key{flex:1 1 0;max-width:none;height:var(--han-action,46px);min-height:0;font-size:12px;letter-spacing:0}
#keyboard.zh .han-actions>.key.enter{flex:2;background:var(--purple);color:#fff;box-shadow:0 3px 0 var(--purple-dark)}
@media(min-width:761px){.keyboard.zh{--han-key:54px;width:min(100%,520px);justify-self:center;margin-inline:auto}}
@media(min-width:761px) and (max-height:840px){.keyboard.zh{--han-key:46px;--han-action:40px}}
@media(max-width:760px) and (max-height:780px){.keyboard.zh{--han-key:47px;--han-action:42px;--han-gap:5px}}
@media(max-width:760px) and (max-height:650px){.keyboard.zh{--han-key:44px;--han-action:40px;--han-gap:4px}#keyboard.zh .key.han-key{font-size:20px}.keyboard.zh .key-pinyin{font-size:10px}}
@media(max-width:370px){.keyboard.zh{--han-gap:4px}.keyboard.zh .key-pinyin{font-size:10px}}
@media(orientation:landscape) and (min-width:480px) and (max-height:500px) and (max-width:950px){.keyboard.zh{--han-key:34px;--han-action:30px;--han-gap:3px}#keyboard.zh .key.han-key{font-size:17px;flex-direction:row;gap:4px}}
/* The answer's pinyin under it (result card, rules example). */
.answer-pinyin{display:block;margin:2px 0 0;font-size:13px;line-height:1.4;letter-spacing:.5px;color:var(--muted);white-space:nowrap}

/* Korean entry row: the word being typed as syllables, and the rules link. */
.word-entry{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:33px;padding:0 2px}
.feedback-slot:has(.word-entry:not([hidden])) .game-message{display:none}
.word-preview{font-size:21px;font-weight:800;color:#6a45c8;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.word-rules{display:inline-flex;align-items:center;gap:6px;min-height:32px;padding:4px 2px;background:transparent;color:#7a6c90;font-size:11px;font-weight:700;white-space:nowrap}
.word-rules-icon{display:grid;place-items:center;width:16px;height:16px;border:1.5px solid currentColor;border-radius:50%;font-size:10px;font-weight:800;font-style:normal}
.ime{position:fixed;left:0;top:0;width:1px;height:1px;opacity:0;pointer-events:none;border:0;padding:0}

/* Korean help and results. */
.answer-jamo{margin:2px 0 0;font-size:12px;line-height:1.4;letter-spacing:2px;color:var(--muted);white-space:nowrap}
.help-rules{margin:16px 0 4px;padding-left:18px;font-size:12px;line-height:1.7;color:var(--muted)}
.korean-example{display:flex;flex-direction:column;align-items:flex-start;gap:2px;margin:6px 0}
.korean-example-word{font-size:28px;font-weight:800;color:#6a45c8}
.korean-example .help-example{margin:6px 0}

/* Wide screens: the same order in one grid column, the board taking the free height. */
@media(min-width:761px) and (min-height:501px), (min-width:951px){
  .play-area{display:grid;max-width:700px;grid-template-columns:auto minmax(0,1fr) auto auto auto;
    grid-template-rows:auto auto auto minmax(0,1fr) auto auto auto;column-gap:12px;
    grid-template-areas:"modes modes modes modes modes" "race race race race race" "result result result result result"
      "board board board board board" "feedback feedback feedback feedback feedback" "keyboard keyboard keyboard keyboard keyboard" "legend legend legend legend legend"}
  .game-toolbar{display:contents}
  .game-toolbar>.modes{grid-area:modes;align-self:end;margin-bottom:10px}
  .play-area .modes button{min-height:40px}
  #race-panel{grid-area:race}
  #race-result{grid-area:result}
  .board-wrap{grid-area:board}
  .play-area>.feedback-slot{grid-area:feedback}
  .keyboard{grid-area:keyboard}
  .legend{grid-area:legend}
  .race-active #race-panel{grid-row:2;grid-column:1 / -1}
}
@media(max-width:370px){
  .game-toolbar{gap:6px}
  #word-language .language-picker{padding-right:6px;gap:6px}
  #word-language .language-mark{width:28px;height:28px;font-size:15px}
  #word-language .language-picker-copy small{font-size:10px}
  #word-language .language-picker-copy strong{font-size:13px}
  .keyboard.ko .key{font-size:15px}
  .keyboard.ko .key-row{gap:3px}
}
@media(max-height:700px){
  .play-area .modes button{min-height:40px}
  .word-entry{min-height:28px}.word-preview{font-size:18px}
}
/* Short screens: the picker drops its caption (still in its accessible name). */
@media(max-height:650px){
  .play-area .modes button{min-height:36px;padding-block:6px}
  #word-language .language-mark{width:26px;height:26px;font-size:14px}
  #word-language .language-picker-copy small{display:none}
  .word-language-leave{min-height:34px}
}
@media(orientation:portrait) and (max-width:600px) and (max-height:600px){
  .header{height:39px}.main{padding-block:4px}.app-shell>.game-page-nav{min-height:30px;margin-top:3px}
  /* Room for the tournament's live/countdown badge inside those 30 px: the tabs never grow when it appears. */
  .app-shell>.game-page-nav button{padding-block:1px}
  .game-toolbar{min-height:28px;margin-bottom:5px}
  .play-area .modes button{min-height:32px;padding-block:4px;font-size:13px}
  .legend{margin-top:6px}
}
/* Short phones keep a readable board under the two control rows: the keys give up a few
   pixels first, and in a room the race title (it only repeats the rules) steps aside while
   playing, as it already does below 650px; the round clock stays. */
@media(max-width:760px) and (max-height:700px){html[data-race-phase=playing] .race-title{display:none}html[data-race-phase=playing] .race-status{justify-content:flex-end}}
@media(max-width:600px) and (min-height:651px) and (max-height:700px){#keyboard .key{min-height:40px}}
@media(orientation:portrait) and (max-width:600px) and (max-height:600px){
  #keyboard .key{min-height:34px}
  .play-area:has(>.keyboard.mn) .board-wrap{margin-bottom:6px}
  .word-language-leave{min-height:30px}
}
/* A finished race keeps the board's gap above the keys small, as race.css intends below 780px
   (the Mongolian keyboard's general gap rule otherwise wins on specificity). */
@media(max-height:780px){html[data-race-phase=finished] .play-area:has(>.keyboard.mn) .board-wrap{margin-bottom:4px}}
/* Short desktop windows (e.g. 800×600) likewise trade a little key height for the board. */
@media(min-width:761px) and (min-height:501px) and (max-height:650px){
  .key{height:36px}
  .keyboard.mn .keyboard-actions .key{height:34px}
  .play-area:has(>.keyboard.mn) .board-wrap{margin-bottom:6px}
  #race-panel{margin-bottom:4px}
  .header{height:56px}
  .game-toolbar>.modes{margin-bottom:6px}
  .play-area .modes button{min-height:36px}
  /* The finished race's result fits on one line: who won, the answer, Rematch. */
  html[data-race-phase=finished] .race-result-details{flex-direction:row;align-items:center;gap:10px}
  html[data-race-phase=finished] .race-answer{margin:0}
}
/* A rotated phone: the records HUD over the board on the left; the controls, feedback and
   keyboard on the right (in a room the locked picker takes the HUD's place). */
@media(orientation:landscape) and (min-width:480px) and (max-height:500px) and (max-width:950px){
  .header{height:37px}.app-shell>.game-page-nav{min-height:32px;margin-top:2px}
  /* The tournament's live/countdown badge fits those 32 px: the tabs never grow when it appears. */
  .app-shell>.game-page-nav button{padding-block:1px}
  /* The feedback row keeps its own height so a word notice never sits on the keys. */
  .play-area{grid-template-rows:auto auto minmax(18px,1fr) auto auto}
  .play-area .modes button{min-height:30px;padding-block:3px;font-size:13px}
  #word-language .language-mark{width:24px;height:24px;font-size:13px}
  .next-word{min-height:28px;padding-block:3px}
  .play-area>.feedback-slot{min-height:18px}
  /* Mongolian word notices live in the keyboard's action row, so that row only keeps what it holds (a race result). */
  .play-area:has(>.keyboard.mn){grid-template-rows:auto auto minmax(auto,1fr) auto auto}
  /* A group lobby stacks its roster and match settings over the keys: tighter spacing there
     keeps the keys (≥30 px) on screen. */
  html[data-race-phase=waiting] .race-group-active #race-panel{margin-bottom:2px}
  html[data-race-phase=waiting] #race-panel[data-group=true][data-phase=waiting]{row-gap:1px}
  /* A finished race's result is one line beside the keys: who won, the answer, Rematch.
     The "Correct answer" label stays for screen readers. */
  html[data-race-phase=finished] .race-result-details{flex-direction:row;align-items:center;gap:8px}
  html[data-race-phase=finished] .race-answer{margin:0}
  html[data-race-phase=finished] .race-answer-label{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
}
/* The shortest rotated phones (320 px tall): the Mongolian keyboard's fourth row would push the
   legend below the screen, so its keys give up 4 px each (still 30 px tall). */
@media(orientation:landscape) and (min-width:480px) and (max-height:360px) and (max-width:950px){
  #keyboard.mn{gap:3px}
  #keyboard.mn .key{height:30px;min-height:30px}
}
