/* Keep one tile pitch for a viewport, independent of the deal or remaining tiles. */
.mahjong-area.triple{container-type:inline-size}
.mahjong-area.triple :is(#mahjong-playfield,#triple-shelf){
 --pitch:min(62px,13.7cqw,clamp(42px,8svh,62px));
}
.mahjong-area.triple #mahjong-playfield{
 width:calc((var(--columns) + .12)*var(--pitch));
 height:calc((var(--rows) + .12)*var(--pitch));aspect-ratio:auto
}
.mahjong-area.triple #mahjong-board{width:100%;height:100%;aspect-ratio:auto}
.mahjong-area.triple .mahjong-tile{
 left:calc((var(--x) + .06)*var(--pitch));top:calc((var(--y) + .06)*var(--pitch));
 width:calc(var(--pitch) - 1px);height:calc(var(--pitch) - 1px);padding:0;border-radius:10%
}
.mahjong-area.triple .mahjong-tile.free{box-shadow:0 3px 0 #b6a984,0 5px 8px #082c2477}
.mahjong-area.triple .mahjong-tile.blocked{background:#afb79d}
.mahjong-area.triple .mahjong-tile.blocked img{filter:brightness(.85) saturate(.85)}
#triple-rack{width:min(435px,100%);margin:0 auto 6px;padding:8px 0;color:#e5efdc}
.tile-rack{display:grid;gap:4px}
#triple-tray{grid-template-columns:repeat(7,minmax(0,1fr))}
.rack-slot{
 display:grid;place-items:center;min-width:0;padding:2px;aspect-ratio:1.13;
 border:1px solid #bdd6bf;border-radius:8px;
 background:linear-gradient(160deg,#e1efda40,#aecfbd26);
 box-shadow:inset 0 2px 0 #f6f7df38
}
.rack-slot.filled{background:linear-gradient(145deg,#fff9e6,#eee3c5);border-color:#d9c996;box-shadow:0 2px 0 #a9aa88}
button.rack-slot:focus-visible{outline:3px solid #ffe29a;outline-offset:1px}
button.rack-slot{cursor:pointer}
.rack-slot img{width:83%;height:83%;object-fit:contain;pointer-events:none}
.rack-slot.hinted{outline:3px solid #ffcc64;outline-offset:-2px;background:#fff0ac}
#triple-shelf{grid-template-columns:repeat(3,calc(var(--pitch) - 1px));justify-content:center;margin:0 0 9px}
#triple-shelf .rack-slot{width:100%;aspect-ratio:1;border-radius:10%}
#triple-shelf .rack-slot img{inset:12%;width:76%;height:76%}
@media(max-height:600px) and (min-width:651px){
 .mahjong-area{grid-template-rows:auto auto auto 1fr}
 .mahjong-rule{grid-row:3}
 .mahjong-table{grid-row:1/5}
 .mahjong-bottom{grid-row:4}
 .mahjong-area.triple{grid-template-columns:minmax(245px,31%) minmax(0,1fr);height:auto;min-height:100%}
 #triple-rack{padding:6px}
}
@media(max-width:650px){
 .mahjong-area.triple{height:auto;min-height:100%}
 .mahjong-area.triple .mahjong-table{flex:1 0 auto;min-height:0;container-type:normal}

}
@media(max-height:600px) and (min-width:651px){
 .mahjong-area.triple{
  height:100%;min-height:320px;grid-template-columns:minmax(245px,33%) minmax(0,1fr);
  grid-template-rows:auto auto 1fr auto auto auto auto;gap:3px 12px;
 }
 .triple .mahjong-table{grid-column:2;grid-row:1/4}
 .triple .mahjong-bottom{display:contents}
 .triple #triple-rack{grid-column:2;grid-row:4/8;align-self:center;width:min(355px,100%);margin:0 auto}
 .triple .mahjong-controls{grid-column:1;grid-row:4/7;align-self:end}
 .triple #mahjong-new-confirm{grid-column:1;grid-row:7}
 .triple .mahjong-rule{align-self:start}
 #triple-tray .rack-slot{height:32px;aspect-ratio:auto}
}
.mahjong-controls{position:relative;width:min(100%,520px);margin-inline:auto;min-height:110px;text-align:center}
#mahjong-play-controls[inert]{visibility:hidden}
#mahjong-status{font-size:14px;color:#ebdfbf}
#triple-recovery{position:absolute;inset:0;overflow:auto;align-content:center;padding:3px 8px;border:1px solid #d6bc7e;border-radius:12px;background:var(--village-snow);color:#253f32}
.recovery-heading,.recovery-links{display:flex;align-items:center;justify-content:center;gap:8px}
#triple-recovery h2{margin:0;font:700 clamp(19px,4.2vw,27px)/1.1 Georgia,serif;color:#723c27}
#triple-recovery p{font-size:13px;line-height:1.25;margin:3px 0}
#triple-recovery-status:empty{display:none}
#triple-recovery-status{color:#813e22}
#triple-recovery button{min-height:32px;font-size:14px;cursor:pointer}
#triple-recovery .play-primary{padding:4px 12px;background:#255844;color:#fff8e4}
#triple-recovery .recovery-secondary{background:transparent;color:#345342;border:0;text-decoration:underline;text-underline-offset:3px;padding:3px 8px}
#triple-recovery button:disabled{opacity:.55;cursor:default}
#triple-tray .last-pick{outline:2px solid #874918;outline-offset:-3px;box-shadow:0 0 0 2px #ffd479}
/* Tile artwork and changing help labels must not size the playing surface. */
.rack-slot{position:relative;min-height:0}
.rack-slot img{position:absolute;inset:8.5%}
#mahjong-status{height:3em;min-height:0;line-height:1.5;overflow:auto;align-content:center;overflow-anchor:none}
.mahjong-area .mahjong-actions{display:grid;grid-template-columns:repeat(4,minmax(0,1fr)) minmax(0,1.5fr);width:min(100%,520px);margin-inline:auto}
.mahjong-area .mahjong-actions button{height:44px;min-width:0;padding:2px 6px;line-height:1.15}
#mahjong-new-confirm{margin:auto;width:min(380px,calc(100% - 24px));padding:20px;border:1px solid #8eaa8c;border-radius:14px;background:var(--village-midnight);color:#fff4db;text-align:center}
#mahjong-new-confirm::backdrop{background:var(--village-veil)}
#mahjong-new-confirm p{margin:12px 0}
#mahjong-new-confirm button{margin:2px}
@media(max-width:370px){
 .mahjong-area .mahjong-actions button{font-size:13px}
}
@media(max-height:600px) and (min-width:651px){
 .mahjong-area .mahjong-actions button{height:34px}
 #mahjong-status{height:4.5em}
}
.mahjong-area .mahjong-tile.free:hover,.mahjong-area .mahjong-tile.selected{transform:none}

/* The numbered journey opens at the player’s current level. */
#mahjong-levels{padding:0;max-height:calc(100dvh - 16px);--paper:var(--village-snow);--ink:var(--village-ink);--muted:var(--village-muted);--edge:var(--village-edge);margin:auto;width:min(calc(100% - 16px),660px);border:1px solid var(--edge);border-radius:24px;overflow:auto;background:var(--paper);color:var(--ink);box-shadow:0 6px 24px #172e2d18;font:500 14px/1.35 system-ui,sans-serif}
#mahjong-levels .landscape{isolation:isolate;position:relative;height:408px;overflow:hidden;background:#29465b url("art/town/alpine-evening.webp") center top / 100% 51% no-repeat}
#mahjong-levels .map-heading{position:absolute;top:21px;left:5%;z-index:3;color:#fff4d9;text-shadow:0 2px 6px #19344a}
#mahjong-levels p,#mahjong-levels h2,#mahjong-levels h3{margin:0}
#mahjong-levels .map-heading p,#mahjong-levels .status{font:750 11px/1.4 system-ui,sans-serif;letter-spacing:.13em;text-transform:uppercase}
#mahjong-levels .map-heading h2{color:inherit;font:600 clamp(25px,5vw,39px)/1.16 Georgia,serif;letter-spacing:-.04em;margin-top:3px}
#mahjong-levels .hills,#mahjong-levels .trail-lines,#mahjong-levels .forest,#mahjong-levels .stops{position:absolute;inset:0;width:100%;height:100%}
#mahjong-levels .lodge{position:absolute;width:clamp(69px,16%,104px);right:10%;top:18%;filter:drop-shadow(2px 5px 1px #47696632);transform:rotate(3deg)}
#mahjong-levels .pine{position:absolute;transform:translate(-50%,-100%);width:calc(var(--h)*.59);height:var(--h);filter:drop-shadow(2px 3px 0 #567c801d);background:linear-gradient(90deg,transparent 46%,#776c5a 46% 55%,transparent 55%) bottom /100% 28% no-repeat}
#mahjong-levels .pine::after{content:"";position:absolute;inset:0 0 10%;background:linear-gradient(164deg,#f3f1de 0 32%,#8cae9f 33% 47%,#598676 48% 65%,#326551 66%);clip-path:polygon(50% 0,74% 31%,64% 30%,87% 59%,72% 56%,100% 88%,76% 98%,28% 100%,0 89%,27% 56%,14% 60%,38% 30%,28% 33%)}
#mahjong-levels .node{position:absolute;transform:translate(-50%,-50%);width:49px;height:47px;border-radius:14px;border:2px solid #acbaa8;background:linear-gradient(140deg,#f3f5e9,#dae3d8);box-shadow:0 4px 0 #b0bfb4,0 6px 6px #35594b21;color:#627969;font:700 23px/1 Georgia,serif;text-align:center;padding:0}
#mahjong-levels .node.cleared{border-color:#386751;color:#fff5d8;background:linear-gradient(145deg,#568666,var(--village-spruce));box-shadow:0 4px 0 #294f3e,0 6px 7px #35594b30}
#mahjong-levels .node.current{border-color:#bd8934;background:linear-gradient(145deg,#fff1ad,var(--village-gold));color:#4b391a;box-shadow:0 4px 0 #a2793e,0 7px 8px #70572240}
#mahjong-levels .node[aria-pressed=true]{outline:2px solid #8e632b;outline-offset:5px}
#mahjong-levels .corner{position:absolute;right:-6px;bottom:-6px;display:grid;place-items:center;width:18px;height:18px;border-radius:50%;background:var(--village-snow);border:1px solid #aeb9a3;color:#315b44;font:bold 12px/1 system-ui}
#mahjong-levels .lock{display:block;width:8px;height:6px;border-radius:1px;background:#627768;position:relative;margin-top:3px}
#mahjong-levels .lock::before{content:"";position:absolute;width:6px;height:5px;left:1px;bottom:4px;border:1.5px solid #627768;border-radius:5px 5px 0 0}
#mahjong-levels .flag{position:absolute;white-space:nowrap;bottom:calc(100% + 10px);left:50%;transform:translateX(-50%);background:var(--village-umber);color:#fff5d8;padding:4px 8px;border-radius:6px;font:700 11px/1.15 system-ui,sans-serif}
#mahjong-levels .flag::after{content:"";position:absolute;left:calc(50% - 4px);top:100%;border:4px solid transparent;border-top-color:var(--village-umber)}
#mahjong-levels nav{display:flex;align-items:center;justify-content:center;gap:12px;padding:2px 12px;background:var(--paper);border-bottom:1px solid var(--edge)}
#mahjong-levels nav button{width:44px;height:44px;background:transparent;border:0;color:var(--ink);font:500 28px/1 Georgia,serif}
#mahjong-levels nav button:disabled{opacity:.25}
#mahjong-levels .range{font-size:13px;font-weight:650;font-variant-numeric:tabular-nums}
#mahjong-levels footer{padding:17px 5%;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
#mahjong-levels .status{color:var(--muted);letter-spacing:.09em}
#mahjong-levels footer h3{font:600 24px/1.25 Georgia,serif;margin-top:3px;color:var(--ink)}
#mahjong-levels .advance{font:650 14px/1.25 system-ui,sans-serif;color:#fff6dd;background:var(--village-spruce);border:1px solid #285139;border-radius:30px;padding:12px 17px;min-height:44px}
@media(max-width:440px){#mahjong-levels .landscape{height:385px}#mahjong-levels footer{padding:13px 15px}#mahjong-levels .advance{padding:10px 12px}#mahjong-levels .node{width:44px;height:44px}#mahjong-levels{border-radius:17px}#mahjong-levels .lodge{top:22%}}

#mahjong-levels .map-tools{position:absolute;z-index:4;right:12px;top:12px;display:flex;gap:6px}
#mahjong-levels .map-tools button{display:grid;place-items:center;width:42px;height:42px;border-radius:50%;color:#fff3d4;background:#203d49;border:1px solid #97ada8;font-size:23px}
#mahjong-levels .map-tools svg{width:24px;height:24px}
#mahjong-levels .advance:disabled{opacity:.55}
@media(max-width:500px){#mahjong-levels .map-heading{top:18px;max-width:calc(95% - 100px)}#mahjong-levels .map-heading h2{font-size:25px}#mahjong-levels .map-tools{right:7px;top:10px;gap:3px}}

.mahjong-coin{width:1.45em;height:1.45em;object-fit:contain;vertical-align:middle}
#mahjong-help-shop{
 --spruce:var(--village-spruce);--cream:#fff4d9;--brass:#bd9659;
 width:min(510px,calc(100% - 20px));max-height:calc(100dvh - 20px);padding:0;margin:auto;overflow:auto;
 background:var(--village-mist);color:var(--spruce);border:1px solid var(--brass);border-radius:20px;
 box-shadow:0 20px 70px #071a21a8
}
#mahjong-help-shop::backdrop{background:var(--village-veil);backdrop-filter:blur(4px)}
.shop-scene{
 position:relative;isolation:isolate;overflow:hidden;min-height:145px;display:flex;align-items:center;
 padding:18px 6% 23px;color:var(--cream);
 background:linear-gradient(90deg,#122b37af,transparent 73%),url("art/town/alpine-evening.webp") center 48% / cover
}
.shop-scene::before{content:"";position:absolute;z-index:-1;bottom:-17px;left:-4%;width:110%;height:34px;border-radius:60% 48% 0 0;background:#e9efe1;transform:rotate(-2deg)}
.shop-scene::after{content:"";position:absolute;bottom:0;inset-inline:0;height:6px;border-block:1px solid #c69a68;background:repeating-linear-gradient(105deg,#943f39 0 17px,#ede1bd 17px 34px)}
.shop-sign{position:relative;z-index:1;max-width:60%}
.shop-sign h2{margin:0 0 10px;color:var(--cream);font:600 clamp(28px,6.6vw,40px)/1.04 Georgia,serif;letter-spacing:-.04em;text-shadow:0 2px 6px #142b38}
#mahjong-shop-balance{display:inline-flex;align-items:center;gap:6px;margin:0;padding:4px 11px 4px 5px;background:#233e41ed;color:#fff4d9;border:1px solid #b39c6c;border-radius:20px;font:bold 15px/1.2 system-ui,sans-serif}
.shop-stall{position:absolute;height:92%;width:36%;object-fit:contain;right:6%;bottom:3px;filter:drop-shadow(1px 5px 2px #14292c66)}
#mahjong-shop-close{position:absolute;right:9px;top:8px;display:grid;place-items:center;width:40px;height:40px;padding:0;border:1px solid #aeb8a1;border-radius:50%;background:#213d46;color:var(--cream);font:22px/1 system-ui,sans-serif}
.shop-counter{padding:16px clamp(12px,4vw,25px) 18px;background:linear-gradient(115deg,var(--village-snow),var(--village-mist))}
.shop-counter section+section{margin-top:16px}
.shop-counter h3{display:flex;align-items:center;gap:10px;margin:0 0 9px;font:600 23px/1.14 Georgia,serif;letter-spacing:-.025em}
.shop-counter h3::after{content:"";height:1px;flex:1;background:linear-gradient(90deg,#baa579,transparent)}
.pack-offers,.single-offers{display:grid;gap:10px}
.pack-offers{grid-template-columns:repeat(2,minmax(0,1fr))}
.shop-pack{
 --felt:#305e49;--shade:#1d4437;
 position:relative;isolation:isolate;overflow:hidden;display:flex;flex-direction:column;align-items:center;gap:4px;
 padding:10px 8px 12px;text-align:center;border-radius:13px;border:1px solid #967b48;
 color:var(--cream);background:radial-gradient(ellipse at 50% 12%,#ffffff22,transparent 57%),linear-gradient(145deg,var(--felt),var(--shade));
 box-shadow:inset 0 0 0 3px var(--shade),inset 0 0 0 4px #d4bc8559,0 2px 3px #553c211a
}
.shop-pack.large-pack{--felt:#955044;--shade:#683930}
.parcel-art{position:relative;width:104px;height:56px;flex:none;filter:drop-shadow(0 3px 2px #1e271d55)}
.parcel-art img{position:absolute;object-fit:contain}
.front-parcel{height:51px;left:26px;bottom:2px;transform:rotate(-7deg)}
.large-pack .front-parcel{height:37px;left:20px;bottom:12px;transform:rotate(-8deg)}
.back-parcel{height:43px;right:17px;bottom:13px;transform:rotate(8deg)}
.parcel-sled{width:93px;left:4px;bottom:0}
.shop-pack h4{margin:0;font:600 22px/1.1 Georgia,serif;color:var(--cream)}
.shop-pack p{margin:0 0 4px;font-size:13px;line-height:1.35;color:#f4e7cd}
.shop-price{display:inline-flex;align-items:center;justify-content:center;gap:5px;width:100%;min-height:40px;padding:5px 8px;border:1px solid #c79b56;border-radius:9px;color:#433422;background:linear-gradient(#ffebae,#e5c27c);box-shadow:0 2px 0 #645134;font:750 15px/1.15 system-ui,sans-serif}
.shop-pack .shop-price{width:min(100%,130px);margin-top:auto}
.shop-price:enabled:hover{background:#ffefb9}
.shop-price:disabled{background:#e5ddc8;color:#5a584d;border-color:#aaa18c;box-shadow:none;cursor:default}
.shop-price.sold{color:#fff3d4;background:#0002;border-color:#e3cb8b88}
.single-offers{grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}
.single-offers article{display:grid;grid-template-columns:auto 1fr;align-items:center;gap:3px 8px;padding:10px;background:var(--village-snow);border:1px solid #d5c6a5;border-radius:10px;box-shadow:0 2px 0 #dbccab}
.boost-mark{grid-row:span 2;display:grid;place-items:center;width:30px;height:33px;border:1px solid #c5b28a;border-radius:5px;background:linear-gradient(140deg,#fffef2,#e9e1c4);box-shadow:0 2px 0 #9c9b79;color:var(--spruce);font:700 21px/1 Georgia,serif}
.single-offers h4{margin:0;font:600 17px/1.12 Georgia,serif}
.boost-stock{color:#65654f;font:500 12px/1.2 system-ui,sans-serif}
.single-offers .shop-price{grid-column:1/-1;margin-top:5px}
#mahjong-shop-status{margin:12px 0 0;font-size:14px;color:#374d39}
#mahjong-shop-status:empty{margin:0}
@media(max-width:440px){
 .shop-scene{min-height:127px}.shop-stall{height:80%;right:7%}
 .single-offers article{display:flex;flex-direction:column;gap:4px;padding:8px 4px}
 .single-offers h4{font-size:16px}.single-offers .shop-price{width:92%;margin-top:auto}
 .shop-price{min-height:44px}
}
.mahjong-area.triple .mahjong-table{container-type:normal;min-height:min-content}
@media(min-width:651px) and (min-height:601px){.mahjong-area.triple{height:auto;min-height:100%}}
@media(max-height:600px) and (min-width:651px){.mahjong-area.triple{height:auto;min-height:100%}}
.mahjong-help-open,#mahjong-levels nav .mahjong-help-open{display:inline-grid;place-items:center;vertical-align:middle;border:1px solid currentColor;border-radius:50%;width:32px;height:32px;padding:0;background:transparent;color:inherit;font:700 18px/1 Georgia,serif}
.mahjong-top .mahjong-help-open{margin-left:6px;color:#f1d59d}
#mahjong-levels nav{display:grid;grid-template-columns:1fr auto 1fr;gap:4px;padding-inline:5%}
#mahjong-levels nav .map-rankings{justify-self:start;width:auto;padding:2px 0;font:650 13px/1.2 system-ui,sans-serif;text-decoration:underline;text-underline-offset:3px}
#mahjong-levels nav .mahjong-help-open{justify-self:end}
#mahjong-levels .map-pages{display:flex;align-items:center;gap:4px}
:is(#mahjong-guide,#mahjong-shelf-empty){margin:auto;width:min(410px,calc(100% - 24px));max-height:calc(100dvh - 24px);overflow:auto;padding:22px;border:1px solid #b4a16d;border-radius:18px;background:var(--village-snow);color:var(--village-ink);box-shadow:0 12px 40px #082c2455}
:is(#mahjong-guide,#mahjong-shelf-empty)::backdrop{background:var(--village-veil);backdrop-filter:blur(3px)}
.mahjong-guide-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}
.mahjong-guide-heading h2{margin:0;font:500 27px/1.15 Georgia,serif}
.mahjong-guide-heading button{border:1px solid #afbaa2;background:transparent;color:var(--village-ink);border-radius:50%;width:36px;height:36px;font-size:23px}
#mahjong-guide p,#mahjong-guide dd{font-size:15px;line-height:1.45}
#mahjong-guide p,#mahjong-guide dt{margin:14px 0 0}
#mahjong-guide dl{margin:0}#mahjong-guide dt{font-weight:700}#mahjong-guide dd{margin:3px 0 0}
@media(max-width:440px){#mahjong-levels nav{padding-inline:10px;display:flex;justify-content:space-between}#mahjong-levels .map-pages{gap:0}#mahjong-levels .map-pages button{width:32px}}
#mahjong-leaderboard .ranking-cleared{display:flex;align-items:baseline;gap:5px}
#mahjong-levels .node.available{border-color:#78927a;background:var(--village-mint);color:#36573b}
.mahjong-icon{display:inline-block;width:22px;height:22px;vertical-align:middle;flex:none;pointer-events:none}
#mahjong-hint,#mahjong-shuffle,#mahjong-undo,#mahjong-shelf{display:inline-flex;align-items:center;justify-content:center;gap:6px}
.boost-count{font:650 13px/1 system-ui,sans-serif;font-variant-numeric:tabular-nums}
.boost-count:empty{display:none}
#triple-shelf .rack-slot>.mahjong-icon{width:53%;height:53%;color:#d8e8ce;opacity:.78}
.pack-contents,.pack-contents>span{display:flex;align-items:center;justify-content:center}
.pack-contents{gap:10px;margin:2px 0 5px}
.pack-contents>span{gap:3px;font:650 13px/1 system-ui,sans-serif}
.pack-contents .mahjong-icon{width:17px;height:17px}
#mahjong-help-shop .single-offers{grid-template-columns:repeat(4,minmax(0,1fr))}
.single-offers article{display:flex;align-items:center;flex-direction:column;text-align:center;padding:9px 4px;gap:4px}
.single-offers .shop-price{width:94%;margin-top:auto}
#mahjong-guide dt{display:flex;align-items:center;gap:7px}
@media(max-width:370px){.pack-contents{gap:5px}.pack-contents .mahjong-icon{width:15px;height:15px}.single-offers h4{font-size:14px}}

#mahjong-shelf-empty h2{margin:0;font:500 27px/1.15 Georgia,serif}
#mahjong-shelf-empty p{margin:12px 0 18px}
#mahjong-shelf-empty form{display:flex;justify-content:flex-end;gap:8px}
#mahjong-shelf-empty button{border:1px solid #afbaa2;border-radius:20px;padding:8px 14px}
