:root{--bg:#eee9df;--panel:#f7f3eb;--line:#d4cec2;--text:#25231f;--muted:#7f786d;--accent:#5f78a8;--accent2:#a8b4c8;--paper:#fffdf8;--ink:#201e1b}
*{box-sizing:border-box}html,body{margin:0;min-height:100%;background:var(--bg);color:var(--text);font-family:Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif}
body{overflow-x:hidden}.app{max-width:900px;margin:auto;padding:16px}
header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:14px;gap:10px}h1{font-size:34px;letter-spacing:.06em;line-height:1;margin:0;font-weight:900}.sub{color:var(--muted);font-size:11px;letter-spacing:.12em;text-transform:uppercase;margin-top:5px}
.headerBtns{display:flex;gap:6px}.ghost{background:#f7f3eb;color:var(--text);border:1px solid var(--line);border-radius:9px;padding:8px 10px;font-weight:700}
.meter{display:grid;grid-template-columns:1fr auto 1fr;gap:12px;align-items:end;background:var(--panel);border:1px solid var(--line);border-radius:13px;padding:12px}.player .label{font-size:11px;font-weight:800;letter-spacing:.07em}.player .label span{color:var(--muted);margin-left:5px}.p2{text-align:right}.bar{height:7px;background:#ddd7cc;border-radius:99px;overflow:hidden;margin-top:6px}.bar i{display:block;height:100%;width:0;background:#4b4a46;transition:width .2s}.p2 .bar i{margin-left:auto}.chance{font-size:19px;font-weight:900;margin-top:5px}.vs{font-size:8px;color:var(--muted);letter-spacing:.12em;padding-bottom:6px}
.wordStage{position:relative;width:min(100%,620px);aspect-ratio:1/1;margin:14px auto;background:var(--paper);border:1px solid #d9d5ca;border-radius:14px;overflow:hidden;padding:14px 14px 94px}.wordStream{width:100%;height:100%;display:grid;grid-template-columns:1fr 1px 1fr;align-items:stretch;color:var(--ink)}.emptyStage{grid-column:1/-1;align-self:center;justify-self:center;font-size:13px;letter-spacing:.14em;color:#9c978d;font-weight:800}.wordLane{min-width:0;display:flex;flex-direction:column;padding:2px 14px}.laneLabel{font-size:9px;letter-spacing:.14em;font-weight:800;color:#9d988e;margin-bottom:8px}.p2Lane .laneLabel{text-align:right}.laneWords{flex:1;display:flex;flex-direction:column;justify-content:flex-end;gap:6px}.playedWord{font-weight:850;letter-spacing:.01em;line-height:1.02;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.p1Lane .playedWord{text-align:left}.p2Lane .playedWord{text-align:right}.playedWord.current{font-size:34px;color:#17191c}.playedWord.prev1{font-size:25px;color:#46505e}.playedWord.prev2{font-size:20px;color:#747b83}.playedWord.older{font-size:16px;color:#aaa59c}.lockedChar{color:#315fae}.laneDivider{width:1px;background:#ded9cf}.laneEmpty{color:#bbb5aa;font-size:22px}.playedWord span{display:inline-block}.typedChar{opacity:0;transform:translateY(2px);animation:typeOn .13s steps(1,end) forwards}@keyframes typeOn{to{opacity:1;transform:none}}
.directEntry{position:absolute;left:14px;right:14px;bottom:12px;padding-top:8px;border-top:1px solid #d7d2c8}.turnLine{display:flex;justify-content:space-between;font-size:8px;font-weight:800;letter-spacing:.08em;color:#77736b}.turnLine #status{color:#9a958c;font-weight:600}.directTypeRow{display:flex;align-items:center;gap:8px;margin-top:4px}.directWord{flex:1;min-width:0;color:#17191c;font-size:24px;font-weight:900;letter-spacing:.025em;line-height:1.15;white-space:nowrap;overflow:hidden}.directWord.empty{color:#aaa59c;font-size:12px;letter-spacing:.08em}.cursor{display:inline-block;margin-left:2px;animation:blink .85s steps(1,end) infinite}@keyframes blink{50%{opacity:0}}.inlineDelete{width:34px;height:30px;border:1px solid #d3cec4;border-radius:7px;background:#ebe7dd;color:#3d3a35;font-size:15px;font-weight:900;flex:none}.help{font-size:8px;color:#9a958c;margin-top:3px}
.keyboard{max-width:620px;margin:auto}.row{display:flex;justify-content:center;gap:5px;margin:5px 0}.key{width:9.2%;max-width:55px;min-width:30px;height:42px;border-radius:7px;border:1px solid var(--line);display:flex;align-items:center;justify-content:center;font-weight:900;position:relative;cursor:pointer;user-select:none;touch-action:manipulation}.key.need{background:#fffdf8;color:#25231f;border-color:#d8d2c7}.key.lockedNeed{background:#c9d0dc;color:#39465d;border-color:#aab4c4}.key.earned{background:#e4dfd6;color:#7c766c}.key.locked{background:#d6d8dc;color:#8c9199;border-color:#c3c7cd}.key.lockedNeed:after,.key.locked:after{content:"LOCK";position:absolute;font-size:6px;bottom:2px;letter-spacing:.04em}.key.action{width:auto;min-width:70px;padding:0 14px;background:#e1e5eb;color:#39465d;border-color:#c4ccd8}.key.playKey{background:var(--accent);color:#fff;border-color:var(--accent);min-width:95px}.key.disabled{opacity:.35;pointer-events:none}.legend{display:flex;justify-content:center;gap:12px;flex-wrap:wrap;color:var(--muted);font-size:9px;margin-top:7px}.legend b{width:9px;height:9px;border-radius:2px;display:inline-block;margin-right:3px;vertical-align:-1px}.legend .need{background:#f2efe5}.legend .lockedNeed{background:var(--accent2)}.legend .earned{background:#e4dfd6}.legend .locked{background:#d6d8dc;border:1px solid #c3c7cd}
.winner{position:fixed;inset:0;background:rgba(0,0,0,.82);display:flex;align-items:center;justify-content:center;z-index:10}.winnerBox{background:var(--panel);border:1px solid var(--line);border-radius:18px;padding:30px;text-align:center;max-width:340px}.winnerBox h2{font-size:32px;margin:4px 0}.winnerBox button{margin-top:16px;border:0;border-radius:9px;padding:11px 18px;background:var(--accent);font-weight:900}

@media(max-width:600px){
html,body{height:100%;overflow:hidden}body{min-height:100dvh}.app{height:100dvh;max-height:100dvh;overflow:hidden;padding:8px;display:flex;flex-direction:column}
header{margin-bottom:7px}h1{font-size:24px}.sub{font-size:8px;margin-top:3px}.ghost{padding:5px 7px;font-size:9px}.meter{padding:7px 9px;gap:7px;border-radius:10px}.player .label{font-size:8px}.bar{height:4px;margin-top:3px}.chance{font-size:14px;margin-top:2px}.vs{font-size:6px;padding-bottom:3px}
.wordStage{height:auto;min-height:0;flex:1;margin:7px 0;padding:10px;border-radius:11px}.playedWord.current{font-size:29px}.playedWord.prev1{font-size:22px}.playedWord.prev2{font-size:18px}.playedWord.older{font-size:14px}.wordLane{padding:2px 8px}.laneLabel{font-size:7px;margin-bottom:4px}
.turnPanel{padding:7px 8px;margin-bottom:5px;border-radius:10px}.turnLine{font-size:8px}.wordEntry{margin-top:5px}.wordDisplay{min-height:36px;font-size:18px;padding:5px 42px 5px 8px}.wordDisplay.empty{font-size:10px}.inlineDelete{right:4px;width:31px;height:28px;font-size:15px}.help{font-size:8px;margin-top:3px}
.row{gap:3px;margin:3px 0}.key{height:32px;min-width:0;border-radius:5px;font-size:11px}.key.action{min-width:56px;height:30px;padding:0 9px}.key.playKey{min-width:76px}.legend{gap:6px;font-size:7px;margin-top:3px}.legend b{width:7px;height:7px}
}
@media(max-width:380px){.help,.legend{display:none}.key{height:29px}.wordDisplay{min-height:33px}.playedWord.current{font-size:30px}}

html,body,.app,.turnPanel,.wordEntry,.wordDisplay,.inlineDelete,.keyboard,.key{
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
}
.inlineDelete,.key,.ghost{user-select:none;-webkit-user-select:none}

.needLine{font-size:7px;color:var(--muted);margin-top:4px;line-height:1.25;min-height:18px}
.needLine span{color:#c8cdd3;font-weight:700;letter-spacing:.03em}
.p2 .needLine{text-align:right}
.key small{position:absolute;right:3px;top:2px;font-size:7px;line-height:1;color:#d7e1f2}
.rulesModal{display:none;position:fixed;inset:0;background:rgba(0,0,0,.78);z-index:20;align-items:center;justify-content:center;padding:20px}
.showRules .rulesModal{display:flex}.rulesCard{position:relative;max-width:390px;background:var(--panel);border:1px solid var(--line);border-radius:16px;padding:24px;color:var(--text)}
.rulesCard h2{font-size:30px;margin:5px 0 14px}.rulesCard p{font-size:14px;line-height:1.45;color:#d5d9df}.rulesClose{position:absolute;right:10px;top:8px;border:0;background:transparent;color:var(--text);font-size:28px}
@media(max-width:600px){.needLine{font-size:6px;margin-top:2px;min-height:13px}.key small{font-size:6px}}

@media(max-width:600px){
  .wordStage{width:min(100%,calc(100dvh - 285px));max-width:100%;margin:7px auto;padding:9px 9px 82px;border-radius:11px;flex:none}
  .wordLane{padding:2px 8px}.laneLabel{font-size:7px;margin-bottom:4px}
  .playedWord.current{font-size:28px}.playedWord.prev1{font-size:21px}.playedWord.prev2{font-size:17px}.playedWord.older{font-size:13px}
  .boardEntry{left:6px;right:6px;bottom:6px;padding:5px 6px}
}

.playedWord{overflow:visible;text-overflow:clip}
.typedChar{opacity:1;animation:letterFlash .18s ease both}
@keyframes letterFlash{from{opacity:0;transform:translateY(1px)}to{opacity:1;transform:none}}
@media(max-width:600px){
  .directEntry{left:9px;right:9px;bottom:7px;padding-top:6px}
  .directWord{font-size:20px}
  .directWord.empty{font-size:10px}
}

.passModal{display:none;position:fixed;inset:0;background:rgba(13,16,20,.96);z-index:25;align-items:center;justify-content:center;padding:20px}
.showPass .passModal{display:flex}
.passCard{width:min(360px,90vw);text-align:center;background:var(--panel);border:1px solid var(--line);border-radius:16px;padding:28px 22px}
.passCard h2{font-size:28px;margin:8px 0}.passCard p{color:var(--muted);font-size:13px}.passCard button{margin-top:14px;border:0;border-radius:10px;padding:12px 22px;background:var(--accent);color:#0b1220;font-weight:900}

header h1{color:#25231f}
.meter{box-shadow:0 1px 0 rgba(80,70,55,.03)}
.wordStage{box-shadow:0 8px 30px rgba(80,70,55,.06)}
.directEntry{background:rgba(255,253,248,.94)}
.inlineDelete{background:#ebe6dc;color:#4b4741;border-color:#d2ccc0}
.rulesCard,.passCard,.winnerBox{background:#f8f4ec;color:#25231f}
.rulesCard p,.passCard p{color:#746e64}
.rulesClose{color:#25231f}
.winner{background:rgba(74,68,60,.55)}
.passModal,.rulesModal{background:rgba(74,68,60,.6)}

.meter.multi{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;align-items:stretch}
.multiPlayerCard{background:#fffdf8;border:1px solid var(--line);border-radius:9px;padding:7px;min-width:0}
.multiPlayerCard.active{box-shadow:inset 0 0 0 1px var(--accent)}
.multiPlayerCard .needLine{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.multiStream{display:flex!important;flex-direction:column;justify-content:flex-end;gap:5px;padding:3px 8px}
.multiMove{display:flex;align-items:baseline;gap:10px;opacity:.48;min-height:26px}
.multiMove.current{opacity:1}
.multiPlayer{width:22px;flex:none;font-size:9px;font-weight:900;letter-spacing:.08em;color:#8d877d}
.multiWord{font-size:21px;font-weight:850;letter-spacing:.015em;white-space:nowrap;color:#4e4b45}
.multiMove.current .multiWord{font-size:29px;color:#201e1b}
.multiWord span{display:inline-block}
@media(max-width:600px){
 .meter.multi{gap:5px;padding:7px}
 .multiPlayerCard{padding:5px}
 .multiPlayerCard .label{font-size:8px}
 .multiPlayerCard .needLine{font-size:7px}
 .multiMove{min-height:22px;gap:7px}
 .multiWord{font-size:17px}.multiMove.current .multiWord{font-size:24px}
}

.inlinePlay{height:30px;border:1px solid var(--accent);border-radius:7px;background:var(--accent);color:#fff;font-size:11px;font-weight:900;padding:0 12px;flex:none;touch-action:manipulation}
.inlinePlay:active{transform:translateY(1px)}

.rulesKeyboard{max-width:430px;text-align:left}
.rulesKeyboard h2{margin:4px 0 12px;font-size:30px;letter-spacing:.05em}
.rulesKeys{display:flex;gap:5px;justify-content:center;margin:8px 0 16px}
.rulesKeys span,.ruleKey,.playChip{display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--line);border-radius:7px;background:#fffdf8;color:#25231f;font-weight:900;box-shadow:0 2px 0 #d8d2c7}
.rulesKeys span{width:34px;height:34px;font-size:13px}
.ruleGrid{display:grid;gap:9px}
.ruleItem{display:grid;grid-template-columns:46px 1fr;gap:10px;align-items:center;padding:9px;border:1px solid var(--line);border-radius:10px;background:#fffdf8}
.ruleKey{width:42px;height:42px;font-size:12px}
.ruleKey.earnedRule{background:#e4dfd6;color:#7c766c}
.ruleKey.lockedRule{background:#c9d0dc;color:#39465d;border-color:#aab4c4}
.ruleKey.repeatRule{background:#ebe6dc;color:#4b4741}
.ruleItem strong,.winRule strong{font-size:11px;letter-spacing:.05em}
.ruleItem p,.winRule p{margin:3px 0 0;font-size:10px;line-height:1.35;color:#746e64}
.winRule{display:grid;grid-template-columns:58px 1fr;gap:10px;align-items:center;margin-top:10px;padding:11px;border-radius:11px;background:#e8edf5;border:1px solid #c9d2e1}
.playChip{width:54px;height:38px;background:var(--accent);color:#fff;border-color:var(--accent);box-shadow:0 2px 0 #48628f}
@media(max-width:600px){
 .rulesKeyboard{padding:22px 16px}
 .rulesKeys span{width:30px;height:30px}
 .ruleItem{grid-template-columns:40px 1fr;padding:8px}
 .ruleKey{width:36px;height:36px}
}

.keyboard{max-width:680px}
.row{gap:7px;margin:7px 0}
.key{width:9.35%;max-width:61px;min-width:32px;height:48px;border-radius:8px;font-size:15px}
@media(max-width:600px){
  .keyboard{max-width:100%}
  .row{gap:4px;margin:5px 0}
  .key{width:9.45%;min-width:0;max-width:none;height:46px;font-size:14px}
}

.rankBtn{min-width:86px;justify-content:center}
.rankModal{display:none;position:fixed;inset:0;background:rgba(74,68,60,.6);z-index:24;align-items:center;justify-content:center;padding:18px}
.showRanks .rankModal{display:flex}
.rankCard{position:relative;width:min(430px,94vw);max-height:88vh;overflow:auto;background:#f8f4ec;border:1px solid var(--line);border-radius:16px;padding:22px}
.rankCard h2{margin:5px 0 14px;font-size:24px}
.rankList{display:grid;gap:7px}
.rankOption{width:100%;display:grid;grid-template-columns:34px 1fr auto;align-items:center;gap:9px;border:1px solid var(--line);border-radius:9px;background:#fffdf8;color:var(--text);padding:9px 10px;text-align:left}
.rankOption.selected{border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}
.rankOption.lockedRank{opacity:.48}
.rankNumber{width:28px;height:28px;display:flex;align-items:center;justify-content:center;border:1px solid var(--line);border-radius:6px;font-size:10px;font-weight:900;background:#ebe6dc}
.rankName{font-size:13px;font-weight:900}
.rankState{font-size:8px;font-weight:900;letter-spacing:.08em;color:var(--muted)}
.rankHint{font-size:10px;color:var(--muted);margin:12px 0 0}
.unlockText{padding:8px 10px;border-radius:8px;background:#e8edf5;border:1px solid #c9d2e1}
@media(max-width:600px){.headerBtns{flex-wrap:wrap;justify-content:flex-end}.rankBtn{min-width:72px;padding-left:7px;padding-right:7px}}

.statsWinner{width:min(430px,92vw)}
.statsWinner h2{margin-bottom:12px}
.statsGrid{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:12px 0}
.statsGrid>div{background:#fffdf8;border:1px solid var(--line);border-radius:9px;padding:10px}
.statsGrid span,.endNeed span,.unlockText span{display:block;font-size:8px;font-weight:900;letter-spacing:.09em;color:var(--muted);margin-bottom:4px}
.statsGrid strong{font-size:19px}
.endNeed{background:#f1ede5;border:1px solid var(--line);border-radius:9px;padding:9px 10px;text-align:left}
.endNeed strong{font-size:11px;letter-spacing:.08em}
.unlockText{margin:8px 0;background:#e8edf5;border:1px solid #c9d2e1;border-radius:9px;padding:9px 10px;text-align:left}
.unlockText strong{font-size:13px}
.winnerActions{display:flex;gap:8px;margin-top:12px}
.winnerActions button{flex:1}
.secondaryBtn{background:#fffdf8!important;color:var(--text)!important;border:1px solid var(--line)!important}
.nextRankBtn{background:var(--accent)!important;color:#fff!important;border:1px solid var(--accent)!important}

.awardList{display:grid;gap:8px;margin:12px 0}
.awardCard{display:grid;grid-template-columns:38px 1fr;gap:10px;align-items:center;background:#fffdf8;border:1px solid var(--line);border-radius:10px;padding:10px;text-align:left}
.awardIcon{width:34px;height:34px;display:flex;align-items:center;justify-content:center;border:1px solid var(--line);border-radius:7px;background:#ebe6dc;font-weight:900;color:#4b4741;box-shadow:0 2px 0 #d8d2c7}
.awardLabel{display:block;font-size:8px;font-weight:900;letter-spacing:.09em;color:var(--muted);margin-bottom:3px}
.awardCard strong{font-size:14px}
.botBadge{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border:1px solid var(--line);border-radius:6px;background:#fffdf8;color:#4b4741;font-size:10px;font-weight:900;box-shadow:0 2px 0 #d8d2c7;margin-right:6px;vertical-align:middle}
.botBadge.small{width:20px;height:20px;font-size:8px;margin-right:5px}
.botBadge.tiny{width:18px;height:18px;font-size:7px;margin-right:5px}
.rankNumber{font-size:8px}
.statsGrid,.endNeed{display:none}

.streakStrip,.ladderStats{display:flex;justify-content:space-between;gap:10px;background:#f1ede5;border:1px solid var(--line);border-radius:9px;padding:8px 10px;font-size:9px;font-weight:900;letter-spacing:.06em;margin:9px 0}
.ladderStats{margin:0 0 9px}
.botBadge{position:relative;overflow:hidden}
.badge-0{background:#f4efe6}
.badge-1{background:#ece8df;border-style:dashed}
.badge-2{background:#e6e2d9;box-shadow:inset 0 -3px 0 #d2cbc0,0 2px 0 #d8d2c7}
.badge-3{background:#dde3eb;border-color:#b8c3d2}
.badge-4{background:#d6dfec;border-color:#a7b7cd;font-weight:950}
.badge-5{background:#dfe8dd;border-color:#b6c8b2}
.badge-6{background:#e7dfd4;border:2px double #b9aa98}
.badge-7{background:#d9d1c3;border-color:#998b76;box-shadow:inset 0 0 0 2px #f6f0e6,0 2px 0 #c4b8a7}
.badge-7:after{content:"★";position:absolute;right:1px;bottom:-1px;font-size:6px}
.rankOption .botBadge{margin:0;width:28px;height:28px}

.rankCard{padding:24px 22px 20px}
.rankCard>.sub{font-size:10px;letter-spacing:.17em;margin-bottom:7px}
.rankCard h2{
  margin:0 0 16px;
  font-size:18px;
  line-height:1.05;
  font-weight:900;
  letter-spacing:.015em;
  text-transform:uppercase;
}
.ladderStats,.streakStrip{
  display:grid;
  grid-template-columns:1fr 1fr;
  align-items:center;
  gap:0;
  background:transparent;
  border:0;
  border-top:1px solid var(--line);
  border-bottom:1px solid var(--line);
  border-radius:0;
  padding:9px 0;
  margin:0 0 12px;
  font-size:9px;
  font-weight:900;
  letter-spacing:.1em;
  color:var(--muted);
}
.ladderStats span,.streakStrip span{display:flex;align-items:baseline;gap:6px}
.ladderStats span:last-child,.streakStrip span:last-child{justify-content:flex-end}
.ladderStats strong,.streakStrip strong{font-size:13px;color:var(--text);letter-spacing:0}
.rankList{gap:8px}
.rankOption{padding:10px 11px}
.rankHint{margin-top:14px}
@media(max-width:600px){
  .rankCard{padding:22px 18px 18px}
  .rankCard h2{font-size:17px;margin-bottom:14px}
}

.modeModal{display:none;position:fixed;inset:0;background:rgba(74,68,60,.6);z-index:25;align-items:center;justify-content:center;padding:18px}
.showMode .modeModal{display:flex}
.modeCard{position:relative;width:min(400px,92vw);background:#f8f4ec;border:1px solid var(--line);border-radius:16px;padding:22px}
.modeCard>.sub{font-size:10px;letter-spacing:.17em;margin-bottom:7px}
.modeCard h2{margin:0 0 14px;font-size:17px;line-height:1.05;font-weight:900;letter-spacing:.015em;text-transform:uppercase}
.modeChoices{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.modeChoice{background:#fffdf8;border:1px solid var(--line);border-radius:10px;padding:13px 11px;text-align:left;color:var(--text)}
.modeChoice strong{display:block;font-size:12px;letter-spacing:.04em;margin-bottom:3px}
.modeChoice span{display:block;font-size:9px;color:var(--muted)}
.modeChoice:first-child{grid-column:1/-1;border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}
.rankCard{max-height:none;overflow:visible}
@media(max-width:600px){
  .rankModal{padding:10px}
  .rankCard{width:min(430px,96vw);padding:18px 16px 14px}
  .rankCard>.sub{margin-bottom:4px}
  .rankCard h2{font-size:16px;margin-bottom:9px}
  .ladderStats{padding:6px 0;margin-bottom:7px}
  .rankList{gap:5px}
  .rankOption{padding:7px 9px;min-height:0}
  .rankOption .botBadge{width:25px;height:25px}
  .rankHint{margin-top:9px}
}
@media(max-height:740px){
  .rankCard{transform:scale(.92);transform-origin:center}
}

/* Bot ladder: hard viewport fit */
.rankModal{
  padding:max(8px,env(safe-area-inset-top)) 8px max(8px,env(safe-area-inset-bottom));
  overflow:hidden;
}
.rankCard{
  box-sizing:border-box;
  width:min(430px,calc(100vw - 16px));
  max-height:calc(100dvh - max(16px,env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  overflow:hidden;
  transform:none!important;
  padding:18px 16px 14px;
}
.rankCard .rulesClose{
  right:10px;
  top:10px;
  width:36px;
  height:36px;
  padding:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:28px;
  line-height:1;
  z-index:2;
}
.rankCard>.sub,
.rankCard>h2{
  padding-right:44px;
}
.rankCard>.sub{margin:0 0 3px}
.rankCard h2{margin:0 0 8px;font-size:15px;line-height:1.05}
.rankList{display:grid;gap:5px}
.ladderStats{
  min-height:30px;
  box-sizing:border-box;
  padding:5px 0;
  margin:0 0 1px;
}
.rankOption{
  box-sizing:border-box;
  height:48px;
  min-height:48px;
  padding:5px 9px;
  gap:8px;
  border-radius:9px;
}
.rankOption .botBadge{
  width:25px;
  height:25px;
  min-width:25px;
  margin:0;
}
.rankName{font-size:12px}
.rankState{font-size:7px}
.rankHint{margin:8px 0 0;font-size:9px;line-height:1.2}

@media(max-height:700px){
  .rankCard{padding:14px 14px 11px}
  .rankCard .rulesClose{top:7px;right:7px;width:32px;height:32px;font-size:25px}
  .rankCard>.sub{font-size:8px}
  .rankCard h2{font-size:13px;margin-bottom:6px}
  .ladderStats{min-height:26px;padding:3px 0}
  .rankList{gap:4px}
  .rankOption{height:43px;min-height:43px;padding:4px 8px}
  .rankOption .botBadge{width:23px;height:23px;min-width:23px}
  .rankHint{margin-top:6px;font-size:8px}
}
@media(max-height:610px){
  .rankCard{padding:10px 12px 8px}
  .rankCard>.sub{display:none}
  .rankCard h2{font-size:12px;margin-bottom:4px}
  .ladderStats{min-height:22px;padding:2px 0;margin-bottom:0}
  .rankList{gap:3px}
  .rankOption{height:38px;min-height:38px;padding:3px 7px}
  .rankOption .botBadge{width:21px;height:21px;min-width:21px}
  .rankHint{margin-top:4px}
}

/* Mobile header + multiplayer viewport fit */
@media(max-width:600px){
  header{align-items:flex-start;gap:7px}
  header>div:first-child{flex:0 0 auto;min-width:128px}
  header h1{font-size:23px;line-height:.95;white-space:nowrap}
  header>div:first-child>.sub{
    font-size:7px;
    letter-spacing:.085em;
    white-space:nowrap;
    line-height:1.1;
    margin-top:4px;
  }
  .headerBtns{flex:1;min-width:0;justify-content:flex-end;align-items:flex-start;gap:4px}
  .headerBtns .ghost{white-space:nowrap}

  .keyboardSection{
    flex:0 0 auto;
    width:100%;
    padding-bottom:max(2px,env(safe-area-inset-bottom));
  }

  /* 3–4 player status must not consume a second tall row */
  .meter.multi{
    display:flex;
    gap:4px;
    padding:5px;
    align-items:stretch;
  }
  .meter.multi .multiPlayerCard{
    flex:1 1 0;
    min-width:0;
    padding:5px 4px;
  }
  .meter.multi .multiPlayerCard .label{
    font-size:7px;
    letter-spacing:.025em;
    white-space:nowrap;
  }
  .meter.multi .multiPlayerCard .label span{
    display:block;
    margin:1px 0 0;
    font-size:7px;
  }
  .meter.multi .bar{height:3px;margin-top:3px}
  .meter.multi .needLine{display:none}

  /* Let the board absorb whatever height remains so the keyboard always stays on-screen. */
  .wordStage{
    flex:1 1 auto;
    width:min(100%,620px);
    height:auto;
    min-height:170px;
    max-height:none;
    aspect-ratio:auto;
    margin:5px auto;
  }
}
@media(max-width:390px){
  header>div:first-child{min-width:116px}
  header h1{font-size:21px}
  header>div:first-child>.sub{font-size:6.4px;letter-spacing:.065em}
  .headerBtns .ghost{padding-left:5px;padding-right:5px}
}

/* Slim bot rank button to match header controls */
.rankBtn{
  min-width:0;
  height:30px;
  padding:4px 7px;
  line-height:1;
  border-radius:8px;
  display:inline-flex;
  align-items:center;
  gap:4px;
}
.rankBtn .botBadge.tiny{
  width:16px;
  height:16px;
  min-width:16px;
  margin-right:2px;
  box-shadow:none;
}
@media(max-width:600px){
  .rankBtn{
    height:28px;
    padding:3px 6px;
    font-size:8px;
  }
  .rankBtn .botBadge.tiny{
    width:15px;
    height:15px;
    min-width:15px;
    font-size:6px;
  }
}

/* Normalize header controls */
.headerBtns{
  display:flex;
  align-items:center;
}
.headerBtns .ghost{
  height:30px;
  min-height:30px;
  padding:0 8px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  line-height:1;
  vertical-align:middle;
  border-radius:8px;
}
.rankBtn{
  height:30px;
  min-height:30px;
  padding:0 8px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  line-height:1;
  gap:5px;
  vertical-align:middle;
}
.rankBtn .botBadge.tiny{
  width:16px;
  height:16px;
  min-width:16px;
  margin:0;
  box-shadow:none;
  line-height:1;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
@media(max-width:600px){
  .headerBtns{align-items:center}
  .headerBtns .ghost,
  .rankBtn{
    height:28px;
    min-height:28px;
    padding:0 6px;
    font-size:8px;
    line-height:1;
  }
  .rankBtn .botBadge.tiny{
    width:14px;
    height:14px;
    min-width:14px;
    font-size:6px;
  }
}

/* Header controls as keyboard keycaps */
.headerBtns{
  gap:5px;
}
.headerBtns .ghost,
.rankBtn{
  background:#fffdf8;
  color:var(--text);
  border:1px solid #cec7bb;
  border-radius:7px;
  box-shadow:0 2px 0 #cfc8bc;
  font-weight:900;
  letter-spacing:.035em;
  text-transform:uppercase;
  transition:transform .06s ease, box-shadow .06s ease, background .12s ease;
}
.headerBtns .ghost:active,
.rankBtn:active{
  transform:translateY(2px);
  box-shadow:0 0 0 #cfc8bc;
}
.headerBtns .ghost:hover,
.rankBtn:hover{
  background:#f5f1e8;
}
#rulesBtn{
  width:30px;
  min-width:30px;
  padding:0;
  font-size:12px;
}
#newGame{
  padding-left:9px;
  padding-right:9px;
}
#modeBtn{
  min-width:62px;
}
.rankBtn{
  min-width:76px;
}
.rankBtn .botBadge.tiny{
  background:#eee8dd;
  border-color:#cfc8bc;
  border-radius:4px;
  box-shadow:inset 0 -1px 0 #d8d1c5;
}
@media(max-width:600px){
  .headerBtns{
    gap:4px;
  }
  .headerBtns .ghost,
  .rankBtn{
    height:27px;
    min-height:27px;
    border-radius:6px;
    box-shadow:0 2px 0 #cfc8bc;
    font-size:7.5px;
    letter-spacing:.025em;
  }
  #rulesBtn{
    width:27px;
    min-width:27px;
    font-size:11px;
  }
  #modeBtn{min-width:54px}
  #newGame{padding-left:6px;padding-right:6px}
  .rankBtn{min-width:68px}
}

/* TYPESET as a spacebar-style key */
.brandBlock{
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  flex:0 0 auto;
}
.brandKey{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:42px;
  padding:0 18px;
  border:1px solid #cec7bb;
  border-radius:9px;
  background:#fffdf8;
  color:var(--text);
  box-shadow:0 3px 0 #cfc8bc;
  font-size:28px;
  font-weight:900;
  letter-spacing:.08em;
  line-height:1;
  text-transform:uppercase;
}
.brandBlock .sub{
  margin-top:6px;
  margin-left:4px;
  font-size:10px;
  font-weight:800;
  letter-spacing:.16em;
  color:var(--muted);
  text-transform:uppercase;
  white-space:nowrap;
}
@media(max-width:600px){
  header>div:first-child{min-width:0}
  .brandKey{
    min-height:34px;
    padding:0 14px;
    border-radius:8px;
    box-shadow:0 2px 0 #cfc8bc;
    font-size:21px;
    letter-spacing:.07em;
  }
  .brandBlock .sub{
    margin-top:4px;
    margin-left:3px;
    font-size:7px;
    letter-spacing:.12em;
  }
}
@media(max-width:390px){
  .brandKey{
    min-height:32px;
    padding:0 12px;
    font-size:19px;
  }
  .brandBlock .sub{
    font-size:6.3px;
    letter-spacing:.1em;
  }
}

/* Restore plain TYPESET wordmark */
.brandBlock{display:flex;flex-direction:column;align-items:flex-start;flex:0 0 auto}
.brandBlock h1{
  margin:0;
  color:var(--text);
  font-size:34px;
  font-weight:900;
  line-height:1;
  letter-spacing:.06em;
}
.brandKey{display:none!important}
.brandBlock .sub{
  margin-top:5px;
  margin-left:0;
  color:var(--muted);
  font-size:11px;
  font-weight:700;
  letter-spacing:.14em;
  text-transform:uppercase;
  white-space:nowrap;
}
.key.lockedNeed,.key.locked{cursor:not-allowed}
.key.lockedNeed.disabled,.key.locked.disabled{opacity:.62}
.key.lockedNeed:after,.key.locked:after{content:""}
@media(max-width:600px){
  .brandBlock h1{font-size:23px;line-height:.95}
  .brandBlock .sub{font-size:7px;letter-spacing:.1em;margin-top:4px}
}
@media(max-width:390px){
  .brandBlock h1{font-size:21px}
  .brandBlock .sub{font-size:6.3px;letter-spacing:.08em}
}

/* Typed TYPESET wordmark */
.typedTitle{display:flex}
.typedTitle span{
  display:inline-block;
  opacity:0;
  transform:translateY(2px);
  animation:titleType .14s steps(1,end) forwards;
  animation-delay:calc(var(--i) * 90ms + 100ms);
}
.typedTitle:after{
  content:"";
  width:2px;
  height:.82em;
  margin-left:3px;
  align-self:center;
  background:var(--text);
  opacity:0;
  animation:titleCursor 1.05s steps(1,end) 100ms 2;
}
@keyframes titleType{to{opacity:1;transform:none}}
@keyframes titleCursor{
  0%,45%{opacity:1}
  46%,100%{opacity:0}
}

/* Locked multiplayer rewards */
.modeChoice.lockedMode{
  opacity:.46;
  cursor:not-allowed;
  box-shadow:none!important;
}
.modeChoice.lockedMode strong:after{
  content:"  LOCKED";
  font-size:7px;
  letter-spacing:.08em;
  color:var(--muted);
}
.modeChoice:disabled:active{transform:none}

/* Simplified header controls */
#modeBtn{
  min-width:50px;
}
.escKey{
  width:30px;
  min-width:30px!important;
  padding:0!important;
  font-size:8px!important;
  letter-spacing:.04em!important;
}
@media(max-width:600px){
  #modeBtn{min-width:46px}
  .escKey{
    width:27px;
    min-width:27px!important;
    font-size:7px!important;
  }
}

/* Make top menu keys match the bottom keyboard */
.headerBtns{
  display:flex;
  align-items:center;
  gap:5px;
}
.headerBtns .ghost,
.rankBtn{
  height:42px;
  min-height:42px;
  padding:0 11px;
  border-radius:7px;
  border:1px solid var(--line);
  background:#fffdf8;
  color:#25231f;
  box-shadow:none;
  font-size:11px;
  font-weight:900;
  line-height:1;
  letter-spacing:0;
  text-transform:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  user-select:none;
  touch-action:manipulation;
}
.headerBtns .ghost:active,
.rankBtn:active{
  transform:none;
  box-shadow:none;
  background:#f3efe6;
}
.headerBtns .ghost:hover,
.rankBtn:hover{
  background:#fffdf8;
}
#rulesBtn,
#newGame{
  width:42px;
  min-width:42px!important;
  padding:0!important;
}
#modeBtn{
  min-width:58px;
}
.rankBtn{
  min-width:86px;
}
.rankBtn .botBadge.tiny{
  width:16px;
  height:16px;
  min-width:16px;
  margin-right:5px;
  border-radius:4px;
  box-shadow:none;
}
@media(max-width:600px){
  .headerBtns{
    gap:3px;
  }
  .headerBtns .ghost,
  .rankBtn{
    height:32px;
    min-height:32px;
    padding:0 7px;
    border-radius:5px;
    font-size:9px;
  }
  #rulesBtn,
  #newGame{
    width:32px;
    min-width:32px!important;
  }
  #modeBtn{min-width:48px}
  .rankBtn{min-width:68px}
  .rankBtn .botBadge.tiny{
    width:13px;
    height:13px;
    min-width:13px;
    margin-right:4px;
    font-size:6px;
  }
}

/* UI polish: quieter header, clearer opening state */
.openingStage{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:7px;
  text-align:center;
}
.openingStage strong{
  font-size:15px;
  letter-spacing:.13em;
  color:#7f786d;
}
.openingStage span{
  font-size:9px;
  letter-spacing:.1em;
  color:#aaa398;
  font-weight:800;
}
@media(max-width:600px){
  .headerBtns .ghost,
  .rankBtn{
    height:29px;
    min-height:29px;
    font-size:8px;
  }
  #rulesBtn,
  #newGame{
    width:29px;
    min-width:29px!important;
  }
  #modeBtn{min-width:43px}
  .rankBtn{
    min-width:72px;
    padding-left:6px;
    padding-right:7px;
  }
  .rankBtn .botBadge.tiny{
    width:12px;
    height:12px;
    min-width:12px;
    margin-right:3px;
  }
  .openingStage strong{font-size:13px}
  .openingStage span{font-size:8px}
  .needLine{font-size:7px}
}

.openingNote{
  display:none;
  margin:5px auto -1px;
  width:min(100%,620px);
  text-align:center;
  font-size:8px;
  font-weight:900;
  letter-spacing:.09em;
  color:var(--muted);
  text-transform:uppercase;
}
.openingNote.show{display:block}
.startStage{
  font-size:15px;
  font-weight:900;
  letter-spacing:.16em;
  color:#9c978d;
}
@media(max-width:600px){
  .openingNote{
    margin:4px auto 0;
    font-size:7px;
    letter-spacing:.07em;
  }
  .startStage{font-size:13px}
}

.openingNote{display:none!important}

.entryTextBlock{
  flex:1;
  min-width:0;
}
.entryTextBlock .directWord{
  width:100%;
}
.entryTextBlock .help{
  margin-top:3px;
}
@media(max-width:600px){
  .entryTextBlock .help{
    margin-top:2px;
    font-size:7px;
    line-height:1.15;
  }
}

/* Simplified header: help, rank, new */
#modeBtn{display:none!important}
.headerBtns{gap:4px}
#newGame{
  width:42px;
  min-width:42px!important;
}
@media(max-width:600px){
  #newGame{
    width:29px;
    min-width:29px!important;
  }
}

/* Ensure header keys remain tappable above animated title */
header{
  position:relative;
}
.brandBlock{
  position:relative;
  z-index:1;
  pointer-events:none;
}
.headerBtns{
  position:relative;
  z-index:5;
  pointer-events:auto;
}
.headerBtns button,
.rankBtn{
  position:relative;
  z-index:6;
  pointer-events:auto;
  -webkit-tap-highlight-color:transparent;
}
.typedTitle,
.typedTitle span,
.typedTitle:after{
  pointer-events:none;
}

/* A–Z bot ladder */
.rankBtn{
  min-width:0!important;
  width:auto!important;
  padding:0 7px!important;
  gap:3px!important;
}
.rankBtn .rankLetter{
  font-size:9px;
  font-weight:1000;
  line-height:1;
}
.rankBtn .rankDot{
  font-size:8px;
  opacity:.45;
}
.rankBtn .rankDescriptor{
  font-size:7px;
  font-weight:900;
  letter-spacing:.03em;
  line-height:1;
}
.ladderExplain{
  margin:2px 0 8px;
  font-size:8px;
  line-height:1.25;
  color:var(--muted);
  text-align:center;
  text-transform:uppercase;
  letter-spacing:.05em;
}
.rankList{
  display:grid!important;
  grid-template-columns:1fr 1fr;
  gap:4px!important;
  overflow:visible!important;
}
.rankOption{
  min-height:30px!important;
  height:30px!important;
  padding:3px 6px!important;
  border-radius:6px!important;
}
.rankOption .rankNumber{
  width:20px!important;
  height:20px!important;
  min-width:20px!important;
  font-size:8px!important;
}
.rankOption .rankName{
  font-size:8px!important;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.rankOption .rankState{
  font-size:6px!important;
}
.rankHint{display:none!important}
@media(max-width:600px){
  .rankBtn .rankLetter{font-size:8px}
  .rankBtn .rankDescriptor{font-size:6.5px}
  .rankCard{max-height:calc(100dvh - 20px)!important}
  .rankList{gap:3px!important}
  .rankOption{
    min-height:28px!important;
    height:28px!important;
    padding:2px 5px!important;
  }
}
@media(max-height:700px){
  .ladderExplain{margin-bottom:5px;font-size:7px}
  .rankOption{
    min-height:25px!important;
    height:25px!important;
  }
  .rankOption .rankNumber{
    width:18px!important;height:18px!important;min-width:18px!important
  }
}

/* Clean bot ladder */
.rankCard{
  width:min(410px,calc(100vw - 20px))!important;
  padding:18px 16px 14px!important;
  border-radius:14px!important;
}
.rankCard>.sub{
  margin:0 0 2px!important;
  font-size:8px!important;
  letter-spacing:.16em!important;
}
.rankCard h2{
  margin:0!important;
  padding-right:36px!important;
  font-size:20px!important;
  line-height:1!important;
  letter-spacing:.05em!important;
}
.ladderExplain{
  margin:5px 0 8px!important;
  text-align:left!important;
  font-size:8px!important;
  line-height:1.2!important;
  letter-spacing:.035em!important;
  text-transform:none!important;
}
.ladderStats{
  min-height:0!important;
  margin:0 0 8px!important;
  padding:6px 0!important;
  border-top:1px solid var(--line)!important;
  border-bottom:1px solid var(--line)!important;
  font-size:8px!important;
  letter-spacing:.07em!important;
}
.ladderStats strong{font-size:11px!important}
.rankList{
  grid-template-columns:1fr 1fr!important;
  gap:4px!important;
}
.rankOption{
  grid-template-columns:22px minmax(0,1fr) 12px!important;
  height:29px!important;
  min-height:29px!important;
  padding:3px 6px!important;
  gap:6px!important;
  border-radius:6px!important;
  box-shadow:none!important;
  background:#fffdf8!important;
}
.rankOption .rankNumber{
  width:20px!important;
  height:20px!important;
  min-width:20px!important;
  border:1px solid var(--line)!important;
  border-radius:5px!important;
  background:#f0ece4!important;
  font-size:8px!important;
  font-weight:950!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
}
.rankOption .rankName{
  font-size:8px!important;
  font-weight:850!important;
  overflow:hidden!important;
  text-overflow:ellipsis!important;
  white-space:nowrap!important;
}
.rankOption.selected{
  border-color:var(--accent)!important;
  background:#f4f6fa!important;
}
.rankOption.selected .rankNumber{
  border-color:var(--accent)!important;
  background:#e6ebf3!important;
}
.rankOption.lockedRank{
  opacity:.34!important;
  filter:none!important;
}
.rankCheck{
  color:var(--accent);
  font-size:9px;
  font-weight:1000;
  text-align:center;
}
.rankLock{
  color:var(--muted);
  font-size:10px;
  text-align:center;
}
.rankState{display:none!important}
.rankCard .rulesClose{
  width:28px!important;
  height:28px!important;
  top:10px!important;
  right:10px!important;
  font-size:20px!important;
}
@media(max-width:600px){
  .rankCard{padding:15px 13px 12px!important}
  .rankCard h2{font-size:18px!important}
  .rankOption{height:27px!important;min-height:27px!important}
}
@media(max-height:650px){
  .rankCard{transform:none!important}
  .rankCard>.sub{display:block!important}
  .ladderExplain{margin:3px 0 5px!important;font-size:7px!important}
  .ladderStats{padding:4px 0!important;margin-bottom:5px!important}
  .rankList{gap:3px!important}
  .rankOption{height:24px!important;min-height:24px!important;padding:2px 5px!important}
  .rankOption .rankNumber{width:17px!important;height:17px!important;min-width:17px!important;font-size:7px!important}
  .rankOption .rankName{font-size:7px!important}
}

/* Bot ladder progress */
.ladderProgress{
  margin:0 0 8px;
}
.ladderProgressTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:4px;
  font-size:7px;
  font-weight:900;
  letter-spacing:.07em;
  color:var(--muted);
}
.ladderProgressTop strong{
  color:var(--text);
  font-size:8px;
  letter-spacing:.02em;
}
.ladderProgressBar{
  height:5px;
  overflow:hidden;
  border-radius:999px;
  background:#e8e2d8;
  border:1px solid var(--line);
}
.ladderProgressBar i{
  display:block;
  height:100%;
  border-radius:999px;
  background:var(--accent);
}
@media(max-height:650px){
  .ladderProgress{margin-bottom:5px}
  .ladderProgressTop{margin-bottom:3px;font-size:6.5px}
  .ladderProgressBar{height:4px}
}

/* Reduce bot-screen copy */
.rankCard>.sub,
.ladderExplain{display:none!important}
.rankCard h2{
  margin:0 0 8px!important;
  font-size:18px!important;
  letter-spacing:.06em!important;
}
.ladderStats{
  margin-bottom:6px!important;
}
.ladderProgress{
  margin-bottom:7px!important;
}

/* Main screen copy reduction */
header .brandBlock>.sub{display:none!important}
.turnLine{display:none!important}
.legend{display:none!important}
.vs{
  min-width:10px!important;
  font-size:0!important;
}
.needLine:empty{display:none!important}
.needLine{
  margin-top:4px!important;
  font-size:7px!important;
  letter-spacing:.07em!important;
}
.directEntry{padding-top:7px!important}

/* Replay records */
.recordStrip{display:grid;grid-template-columns:1fr 1fr;gap:0;padding:7px 0;margin:-1px 0 9px;border-bottom:1px solid var(--line);font-size:8px;font-weight:900;letter-spacing:.07em;color:var(--muted)}
.recordStrip span{display:flex;align-items:baseline;gap:5px}.recordStrip span:last-child{justify-content:flex-end}.recordStrip strong{color:var(--text);font-size:10px;letter-spacing:0}
.ladderStats{grid-template-columns:1fr 1fr 1fr!important}.ladderStats span:nth-child(2){justify-content:center!important}.ladderStats span:nth-child(3){justify-content:flex-end!important}.winnerActions .nextRankBtn{white-space:nowrap}

/* First-game typed tutorial */
.tutorialStage{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:7px;
  width:100%;
  text-align:center;
}
.tutorialLine{
  min-height:14px;
  font-size:10px;
  line-height:1.25;
  font-weight:850;
  letter-spacing:.055em;
  color:var(--muted);
  white-space:nowrap;
}
.tutorialChar{
  opacity:0;
  display:inline-block;
  animation:tutorialType .01s steps(1,end) forwards;
  animation-delay:var(--d);
}
.tutorialStart{
  margin-top:10px;
  font-size:14px;
  font-weight:1000;
  letter-spacing:.16em;
  color:var(--text);
  opacity:0;
  animation:tutorialStartIn .18s ease forwards;
  animation-delay:var(--startDelay);
}
@keyframes tutorialType{to{opacity:1}}
@keyframes tutorialStartIn{
  from{opacity:0;transform:translateY(3px)}
  to{opacity:1;transform:none}
}
@media(max-width:600px){
  .tutorialStage{gap:6px}
  .tutorialLine{
    font-size:8px;
    letter-spacing:.035em;
  }
  .tutorialStart{
    margin-top:8px;
    font-size:12px;
  }
}
@media(max-width:370px){
  .tutorialLine{
    font-size:7.2px;
    letter-spacing:.02em;
  }
}

/* Stabilize first-game typing sequence */
.tutorialChar{
  opacity:0;
  animation-name:tutorialType!important;
  animation-duration:.01s!important;
  animation-timing-function:steps(1,end)!important;
  animation-fill-mode:both!important;
}
.tutorialStart{
  opacity:0;
  animation-name:tutorialStartIn!important;
  animation-duration:.18s!important;
  animation-timing-function:ease!important;
  animation-fill-mode:both!important;
}
.tutorialLine{
  width:100%;
  text-align:center;
}

/* Safari-safe tutorial START reveal */
.tutorialStart{
  opacity:0!important;
  transform:translateY(3px);
  animation:none!important;
}
.tutorialStart.show{
  opacity:1!important;
  transform:none;
  transition:opacity .16s ease,transform .16s ease;
}

/* Reliable JS-driven first-game tutorial */
.tutorialChar{display:none!important}
.tutorialLine{
  min-height:14px;
}
.tutorialStart{
  opacity:0!important;
  transform:translateY(3px);
  animation:none!important;
}
.tutorialStart.show{
  opacity:1!important;
  transform:none;
  transition:opacity .16s ease,transform .16s ease;
}

/* Tutorial copy alignment */
.tutorialStage{
  align-items:flex-end!important;
  text-align:right!important;
}
.tutorialLine{
  width:auto!important;
  max-width:92%;
  text-align:right!important;
}

/* Opening prompt lives in entry bar */
.tutorialStart{display:none!important}

/* No START prompt; tutorial hands off to entry box */
.startStage{display:none!important}

.startStage,.tutorialStart{display:none!important}

#wordDisplay:before,
#wordDisplay:after{content:none!important}

/* Center tutorial block; justify rule lines */
.tutorialStage{
  align-items:center!important;
  text-align:center!important;
}
.tutorialLine{
  width:min(92%,340px)!important;
  max-width:340px!important;
  text-align:justify!important;
  text-align-last:justify!important;
}

/* Center tutorial block, left-align copy */
.tutorialStage{
  align-items:center!important;
  text-align:left!important;
}
.tutorialLine{
  width:min(92%,340px)!important;
  max-width:340px!important;
  text-align:left!important;
  text-align-last:auto!important;
}

/* Desktop: full-width play surface and keyboard above the fold */
@media(min-width:601px){
  html,body{
    height:100%;
    overflow:hidden;
  }
  body{min-height:100dvh}
  .app{
    width:100%;
    height:100dvh;
    max-height:100dvh;
    max-width:900px;
    overflow:hidden;
    display:flex;
    flex-direction:column;
  }
  header,
  .meter,
  .keyboardSection{
    flex:0 0 auto;
  }
  header{margin-bottom:10px}
  .wordStage{
    flex:1 1 auto;
    width:100%;
    max-width:none;
    min-height:240px;
    height:auto;
    aspect-ratio:auto;
    margin:10px 0 8px;
  }
  .keyboardSection{
    width:100%;
    padding-bottom:4px;
  }
  .keyboard{
    max-width:100%;
  }
  .row{
    margin:5px 0;
  }
  .key{
    height:44px;
    max-width:78px;
  }
}

/* Desktop legend */
@media(min-width:601px){
  .legend{
    display:flex!important;
    justify-content:center;
    align-items:center;
    gap:14px;
    margin:4px auto 2px;
    font-size:8px;
    font-weight:800;
    letter-spacing:.06em;
    color:var(--muted);
    text-transform:uppercase;
  }
}
@media(max-width:600px){
  .legend{display:none!important}
}

.legendItem{
  display:inline-flex;
  align-items:center;
  gap:5px;
}
.legendKey{
  width:12px;
  height:12px;
  border-radius:3px;
  border:1px solid var(--line);
  display:inline-block;
}
.legendKey.need{
  background:#fffdf8;
  border-color:#d8d2c7;
}
.legendKey.lockedNeed{
  background:#c9d0dc;
  border-color:#aab4c4;
}
.legendKey.earned{
  background:#e4dfd6;
}

/* Desktop legend: below keyboard, exact key states */
@media(min-width:601px){
  .keyboardSection .legend{
    order:2;
    margin:6px auto 0!important;
  }
  .keyboardSection .keyboard{
    order:1;
  }
  .legendItem{
    display:inline-flex;
    align-items:center;
    gap:5px;
  }
  .legend .legendKey.key{
    width:14px!important;
    min-width:14px!important;
    max-width:14px!important;
    height:14px!important;
    min-height:14px!important;
    border-radius:4px!important;
    padding:0!important;
    flex:none!important;
    font-size:0!important;
  }
}

/* Desktop tutorial: true centered block with left-aligned lines */
@media(min-width:601px){
  .tutorialStage{
    width:max-content!important;
    max-width:92%!important;
    margin-left:auto!important;
    margin-right:auto!important;
    align-items:stretch!important;
    text-align:left!important;
  }
  .tutorialLine{
    width:auto!important;
    max-width:none!important;
    text-align:left!important;
    text-align-last:auto!important;
  }
}

/* Mobile keyboard visibility guard */
@media(max-width:600px){
  .keyboardSection{
    display:block!important;
    visibility:visible!important;
    opacity:1!important;
    flex:0 0 auto!important;
    width:100%!important;
    padding-bottom:max(2px,env(safe-area-inset-bottom))!important;
  }
  .keyboard{
    display:block!important;
    visibility:visible!important;
    width:100%!important;
    max-width:100%!important;
  }
  .keyboard .row{
    display:flex!important;
    gap:3px!important;
    margin:3px 0!important;
  }
  .keyboard .key{
    display:flex!important;
    height:32px!important;
    min-height:32px!important;
    width:9.45%!important;
    min-width:0!important;
    max-width:none!important;
    font-size:11px!important;
  }
  .wordStage{
    flex:1 1 auto!important;
    min-height:110px!important;
    height:auto!important;
    max-height:none!important;
    aspect-ratio:auto!important;
    margin:5px auto!important;
  }
}
