/* Chat controls remain part of the composer when the mobile keyboard opens. */
.chat-message-menu{min-width:156px;z-index:2000;overflow:auto}
.chat-message-menu[hidden]{display:none!important}
.chat-message-menu button{justify-content:flex-start;gap:11px;min-height:44px;padding:9px 12px;border-radius:7px}
.chat-message-menu button:first-child{color:#c5bbff;font-weight:700}
.chat-message-menu button:focus-visible,.chat-replyable:focus-visible{outline:2px solid #a698ff;outline-offset:-2px}
.chat-message-menu button span{width:18px;text-align:center;font-size:18px}
@media(pointer:coarse){.chat-replyable{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}}
.chat-reply-quote{margin:0 0 4px;padding:3px 8px;border-left:2px solid #9b8cff;color:#9fb2c7;font-size:.85em;white-space:normal;overflow-wrap:anywhere}
/* Mention treatment is applied only for the addressed account. No layout-shifting animation. */
#lobby-chat>.chat-mentioned,#room-chat>.chat-mentioned{background:linear-gradient(100deg,#3d414f,#2f323d);border:1px solid #a99af0;border-left:4px solid #c4b6ff;border-radius:9px;padding:9px 11px;margin-block:6px;color:#f1efff;box-shadow:0 2px 10px #18191f33;overflow-wrap:anywhere}
.chat-mention-label{display:block;width:fit-content;margin-bottom:5px;color:#ddd3ff;font-size:11px;font-weight:800;letter-spacing:.02em}
.chat-mention-token{display:inline;padding:1px 4px;border-radius:4px;background:#d5c6ff;color:#23252d;font-weight:800;box-decoration-break:clone;-webkit-box-decoration-break:clone}
html.mobile-layout body.mobile-room-active .mobile-game-chat-toggle.has-mention{border-color:#d0bcff;background:#46316d;color:#fff;box-shadow:0 0 0 2px #bca5ee38,0 4px 14px #22242c66;animation:none}
html.mobile-layout body.mobile-room-active .mobile-game-chat-toggle.has-mention em{background:#d9c6ff;color:#272932;min-width:25px}
.chat-reply-preview{display:flex;align-items:center;gap:8px;padding:5px 8px;background:#2a2d37;border-radius:8px;font-size:12px;min-height:32px;flex-shrink:0}
.chat-reply-preview span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-reply-preview button{padding:3px 9px}.chat-mentions{display:flex;flex-wrap:wrap;gap:4px;max-height:100px;overflow:auto;flex-shrink:0;padding:6px;background:#1c1e24}
.chat-mentions button{padding:6px 9px;font-size:12px}.chat-sound-setting{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;border:1px solid #414555;border-radius:14px;gap:14px;margin:12px 0}
.chat-sound-setting span{display:grid;gap:3px}.chat-sound-setting small{color:#92a7bf;font-size:11px}.chat-sound-setting input{appearance:none;flex-shrink:0;width:42px;height:24px;border-radius:20px;background:#3c404f;position:relative;cursor:pointer}
.chat-sound-setting input:before{content:"";position:absolute;width:18px;height:18px;left:3px;top:3px;border-radius:50%;background:white;transition:translate .15s}
.chat-sound-setting input:checked{background:#7463e9}.chat-sound-setting input:checked:before{translate:18px 0}
.player.inspectable{-webkit-touch-callout:none;user-select:none;-webkit-user-select:none}
html.mobile-layout #spectator-box:not([hidden]){display:flex!important;position:relative;z-index:25;max-width:100%;min-width:0;gap:5px}
html.mobile-layout #spectator-select{max-width:100%;min-width:0;font-size:12px;min-height:32px;padding:4px 8px}

.record-crowns{display:flex;gap:5px;flex-wrap:wrap;position:absolute;right:5px;bottom:4px;pointer-events:none}.record-crown{position:relative;display:inline-grid;place-items:center;width:27px;height:27px;border:1px solid currentColor;border-radius:50%;font-style:normal;font-size:16px;background:#1c1e24;color:#ffe18b;animation:record-glow 2.5s ease-in-out infinite}
.record-minesweeper{color:#61ffcf;animation:record-radar 2.4s ease-out infinite}.record-applegame{color:#ff87a3;animation:record-float 2s ease-in-out infinite}.record-tetris{color:#60e3ff;border-radius:4px;animation:record-line 2.2s ease-in-out infinite}.record-poker{color:#dbb2ff;border-radius:45% 45% 20% 20%;animation:record-glow 2s ease-in-out infinite}.record-sevenpoker{color:#ffbf66;animation:record-diamond 3s ease-in-out infinite}.record-wordchain{color:#c9b5ff;border-style:dotted;animation:record-letters 2.7s ease-in-out infinite}.record-yutnori{color:#ffc891;border-radius:12px 4px;animation:record-yut 2.8s ease-in-out infinite}.record-worldmarble{color:#77ddff;animation:record-orbit 4s linear infinite}.record-territory{color:#84f6b6;border-radius:3px;animation:record-territory 2.5s steps(4) infinite}.record-skybattle{color:#ffed87;border-style:dashed;animation:record-sky 2.3s ease-in-out infinite}
@keyframes record-glow{50%{box-shadow:0 0 12px currentColor}}@keyframes record-radar{0%{box-shadow:0 0 0 0 #61ffcf66}100%{box-shadow:0 0 0 9px #61ffcf00}}@keyframes record-float{50%{translate:0 -4px;rotate:-8deg}}@keyframes record-line{50%{box-shadow:inset 0 -12px #60e3ff44,0 0 10px #60e3ff55}}@keyframes record-diamond{50%{rotate:15deg;filter:brightness(1.6)}}@keyframes record-letters{50%{border-color:transparent;text-shadow:0 -4px 8px #c9b5ff}}@keyframes record-yut{50%{rotate:-16deg;translate:0 -3px}}@keyframes record-orbit{50%{box-shadow:5px 0 #77ddff55,-5px 0 #77ddff55}}@keyframes record-territory{50%{outline:2px dashed #84f6b666;outline-offset:4px}}@keyframes record-sky{45%,55%{text-shadow:3px 0 9px #ffed87;box-shadow:0 0 8px #ffed8766}}
#game-record-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}#game-record-list article{display:flex;align-items:center;gap:12px;padding:13px;background:#1c1e25;border:1px solid #3d4150;border-radius:12px}#game-record-list span{display:grid;gap:4px;min-width:0}#game-record-list small{color:#a7b9cb;overflow-wrap:anywhere}
@media(max-width:440px){#game-record-list{grid-template-columns:1fr}}@media(prefers-reduced-motion:reduce){.record-crown{animation:none}}

/* Loaded after legacy device/game sheets so portrait rules do not leak into landscape. */
html.mobile-layout body.has-lobby:not(#_) #lobby>.panel.grow>.section-title{display:grid;position:static;flex:0 0 auto;min-height:82px;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:34px 42px;gap:5px 8px;align-items:center}
html.mobile-layout body.has-lobby:not(#_) #lobby>.panel.grow>.section-title>div:first-child{grid-column:1;grid-row:1}
html.mobile-layout body.has-lobby:not(#_) .lobby-title-actions{display:contents}
html.mobile-layout body.has-lobby:not(#_) .lobby-room-actions{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));grid-column:1/-1;grid-row:2;gap:4px;min-width:0}
html.mobile-layout body.has-lobby:not(#_) .lobby-room-actions button{min-width:0;padding:5px 2px;font-size:9px;white-space:normal;line-height:1.25}
html.mobile-layout body.has-lobby:not(#_) #open-create{grid-column:2;grid-row:1;position:static;margin:0}
html.mobile-layout body.mobile-room-active:not(.game-active) .waiting-participants .player{position:relative;min-width:0;width:auto;height:auto;min-height:48px;flex-shrink:0;align-items:center;overflow:visible}
html.mobile-layout body.mobile-room-active:not(.game-active) .waiting-participants .player-label{display:block;flex:1 1 auto;min-width:0;width:auto;max-width:100%;font-size:12px;white-space:normal;overflow-wrap:anywhere}
html.mobile-layout .record-crowns{position:static;flex:0 0 auto;margin-left:5px}.player[data-record-user]{position:relative}
@media(orientation:landscape) and (max-height:600px){
 html.mobile-layout body.has-lobby:not(#_) #lobby{grid-template-columns:minmax(0,1.2fr) minmax(245px,1fr);grid-template-rows:minmax(0,1fr)}
 html.mobile-layout body.mobile-room-active:not(.game-active) #room{display:grid!important;grid-template-columns:126px minmax(0,1fr);grid-template-rows:minmax(0,1fr);gap:6px}
 html.mobile-layout body.mobile-room-active:not(.game-active) #room>.room-spectator-panel{height:100%;min-height:0;max-height:100%;width:100%;margin:0;overflow:auto;align-self:stretch}
 html.mobile-layout body.mobile-room-active:not(.game-active) #room>.panel.grow{height:100%;max-height:100%;overflow:hidden}
 html.mobile-layout body.mobile-room-active:not(.game-active) .waiting-participants #players{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-rows:minmax(48px,max-content);align-content:start;gap:5px}
 html.mobile-layout body.mobile-room-active:not(.game-active) .waiting-participants h3{flex:0 0 34px}
 html.mobile-layout body.mobile-room-active:not(.game-active) #waiting-onboarding{min-height:30px;padding:3px 8px;font-size:10px}
 html.mobile-layout body.mobile-room-active:not(.game-active) .onboarding-nudge{padding:4px 8px;margin-bottom:4px;gap:5px;flex-wrap:nowrap}
 html.mobile-layout body.mobile-room-active:not(.game-active) .onboarding-nudge button{min-height:32px;font-size:10px;padding:4px 8px}
 html.mobile-layout body.mobile-room-active:not(.game-active) .onboarding-nudge b{font-size:10px}
 html.mobile-layout body.mobile-room-active:not(.game-active) .onboarding-nudge-copy{flex:1 1 auto}
 html.mobile-layout body.mobile-room-active:not(.game-active) .onboarding-nudge-actions{flex-wrap:nowrap}
 html.mobile-layout body.mobile-room-active:not(.game-active) #players.sky-team-players{display:flex;overflow:auto}
}

/* Weekly rankings and permanent record holders share one accessible dialog. */
#ranking-dialog[open]{display:flex;flex-direction:column;width:min(800px,calc(100vw - 24px));max-height:calc(100dvh - 24px)}
#ranking-dialog>.hub-dialog-head{flex:0 0 auto}
#ranking-dialog .ranking-view-tabs{display:grid;grid-template-columns:1fr 1fr;gap:5px;flex:0 0 auto;padding:5px;margin:14px 22px 0;border:1px solid #ffffff12;border-radius:12px;background:#121317}
#ranking-dialog .ranking-view-tabs button{min-height:42px;border:0;border-radius:8px;color:#aab7cc;background:transparent;font-weight:700}
#ranking-dialog .ranking-view-tabs button[aria-selected="true"]{color:#fff;background:#6250b9;box-shadow:0 2px 8px #0003}
#ranking-dialog .ranking-view-tabs button:focus-visible{outline:2px solid #c4b7ff;outline-offset:-2px}
#ranking-dialog .ranking-view-panel{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain}
#ranking-dialog .ranking-view-panel[hidden]{display:none!important}
#ranking-dialog .hub-ranking-list{min-height:140px;max-height:none;overflow:visible}
#ranking-records-panel{padding:16px 22px 22px}
#ranking-dialog .ranking-records-guide{margin:0 0 14px;color:#bdcbe0;font-size:13px;line-height:1.6}
#ranking-dialog .ranking-records-note{margin:16px 0 0;color:#97a9c3;font-size:11px;line-height:1.7}
#game-record-list article>.record-crown{flex-shrink:0}
@media(max-width:600px),(max-height:480px){
 #ranking-dialog>.hub-dialog-head{padding:13px 16px 10px}
 #ranking-dialog .hub-dialog-head h2{font-size:21px}
 #ranking-dialog .ranking-view-tabs{margin:9px 12px 0}
 #ranking-records-panel{padding:12px}
 #game-record-list article{padding:11px;gap:10px}
}

/* Spectator picker uses the same play-area coordinates as the touch editor. */
#spectator-box.tetris-touch-spectator,#tetris-touch-editor-spectator{
 position:absolute;display:flex;align-items:center;gap:6px;box-sizing:border-box;margin:0;
 width:calc(26% * var(--touch-width,1));height:calc(10% * var(--touch-height,1));
 min-width:0;min-height:0;padding:3px 7px;border:1px solid #6887a8;border-radius:9px;
 color:#dbeaf7;background:#1e1f26ed;transform-origin:center;font-size:12px;
}
#spectator-box.tetris-touch-spectator{position:absolute!important;z-index:30;left:var(--touch-layout-x);top:var(--touch-layout-y);transform:translate(-50%,-50%) scale(var(--touch-layout-scale,1));pointer-events:auto}
#spectator-box.tetris-touch-spectator[hidden]{display:none!important}
#spectator-box.tetris-touch-spectator select{flex:1;min-width:0;width:0;height:100%;min-height:0;margin:0;padding:0 18px 0 5px;font-size:12px;text-overflow:ellipsis;border:0;background-color:transparent}
#tetris-touch-editor-spectator{z-index:4;left:var(--editor-x);top:var(--editor-y);transform:translate(-50%,-50%) scale(var(--editor-scale));touch-action:none;user-select:none;cursor:grab}
#tetris-touch-editor-spectator b{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}
#tetris-touch-editor-spectator i{font-style:normal}
#tetris-touch-editor-spectator.selected{border-color:#7af8ed;background:#17626c;box-shadow:0 0 0 3px #65eade38,0 0 22px #4fe6d56b}
#tetris-touch-editor-preview.portrait #tetris-touch-editor-spectator{width:calc(56% * var(--touch-width,1));height:calc(4% * var(--touch-height,1))}
@media(orientation:portrait){#spectator-box.tetris-touch-spectator{width:calc(56% * var(--touch-width,1));height:calc(4% * var(--touch-height,1))}}
