:root { --gold:#c6a477; --muted:#b9aa96; background:#241e19; }
body { background:radial-gradient(ellipse at 50% 15%,#615244,#302821 65%,#211b17); }
body:has(#game:not([hidden])) .top { display:none; }
.hero { grid-template-columns:1fr 1.12fr; padding:0; min-height:310px; background:#eee5d8; }
.hero-copy { padding:30px; }
.hero .eyebrow { letter-spacing:.18em; }
.room-photo { align-self:stretch; min-height:310px; background:url(table-reference.jpg) center 47%/cover; }
.table,.duel .table {
 isolation:isolate; width:min(100%,720px); height:auto; min-height:0; aspect-ratio:1.15;
 margin:0 auto; padding:0; border:0; border-radius:4px;
 background:url(walnut-table.webp) center/100% 100% no-repeat;
 box-shadow:0 12px 0 #211814,0 14px 0 #8a7150,0 22px 32px #110e0a70;
}
.table::before,.table::after { display:none; }
#game { max-width:950px; padding:8px 14px 16px; }
.gamebar { max-width:720px;margin:auto;min-height:48px; }
.gamebar button { background:#342a22; border-color:#8a755b; }
.gamebar small { color:#ddd0b9; }
.gamebar strong { color:#f1dbb7; }
.opponent { z-index:5; padding:4px 7px; gap:5px; border-radius:3px; background:linear-gradient(#3c3027,#251c17); border-color:#967b55; box-shadow:0 3px 5px #1a120c60; }
.opponent .seat-wind,#me .seat-wind { border-radius:3px; background:#69543e;color:#f4dcaf;border-color:#ac8c60; }
.opponent.turn { box-shadow:0 0 0 1px #e4c08a,0 2px 9px #21140780; }
.opponent .seat-details small { color:#d6c7b1; }
.north { top:1.5%; }
.east { right:1.7%;top:48%; }
.west { left:1.7%;top:48%; }
.east,.west { flex-direction:column; text-align:center; padding:5px 3px; }
.east .seat-details strong,.west .seat-details strong { font-size:11px; }
.east .seat-details small,.west .seat-details small { font-size:9px; }
.wallstack,.duel .wallstack {
 display:flex; z-index:1; gap:1px; width:54%; height:4.2%; opacity:1;
 background:none; box-shadow:none; border:0; border-radius:0;
}
.wallstack-top { top:16%;left:47%;transform:translateX(-50%) rotate(180deg); }
.wallstack-bottom { bottom:16%;left:53%;transform:translateX(-50%); }
.wallstack-left { left:18%;top:53%;transform:translate(-50%,-50%) rotate(90deg); }
.wallstack-right { right:18%;top:47%;transform:translate(50%,-50%) rotate(-90deg); }
.wall-unit { flex:1; min-width:0; height:100%; position:relative; border:1px solid #54351e; border-radius:2px; background:repeating-linear-gradient(91deg,#9c663c 0 1px,#b48150 2px 3px,#9c6d43 4px 5px); box-shadow:0 3px 0 #d5af7b,0 4px 0 #654323,0 7px 0 #bb8b55,0 8px 0 #694527,2px 10px 3px #281a0d60; }
.wall-unit::after { content:""; position:absolute;inset:2px;border:1px solid #d5a5785a;border-radius:1px; }
.wall-unit.layers-0 { visibility:hidden; }
.wall-unit.layers-1 { transform:translateY(4px); box-shadow:0 3px 0 #bb8b55,0 4px 0 #694527,1px 6px 2px #281a0d60; }
#compass { left:50%;top:49.3%;width:11.7%; min-width:38px; background:transparent;border:0;border-radius:50%;box-shadow:none;color:#f4dfb4;z-index:2; }
#compass.mine { border:1px solid #e2c18d;box-shadow:0 0 0 3px #f4d29524; }
#activeWind { font-size:clamp(17px,3vw,30px);text-shadow:0 1px 2px #362616; }
#wall { color:#f4e0bd;font-size:10px;text-shadow:0 1px 2px #39291a; }
#rivers,.duel #rivers { position:absolute;inset:0;width:100%;height:100%;align-self:auto;display:block;pointer-events:none; }
.river { position:absolute; width:31%; height:24%; padding:0; background:none; border:0; border-radius:0; overflow:auto; scrollbar-width:thin;pointer-events:auto; }
.riverhead { display:none; }
.river-0 { left:35%;top:59%; transform:none; }
.river-2,.duel .river-1 { left:34%;top:17%;transform:rotate(180deg); }
.river-1 { left:59%;top:38%;transform:rotate(-90deg); }
.river-3 { left:10%;top:38%;transform:rotate(90deg); }
.river .tiles { display:grid;grid-template-columns:repeat(6,1fr);gap:2px;align-content:start; }
.river .tile { width:100%;height:auto;aspect-ratio:100/144;min-height:0; }
.tile,#hand .tile,.river .tile,.mode .tile,.winning-hand .tile,#waits .tile,.flying-tile {
 position:relative; overflow:hidden; background:linear-gradient(110deg,#bc8b56,#9d6739);border:1px solid #5f3f27;
 border-radius:5%;box-shadow:0 2px 0 #654125,0 3px 2px #2b1c1370;filter:none;padding:0;
}
.wood-face { position:absolute;inset:0;width:100%;height:100%;display:block;pointer-events:none; }
#hand .tile { height:auto;aspect-ratio:100/144;width:clamp(18px,calc((100vw - 69px)/14),43px);border-width:1px;flex:none;filter:none; }
#hand .tile:disabled { opacity:1;filter:brightness(.94); }
#hand .tile:enabled:hover { filter:brightness(1.12); }
#hand .tile.selected { outline:2px solid #f1d8a4; outline-offset:2px;transform:translateY(-8px);box-shadow:0 5px 0 #684225,0 8px 8px #160f0c70;filter:none; }
#hand .tile.drawn { margin-left:8px; }
.rack { max-width:780px;margin:17px auto 0;padding:5px 10px 10px;background:linear-gradient(135deg,#483728,#2a211b);border:1px solid #866b48;border-radius:4px;box-shadow:inset 0 1px #bca17b50,0 4px 12px #170e0a60; }
.racktop { min-height:40px;gap:7px; }
.racktop .sort-controls button,.racktop #autoOrder[aria-pressed=true] { background:#4a3d2c;border-color:#a48c675c;color:#e9dcc7; }
.racktop #actions button { background:#53402d;border-color:#af9167;color:#f4e2c5; }
.racktop #actions .gold { background:linear-gradient(#e4c995,#bb945d);color:#2e2116; }
#hand { min-height:0;background:linear-gradient(#20161099,#513a2560);border-color:#ac895540;gap:3px;padding:13px 2px 7px; }
#tableMelds { position:absolute;inset:0;pointer-events:none; }
#concealedHands {position:absolute;inset:0;pointer-events:none;}
.concealed {position:absolute;display:flex;gap:1px;width:42%;height:3.6%;}
.concealed-2 {top:10.5%;left:29%;transform:rotate(180deg);}
.concealed-1 {top:50%;right:10.8%;transform:translate(50%,-50%) rotate(-90deg);}
.concealed-3 {top:50%;left:10.8%;transform:translate(-50%,-50%) rotate(90deg);}
.back-tile {flex:1;max-width:7.1%;border:1px solid #5b3921;border-radius:2px;background:repeating-linear-gradient(92deg,#ac7747 0 1px,#a16c3f 2px 3px,#bb8b58 4px 5px);box-shadow:0 3px 0 #54331d,1px 4px 2px #2a1b1360;}
.back-tile.fresh{margin-left:4px;}
.table-meld { position:absolute;display:flex;gap:4px; }
.table-meld .tile { width:17px;height:24px; }
.meld-1 { right:7%;top:68%;transform:rotate(-90deg);transform-origin:right top; }
.meld-2 { right:25%;top:10%;transform:rotate(180deg); }
.meld-3 { left:7%;top:28%;transform:rotate(90deg);transform-origin:left top; }
#ownMelds { display:flex;justify-content:flex-end;gap:6px;padding:4px 0 7px; }
#ownMelds .tile { width:25px;height:36px; }
.exposed { margin-left:0; }
dialog { background:linear-gradient(145deg,#493b2d,#261e18);border-color:#b09265; }
dialog p,dialog li { color:#ddcfbb; }
#faceDetail { background:#1d1510;border-color:#aa865451; }
#faceDetail .tile { width:90px;aspect-ratio:100/144; }
.face-group .tile { aspect-ratio:100/144; }
@media(max-width:640px){
 #game{padding:5px 7px 14px;}
 .hero{grid-template-columns:1fr;}
 .hero-copy{padding:22px;}
 .room-photo{min-height:225px;background-position:center 46%;}
 .table,.duel .table{height:auto;aspect-ratio:1.05;}
 .opponent{gap:2px;padding:3px;}
 .opponent .seat-wind{width:19px;height:19px;font-size:11px;}
 .east .seat-details strong,.west .seat-details strong{font-size:9px;}
 .east .seat-details small,.west .seat-details small{font-size:8px;}
 .rack{padding-inline:5px;margin-top:14px;}
 .racktop .sort-controls button{font-size:10px;padding-inline:5px;}
 #hand{gap:2px;}
 #hand .tile{width:calc((100vw - 65px)/14);}
 #hand .tile.drawn{margin-left:5px;}
 .river .tiles{gap:1px;}
 #wall{font-size:8px;}
 .table-meld .tile{width:11px;height:16px;}
}
@media(max-height:570px) and (orientation:landscape){
 #game {padding:2px 12px 6px;display:grid;grid-template-columns:minmax(0,1fr) minmax(285px,1fr);gap:6px 18px;align-items:center;min-height:100dvh;}
 .gamebar {grid-column:1/-1;width:100%;max-width:none;min-height:35px;padding:0;}
 .table,.duel .table {width:auto;height:calc(100dvh - 58px);max-height:470px;aspect-ratio:1.05;margin:auto;max-width:100%;}
 .rack {width:100%;margin:0;align-self:center;padding:8px;}
 .racktop{display:grid;grid-template-columns:1fr;gap:12px;}
 .racktop .sort-controls {justify-content:flex-start;}
 .racktop #actions{justify-content:flex-start;margin:0;min-height:38px;}
 #hand{justify-content:flex-start;flex-wrap:wrap;gap:5px;padding:14px 3px 8px;}
 #hand .tile{width:calc((100% - 40px)/7);max-width:40px;}
 #hand .tile.drawn{margin-left:0;outline:1px solid #c9aa78;outline-offset:1px;}
 #compass{width:11.7%;}
 #activeWind{font-size:18px;}
 #wall{font-size:7px;}
 .opponent .seat-details strong{font-size:10px;}
 .opponent .seat-details small{font-size:8px;}
 .opponent .seat-wind{width:18px;height:18px;font-size:11px;}
 .river .tile{width:100%;height:auto;}
 .table-meld .tile{width:10px;height:14px;}
}
@media(prefers-reduced-motion:reduce){.tile{transition:none;}}
/* A hand stays in a single physical row, including short landscape screens. */
@media(max-height:570px) and (orientation:landscape){
 #game{display:block;min-height:0;padding:2px 10px 5px;}
 .gamebar{height:34px;min-height:34px;max-width:780px;}
 .gamebar strong{font-size:15px;}
 .gamebar small{font-size:9px;}
 .table,.duel .table{height:calc(100dvh - 162px);width:auto;aspect-ratio:1.35;max-width:100%;max-height:none;}
 .rack{margin:12px auto 0;padding:2px 7px 5px;max-width:780px;}
 .racktop{display:flex;gap:5px;min-height:28px;}
 .racktop #actions{margin-left:auto;min-height:28px;}
 .racktop button,.racktop .sort-controls button{min-height:27px;padding:2px 8px;}
 .racktop #me .seat-wind{width:21px;height:21px;font-size:12px;}
 .racktop #me .seat-details strong{font-size:11px;}
 .racktop #me .seat-details small{font-size:9px;}
 #hand{flex-wrap:nowrap;justify-content:center;gap:3px;padding:8px 2px 2px;}
 #hand .tile{width:min(calc((100vw - 80px)/14),30px);max-width:none;}
 #hand .tile.drawn{margin-left:7px;}
 #ownMelds{position:absolute;right:12px;top:48px;max-width:180px;flex-wrap:wrap;}
 #ownMelds .tile{width:18px;height:26px;}
 #waits{position:absolute;left:12px;top:48px;max-width:170px;}
 .east,.west{top:48%;}
 .river .tile{aspect-ratio:100/115;}
}
/* Reconstructed full-set art; identical face source for every gameplay area. */
.wood-face { border-radius:inherit; }
#faceDetail .tile { width:clamp(105px,24vw,160px); aspect-ratio:100/144; }
.face-group .tile { flex-basis:clamp(27px,6.5vw,45px); }
#faceDetail { padding:18px; background:radial-gradient(ellipse,#654a32,#281e16); }
.tile { -webkit-tap-highlight-color:transparent; }
.tile:focus-visible { outline:2px solid #f3d9aa; outline-offset:3px; }
/* Flicker fix: tile faces are atlas crops via CSS background (see wood-faces.mjs). */
.wood-face { background-repeat:no-repeat; }
