:root{--paper:#f4ecdf;--ink:#241e17;--muted:#74695d;--green:#235a49;--deep:#173e33;--gold:#e2bd72;--red:#a83f32;--line:#ded4c4;--white:#fffcf6;font-family:"Avenir Next","PingFang SC","Microsoft YaHei",sans-serif;color:var(--ink);background:var(--paper);font-synthesis:none}*{box-sizing:border-box}body{margin:0;background:radial-gradient(ellipse at 5% 0,#fffaf3,transparent 60%)}button,input,select{font:inherit}button{cursor:pointer;border:1px solid var(--line);background:var(--white);color:var(--ink);padding:11px 16px;border-radius:9px;font-size:14px;transition:background .12s,transform .12s}button:hover:not(:disabled){background:#eee2cd}button:disabled{opacity:.45;cursor:not-allowed}button:focus-visible,a:focus-visible{outline:3px solid #cf982c;outline-offset:3px}.primary{background:var(--green);border-color:var(--green);color:#fff}.primary:hover:not(:disabled){background:var(--deep)}.quiet{background:transparent}.wide{width:100%}a{color:var(--green)}[hidden]{display:none!important}.shell{max-width:1280px;margin:auto;padding:24px 32px}.top{display:flex;align-items:center;justify-content:space-between;gap:12px;border-bottom:1px solid var(--line);padding-bottom:20px}.back{text-decoration:none;font-size:14px}.brand{font-size:11px;letter-spacing:3px;color:var(--muted)}.eyebrow{display:block;font-size:11px;font-weight:600;letter-spacing:2px;color:var(--green)}.lobby{display:grid;grid-template-columns:1.2fr 1fr;gap:80px;align-items:center;max-width:1000px;margin:66px auto 85px}.intro h1{font-family:Georgia,"Songti SC",serif;font-size:58px;font-weight:500;letter-spacing:5px;margin:20px 0}.intro h1 span{display:block;font-family:inherit;font-size:23px;letter-spacing:1px;margin-top:20px}.intro p{color:var(--muted);font-size:16px;line-height:1.9}.hero-tiles{display:flex;padding:24px 18px 34px;gap:9px}.hero-tile{display:grid;place-content:center;text-align:center;width:76px;height:104px;background:#fffdf4;border:1px solid #d9cbb2;border-radius:9px;box-shadow:0 6px 0 #b7a98e,0 14px 24px #38251122;font-size:38px;color:#245b47;font-family:"Songti SC",serif;transform:rotate(-10deg)}.hero-tile small{font-size:23px;line-height:1}.hero-tile:nth-child(2){transform:translateY(-9px) rotate(1deg)}.hero-tile:nth-child(3){transform:rotate(12deg)}.red{color:var(--red)}.rule-strip{display:flex;gap:30px;border-top:1px solid var(--line);padding-top:24px}.rule-strip span{font-size:12px;color:var(--muted)}.rule-strip b{display:block;font-size:21px;color:var(--ink);font-weight:500;margin-bottom:7px}.room-panel{background:var(--white);padding:32px;border:1px solid var(--line);border-radius:18px;box-shadow:0 20px 45px #3025140a}h2{font-size:22px;font-weight:600;margin:12px 0 22px}label{display:block;font-size:13px;color:var(--muted);margin-bottom:18px}input,select{display:block;width:100%;padding:13px 12px;margin-top:8px;border:1px solid var(--line);border-radius:8px;background:#fffdf9;color:var(--ink);min-width:0}input:focus,select:focus{outline:2px solid #497f6c;outline-offset:1px}.divider{display:flex;align-items:center;gap:12px;color:var(--muted);font-size:12px;margin:22px 0}.divider:before,.divider:after{content:"";height:1px;background:var(--line);flex:1}.join-row{display:flex;gap:8px}.join-row input{margin:0;flex:1;text-transform:uppercase}.muted{color:var(--muted);line-height:1.7}.small{font-size:12px}.room-bar{display:flex;align-items:center;justify-content:space-between;margin:26px 0 20px;gap:16px}.game-title{font-size:23px;margin:8px 0;letter-spacing:1px;font-weight:500}.room-tools{display:flex;align-items:center;gap:10px}.connection{font-size:12px;color:var(--green)}.connection:before{content:"";display:inline-block;width:6px;height:6px;border-radius:50%;background:currentColor;margin-right:6px}.connection.bad{color:var(--red)}.scores{display:grid;grid-template-columns:1fr auto 1fr;gap:16px;align-items:center;margin-bottom:24px}.score-card{display:flex;align-items:center;justify-content:space-between;gap:12px;background:var(--white);border:1px solid var(--line);padding:17px 20px;border-radius:12px}.score-card.active{border-color:#447e64;box-shadow:inset 0 -3px 0 #447e64}.player-name{font-size:14px;overflow-wrap:anywhere}.score-card strong{font:28px Georgia,serif;font-variant-numeric:tabular-nums}.badge{font-size:10px;border:1px solid var(--line);padding:3px 5px;border-radius:4px;margin-left:6px}.goal{text-align:center;font-size:11px;color:var(--muted);line-height:1.8}.goal b{display:block;font-size:18px;color:var(--ink)}.game-layout{display:grid;grid-template-columns:minmax(0,1fr) 265px;gap:24px}.table-column{min-width:0}.table{background:radial-gradient(ellipse at 50% 45%,#2b6855,#1c493b);border:6px solid #b7a080;box-shadow:0 3px 0 #8c775e,0 12px 28px #30251417;border-radius:18px;padding:20px 24px;color:#e7ecdf;min-height:440px}.opponent-head{display:flex;justify-content:space-between;font-size:12px;margin-bottom:12px;color:#e0e8db}.opponent-hand{display:flex;gap:3px;justify-content:center;min-height:36px}.opponent-hand .tile{width:24px;height:35px;font-size:14px}.opponent-hand .tile small{font-size:8px}.opponent-hand .tile.back-tile{background:linear-gradient(135deg,#80a68e,#4b7c65);border-color:#97b29a;box-shadow:0 2px 0 #153c2d}.river-area{margin-top:14px}.river-label{font-size:11px;display:flex;justify-content:space-between;gap:8px;opacity:.72;margin-bottom:8px}.river-label span{font-size:10px}.river{display:flex;flex-wrap:wrap;gap:4px;min-height:49px;align-content:start}.tile{position:relative;flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;flex-direction:column;width:40px;height:56px;padding:2px;background:#fffdf1;border:1px solid #e3dbc5;border-radius:5px;color:#1b4434;box-shadow:0 3px 0 #bcba9d;font-family:Georgia,"Songti SC",serif;font-size:25px;vertical-align:middle;user-select:none}.tile small{font-size:13px;line-height:1.05;font-weight:bold}.tile.wan{color:#a2372d}.tile.honor{font-family:"Songti SC",serif;font-size:26px}.tile.honor.red{color:#ad382e}.tile.honor.green{color:#267449}.tile svg{width:100%;height:100%}.tile.back-tile{background:repeating-linear-gradient(45deg,#4e7e68 0 4px,#568971 4px 8px);border-color:#8ba792;color:#e4eadf}.tile.back-tile:after{content:"";position:absolute;inset:4px;border:1px solid #bdd0b67a;border-radius:2px}.river .tile,.mini-tiles .tile{width:30px;height:42px;font-size:20px}.river .tile small,.mini-tiles .tile small{font-size:9px}.river .tile.called{opacity:.48;box-shadow:none}.tile em{position:absolute;bottom:0;right:0;left:0;font:8px sans-serif;background:#6c5929;color:white;text-align:center;font-style:normal}.tile.riichi{outline:2px solid var(--gold)}.tile.concealed{outline:1px dashed #c79542}.table-center{display:flex;align-items:center;justify-content:space-between;gap:12px;border-top:1px solid #dae4d021;border-bottom:1px solid #dae4d021;padding:15px 0;margin:16px 0}.table-center strong{display:block;font-size:20px;font-weight:500;margin:6px 0}.table-center span:not(.eyebrow){font-size:11px;color:#ceddcb}.eyebrow.light{color:#d6c594;font-size:10px}.dora-wrap{text-align:right}.mini-tiles{display:flex;gap:4px;margin-top:7px;justify-content:flex-end}.melds{display:flex;gap:12px;flex-wrap:wrap;margin-top:10px}.meld-group{display:flex;gap:2px;align-items:center}.meld-group .tile{width:27px;height:38px;font-size:18px}.meld-group .tile small{font-size:10px}.meld-group>small{font:10px sans-serif;opacity:.8;margin-right:3px}.hand-panel{margin-top:22px;background:var(--white);border:1px solid var(--line);border-radius:12px;padding:19px 18px}.hand-header{display:flex;justify-content:space-between;gap:10px;font-size:13px;margin-bottom:18px}.hand-header span{color:var(--muted);font-size:11px}.hand{display:flex;gap:5px;overflow-x:auto;padding:24px 3px 10px;min-height:96px}.hand .tile{width:44px;height:62px;cursor:pointer}.hand .tile:hover:not(:disabled){background:#fff6d5}.hand .tile:disabled{opacity:1;cursor:default}.hand .tile.selected{transform:translateY(-10px);outline:2px solid #c79128;background:#fff1cf}.hand .tile.drawn{margin-left:12px}.tile .hint-badge{position:absolute;right:-3px;top:-11px;border-radius:3px;background:var(--red);color:#fff;font:10px sans-serif;padding:2px 4px}.selection-hint{min-height:25px;margin-top:8px;font-size:12px;line-height:1.8;color:var(--green)}.actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}.actions .danger{color:var(--red)}.status-card,.history-card{border-bottom:1px solid var(--line);padding-bottom:22px;margin-bottom:22px}.status-card h2{margin:12px 0;font-size:22px}.status-card p{font-size:13px;color:var(--muted);line-height:1.85}.history-card h3{font-size:13px;font-weight:600;margin-top:0}.history-card ol{list-style:none;margin:0;padding:0;font-size:12px;color:var(--muted);line-height:1.8}.history-card li{padding:8px 0;border-top:1px solid #ded4c46b}.aside-note{font-size:11px;color:var(--muted);line-height:1.9}#waits-panel .mini-tiles{justify-content:flex-start;flex-wrap:wrap}#waits-panel p{font-size:11px}.guess-panel,.result-panel{background:var(--white);border:1px solid #b5bfab;border-radius:12px;padding:24px;margin-top:22px}.panel-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}.panel-heading h2{margin:10px 0 0}.panel-heading>strong{font-size:13px;color:var(--green)}.guess-panel p{font-size:13px}.guess-row{display:flex;gap:5px;align-items:center;margin:16px 0;flex-wrap:wrap}.guess-row>span{width:22px;font-size:11px;color:var(--muted)}.guess-row .tile.selected{background:#f6dda0;outline:2px solid #a87a22;transform:translateY(-3px)}.guess-panel .actions{margin-top:22px}.guess-entry{display:flex;align-items:center;gap:6px;margin:10px 0;font-size:11px}.guess-entry .tile{width:25px;height:35px;font-size:17px}.guess-entry .tile small{font-size:9px}.result-panel h2{font-size:27px;color:var(--green);margin:8px 0 12px}.result-panel p{line-height:1.7;font-size:13px}.score-detail{display:flex;flex-wrap:wrap;gap:8px;margin:15px 0}.score-detail span{background:#eee8da;border-radius:5px;padding:6px 9px;font-size:12px}.candidate-line{display:flex;gap:12px;align-items:center;background:#f4eddc;border-radius:8px;padding:12px;margin:12px 0}.candidate-line p{margin:3px 0;font-size:12px}#toast{position:fixed;bottom:25px;left:50%;transform:translateX(-50%);z-index:10;background:#253f34;color:#fff;max-width:calc(100% - 24px);width:max-content;padding:14px 22px;border-radius:10px;box-shadow:0 8px 30px #0003;font-size:14px;line-height:1.5}footer{display:flex;justify-content:space-between;gap:15px;margin-top:42px;padding:20px 0;color:#8d8275;font-size:11px;border-top:1px solid var(--line)}dialog{width:min(700px,calc(100% - 28px));max-height:85vh;border:1px solid var(--line);border-radius:14px;background:var(--white);color:var(--ink);padding:25px}dialog::backdrop{background:#11281ed0}.dialog-head{display:flex;justify-content:space-between;align-items:center;gap:15px}.dialog-head h2{margin:0}.rule-content{font-size:13px;line-height:1.95}.rule-content h3{font-size:15px;margin-top:24px}.empty-river{font-size:11px;opacity:.4;align-self:center}.winning{color:var(--green);font-weight:bold}
@media(max-width:1050px){.shell{padding:20px}.lobby{gap:40px}.game-layout{grid-template-columns:minmax(0,1fr) 220px;gap:18px}.table{padding:16px}.hand .tile{width:38px;height:56px}.hand{gap:4px}.guess-row .tile{width:35px;height:49px}}
@media(max-width:760px){.shell{padding:16px 12px}.brand{font-size:9px;letter-spacing:1px}.top{padding-bottom:15px}.lobby{grid-template-columns:1fr;margin:32px auto;gap:32px;max-width:440px}.intro h1{font-size:45px}.intro h1 span{font-size:21px}.hero-tiles{padding:15px 15px 28px}.room-panel{padding:25px}.game-layout{grid-template-columns:1fr}.side-panel{display:grid;grid-template-columns:1fr 1fr;gap:18px}.status-card{grid-column:1/-1}.side-panel .history-card{min-width:0}.aside-note{grid-column:1/-1;margin:0}.room-bar{align-items:flex-start;margin-top:22px}.room-tools{flex-wrap:wrap;justify-content:flex-end;max-width:195px;gap:6px}.room-tools button{padding:8px;font-size:11px}.connection{font-size:10px}.game-title{font-size:19px}.scores{gap:7px;margin-bottom:18px}.score-card{padding:12px 10px;display:block}.score-card strong{display:block;margin-top:9px;font-size:24px}.player-name{font-size:12px}.badge{font-size:9px;padding:2px;margin-left:4px}.goal{font-size:10px}.goal b{font-size:14px}.table{padding:15px 12px;border-width:4px;border-radius:13px;min-height:410px}.table-center strong{font-size:17px}.table-center{padding:13px 0}.hand-panel{padding:16px 12px}.hand{gap:4px}.hand .tile{width:35px;height:52px;font-size:23px}.hand .tile small{font-size:11px}.hand-header span{font-size:10px}.hand-header{margin-bottom:13px}.guess-panel,.result-panel{padding:19px 14px}.guess-row{gap:4px;flex-wrap:nowrap}.guess-row>span{width:14px;flex-shrink:0}.guess-row .tile{width:calc((100% - 50px)/9);max-width:40px;height:46px;font-size:22px}.guess-row .tile small{font-size:10px}.panel-heading h2{font-size:20px}.panel-heading>strong{font-size:11px}.opponent-hand .tile{width:20px;height:30px}.river .tile{width:28px;height:39px}.dora-wrap .tile{width:24px;height:35px}.hand-help{font-size:10px}.river-label span{font-size:9px}footer{font-size:10px}.hero-tile{width:65px;height:90px}.hand-panel .actions button{flex:1 0 auto}}
@media(prefers-reduced-motion:reduce){*{transition:none!important}}
/* The reference tiles are cropped once and shared by every tile display. */
.tile:not(.back-tile){padding:0;border:0;background:transparent;box-shadow:none}
.tile .tile-face{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;border-radius:5px}
.tile{height:66px}.hand .tile{height:72px}.river .tile,.mini-tiles .tile{height:49px}.opponent-hand .tile{height:39px}.meld-group .tile{height:44px}.guess-entry .tile{height:41px}
button.tile:hover:not(:disabled){background:transparent;filter:brightness(1.07)}.hand .tile.selected,.guess-row .tile.selected{background:transparent;outline:3px solid #b4332a;outline-offset:2px}.hand .tile:hover:not(:disabled){background:transparent}.tile em{z-index:1}.tile .hint-badge{z-index:2}
:root{--ink:#241910;--muted:#5c4a3a;--red:#b4332a;--white:#fffaf4;--line:rgba(90,62,36,.18)}
body{background:radial-gradient(1200px 600px at 10% -10%,rgba(180,51,42,.08),transparent 55%),radial-gradient(900px 500px at 100% 0%,rgba(196,150,74,.18),transparent 50%),linear-gradient(180deg,#f7f1e7,#efe4d4);min-height:100vh}
.shell{width:min(1120px,calc(100% - 32px));padding:22px 0 40px}.top{align-items:flex-end;border:0;padding:0;margin-bottom:22px}.site-brand h1{font-family:"Iowan Old Style",Palatino,"Songti SC",serif;font-weight:600;font-size:34px;letter-spacing:.12em;margin:0}.site-brand p{margin:4px 0 0;font-size:14px;color:var(--muted)}.top-actions{display:flex;align-items:center;gap:12px}.back{color:#8d241f;border-bottom:1px solid #b4332a59;padding-bottom:1px}.top-actions button{font-size:12px;padding:8px 10px}
.primary{background:#b4332a;border-color:#b4332a}.primary:hover:not(:disabled){background:#8d241f}.lobby{grid-template-columns:minmax(0,1fr) 320px;gap:22px;align-items:start;max-width:none;margin:0}.lobby-stage,.room-panel{background:rgba(255,250,244,.78);border:1px solid rgba(90,62,36,.12);border-radius:18px;padding:18px;box-shadow:0 22px 50px rgba(28,16,8,.2);min-width:0}.room-panel{background:rgba(255,250,244,.86)}.room-panel h2{font-family:"Iowan Old Style",Palatino,"Songti SC",serif;font-size:22px;letter-spacing:.08em;margin:0 0 6px}.room-panel .hint{color:var(--muted);font-size:13px;line-height:1.55;margin:0 0 16px}.room-panel label{font-size:12px;letter-spacing:.08em;margin-bottom:12px}.room-panel input,.room-panel select{border-color:rgba(90,62,36,.22);border-radius:10px;padding:11px 12px;font-size:14px}.room-panel input:focus,.room-panel select:focus{outline-color:#b4332a88}.lobby-actions{display:grid;gap:8px}.lobby-actions button{border:0;border-radius:10px;padding:11px 12px}.lobby-actions button:not(.primary){background:#efe6d8}.lobby-summary{display:grid;gap:6px;border:1px solid #b4332a1f;border-radius:12px;background:#fff8ee;margin-top:16px;padding:12px;font-size:12px;color:var(--muted)}
.preview-player{display:flex;align-items:center;gap:7px;width:max-content;max-width:100%;padding:5px 10px 5px 7px;border-radius:99px;border:1px solid var(--line);background:rgba(255,250,244,.9);box-shadow:0 3px 10px #2d190a1f;font-size:13px;margin-bottom:8px}.preview-player i{width:16px;height:16px;border-radius:50%;background:radial-gradient(circle at 35% 30%,#68756b,#224635)}.preview-player span{font-size:11px;color:var(--muted)}.preview-player.self{margin:8px 0 0 auto}.preview-player.self i{background:radial-gradient(circle at 35% 30%,#fff,#d8c4a3)}.preview-table{min-height:420px;aspect-ratio:1.42;border:10px solid #7a4d2b;border-radius:10px;box-shadow:inset 0 0 0 1px #ffdda040,0 10px 24px #46240c38;background:radial-gradient(ellipse at 50% 40%,#376b56,#224b3e);display:flex;flex-direction:column;justify-content:space-between;align-items:center;padding:24px 14px;overflow:hidden}.preview-opponent,.preview-hand,.preview-river{display:flex;gap:4px;justify-content:center;width:100%;min-width:0}.preview-opponent .tile{width:calc((100% - 48px)/13);max-width:32px;height:auto;aspect-ratio:106/174}.preview-hand .tile{width:calc((100% - 48px)/13);max-width:39px;height:auto;aspect-ratio:106/174}.preview-river .tile{width:31px;height:51px}.preview-center{text-align:center;padding:20px 0;color:#f4ecdf}.preview-center strong{display:block;font-family:"Songti SC",serif;font-weight:500;font-size:27px;margin:14px 0}.preview-center p{font-size:13px;line-height:1.8;color:#d0dfcf;margin:0 0 20px}.preview-help{font-size:12px;line-height:1.45;text-align:center;color:var(--muted);margin:12px 0 0}.table{border-color:#7a4d2b}.score-card.active{border-color:#ad5845;box-shadow:inset 0 -3px 0 #ad5845}
@media(max-width:1050px){.hand .tile{height:62px}.guess-row .tile{height:57px}}
@media(max-width:820px){.lobby{grid-template-columns:minmax(0,1fr) 285px;gap:16px}.preview-table{min-height:385px;padding:22px 10px}.preview-center strong{font-size:22px}.preview-opponent,.preview-hand{gap:3px}.preview-opponent .tile,.preview-hand .tile{width:calc((100% - 36px)/13)}}
@media(max-width:760px){.shell{width:calc(100% - 24px);padding:18px 0 30px}.site-brand h1{font-size:28px}.site-brand p{font-size:12px}.top{align-items:center;gap:8px}.top-actions{gap:9px}.top-actions .back{font-size:12px}.lobby{grid-template-columns:1fr;max-width:none;margin:0;gap:18px}.lobby-stage{padding:14px}.preview-table{min-height:330px;aspect-ratio:1.45;padding:18px 10px;border-width:7px}.preview-center{padding:16px 0}.preview-center strong{font-size:23px;margin:10px 0}.preview-center p{font-size:12px;margin-bottom:16px}.preview-river .tile{width:26px;height:43px}.preview-opponent .tile{max-width:24px}.preview-hand .tile{max-width:31px}.room-panel{padding:18px}.hand .tile{height:57px}.river .tile{height:46px}.opponent-hand .tile{height:33px}.dora-wrap .tile{height:39px}.guess-row .tile{height:52px}.table .river{row-gap:7px}}
@media(max-width:370px){.top-actions{flex-direction:column;align-items:flex-end;gap:6px}.preview-center strong{font-size:20px}.preview-player{font-size:12px}.preview-table{min-height:310px}}
.preview-table{width:100%;min-width:0}

/* Opposite player's claimed tile sits sideways in the middle of each open meld. */
.meld-group,.meld-tiles{display:inline-flex;align-items:flex-end;gap:2px}.meld-group>small{align-self:center;margin-right:4px}.meld-called{position:relative;display:inline-block;flex:0 0 44px;width:44px;height:27px}.meld-called>.tile{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%) rotate(90deg);width:27px;height:44px}.meld-stack{display:inline-flex;flex-direction:column;gap:2px;align-items:center}
.guess-row .tile.guessed{opacity:.3;filter:grayscale(1) brightness(.65);cursor:not-allowed;outline:none;transform:none}
.meld-stack>.meld-called{flex:0 0 27px}

/* Keep the table prominent once both players have joined. */
body.game-started .top,body.game-started .room-bar>div:first-child,body.game-started .room-tools>:not(#leave){display:none}
body.game-started .room-bar{margin:0 0 10px;justify-content:flex-end}
body.game-started .room-tools{max-width:none}
.history-card{align-self:start;padding-bottom:14px;margin-bottom:14px}
.history-card summary{cursor:pointer;font-size:13px;font-weight:600;padding:6px 0;line-height:1.6}
.history-card summary span{font-size:11px;font-weight:400;color:var(--muted);margin-left:6px;white-space:nowrap}
.history-card summary:focus-visible{outline:3px solid #cf982c;outline-offset:3px;border-radius:3px}
.history-card .history-content{max-height:240px;overflow-y:auto;overscroll-behavior:contain;margin-top:10px;scrollbar-gutter:stable}

/* Ordinary discards need only the tiles; reserve space for available decisions. */
#actions:empty,#selection-hint:empty,#hand-help:empty{display:none}
