:root{color-scheme:dark;--gold:#f5d58a;--ink:#f4f2e9}*{box-sizing:border-box}body{margin:0;background:#101d24;color:var(--ink);font:16px/1.6 system-ui,sans-serif}header,main{max-width:1100px;margin:auto;padding:18px}header{display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap}h1,h2,p{margin:0 0 12px}h1{font-size:28px}h1 small{display:block;font-size:11px;letter-spacing:.3em;color:var(--gold)}h2{font-size:19px}a{color:var(--gold)}button,select{font:inherit;border:1px solid #60737b;border-radius:8px;padding:9px 14px;background:#253943;color:var(--ink);cursor:pointer}button:disabled{opacity:.4;cursor:not-allowed}button:focus-visible,select:focus-visible{outline:3px solid var(--gold);outline-offset:3px}.primary{background:var(--gold);color:#242016;border-color:var(--gold);font-weight:700}.players{display:grid;grid-template-columns:repeat(auto-fit,minmax(135px,1fr));gap:10px;margin-bottom:18px}.player{border:1px solid #4a6269;border-radius:12px;padding:12px;background:#192d35}.player.active{border-color:var(--gold);box-shadow:0 0 0 2px #f5d58a33}.player small{display:block;color:#c0cdd0}.table{padding:24px;text-align:center;min-height:310px;border:3px solid #647969;border-radius:28px;background:radial-gradient(ellipse at center,#286452,#174336);box-shadow:inset 0 0 65px #091e1a88}.table-top{display:flex;justify-content:space-between;gap:12px;font-size:14px;color:#e8ddba;margin-bottom:18px}.cards{display:flex;gap:8px;flex-wrap:wrap;align-items:center}.pile{justify-content:center;min-height:106px}.card{position:relative;width:64px;height:92px;border:2px solid #d9d7ce;border-radius:8px;background:#fffaf0;color:#182634;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:24px;font-weight:800;padding:4px;box-shadow:0 3px 5px #0003;flex-shrink:0;line-height:1.15}.card.red{color:#be3544}.card.joker{color:#70429a;font-size:15px}.card.selected{transform:translateY(-10px);border-color:#eab448;box-shadow:0 0 0 3px #eab448}.card small{font-size:20px}.hand-area{margin:24px 0}.hand-title{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}.hand{padding:18px 2px 10px;min-height:124px}.actions{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;margin-top:14px}#status{min-height:26px;color:#ffeab8}#tableInfo{color:#d5e6dd;font-size:14px;min-height:23px;margin-top:10px}details{border-top:1px solid #496069;padding:16px 0}#log{max-height:220px;overflow:auto;font-size:14px;color:#c2d3d7}dialog{width:min(740px,95vw);max-height:90vh;background:#172a32;color:var(--ink);border:1px solid #678087;border-radius:16px;padding:26px}dialog::backdrop{background:#000a}.rules{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:18px 0}.rule{padding:12px;background:#223b44;border-radius:8px;cursor:pointer}.rule input{accent-color:#dfb95b;width:18px;height:18px;margin-right:8px}.rule small{display:block;color:#bdced2;font-size:13px;margin-top:4px}.selects{display:flex;gap:20px;flex-wrap:wrap}.selects label{display:grid;gap:4px}.note{font-size:13px;color:#bdced2}#next{background:#3e705c} @media(max-width:600px){header,main{padding:12px}.table{padding:16px 10px;min-height:285px}.card{width:49px;height:73px;font-size:20px}.cards{gap:6px}.rules{grid-template-columns:1fr}.hand-title button{font-size:13px;padding:7px}.players{grid-template-columns:repeat(3,1fr);gap:6px}.player{padding:8px;font-size:14px}.table-top{font-size:12px}}@media(prefers-reduced-motion:no-preference){.card{transition:transform .12s}.player{transition:border-color .2s}}
/* Card-table presentation */
.table{position:relative;overflow:hidden;background:radial-gradient(ellipse at 50% 35%,#34745b,#133d32);border:7px solid #66513b;box-shadow:0 12px 30px #0005,inset 0 0 0 2px #baa47666,inset 0 0 70px #071c15}
.pile{position:relative;display:block;height:164px;min-height:164px;isolation:isolate}
.card-corner{position:absolute;left:6px;top:6px;font-size:17px;writing-mode:vertical-rl;letter-spacing:2px}
.card-pip{font-size:38px;text-shadow:0 1px 0 #fff}
.card.joker .card-corner{font-size:11px;letter-spacing:0}
.table-card{position:absolute;left:50%;top:22px;width:78px;height:112px;transform:translate(calc(-50% + var(--x)),var(--y)) rotate(var(--angle));box-shadow:1px 5px 10px #0006}
.old-card{filter:brightness(.78);pointer-events:none}
.hand{position:relative;display:block;height:250px;overflow-x:auto;overflow-y:hidden;padding:0;isolation:isolate}
.hand:after{content:"";display:block;width:var(--fan-width,100%);height:1px;pointer-events:none}
.hand .card{position:absolute;left:calc(var(--fan-width,100%) / 2);top:52px;width:90px;height:132px;z-index:var(--index);transform-origin:50% 120%;transform:translate(calc(-50% + var(--x)),calc(var(--arc) - var(--lift,0px))) rotate(var(--angle));box-shadow:-3px 4px 9px #0006;border:1px solid #d8cbb2}
.hand .card:disabled{opacity:1;filter:brightness(.89)}
.hand .card.selected{--lift:25px;border:3px solid #f5d58a;box-shadow:0 0 15px #f5d58a77;z-index:60}
.hand .card:focus-visible{--lift:30px;z-index:70}
@media(hover:hover){.hand .card:not(:disabled):hover{--lift:30px;z-index:70}}
.hand .card-corner{font-size:19px}
#rule-effect{position:absolute;z-index:80;left:50%;top:45%;transform:translate(-50%,-50%);width:max-content;max-width:94%;padding:14px 24px;background:#162921ed;border:1px solid #ffe4a2;color:#ffe4a2;font-size:clamp(18px,3vw,30px);font-weight:900;letter-spacing:.08em;box-shadow:0 0 40px #f5d58a44;opacity:0;pointer-events:none;border-radius:8px;text-wrap:balance}
#rule-effect.visible{opacity:1}
#rule-effect[data-kind=revolution]{color:#ffd4dc;border-color:#ff7e9b;background:#542436ee;box-shadow:0 0 60px #eb4d8144}
#rule-effect[data-kind=back]{color:#d5e7ff;border-color:#8bc7ff}
@media(max-width:600px){.hand{height:210px}.hand .card{width:68px;height:106px;top:44px}.hand .card-corner{font-size:17px}.hand .card-pip{font-size:30px}.table-card{width:66px;height:96px}.pile{height:146px;min-height:146px}}
@media(prefers-reduced-motion:no-preference){.hand .card{transition:transform .18s ease,box-shadow .18s}.player.active{animation:seat-glow 1.5s ease-in-out infinite alternate}@keyframes seat-glow{to{box-shadow:0 0 18px #f5d58a33}}}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important}}

/* Compact desktop chrome: retain the card fan and table animations. */
@media(min-width:768px){
 header{padding:8px 18px;gap:10px;flex-wrap:nowrap}
 header h1{font-size:22px;margin:0;line-height:1.2}
 header h1 small{display:inline;font-size:10px;margin-left:8px}
 header a,header button{font-size:13px}
 header button{padding:6px 10px}
 main{padding:4px 18px 10px}
 .players{grid-template-columns:repeat(6,minmax(0,1fr));gap:6px;margin-bottom:8px}
 .player{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:5px 9px;border-radius:7px;font-size:13px}
 .player small{font-size:12px}
 .table{min-height:0;padding:10px 18px;border-width:5px;border-radius:20px}
 .table-top{font-size:12px;margin-bottom:3px}
 .table h2{font-size:18px;margin-bottom:2px}
 .pile{height:150px;min-height:150px}
 #tableInfo{margin:2px 0;font-size:12px;min-height:19px}
 #status{margin:0;font-size:13px;min-height:21px}
 .hand-area{margin:10px 0 8px}
 .hand-title{flex-wrap:nowrap;gap:8px}
 .hand-title h2{font-size:16px;margin:0}
 .hand-title button{font-size:12px;padding:5px 9px}
 .hand{height:218px}
 .hand .card{top:38px}
 .hand-area .actions{margin-top:0;gap:8px}
 .hand-area .actions button{padding:7px 16px;font-size:14px}
 main>details{padding:5px 0;font-size:12px}
}
@media(min-width:768px) and (max-height:720px){
 .pile{height:130px;min-height:130px}
 .table-card{top:8px}
 .hand{height:196px}
 .hand .card{top:32px;height:120px}
 .hand-area{margin-top:6px}
}
@media(min-width:768px) and (max-height:640px){
 header{padding-top:4px;padding-bottom:4px}
 .table{padding-top:5px;padding-bottom:5px}
 .pile{height:116px;min-height:116px}
 .table-card{top:3px;height:100px}
 .hand{height:184px}
 .hand .card{top:30px;height:110px}
}

/* Seats and controls share the board, leaving the fan immediately below it. */
.table{display:grid;grid-template-columns:100px minmax(0,1fr);gap:8px 12px;align-items:center;padding:12px;min-height:0}
.table .players{display:flex;flex-direction:column;gap:5px;margin:0;align-self:center}
.table .player{display:flex;flex-direction:column;align-items:flex-start;gap:0;padding:5px 8px;border-radius:7px;font-size:13px;background:#102d25aa;line-height:1.4}
.table .player small{font-size:12px;color:#e0ece4}
.table-center{min-width:0}
.table-top{margin-bottom:5px}
.table h2{font-size:18px;margin-bottom:4px}
.table-actions{grid-column:1/-1;display:flex;gap:7px;margin:0}
.table-actions button{min-height:44px;padding:7px 16px}
.table-actions [hidden]{display:none}
#tableInfo{margin:2px 0}
#status{font-size:12px;margin:0;min-height:20px;overflow-wrap:anywhere}
.hand-area{position:relative;margin:-24px 0 0;padding-bottom:22px}
.hand-title{position:absolute;bottom:0;left:4px;pointer-events:none}
.hand-title h2{font-size:13px;margin:0;color:#bccfca}
.hand{height:205px}
.hand .card{top:36px}
main>details{padding:6px 0}
@media(min-width:768px){
 header,main{max-width:1240px}
 .table{grid-template-columns:140px minmax(0,1fr) 128px;gap:18px;padding:18px}
 .table .player{flex-direction:row;justify-content:space-between;align-items:center;font-size:15px;padding:8px}
 .table .player small{font-size:13px}
 .table-actions{grid-column:3;flex-direction:column;align-self:center}
 .table-actions button{font-size:18px;padding:10px 12px;min-height:48px}
 .table h2{font-size:23px}
 .table-top{font-size:14px}
 .pile{height:180px;min-height:180px}
 .table-card{width:90px;height:130px;top:20px}
 #tableInfo{font-size:14px}
 #status{font-size:13px}
 .hand{height:220px}
 .hand .card{height:132px}
}
@media(min-width:768px) and (max-height:680px){
 .table{padding:10px 14px}
 .pile{height:146px;min-height:146px}
 .table-card{top:8px;height:120px}
 .table .player{padding:5px 8px}
 .hand{height:198px}
 .hand .card{height:116px}
}
@media(max-width:767px){
 header{padding:8px 10px;gap:6px}
 header h1{font-size:21px;margin:0}
 header h1 small{display:none}
 header a,header button{font-size:12px}
 header button{padding:6px 8px}
 main{padding:4px 8px 8px}
 .table{grid-template-columns:82px minmax(0,1fr);gap:6px;border-width:4px;border-radius:18px;padding:8px}
 .table h2{font-size:16px}
 .table-top{font-size:11px;gap:4px}
 .pile{height:140px;min-height:140px}
 .table-actions{justify-content:flex-end}
 .table-actions button{flex:1;font-size:15px;padding:7px 10px}
 .hand{height:190px}
 .hand-area{margin-top:-24px}
}
