:root{color-scheme:dark;font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",Arial,sans-serif;background:#0c1020;color:#f6f7ff}
*{box-sizing:border-box}
body{margin:0;min-height:100vh;min-height:100dvh}
button,input,select{font:inherit}
button{cursor:pointer}
a{color:inherit;text-decoration:none}
[hidden]{display:none!important}
.background{position:fixed;inset:0;z-index:-1;background:radial-gradient(ellipse 70% 50% at 20% 6%,#7933e63d,transparent 70%),radial-gradient(ellipse 55% 35% at 85% 20%,#f2219827,transparent 75%),#0b1022}
.nav{height:78px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #ffffff17;padding:0 max(20px,calc((100vw - 1060px)/2));background:#0e1422b0;backdrop-filter:blur(20px)}
.logo{font-size:27px;font-weight:1000;letter-spacing:-2px}.logo span{color:#fc3cae}.logo small{display:block;font-size:9px;letter-spacing:4px;color:#b1b7d6}
.back{color:#bbc4ed;font-size:13px}
main{max-width:1060px;padding:34px 18px 55px;margin:0 auto}
.hero{padding:25px 0 14px}.hero h1{font-size:clamp(42px,7vw,82px);font-weight:1000;letter-spacing:-.075em;line-height:.99;margin:18px 0}
.hero h1 em{font-style:normal;background:linear-gradient(100deg,#ec49df,#8061ff,#41baff);-webkit-background-clip:text;background-clip:text;color:transparent}
.hero p,.panel>p{color:#b7c0dd;line-height:1.6;max-width:660px}
.tag{font-size:11px;font-weight:900;letter-spacing:.16em;color:#b89cff}
.game-picker{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:17px;margin:25px 0 26px}
.pick{min-height:135px;background:linear-gradient(145deg,#1b2342,#111a32);border:1px solid #ffffff1d;border-radius:20px;display:flex;align-items:center;gap:19px;padding:25px;transition:border-color .2s,transform .2s}
.pick:hover,.pick:focus-visible{border-color:#9a84ff;transform:translateY(-2px)}.pick.active{border-color:#ae81ff;background:linear-gradient(140deg,#302455,#121a35)}
.pick-icon{font-size:68px;line-height:1;color:#c9afff;text-shadow:0 0 35px #c9afff44}.pick-icon.multicolor{color:#fb4fa4}
.pick strong{font-size:clamp(17px,2vw,24px);letter-spacing:-.03em;display:block}.pick small{font-size:13px;color:#aeb8d6;margin-top:8px;display:block}
.arrow{margin-left:auto;color:#9f80fc;font-size:28px;align-self:flex-start}
.panel{border:1px solid #ffffff23;background:#121a30ed;border-radius:24px;padding:clamp(17px,3vw,32px);margin-bottom:20px;box-shadow:0 20px 80px #05081635}
.section-head{display:flex;justify-content:space-between;gap:12px;align-items:center;margin-bottom:14px}
h2{font-size:clamp(24px,4vw,38px);line-height:1;margin:8px 0 0;letter-spacing:-.045em}
.tiny{font-size:10px;font-weight:800;letter-spacing:.1em;color:#a8b3d1;white-space:nowrap}
label{display:block;font-size:11px;font-weight:850;letter-spacing:.1em;color:#acb8d7;margin:20px 0 8px}
input,select{width:100%;padding:13px 16px;border-radius:13px;background:#090e22;border:1px solid #485075;color:#fff;outline:0;max-width:430px}
input:focus,select:focus{border-color:#9d83ff;box-shadow:0 0 0 3px #a98cff27}
.buttons{display:flex;gap:12px;flex-wrap:wrap;margin-top:20px}
.primary,.secondary{border:1px solid #7652cf;border-radius:13px;padding:13px 18px;font-weight:850;font-size:14px;transition:filter .2s,transform .2s}
.primary{background:linear-gradient(110deg,#d327c8,#6948fb);color:#fff;border:0;box-shadow:0 8px 22px #b92bb83b}
.secondary{background:#1d2948;color:#f5f5ff}.primary:hover,.secondary:hover{filter:brightness(1.18)}
.primary:disabled,.secondary:disabled{opacity:.45;cursor:not-allowed}
.compact{padding:8px 11px;font-size:12px}
.hint{color:#9caccc;font-size:12px;line-height:1.65}.hint.error{color:#ffa7c1}
.game-panel{max-width:900px;margin:auto}.live{font-size:12px;background:#195b4c;padding:8px 12px;border-radius:22px;white-space:nowrap}
.room-share{display:flex;align-items:center;justify-content:space-between;gap:10px;border:1px dashed #ffffff55;border-radius:13px;padding:10px;margin-bottom:20px}
#room-code{font-family:ui-monospace,monospace;font-size:15px;letter-spacing:.09em;color:#c5b4ff}
.player-head{display:flex;justify-content:space-between;align-items:center;gap:10px;margin:16px 0 19px}.player{min-width:0;flex:1;background:#1c2848;border-radius:12px;padding:12px;font-weight:700;text-align:center;overflow-wrap:anywhere}.vs{font-weight:1000;color:#e64fdb}
.board-wrap{margin:0 auto;max-width:560px;border-radius:13px;overflow:hidden;box-shadow:0 20px 36px #070a1780}
.board{display:grid;grid-template-columns:repeat(8,1fr);width:100%;aspect-ratio:1}
.square{border:0;border-radius:0;display:flex;justify-content:center;align-items:center;font-size:clamp(26px,7vw,59px);line-height:1;padding:0;position:relative;color:#171b30;touch-action:manipulation;font-family:"Segoe UI Symbol","DejaVu Sans",serif}
.square.light{background:#d7d5ed}.square.dark{background:#716caa}.square.selected{background:#e6bc55}.square.possible::after{content:"";background:#215a628c;border-radius:50%;width:21%;height:21%;position:absolute;pointer-events:none}
.square:focus-visible{outline:3px solid #e02b9e;outline-offset:-4px}
.square.white-piece{color:#fffdf3;text-shadow:1px 2px 2px #242138,-1px -1px #242138}
.square.black-piece{color:#192035;text-shadow:1px 1px 2px #e5dcf3}
.caption{color:#a6b0d0;font-size:12px;text-align:center;line-height:1.6;overflow-wrap:anywhere}
.card-table{background:radial-gradient(ellipse at center,#264260,#111c32);border:1px solid #526183;border-radius:22px;padding:25px 14px 10px;text-align:center}
.opponent-cards{display:flex;justify-content:center;gap:3px;margin-bottom:25px}.back-card{width:31px;height:51px;transform:rotate(-5deg);border:2px solid #ddd2fe;border-radius:7px;background:linear-gradient(140deg,#f450a8,#5433d5);box-shadow:0 3px 12px #0008}
.card-center{display:flex;justify-content:center;align-items:center;gap:24px}.active-color{display:grid;gap:7px;place-items:center;text-transform:uppercase;font-size:10px;color:#ccd1e4;font-weight:800}
#color-dot{width:25px;height:25px;border-radius:50%;border:3px solid #fff9}
.my-hand{display:flex;justify-content:center;flex-wrap:wrap;gap:6px;margin:18px 0 20px;min-height:124px}
.card{border:3px solid #f5f5ff;color:#fff;display:grid;place-items:center;width:76px;height:116px;border-radius:13px;background:#455;box-shadow:0 7px 10px #0004;position:relative;transition:transform .15s}
.card::before{content:"";position:absolute;inset:13px 6px;border-radius:50%;transform:rotate(-38deg);background:#fff4}
.card .card-face{position:relative;z-index:1;color:#fff;font-size:24px;font-weight:1000;text-shadow:0 2px 3px #111a}
.card.red{background:#e53d59}.card.blue{background:#2671db}.card.green{background:#22a37d}.card.yellow{background:#d3a620}.card.wild{background:conic-gradient(#e53d59 0 25%,#2671db 25% 50%,#22a37d 50% 75%,#d3a620 75%)}
.card:disabled{opacity:.57;cursor:default}.my-hand .card:not(:disabled):hover{transform:translateY(-8px)}
#top-card .card{width:91px;height:136px;cursor:default}.endrow{border-top:1px solid #ffffff16;margin-top:25px;padding-top:15px;display:flex;align-items:center;justify-content:space-between;gap:10px;color:#a0abce;font-size:12px}
.link-button{display:inline-block}.footer-note{margin-top:30px;text-align:center;color:#8b94b7;font-size:12px;line-height:1.6}
@media(max-width:650px){.nav{height:67px;padding:0 15px}.back{font-size:11px}.game-picker{grid-template-columns:1fr;gap:9px}.pick{min-height:94px;padding:17px}.pick-icon{font-size:48px}main{padding:15px 12px 38px}.hero{padding-top:17px}.panel{border-radius:16px;padding:16px}.section-head{align-items:flex-start}.tiny{font-size:9px}.room-share{flex-wrap:wrap}.player-head{margin:14px 0}.square{font-size:clamp(26px,10vw,52px)}.card{width:62px;height:94px}.card .card-face{font-size:20px}}
@media(prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}

/* UTOON Originals — polished multiplayer board and invitation flow */
:root{--panel:#111c33;--stroke:#2c3b58;--muted:#a2b2cf;--accent:#c7a2ff}
html{scroll-behavior:smooth}
body{overflow-x:hidden;background:#090f1e}
.background{background:radial-gradient(ellipse 58% 45% at 25% 5%,#764fe01e,transparent),radial-gradient(ellipse 65% 45% at 95% 20%,#e026a31a,transparent),linear-gradient(165deg,#0a1120,#111831 50%,#090e1d)}
.nav{border-bottom-color:#ffffff10}
.game-picker.in-match{display:flex;gap:10px;margin:2px auto 16px;max-width:900px}
.game-picker.in-match .pick{min-height:56px;flex:1;justify-content:center;padding:11px 15px;gap:10px;border-radius:12px;background:#151f37}
.game-picker.in-match .pick-icon{font-size:26px;text-shadow:none}
.game-picker.in-match .pick strong{font-size:14px;letter-spacing:0}
.game-picker.in-match .pick small,.game-picker.in-match .arrow{display:none}
.game-picker.in-match .pick.active{border-color:#a996ff;background:#25254d}
.game-panel{max-width:900px;border-color:#374460;padding:clamp(16px,3vw,26px);background:linear-gradient(145deg,#17223c,#111a30)}
.game-panel .section-head{padding-bottom:17px;border-bottom:1px solid #ffffff15}
.game-panel h2{font-size:clamp(26px,3.4vw,36px)}
.live{font-size:11px;letter-spacing:.045em;border:1px solid #49d9ac70;background:#124535;box-shadow:inset 0 0 22px #54ca9830}
.live.waiting{color:#ffe9b9;border-color:#9b753e;background:#3e3222;box-shadow:none}
.room-share{display:flex;background:#0b172c;border:1px solid #364665;gap:20px;padding:14px 16px;border-radius:14px}
.invite-meta{display:flex;flex-direction:column;gap:5px}.invite-meta .tag{font-size:9px}.invite-meta strong{font-size:17px;letter-spacing:.16em;color:#f2e7ff;user-select:all;font-family:ui-monospace,Menlo,Consolas,monospace}
.share-actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin-left:auto}
.share-actions .primary,.share-actions .secondary{white-space:nowrap}
.waiting-banner{background:linear-gradient(120deg,#30244a,#1c2b47);border:1px solid #cba1fd55;box-shadow:0 10px 40px #0002;border-radius:16px;padding:16px;display:flex;align-items:center;gap:15px;margin-bottom:21px}
.waiting-banner>div:nth-child(2){flex:1;min-width:0}.waiting-banner strong{font-size:15px;letter-spacing:-.02em}
.waiting-banner p{font-size:12px;line-height:1.45;color:#c6cfeb;margin:4px 0 0}
.pulse-dot{flex:0 0 11px;height:11px;width:11px;background:#ffe4a3;border-radius:50%;box-shadow:0 0 0 5px #f2c98121,0 0 18px #ffb94c88;animation:gentle-pulse 2s ease-in-out infinite}
@keyframes gentle-pulse{50%{box-shadow:0 0 0 10px #f2c98110,0 0 26px #ffb94c88}}
.player-head{max-width:640px;margin:18px auto 11px;gap:8px}
.player{padding:13px;border-radius:12px;background:#202c49;border:1px solid #ffffff14;font-size:13px}
.vs{font-size:11px;letter-spacing:.18em}
.board-wrap{max-width:590px;position:relative;border:6px solid #1c2945;box-shadow:0 20px 65px #0209158a,0 0 0 1px #6275966b;border-radius:12px}
.board-frame{position:relative;overflow:hidden;border-radius:5px}
.board{aspect-ratio:1;user-select:none}
.square{appearance:none;border:0;border-radius:0;box-shadow:none;outline-offset:-3px;line-height:1;padding:0;position:relative;display:flex;align-items:center;justify-content:center;touch-action:manipulation;overflow:hidden}
.square.light{background:#e8e8e1}
.square.dark{background:#8194a4}
.square.last-move.light{background:#efe4a4}
.square.last-move.dark{background:#bdba7c}
.square.selected,.square.selected.light,.square.selected.dark{background:#e6b65a;box-shadow:inset 0 0 0 3px #a56c16a9}
.square.possible::after{content:"";position:absolute;inset:auto;width:23%;height:23%;border-radius:50%;background:#176f6c7d;pointer-events:none}
.square.possible:has(.chess-piece)::after{width:85%;height:85%;border:5px solid #0b84768c;background:transparent}
.square:focus-visible{outline:3px solid #d61dcd;z-index:2}
.chess-piece{display:block;max-width:83%;max-height:83%;width:83%;height:83%;object-fit:contain;pointer-events:none;user-select:none;-webkit-user-drag:none;filter:drop-shadow(0 2px 1px #0002)}
.square:hover:not(:disabled){filter:brightness(1.04)}
.coord-file,.coord-rank{pointer-events:none;position:absolute;z-index:1;font-size:clamp(8px,1.2vw,12px);font-weight:850;line-height:1;color:#1f3340c7}
.coord-file{bottom:3px;right:4px}.coord-rank{top:4px;left:4px}
.square.dark .coord-file,.square.dark .coord-rank{color:#f7f5ecdc}
.chess-info{max-width:590px;margin:14px auto 0;background:#0e1b30;border:1px solid #293d5c;padding:13px 17px;border-radius:13px;display:flex;align-items:center;justify-content:space-between;gap:8px}
.chess-turn{color:#f4d6a4;font-size:12px;font-weight:850;letter-spacing:.015em;max-width:45%}
.chess-moves{color:#b0bfdb;font-family:ui-monospace,Consolas,monospace;font-size:11px;line-height:1.6;flex:1;text-align:right;overflow-wrap:anywhere;max-height:75px;overflow:auto}
.chess-instructions{text-align:center;margin-top:11px;color:#8598b7}
#game-alert:not(:empty){font-size:12px}
.game-panel #game-alert{max-width:100%;margin:0}
#waiting-banner:not([hidden])+#game-alert{margin-bottom:12px}
.buttons .secondary{border-color:#7a72b0}
@media(min-width:1000px){.game-picker.in-match{margin-top:0}.nav{height:70px}main:has(.game-picker.in-match){padding-top:20px}}
@media(max-width:720px){
.game-picker.in-match{display:grid;grid-template-columns:1fr 1fr;gap:7px}
.game-picker.in-match .pick{min-height:53px;padding:10px 8px}
.game-picker.in-match .pick-icon{font-size:20px}
.game-picker.in-match .pick strong{font-size:12px;line-height:1.2}
.game-panel .section-head{gap:7px;align-items:center}
.game-panel .section-head h2{font-size:25px}
.live{font-size:9px;padding:7px 8px}
.waiting-banner{display:grid;grid-template-columns:12px 1fr;gap:11px;padding:12px}
.waiting-banner .primary,.waiting-banner .secondary{grid-column:1/-1;width:100%;font-size:12px;min-height:42px}
.room-share{flex-direction:column;align-items:stretch;gap:9px}
.share-actions{margin-left:0;width:100%}
.share-actions button{flex:1}
.player-head{margin:14px auto 9px}
.player{padding:10px 6px;font-size:12px}
.board-wrap{width:100%;border-width:3px;border-radius:8px}
.chess-info{padding:10px}
.chess-turn,.chess-moves{font-size:11px}
.chess-piece{width:90%;height:90%;max-width:90%;max-height:90%}
.coord-file,.coord-rank{font-size:9px}
}
@media(prefers-reduced-motion:reduce){.pulse-dot{animation:none}}

.promotion-menu{max-width:590px;background:#293156;margin:12px auto;border:1px solid #cfafff;border-radius:12px;padding:13px;text-align:center}
.promotion-menu strong{display:block;color:#f1d7fe;font-size:12px;margin-bottom:10px}
.promotion-options{display:flex;flex-wrap:wrap;justify-content:center;gap:7px}
.promotion-options button{font-size:12px;padding:9px 11px}


/* Stable game-first layout (UTOON Originals).
   Secondary controls never occupy the board's grid area or shift its position. */
body.match-active .game-picker.in-match{display:none}
body.match-active .footer-note{display:none}
body.match-active main{max-width:1240px;padding-top:16px}
body.match-active .game-panel{max-width:1160px;margin-inline:auto}
#match.is-chess {
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(240px,292px);
  grid-template-rows:auto auto auto auto auto;
  column-gap:clamp(14px,2.6vw,28px);
  row-gap:10px;
  align-items:start;
  padding:clamp(12px,2vw,22px);
}
#match.is-chess > .section-head{
  grid-column:1/-1;grid-row:1;
  margin:0;padding:0 0 10px;
  min-height:50px;
}
#match.is-chess .section-head h2{
  font-size:clamp(18px,2.2vw,26px);line-height:1.15;
  margin:3px 0 0;
}
#match.is-chess #chess-ui{display:contents}
#match.is-chess .player-head{
  grid-column:1;grid-row:2;margin:0;
  width:100%;max-width:none;min-height:46px;
}
#match.is-chess .room-share{
  grid-column:2;grid-row:2;
  margin:0;padding:10px 12px;gap:9px;min-height:46px;
  flex-direction:column;align-items:stretch;
}
#match.is-chess .room-share .share-actions{margin:0;width:100%}
#match.is-chess .room-share .share-actions button{flex:1}
#match.is-chess .board-wrap{
  grid-column:1;grid-row:3;
  width:min(100%,calc(100dvh - 148px));
  max-width:690px;
  margin:0 auto;
  align-self:start;
  position:sticky;top:12px;
}
#match.is-chess .chess-info{
  grid-column:1;grid-row:4;
  margin:0;width:100%;max-width:690px;min-height:46px;
}
#match.is-chess .chess-instructions{
  grid-column:1;grid-row:5;
  margin:0;max-width:690px;
  justify-self:center;
}
#match.is-chess .promotion-menu{
  grid-column:1;grid-row:6;
  margin:0;width:100%;max-width:690px;
}
#match.is-chess .waiting-banner{
  grid-column:2;grid-row:3;
  display:flex;flex-wrap:wrap;align-content:start;
  margin:0;min-width:0;
}
#match.is-chess .waiting-banner .primary,
#match.is-chess .waiting-banner .secondary{flex:1 1 100%}
#match.is-chess #game-alert{
  grid-column:2;grid-row:4;
  margin:0;min-width:0;
}
#match.is-chess .endrow{
  grid-column:2;grid-row:5;
  margin:0;border:1px solid #ffffff12;
  padding:12px;border-radius:12px;
  display:flex;align-items:center;justify-content:space-between;
  min-width:0;
}
#match.is-chess .endrow .link-button{padding:10px 12px}
@media (max-width:760px){
  body.match-active main{padding:8px 8px 28px}
  body.match-active .nav{height:50px;padding-inline:12px}
  body.match-active .logo{font-size:22px}
  body.match-active .logo small{font-size:8px}
  #match.is-chess{
    display:flex;flex-direction:column;gap:8px;
    padding:10px 9px 16px;border-radius:12px;
  }
  #match.is-chess > .section-head{
    width:100%;flex:0 0 auto;
    min-height:36px;padding:0 0 6px;
  }
  #match.is-chess .section-head .tag{font-size:9px}
  #match.is-chess .section-head h2{font-size:18px;margin:2px 0 0}
  #match.is-chess .live{font-size:9px}
  #match.is-chess .player-head{
    order:1;width:100%;min-height:36px;
    margin:0;gap:5px;
  }
  #match.is-chess .player{padding:8px 5px;font-size:11px}
  #match.is-chess .board-wrap{
    order:2;flex:none;
    width:min(100%,calc(100dvh - 162px));
    max-width:520px;
    margin:0 auto;
    position:sticky;top:6px;
    z-index:3;
  }
  #match.is-chess .chess-info{
    order:3;width:100%;max-width:520px;margin:0 auto;
    min-height:38px;padding:8px 10px;
  }
  #match.is-chess .room-share{
    order:4;width:100%;max-width:520px;margin:0 auto;
    min-height:0;display:flex;flex-direction:row;
    align-items:center;flex-wrap:wrap;
  }
  #match.is-chess .room-share .invite-meta{flex:1 1 130px}
  #match.is-chess .room-share .share-actions{
    flex:1 1 170px;width:auto;
  }
  #match.is-chess .waiting-banner{
    order:5;width:100%;max-width:520px;margin:0 auto;
  }
  #match.is-chess .waiting-banner .primary,
  #match.is-chess .waiting-banner .secondary{min-height:40px}
  #match.is-chess #game-alert{order:6;width:100%;max-width:520px;margin:0 auto}
  #match.is-chess .chess-instructions{
    order:7;max-width:520px;
    text-align:center;margin:0 auto;
    color:#8090ac;font-size:11px;line-height:1.5;
  }
  #match.is-chess .promotion-menu{order:3;width:100%;max-width:520px;margin:0 auto}
  #match.is-chess .endrow{
    order:8;width:100%;max-width:520px;margin:0 auto;
    padding:8px 11px;
  }
}
@media(max-width:350px){
  #match.is-chess .section-head h2{font-size:16px}
  #match.is-chess .room-share .share-actions{flex-basis:100%}
}
@media(max-height:540px) and (orientation:landscape){
  #match.is-chess .board-wrap{width:min(100%,calc(100dvh - 85px))}
}

html:has(body.match-active){scroll-behavior:auto}

#match.is-chess .section-head .live{flex:0 0 116px;min-width:116px;text-align:center;white-space:nowrap}
@media(max-width:350px){#match.is-chess .section-head .live{flex-basis:105px;min-width:105px}}

@media(max-width:760px){#match.is-chess .player-head{height:42px;min-height:42px}#match.is-chess .player{height:42px;display:flex;align-items:center;justify-content:center;line-height:1.15;max-height:42px;overflow:hidden}#match.is-chess > .section-head{height:48px;min-height:48px;max-height:48px;overflow:hidden}#match.is-chess .section-head h2{line-height:1.1}}

/* Detached secondary sidebar: header/player/board rows stay fixed on desktop. */
#match.is-chess > .chess-sidebar{
 grid-column:2;grid-row:2 / 7;
 display:flex;flex-direction:column;gap:12px;
 min-width:0;align-self:start;
 position:sticky;top:12px;
}
#match.is-chess > .chess-sidebar .room-share,
#match.is-chess > .chess-sidebar .waiting-banner,
#match.is-chess > .chess-sidebar #game-alert,
#match.is-chess > .chess-sidebar .endrow{
 grid-column:auto;grid-row:auto;
 margin:0;width:100%;
}
#match.is-chess > .chess-sidebar .waiting-banner{flex-direction:column;align-items:stretch}
#match.is-chess > .chess-sidebar .waiting-banner .pulse-dot{align-self:flex-start}
#match.is-chess > .chess-sidebar .endrow{margin-top:6px}
@media(max-width:760px){
 #match.is-chess > .chess-sidebar{
   position:static;order:4;
   display:flex;flex-direction:column;align-self:center;
   width:100%;max-width:520px;gap:8px;
 }
 #match.is-chess > .chess-sidebar .waiting-banner{display:grid;grid-template-columns:12px 1fr;align-items:center}
 #match.is-chess > .chess-sidebar .waiting-banner .primary,
 #match.is-chess > .chess-sidebar .waiting-banner .secondary{grid-column:1/-1}
 #match.is-chess > .chess-sidebar .endrow{margin-top:0}
}

/* Fixed 8x8 chess geometry: prevent intrinsic button sizes stretching rows. */
#chess-board.board{display:grid;grid-template-columns:repeat(8,minmax(0,1fr));grid-template-rows:repeat(8,minmax(0,1fr));width:100%;aspect-ratio:1/1;min-width:0;min-height:0;}
#chess-board>.square{display:flex;min-width:0;min-height:0;width:100%;height:100%;aspect-ratio:1/1;overflow:hidden;}

/* Mobile chess: fit the entire match within the visible viewport, no page scroll. */
@media(max-width:760px){
 body.match-active{height:100dvh;overflow:hidden;}
 body.match-active main{height:calc(100dvh - 50px);min-height:0;overflow:hidden;padding:4px 6px;}
 body.match-active #match.is-chess{height:100%;min-height:0;overflow:hidden;gap:4px;padding:5px;}
 #match.is-chess>.section-head{min-height:0;padding:0;height:28px;flex:0 0 28px;}
 #match.is-chess .section-head h2{font-size:15px;}
 #match.is-chess .player-head{min-height:0;height:30px;flex:0 0 30px;}
 #match.is-chess .player{padding:5px;font-size:10px;}
 #match.is-chess .board-wrap{width:min(100%,calc(100dvh - 215px));max-width:520px;position:relative;top:auto;}
 #match.is-chess .chess-info{min-height:28px;padding:5px 8px;}
 #match.is-chess .chess-instructions{display:none;}
 #match.is-chess .room-share{padding:5px;gap:4px;}
 #match.is-chess .room-share .share-actions button{min-height:30px;padding:5px 8px;}
 #match.is-chess .endrow{padding:4px 8px;margin:0;}
}

/* Recovery: prevent overlap/clipping, keep board first and controls accessible. */
@media(max-width:760px){
 html,body.match-active{height:auto;min-height:100dvh;overflow-x:hidden;overflow-y:auto;}
 body.match-active main{height:auto;min-height:0;overflow:visible;padding:6px 8px 16px;}
 body.match-active #match.is-chess{display:flex;flex-direction:column;height:auto;min-height:0;overflow:visible;gap:7px;padding:9px;}
 #match.is-chess>.section-head{order:0;position:static;height:auto;min-height:44px;max-height:none;overflow:visible;padding:0 0 4px;}
 #match.is-chess .section-head h2{font-size:17px;line-height:1.15;}
 #match.is-chess .player-head{order:1;height:38px;min-height:38px;max-height:38px;flex:0 0 38px;}
 #match.is-chess .player{height:38px;max-height:38px;padding:5px;}
 #match.is-chess #chess-ui{display:contents;}
 #match.is-chess .board-wrap{order:2;position:relative;top:auto;flex:0 0 auto;width:min(100%,calc(100dvh - 235px));max-width:520px;aspect-ratio:1/1;margin:0 auto;}
 #match.is-chess .chess-info{order:3;min-height:34px;margin:0 auto;padding:7px 9px;}
 #match.is-chess>.chess-sidebar{order:4;position:static;display:flex;flex-direction:column;gap:7px;width:100%;max-width:520px;margin:0 auto;}
 #match.is-chess .room-share,#match.is-chess .waiting-banner{height:auto;max-height:none;overflow:visible;}
 #match.is-chess .chess-instructions{display:none;}
}

/* Compact player names without affecting the board. */
#match.is-chess .player-head{gap:6px;min-height:0;}
#match.is-chess .player{min-height:0;padding:7px 9px;border-radius:9px;font-size:clamp(11px,2.6vw,14px);line-height:1.15;}
#match.is-chess .vs{font-size:14px;flex:0 0 auto;}
@media(max-width:760px){
 #match.is-chess .player-head{height:29px;min-height:29px;max-height:29px;flex:0 0 29px;margin:0;}
 #match.is-chess .player{height:29px;max-height:29px;padding:4px 7px;font-size:11px;border-radius:7px;}
 #match.is-chess .vs{font-size:12px;}
}

/* Player names beside WAITING status in match header. */
@media(max-width:760px){
 #match.is-chess>.section-head{display:flex;flex-wrap:wrap;align-items:center;gap:5px 8px;height:auto;min-height:42px;max-height:none;}
 #match.is-chess>.section-head>div:first-child{flex:1 1 125px;min-width:0;}
 #match.is-chess>.section-head .live{flex:0 0 auto;min-width:85px;padding:6px 9px;}
 #match.is-chess>.player-head{order:0;align-self:flex-end;width:auto;max-width:100%;height:25px;min-height:25px;max-height:25px;flex:0 1 auto;margin:0;}
 #match.is-chess>.player-head .player{height:25px;max-height:25px;min-width:0;padding:4px 7px;font-size:10px;}
 #match.is-chess>.player-head .vs{font-size:10px;}
}

@media(max-width:760px){
 #match.is-chess>.section-head{display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto 26px;gap:4px 8px;align-items:center;}
 #match.is-chess>.section-head>div:first-child{grid-column:1/-1;grid-row:1;}
 #match.is-chess>.section-head>.player-head{grid-column:1;grid-row:2;justify-self:stretch;align-self:center;width:100%;max-width:none;min-width:0;}
 #match.is-chess>.section-head>.live{grid-column:2;grid-row:2;min-width:82px;}
}

/* Two equal actions side-by-side in the waiting room. */
@media(max-width:760px){
 #match.is-chess>.chess-sidebar .waiting-banner{grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px;padding:10px;}
 #match.is-chess>.chess-sidebar .waiting-banner>.pulse-dot{grid-column:1;grid-row:1;}
 #match.is-chess>.chess-sidebar .waiting-banner>div:nth-child(2){grid-column:1/-1;grid-row:2;}
 #match.is-chess>.chess-sidebar .waiting-banner #waiting-share{grid-column:1;grid-row:3;width:100%;min-width:0;min-height:42px;padding:8px 5px;font-size:11px;}
 #match.is-chess>.chess-sidebar .waiting-banner #waiting-bot{grid-column:2;grid-row:3;width:100%;min-width:0;min-height:42px;padding:8px 5px;font-size:11px;}
}

/* New match beside title, remove unused bottom footer. */
#match.is-chess>.section-head>#new-match{grid-column:auto;grid-row:auto;flex:0 0 auto;padding:7px 10px;font-size:12px;line-height:1.1;white-space:nowrap;border-radius:9px;}
#match.is-chess>.chess-sidebar .endrow{display:none;}
@media(max-width:760px){
 #match.is-chess>.section-head{grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto 26px;}
 #match.is-chess>.section-head>div:first-child{grid-column:1;grid-row:1;min-width:0;}
 #match.is-chess>.section-head>#new-match{grid-column:2;grid-row:1;justify-self:end;padding:6px 8px;font-size:11px;}
 #match.is-chess>.section-head>.player-head{grid-column:1;grid-row:2;}
 #match.is-chess>.section-head>.live{grid-column:2;grid-row:2;}
}

/* Keep the chessboard entirely below the match header on small screens. */
@media(max-width:760px){
 #match.is-chess>.section-head{flex:0 0 auto;align-self:stretch;height:auto;min-height:0;max-height:none;overflow:visible;position:relative;z-index:1;margin:0 0 6px;}
 #match.is-chess .board-wrap{flex:0 0 auto;position:relative;top:auto;clear:both;margin:0 auto;z-index:0;}
 #match.is-chess .board-frame{position:relative;}
}

/* Names on the first line beside INVITE FRIEND, not below title. */
@media(max-width:760px){
 #match.is-chess>.section-head{display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto auto;gap:5px 8px;align-items:center;}
 #match.is-chess>.section-head>div:first-child{grid-column:1;grid-row:1/3;align-self:center;}
 #match.is-chess>.section-head>.player-head{grid-column:1;grid-row:1;justify-self:end;align-self:start;width:min(62%,245px);height:25px;min-height:25px;max-height:25px;z-index:2;}
 #match.is-chess>.section-head>#new-match{grid-column:2;grid-row:1;align-self:start;}
 #match.is-chess>.section-head>.live{grid-column:2;grid-row:2;align-self:center;}
 #match.is-chess>.section-head>div:first-child .tag{display:inline-block;max-width:36%;}
 #match.is-chess>.section-head>div:first-child h2{margin-top:7px;}
}

/* Compact pre-game lobby on phones: game choices and setup visible sooner. */
@media(max-width:760px){
 body:not(.match-active) main{padding:12px 12px 24px;}
 body:not(.match-active) .hero{padding:4px 0 2px;}
 body:not(.match-active) .hero h1{font-size:clamp(30px,8vw,43px);margin:7px 0;line-height:1;}
 body:not(.match-active) .hero p{font-size:12px;line-height:1.4;margin:5px 0;}
 body:not(.match-active) .game-picker{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:12px 0;}
 body:not(.match-active) .pick{min-height:76px;padding:9px;gap:7px;border-radius:13px;}
 body:not(.match-active) .pick-icon{font-size:27px;}
 body:not(.match-active) .pick strong{font-size:12px;line-height:1.2;}
 body:not(.match-active) .pick small{font-size:10px;line-height:1.2;margin-top:3px;}
 body:not(.match-active) .pick .arrow{display:none;}
 body:not(.match-active) #lobby{padding:14px;border-radius:15px;margin-bottom:8px;}
 body:not(.match-active) #lobby .section-head{margin-bottom:6px;}
 body:not(.match-active) #lobby h2{font-size:20px;margin-top:4px;}
 body:not(.match-active) #lobby>p{font-size:12px;line-height:1.35;margin:6px 0;}
 body:not(.match-active) #lobby label{margin:9px 0 5px;}
 body:not(.match-active) #lobby input{padding:9px 11px;}
 body:not(.match-active) #lobby .buttons{margin-top:10px;gap:8px;flex-wrap:nowrap;}
 body:not(.match-active) #lobby .buttons button{flex:1;min-width:0;padding:10px 6px;font-size:11px;}
}

/* Sharper, modern corners across UTOON Originals. */
.panel{border-radius:12px;}
.pick{border-radius:9px;}
.primary,.secondary,.link-button{border-radius:8px;}
input,select{border-radius:8px;}
.room-share,.waiting-banner,.chess-info{border-radius:9px;}
.board-wrap{border-radius:7px;}
.player{border-radius:7px;}
@media(max-width:760px){body:not(.match-active) .pick{border-radius:8px;}body:not(.match-active) #lobby{border-radius:10px;}}

/* Elemental Wardens original — isolated, responsive game frame */
#wardens-link{grid-column:1/-1;background:linear-gradient(115deg,#1f3b41,#141d38);min-height:115px}
#wardens-link .pick-icon{color:#8ce4cb;text-shadow:0 0 32px #56d9af48}
.game-picker.in-match #wardens-link{display:none}
.ew-page{height:100dvh;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.ew-page .nav{flex:0 0 auto}
.ew-page .ew-main{width:100%;max-width:1480px;margin:0 auto;padding:14px 20px;flex:1;min-height:0;display:flex;flex-direction:column;gap:10px}
.ew-header{display:flex;align-items:center;justify-content:space-between;gap:12px}
.ew-header .tag{font-size:10px}
.ew-header h1{font-size:clamp(22px,2.9vw,34px);line-height:1.13;letter-spacing:-.04em;margin:5px 0 0}
.ew-full{padding:9px 13px;border:1px solid #48606d;border-radius:11px;color:#9ce7d8;font-size:12px;font-weight:800;white-space:nowrap}
.ew-full:hover{background:#244153}
.ew-frame{background:#121e20;border:1px solid #41546c;border-radius:13px;overflow:hidden;flex:1;min-height:0}
.ew-frame iframe{width:100%;height:100%;display:block;border:0}
.ew-footer{display:flex;align-items:center;justify-content:space-between;gap:15px;color:#a4b4d1;font-size:12px}
.ew-footer p{margin:0}.ew-footer a{color:#96e8d6;white-space:nowrap}
@media(max-width:650px){.ew-page .ew-main{padding:8px 5px;gap:7px}.ew-header{padding:2px 8px}.ew-header h1{font-size:21px}.ew-header .tag{font-size:9px}.ew-full{font-size:10px;padding:8px}.ew-frame{border-radius:8px}.ew-footer{padding:0 8px}.ew-footer p{display:none}}

/* 2026-11: Game-first responsive viewport fitting.
   This never suppresses page scrolling. The board and controls are sized instead. */
body.originals-entry .hero,
body.originals-entry .game-picker,
body.originals-entry .footer-note { display:none; }
body.originals-entry:not(.match-active) .nav { height:50px; }
body.originals-entry:not(.match-active) main { padding:clamp(8px,1.5vh,16px) 10px; min-height:calc(100dvh - 50px); display:grid; align-items:center; }
body.originals-entry:not(.match-active) #lobby { max-width:560px; width:100%; margin:0 auto; padding:clamp(14px,2vw,22px); }
body.originals-entry:not(.match-active) #lobby label { margin-top:10px; }
body.originals-entry:not(.match-active) #lobby .buttons { margin-top:12px; }
body.originals-entry:not(.match-active) #lobby .buttons button { flex:1 1 120px; }
body.match-active { height:auto!important; min-height:100dvh; overflow-x:hidden; overflow-y:auto!important; }
body.match-active .nav { height:46px!important; min-height:46px; }
body.match-active main { max-width:100%; width:100%; min-height:calc(100dvh - 46px); height:auto!important; overflow:visible!important; padding:6px 8px max(9px,env(safe-area-inset-bottom))!important; display:flex; align-items:center; justify-content:center; }
body.match-active #match.game-panel { position:relative; min-width:0; width:100%; max-width:950px; height:auto!important; min-height:0; margin:0 auto; overflow:visible!important; padding:clamp(6px,1vh,12px); border-radius:10px; }
#match.is-chess { display:flex!important; flex-direction:column; align-items:center; gap:clamp(4px,.85vh,9px); max-width:750px!important; }
#match.is-chess > .section-head,
#match.is-cards > .section-head { width:100%; margin:0!important; padding:0 0 4px!important; border-bottom:1px solid #ffffff18; display:grid!important; grid-template-columns:minmax(0,1fr) auto auto; grid-template-rows:auto auto; gap:2px 6px; align-items:center; min-height:0!important; max-height:none!important; height:auto!important; overflow:visible!important; }
#match.game-panel > .section-head > div:first-child { grid-column:1; grid-row:1; min-width:0; align-self:center; }
#match.game-panel > .section-head > div:first-child .tag { font-size:9px; display:block; }
#match.game-panel > .section-head h2 { margin:1px 0 0!important; font-size:clamp(14px,2.2vw,19px)!important; line-height:1.14; }
#match.game-panel > .section-head > #new-match { grid-column:2; grid-row:1; padding:6px 9px; font-size:11px; align-self:center; }
#match.game-panel > .section-head > .match-controls-toggle { grid-column:3; grid-row:1; padding:6px 9px; font-size:11px; white-space:nowrap; min-height:32px; }
#match.game-panel > .section-head > .player-head { grid-column:1 / 3; grid-row:2; width:100%!important; min-width:0; max-width:none!important; height:auto!important; max-height:30px!important; min-height:26px!important; flex:none; margin:0!important; align-self:center!important; justify-self:stretch!important; gap:5px; }
#match.game-panel > .section-head > .player-head .player { height:auto!important; min-height:26px; max-height:28px; padding:5px 8px; font-size:11px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#match.game-panel > .section-head > .live { grid-column:3; grid-row:2; min-width:0!important; flex:none; font-size:9px; text-align:center; padding:6px; }
#match.is-chess #chess-ui { display:contents!important; }
#match.is-chess .board-wrap { grid-column:auto; grid-row:auto; order:2!important; position:relative!important; top:auto!important; width:min(100%,var(--chess-fit,560px))!important; max-width:560px!important; aspect-ratio:1; flex:none!important; margin:0 auto!important; border-width:clamp(2px,.45vw,4px); }
#match.is-chess .chess-info { grid-column:auto; grid-row:auto; order:3!important; width:min(100%,var(--chess-fit,560px))!important; max-width:560px!important; padding:5px 9px!important; min-height:30px!important; margin:0 auto!important; }
#match.is-chess .chess-instructions { display:none!important; }
#match.is-chess .promotion-menu:not([hidden]) { position:absolute; z-index:25; top:50%; left:50%; transform:translate(-50%,-50%); width:min(94%,460px); background:#202743; padding:13px; box-shadow:0 0 0 100vmax #060715bd; }
#match.game-panel > .match-controls { position:absolute!important; z-index:30; top:46px; right:3px; width:min(96%,340px)!important; max-width:340px!important; display:none!important; flex-direction:column; gap:8px; max-height:min(76dvh,540px); overflow-y:auto; overscroll-behavior:contain; padding:10px; border:1px solid #7c65b3; border-radius:12px; background:#151d37; box-shadow:0 18px 40px #060816e8; }
#match.game-panel > .match-controls.is-open { display:flex!important; }
#match.game-panel > .match-controls .room-share { width:100%; padding:8px; margin:0; flex-direction:column; gap:7px; }
#match.game-panel > .match-controls .share-actions { width:100%; gap:6px; }
#match.game-panel > .match-controls .share-actions button { min-height:34px; flex:1; padding:7px; }
#match.game-panel > .match-controls .waiting-banner { width:100%; display:flex; flex-direction:column; align-items:stretch; gap:7px; margin:0; padding:9px; }
#match.game-panel > .match-controls .waiting-banner button { min-height:36px; width:100%; }
#match.game-panel > .match-controls #game-alert:not(:empty) { margin:0; font-size:12px; overflow-wrap:anywhere; }
#match.game-panel > .match-controls .endrow { display:none!important; }
#match.is-cards { display:flex!important; flex-direction:column; align-items:stretch; gap:clamp(3px,.7vh,8px); max-width:940px!important; }
#match.is-cards #cards-ui:not([hidden]) { display:flex; flex-direction:column; align-items:center; width:100%; min-height:0; gap:clamp(3px,.7vh,7px); }
#match.is-cards .card-table { width:100%; flex:none; min-height:0; padding:clamp(7px,1.1vh,12px); border-radius:10px; }
#match.is-cards .opponent-cards { margin-bottom:5px; height:clamp(22px,5vh,40px); overflow:hidden; }
#match.is-cards .back-card { flex:none; width:clamp(15px,3.7vw,26px); height:clamp(25px,6vh,39px); }
#match.is-cards .card-center { gap:clamp(8px,2vw,20px); }
#match.is-cards #top-card .card { width:clamp(50px,10vh,77px); height:clamp(72px,15vh,110px); }
#match.is-cards .card-table .caption { margin:4px 0 0; line-height:1.2; }
#match.is-cards #cards-ui>label { margin:1px 0 0; font-size:10px; }
#match.is-cards #wild-color { max-width:260px; padding:6px 10px; height:35px; }
#match.is-cards .my-hand { width:100%; flex:none; min-height:0; margin:2px 0; display:flex; align-items:center; justify-content:safe center; flex-wrap:nowrap; gap:clamp(2px,.55vw,6px); overflow-x:auto; overflow-y:visible; padding:6px 3px; scrollbar-width:thin; }
#match.is-cards .my-hand .card { flex:0 0 auto; width:clamp(42px,9vw,70px); height:clamp(62px,15vh,104px); }
#match.is-cards #draw { width:min(100%,290px); min-height:34px; padding:8px 12px; }
#match.is-cards .cards-rules { font-size:11px; color:#9daecf; max-width:100%; text-align:center; }
#match.is-cards .cards-rules summary { cursor:pointer; }
#match.is-cards .cards-rules[open] { padding:8px; border:1px solid #344b69; border-radius:8px; }
#match.is-cards .cards-rules p { line-height:1.45; }
@media(max-height:630px) {
 #match.game-panel > .section-head > div:first-child .tag { display:none!important; }
 #match.is-cards .card-table { padding:4px 7px; }
 #match.is-cards .opponent-cards { margin-bottom:2px; height:25px; }
 #match.is-cards #top-card .card { height:72px; width:51px; }
 #match.is-cards .my-hand .card { height:68px; width:45px; }
 #match.is-cards #cards-ui { gap:2px; }
 #match.is-cards .cards-rules { display:none; }
}
@media(max-width:500px) {
 #match.game-panel > .section-head h2 { font-size:14px!important; }
 #match.game-panel > .section-head > .player-head .player { font-size:10px; }
 #match.is-cards .my-hand .card { width:45px; height:72px; }
}

/* Accessible popover: open over the game, never beyond the viewport. */
#match.game-panel > .match-controls{max-height:calc(100dvh - 72px);}
@media(max-height:490px) and (orientation:landscape){
 body.match-active .nav{height:36px!important;min-height:36px}
 body.match-active main{min-height:calc(100dvh - 36px);padding:2px 6px max(2px,env(safe-area-inset-bottom))!important;}
 body.match-active #match.game-panel{padding:4px;gap:2px}
 #match.game-panel > .section-head{gap:0 5px;padding:0 0 2px!important}
 #match.game-panel > .section-head > .player-head{max-height:23px!important;min-height:23px!important}
 #match.game-panel > .section-head > .player-head .player{min-height:22px;max-height:22px;padding:3px 5px}
 #match.game-panel > .section-head > .match-controls-toggle{min-height:26px;padding:4px 7px}
 #match.is-cards #cards-ui:not([hidden]){gap:2px}
 #match.is-cards .card-table{padding:3px 6px}
 #match.is-cards .opponent-cards{height:17px;margin:0 0 2px}
 #match.is-cards .back-card{height:22px;width:13px;border-width:1px}
 #match.is-cards #top-card .card{width:43px;height:58px}
 #match.is-cards .card-table .caption{font-size:9px;margin-top:1px}
 #match.is-cards #cards-ui>label{margin:0;font-size:9px}
 #match.is-cards #wild-color{height:27px;padding:3px 8px}
 #match.is-cards .my-hand{margin:0;padding:1px 3px}
 #match.is-cards .my-hand .card{width:39px;height:52px;border-width:2px}
 #match.is-cards .my-hand .card .card-face{font-size:15px}
 #match.is-cards #draw{min-height:27px;padding:4px 8px}
 #match.is-cards .cards-rules{display:block;font-size:9px}
}

/* Elemental Wardens embeds: fit the frame first; scroll normally only on tiny screens. */
.ew-page{height:auto;min-height:100dvh;overflow-x:hidden;overflow-y:auto}
.ew-page .ew-main{height:calc(100dvh - 78px);min-height:0}
.ew-page .ew-frame{min-height:clamp(195px,35dvh,270px)}
@media(max-width:650px){
 .ew-page .ew-main{height:calc(100dvh - 67px);min-height:0}
}

/* Critical: absolutely anchor the iframe to the *measured flex frame*.
   A 100%-height iframe in a flex item with indefinite intrinsic height
   collapses to its default 150px, leaving a blank page-sized frame. */
.ew-page .ew-frame{position:relative;flex:1 1 auto;min-height:clamp(195px,35dvh,270px);}
.ew-page .ew-frame iframe{position:absolute;inset:0;width:100%;height:100%;min-height:0;display:block;border:0;}

/* Short landscape: allocate space to playing, not the marketing shell. */
@media(max-height:600px) and (orientation:landscape){
 .ew-page .nav{height:38px;flex:0 0 38px;padding-inline:10px;}
 .ew-page .logo{font-size:20px;}
 .ew-page .logo small{font-size:7px;}
 .ew-page .ew-main{height:calc(100dvh - 38px);padding:4px 8px;gap:4px;}
 .ew-page .ew-header{flex:0 0 auto;min-height:27px;}
 .ew-page .ew-header .tag{display:none;}
 .ew-page .ew-header h1{font-size:16px;margin:0;}
 .ew-page .ew-full{font-size:10px;padding:5px 7px;}
 .ew-page .ew-frame{min-height:160px;}
 .ew-page .ew-footer{display:none;}
}


/* UTOON Originals full-bleed gameplay; the real game owns its internal scrolling. */
html:has(body.ew-immersive){width:100%;height:100%;overflow:hidden;}
body.ew-page.ew-immersive{position:relative;display:block;width:100%;height:100dvh;min-height:0;margin:0;padding:0;overflow:hidden;background:#19382f;}
.ew-immersive .ew-immersive-shell{position:fixed;inset:0;width:100%;height:100dvh;max-width:none;min-height:0;margin:0;padding:0;display:block;overflow:hidden;}
.ew-immersive .ew-immersive-shell iframe{position:absolute;inset:0;display:block;width:100%;height:100%;border:0;background:#19382f;}
