:root { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif; color: #26362f; background: #f5f3ec; font-synthesis: none; --green: #315b50; --muted: #7b8278; --line: #dcded2; --ivory: #fffaf0; }
* { box-sizing: border-box; }
body { margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, a:focus-visible { outline: 3px solid #dfac50; outline-offset: 4px; }
button { transition: background .15s, color .15s, box-shadow .15s; }
.shell { width: min(1144px, 100%); margin: auto; padding: 0 40px max(20px, env(safe-area-inset-bottom)); }
.site-header { min-height: 104px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); gap: 16px; }
.brand { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.brand strong { display: block; font-size: 18px; font-weight: 650; letter-spacing: 2px; }
.brand small { display: block; margin-top: 7px; font-size: 8px; letter-spacing: 1.8px; color: var(--muted); }
.brand-mark { width: 46px; height: 42px; position: relative; display: block; }
.brand-mark i { position: absolute; top: 4px; width: 24px; height: 34px; background: var(--green); color: #faf8ec; border-radius: 4px; font-style: normal; font-family: Georgia, serif; font-size: 23px; font-weight: bold; text-align: center; line-height: 34px; }
.brand-mark i:first-child { left: 2px; transform: rotate(-13deg); opacity: .5; }
.brand-mark i:last-child { left: 18px; transform: rotate(9deg); }
.header-actions { display: flex; align-items: center; gap: 24px; }
.practice-lessons { display: flex; align-items: center; padding: 2px; border: 1px solid var(--line); border-radius: 8px; }
.practice-lessons a { display: grid; place-items: center; min-width: 44px; min-height: 30px; padding: 4px 9px; color: var(--muted); font-size: 11px; text-decoration: none; border-radius: 5px; }
.practice-lessons a[aria-current="page"] { color: var(--green); background: #e6eadf; font-weight: 600; }
.mode-badge { display: flex; align-items: center; gap: 7px; font-size: 11px; letter-spacing: 1px; color: #687366; white-space: nowrap; }
.mode-badge > span:first-child { width: 6px; height: 6px; border-radius: 50%; background: #92a284; }
.quiet-button { border: 0; background: transparent; padding: 9px 0; font-size: 12px; }
.quiet-button span { margin-left: 10px; color: var(--muted); }
.game-heading { display: flex; justify-content: space-between; align-items: center; padding: 30px 0 26px; gap: 16px; }
.eyebrow { font-size: 9px; letter-spacing: 2.4px; color: var(--muted); margin: 0 0 12px; }
h1 { font-size: 35px; font-weight: 600; letter-spacing: 3px; margin: 0; }
h1 span { display: inline-block; margin-left: 23px; font-size: 14px; font-weight: 400; letter-spacing: 1px; color: #889083; vertical-align: middle; }
.description { font-size: 12px; color: var(--muted); margin: 12px 0 0; line-height: 1.7; }
.round-summary { display: grid; gap: 8px; text-align: right; font-size: 11px; white-space: nowrap; }
.round-summary span { color: var(--muted); }
.round-summary strong { font-weight: 500; border: 1px solid #d7dacb; border-radius: 20px; padding: 7px 12px; background: #eeeede; }
.game-table { background: #43685b; background-image: radial-gradient(ellipse at 20% 10%, #ffffff09, transparent 60%), repeating-linear-gradient(0deg, #ffffff02 0px, #ffffff02 1px, transparent 1px, transparent 3px); padding: 20px 25px 17px; border-radius: 14px; box-shadow: inset 0 0 0 1px #ffffff0a, 0 8px 20px #294a3d0c; color: #e4eadb; }
.table-topline { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 1.2px; color: #d5dec2; }
.table-topline > span:first-child { display: flex; align-items: center; gap: 7px; }
.small-dot { width: 5px; height: 5px; border-radius: 100%; background: #b4c49e; }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; min-height: 217px; padding: 22px 0 14px; }
.meld { min-width: 0; }
.meld-header { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 8px; padding: 0 1px 9px; border: 0; background: transparent; color: #d5dfc8; text-align: left; font-size: 10px; }
.meld-header small { color: #b7c7af; font-size: 9px; }
.meld-header:hover { color: #fffaf0; }
.meld-tiles { display: flex; flex-wrap: wrap; gap: 5px; min-height: 66px; border-radius: 7px; }
.meld .tile { width: 43px; height: 62px; font-size: 30px; }
.meld.locked .meld-header { opacity: .8; }
.meld.invalid .meld-header small { color: #f2c6a2; }
.meld.invalid .meld-tiles { outline: 1px dashed #f2c6a280; outline-offset: 4px; }
.new-meld { border: 1px dashed #bbceb067; border-radius: 8px; min-height: 94px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: #ced9be; background: #ffffff03; text-align: center; padding: 14px; font: inherit; }
.new-meld:hover { background: #ffffff0a; }
.new-meld b { font-size: 20px; font-weight: 300; line-height: 1; }
.new-meld span { font-size: 11px; }
.drop-active { outline: 2px dashed #f5dc93 !important; outline-offset: 6px; }
.table-note { display: flex; gap: 8px; align-items: center; font-size: 10px; color: #c6d4b9; padding-top: 11px; border-top: 1px solid #ceddc120; line-height: 1.7; }
.table-note > span:first-child { font-size: 15px; }
.rack-section { padding: 26px 0 0; }
.rack-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 4px 14px; }
h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 1px; }
.rack-heading h2 span { font-family: Georgia, serif; margin-left: 7px; font-size: 14px; color: #87917d; }
.rack-heading p { margin: 8px 0 0; font-size: 10px; color: var(--muted); line-height: 1.6; }
.sort-controls { display: flex; background: #eeeee4; border: 1px solid #deded1; border-radius: 7px; padding: 3px; flex-shrink: 0; }
.sort-button { font-size: 10px; border: 0; background: transparent; padding: 7px 10px; border-radius: 4px; }
.sort-button.active { background: #faf9f3; box-shadow: 0 1px 3px #283c2014; }
.rack { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 7px; padding: 16px; border-radius: 11px; background: #e9e5d8; box-shadow: inset 0 1px 3px #4b403f0b; min-height: 115px; align-items: start; }
.tile { --tile-color: #2e3633; aspect-ratio: .7; border: 1px solid #e5dfcf; border-bottom: 3px solid #d5cbb8; border-radius: 6px; background: linear-gradient(155deg, #fffef5, #f8f1e2); box-shadow: 0 2px 3px #243c331c; color: var(--tile-color); display: inline-flex; align-items: center; justify-content: center; position: relative; padding: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: clamp(25px, 2.7vw, 34px); user-select: none; touch-action: none; -webkit-user-select: none; min-width: 0; }
.tile::before { content: ""; position: absolute; top: 6px; left: 6px; width: 4px; height: 9px; border-radius: 2px; background: var(--tile-color); }
.tile::after { content: ""; position: absolute; bottom: 8px; width: 7px; height: 3px; border-radius: 2px; background: var(--tile-color); }
.tile[data-color="red"] { --tile-color: #e01624; }
.tile[data-color="blue"] { --tile-color: #005bd7; }
.tile[data-color="orange"] { --tile-color: #e6ae00; text-shadow: .35px 0 #956700, -.35px 0 #956700, 0 .35px #956700, 0 -.35px #956700; }
.tile[data-color="black"] { --tile-color: #15171b; }
.tile.joker { --tile-color: #84744d; font-family: sans-serif; font-weight: 400; }
.tile.joker::before { display: none; }
.tile.joker::after { background: linear-gradient(90deg, #e01624 25%, #005bd7 25% 50%, #e6ae00 50% 75%, #15171b 75%); width: 16px; }
.tile.selected { border-color: #d49d42; box-shadow: 0 0 0 2px #d9b263, 0 5px 8px #283c3420; transform: translateY(-5px); }
.tile:hover { background: #fffdf5; }
.tile.dragging { opacity: .25; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; transform: translate(-50%, -65%) rotate(-4deg); box-shadow: 0 12px 20px #17382f40; width: 54px !important; height: 77px !important; font-size: 34px !important; }
.rack-bottom { display: flex; justify-content: space-between; align-items: center; padding: 10px 4px 0; color: var(--muted); font-size: 10px; }
.text-button { background: transparent; border: 0; padding: 5px 0; font-size: 10px; color: #6a7764; text-decoration: underline; text-underline-offset: 3px; }
.turn-bar { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 21px 0 0; }
.feedback { display: flex; align-items: center; gap: 9px; color: #79836e; font-size: 11px; line-height: 1.6; max-width: 370px; }
.feedback-icon { font-size: 18px; flex-shrink: 0; }
.feedback.valid { color: #315b50; }
.feedback.invalid { color: #ad6847; }
.turn-actions { display: flex; gap: 7px; flex-shrink: 0; }
.primary-button, .secondary-button { min-height: 41px; padding: 10px 16px; border-radius: 7px; border: 1px solid #d9decd; font-size: 11px; white-space: nowrap; }
.secondary-button { background: #f8f7f0; }
.secondary-button:not(:disabled):hover { background: #eeeee2; }
.primary-button { background: var(--green); border-color: var(--green); color: #fffaf0; font-weight: 500; }
.primary-button span { margin-left: 15px; opacity: .75; }
.primary-button:not(:disabled):hover { background: #244a3f; }
.page-footer { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 25px 0 10px; margin-top: 24px; border-top: 1px solid var(--line); color: #979b8e; font-size: 10px; line-height: 1.7; }
.page-footer .text-button { flex-shrink: 0; }
dialog { border: 1px solid #dfdece; color: #26362f; background: #f8f6ee; padding: 32px; border-radius: 16px; max-width: 500px; width: calc(100% - 32px); max-height: calc(100dvh - 40px); box-shadow: 0 25px 100px #203a3540; }
dialog::backdrop { background: #153b324d; backdrop-filter: blur(4px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; }
.close-button { border: 0; background: transparent; font-size: 27px; color: #839080; line-height: 1; padding: 0 0 10px 20px; }
.rules-dialog h2 { font-size: 25px; font-weight: 500; margin: 8px 0 10px; letter-spacing: 2px; }
.dialog-intro { color: #87917d; font-size: 11px; margin-bottom: 24px; }
.rules-list { list-style: none; counter-reset: rule; padding: 0; }
.rules-list li { counter-increment: rule; position: relative; padding-left: 31px; margin: 18px 0; }
.rules-list li::before { content: "0" counter(rule); position: absolute; left: 0; top: 1px; font-size: 10px; color: #97a089; font-family: Georgia, serif; }
.rules-list strong { font-size: 12px; font-weight: 600; }
.rules-list p, .dialog-tip p { font-size: 11px; line-height: 1.9; color: #7a8274; margin: 6px 0 0; }
.dialog-tip { padding: 17px; background: #eeede0; border-radius: 8px; }
.dialog-tip strong { font-size: 11px; }
.prototype-note { font-size: 10px; line-height: 1.8; color: #8b917f; margin: 20px 0; }
.rules-dialog > .primary-button { width: 100%; }
.confirm-dialog h2 { font-size: 20px; }
.confirm-dialog p { margin: 17px 0 23px; color: #7a8274; font-size: 12px; line-height: 1.8; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: max(28px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); background: #243e34; color: #fffbea; padding: 12px 20px; border-radius: 9px; box-shadow: 0 6px 20px #1c372e30; font-size: 12px; line-height: 1.7; z-index: 150; pointer-events: none; }
.noscript { padding: 20px; text-align: center; }
[hidden] { display: none !important; }
.quiet-link { font-size: 11px; text-decoration: none; color: #73816d; }
.lobby-hero { position: relative; padding: 75px 0 64px; }
.lobby-hero h1 { font-size: 50px; font-weight: 500; letter-spacing: 4px; }
.lobby-hero > p:last-of-type { font-size: 14px; color: var(--muted); margin: 22px 0 0; line-height: 1.8; }
.hero-tiles { position: absolute; right: 33px; top: 70px; display: flex; gap: 12px; transform: rotate(8deg); }
.hero-tiles .tile { width: 67px; height: 96px; font-size: 39px; }
.hero-tiles .tile:first-child { transform: rotate(-17deg) translateY(10px); }
.hero-tiles .tile:last-child { transform: rotate(12deg) translateY(6px); }
.lobby-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 23px; }
.room-card { padding: 30px; border: 1px solid #dce0d2; border-radius: 13px; }
.room-card h2 { font-size: 24px; font-weight: 500; letter-spacing: 2px; }
.room-card > p:not(.eyebrow) { font-size: 11px; color: #86917d; line-height: 1.9; margin: 14px 0 26px; }
.create-card { background: #315b50; border-color: #315b50; color: #fffbee; }
.create-card .eyebrow, .create-card > p:not(.eyebrow) { color: #bdccb1; }
form label { display: block; font-size: 11px; margin-bottom: 9px; }
input { width: 100%; min-width: 0; font: inherit; font-size: 13px; min-height: 46px; padding: 12px; border: 1px solid #d4dbc9; border-radius: 6px; color: #26362f; background: #fffdf7; }
input:focus-visible { outline: 2px solid #c5a567; outline-offset: 3px; }
.room-card form > button { width: 100%; margin-top: 17px; min-height: 45px; }
.create-card .primary-button { color: #2d584a; background: #e3e7d3; border-color: #e3e7d3; }
.create-card .primary-button:hover { background: #f2f1df; }
.join-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
#join-code { text-transform: uppercase; letter-spacing: 1px; }
.lobby-notice { font-size: 12px; padding: 14px 18px; color: #985d3f; background: #f0e7d8; border-radius: 8px; line-height: 1.7; }
.lobby-bottom { margin: 27px 0 45px; display: flex; justify-content: space-between; gap: 15px; font-size: 11px; color: #8a927e; line-height: 1.8; }
.lobby-bottom a { color: #5e765e; text-underline-offset: 4px; }
.recent-section { margin-top: 30px; }
.recent-section > p { font-size: 11px; color: var(--muted); }
.recent-seat { width: 100%; display: flex; justify-content: space-between; text-align: left; gap: 15px; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 14px 0; font-size: 12px; }
.recent-seat span:last-child { color: var(--muted); font-size: 10px; }
.room-topbar { display: flex; justify-content: space-between; gap: 15px; align-items: center; padding: 22px 0; font-size: 11px; color: #849078; }
.room-topbar strong { font-weight: 500; font-family: ui-monospace, monospace; font-size: 15px; letter-spacing: 2px; color: var(--green); }
.room-players { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.player-seat { padding: 15px; border: 1px solid #dce0d2; background: #f9f8f2; border-radius: 8px; min-width: 0; }
.player-seat.current { border-color: #69866a; background: #e7ecdd; }
.player-seat strong { display: block; font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.player-seat span { display: block; margin-top: 8px; font-size: 10px; color: #89917d; }
.player-seat.empty { background: transparent; border-style: dashed; color: #a4aa99; }
.room-waiting { text-align: center; padding: 65px 20px 45px; }
.room-waiting h2 { font-size: 27px; font-weight: 500; }
.room-waiting > p:not(.eyebrow) { color: var(--muted); font-size: 12px; line-height: 1.9; }
.waiting-actions { display: flex; justify-content: center; align-items: center; gap: 13px; margin: 30px 0; }
.room-rule-note { max-width: 420px; margin: 35px auto 0; }
.room-result { text-align: center; border-radius: 12px; background: #e6ebdc; margin-top: 25px; padding: 30px; }
.room-result h2 { font-size: 25px; font-weight: 500; }
.room-result > p:not(.eyebrow) { color: #78866d; font-size: 12px; line-height: 1.8; }
.result-row { padding: 12px 0; border-top: 1px solid #c7d1bd; display: flex; justify-content: space-between; font-size: 12px; }
.room-result > .primary-button { margin-top: 20px; }
@media(max-width:600px) { .lobby-hero { padding: 43px 0 40px; } .lobby-hero h1 { font-size: 32px; } .lobby-hero > p:last-of-type { font-size: 11px; max-width: 200px; margin-top: 16px; } .hero-tiles { right: 5px; top: 48px; gap: 4px; } .hero-tiles .tile { width: 33px; height: 47px; font-size: 24px; } .lobby-forms { grid-template-columns: 1fr; gap: 17px; } .room-card { padding: 25px; } .room-card h2 { font-size: 22px; } .lobby-bottom { flex-direction: column; margin-bottom: 20px; gap: 8px; font-size: 10px; } .room-topbar { font-size: 9px; gap: 8px; padding: 17px 0; } .room-topbar strong { font-size: 12px; } .room-players { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; } .player-seat { padding: 12px; } .room-waiting { padding: 40px 0 30px; } .room-waiting h2 { font-size: 22px; } .waiting-actions { gap: 9px; flex-wrap: wrap; } .room-result { padding: 23px; } }
@media (min-width: 850px) { .new-meld { grid-column: 1 / -1; min-height: 74px; flex-direction: row; gap: 13px; } }
@media (max-width: 849px) {
  .shell { padding-inline: 25px; }
  .rack { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 9px; }
  .tile { font-size: 33px; max-height: 92px; }
  .turn-bar { flex-direction: column; align-items: stretch; }
  .feedback { max-width: 100%; min-height: 28px; }
  .turn-actions { justify-content: flex-end; }
  .game-table { padding-inline: 20px; }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .new-meld { min-height: 85px; }
}
@media (max-width: 500px) {
  .shell { padding-inline: 16px; }
  .site-header { min-height: 78px; gap: 10px; }
  .brand { gap: 8px; }
  .brand strong { font-size: 14px; letter-spacing: 1px; }
  .brand small { font-size: 6px; letter-spacing: .7px; margin-top: 5px; }
  .brand-mark { width: 37px; transform: scale(.8); transform-origin: left center; margin-right: -5px; }
  .header-actions { gap: 13px; }
  .mode-badge { font-size: 9px; gap: 4px; letter-spacing: 0; }
  .quiet-button { font-size: 10px; }
  .quiet-button span { display: none; }
  .game-heading { padding: 22px 0 20px; }
  .eyebrow { font-size: 8px; letter-spacing: 1.6px; margin-bottom: 9px; }
  h1 { font-size: 28px; letter-spacing: 2px; }
  h1 span { font-size: 10px; letter-spacing: 0; margin-left: 12px; }
  .description { font-size: 9px; margin-top: 9px; max-width: 230px; }
  .round-summary { font-size: 9px; gap: 6px; }
  .round-summary strong { padding: 6px 8px; }
  .game-table { padding: 15px 15px 12px; border-radius: 10px; }
  .table-topline { font-size: 9px; }
  .board { grid-template-columns: 1fr; gap: 12px; padding: 15px 0 12px; min-height: 0; max-height: 285px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding-inline: 3px; scrollbar-width: thin; scrollbar-color: #9bafa270 transparent; }
  .meld { display: flex; align-items: center; gap: 13px; }
  .meld-header { width: 57px; flex-shrink: 0; flex-direction: column; align-items: start; gap: 5px; padding: 5px 0; font-size: 9px; }
  .meld-header small { font-size: 8px; }
  .meld-tiles { flex: 1; min-width: 0; min-height: 47px; gap: 5px; }
  .meld .tile { width: 33px; height: 47px; font-size: 25px; border-radius: 4px; }
  .tile::after { bottom: 6px; height: 2px; width: 4px; }
  .new-meld { min-height: 45px; flex-direction: row; gap: 10px; padding: 10px; }
  .new-meld span { font-size: 10px; }
  .table-note { font-size: 8px; padding-top: 8px; gap: 6px; }
  .table-note > span:first-child { font-size: 12px; }
  .rack-section { padding-top: 20px; }
  .rack-heading { gap: 8px; padding: 0 2px 12px; }
  h2 { font-size: 12px; }
  .rack-heading p { font-size: 8px; max-width: 210px; margin-top: 6px; }
  .sort-controls { padding: 2px; }
  .sort-button { font-size: 8px; padding: 7px 7px; }
  .rack { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; padding: 11px; border-radius: 8px; }
  .tile { font-size: 27px; border-radius: 5px; }
  .rack-bottom { font-size: 8px; padding-top: 7px; }
  .text-button { font-size: 9px; }
  .turn-bar { padding-top: 13px; gap: 9px; }
  .feedback { font-size: 9px; gap: 6px; min-height: 26px; }
  .feedback-icon { font-size: 15px; }
  .turn-actions { display: grid; grid-template-columns: 1fr 1fr 1fr 1.5fr; gap: 5px; }
  .primary-button, .secondary-button { padding: 9px 8px; min-height: 42px; font-size: 10px; }
  .primary-button span { margin-left: 7px; }
  .page-footer { padding: 16px 0 8px; margin-top: 18px; gap: 10px; font-size: 8px; }
  dialog { padding: 23px; }
}
@media (max-width: 360px) {
  .rack { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .shell:not(.lobby-shell) .brand small { display: none; }
  .shell:not(.lobby-shell) .header-actions { gap: 9px; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } }

/* Game pages use the short landscape viewport; the lobby keeps its own layout. */
.orientation-hint { display: none; }
@media (max-width: 600px) and (orientation: portrait) {
  .shell:not(.lobby-shell) .orientation-hint {
    display: block;
    margin: 12px 0 0;
    padding: 9px 12px;
    border: 1px solid #dce0d2;
    border-radius: 7px;
    background: #eeeee4;
    color: #526b5d;
    font-size: 11px;
    line-height: 1.5;
  }
}

@media (min-width: 640px) and (max-width: 1000px) and (max-height: 600px) and (orientation: landscape) {
  .shell:not(.lobby-shell) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 320px;
    min-width: 0;
    padding: max(3px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .shell:not(.lobby-shell) > .site-header {
    min-height: 28px;
    flex-shrink: 0;
    gap: 12px;
  }
  .shell:not(.lobby-shell) .brand { gap: 5px; min-width: 0; }
  .shell:not(.lobby-shell) .brand-mark {
    width: 31px;
    height: 28px;
    margin-right: -3px;
    transform: scale(.6);
    transform-origin: left center;
  }
  .shell:not(.lobby-shell) .brand strong { font-size: 12px; letter-spacing: 1px; }
  .shell:not(.lobby-shell) .brand small { display: none; }
  .shell:not(.lobby-shell) .header-actions { gap: 14px; }
  .shell:not(.lobby-shell) .mode-badge { font-size: 9px; letter-spacing: 0; }
  .shell:not(.lobby-shell) .quiet-button { padding: 7px 0; font-size: 10px; }
  .shell:not(.lobby-shell) .quiet-button span { margin-left: 5px; }
  .shell:not(.lobby-shell) > main {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .shell:not(.lobby-shell) #room-play {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
  }
  .shell:not(.lobby-shell) .room-topbar {
    flex-shrink: 0;
    min-height: 22px;
    padding: 2px 0;
    gap: 10px;
    font-size: 9px;
  }
  .shell:not(.lobby-shell) .room-topbar strong { font-size: 12px; letter-spacing: 1px; }
  .shell:not(.lobby-shell) .room-topbar .text-button { padding: 3px 0; font-size: 9px; }
  .shell:not(.lobby-shell) .quiet-link { font-size: 10px; }
  .shell:not(.lobby-shell) .room-players {
    display: flex;
    flex-shrink: 0;
    gap: 6px;
    min-width: 0;
    margin-bottom: 3px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
  }
  .shell:not(.lobby-shell) .player-seat {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    min-width: 120px;
    max-width: 200px;
    padding: 4px 8px;
    border-radius: 6px;
  }
  .shell:not(.lobby-shell) .player-seat strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
    line-height: 12px;
  }
  .shell:not(.lobby-shell) .player-seat span {
    flex-shrink: 0;
    margin: 0;
    white-space: nowrap;
    font-size: 9px;
    line-height: 12px;
  }
  .shell:not(.lobby-shell) .game-heading {
    flex-shrink: 0;
    min-height: 26px;
    padding: 3px 0;
    gap: 10px;
  }
  .shell:not(.lobby-shell) .game-heading h1 { font-size: 18px; line-height: 1.1; letter-spacing: 2px; }
  .shell:not(.lobby-shell) .game-heading .eyebrow,
  .shell:not(.lobby-shell) .game-heading h1 span,
  .shell:not(.lobby-shell) .game-heading .description,
  .shell:not(.lobby-shell) .table-note,
  .shell:not(.lobby-shell) .rack-heading p,
  .shell:not(.lobby-shell) .page-footer { display: none; }
  .shell:not(.lobby-shell) .round-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 9px;
  }
  .shell:not(.lobby-shell) .round-summary strong { padding: 3px 8px; }
  .shell:not(.lobby-shell) .game-table {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 92px;
    min-width: 0;
    padding: 7px 10px;
    border-radius: 9px;
  }
  .shell:not(.lobby-shell) .table-topline { flex-shrink: 0; font-size: 9px; line-height: 12px; }
  .shell:not(.lobby-shell) .board {
    flex: 1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-content: start;
    gap: 9px 12px;
    min-height: 0;
    min-width: 0;
    max-height: none;
    padding: 7px 3px 6px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #9bafa270 transparent;
  }
  .shell:not(.lobby-shell) .meld-header { gap: 5px; padding-bottom: 4px; font-size: 9px; line-height: 12px; }
  .shell:not(.lobby-shell) .meld-header small { font-size: 8px; }
  .shell:not(.lobby-shell) .meld-tiles { gap: 4px; min-height: 54px; }
  .shell:not(.lobby-shell) .meld .tile { flex: 0 0 38px; width: 38px; height: 54px; font-size: 28px; border-radius: 5px; }
  .shell:not(.lobby-shell) .new-meld {
    grid-column: auto;
    min-height: 54px;
    flex-direction: row;
    gap: 8px;
    padding: 8px;
  }
  .shell:not(.lobby-shell) .new-meld span { font-size: 9px; }
  .shell:not(.lobby-shell) .rack-section { flex-shrink: 0; min-width: 0; padding-top: 4px; }
  .shell:not(.lobby-shell) .rack-heading { gap: 8px; padding: 0 2px 3px; }
  .shell:not(.lobby-shell) .rack-heading h2 { font-size: 10px; }
  .shell:not(.lobby-shell) .rack-heading h2 span { font-size: 11px; }
  .shell:not(.lobby-shell) .sort-controls { padding: 2px; }
  .shell:not(.lobby-shell) .sort-button { padding: 3px 9px; font-size: 9px; }
  .shell:not(.lobby-shell) .rack {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 6px;
    min-height: 72px;
    height: 72px;
    min-width: 0;
    padding: 6px 10px;
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    scrollbar-width: thin;
  }
  .shell:not(.lobby-shell) .rack .tile {
    flex: 0 0 40px;
    width: 40px;
    height: 54px;
    max-height: none;
    font-size: 29px;
    touch-action: pan-x;
  }
  .shell:not(.lobby-shell) .rack .tile.selected { transform: translateY(-3px); }
  .shell:not(.lobby-shell) .rack-bottom { padding: 2px 3px 0; font-size: 9px; line-height: 16px; }
  .shell:not(.lobby-shell) .rack-bottom .text-button { padding: 0; font-size: 9px; line-height: 16px; }
  .shell:not(.lobby-shell) .turn-bar {
    flex-shrink: 0;
    flex-direction: row;
    align-items: center;
    min-width: 0;
    min-height: 44px;
    padding-top: 5px;
    gap: 10px;
  }
  .shell:not(.lobby-shell) .feedback { flex: 1; min-width: 0; min-height: 0; max-width: none; gap: 6px; font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; }
  .shell:not(.lobby-shell) .feedback-icon { font-size: 15px; }
  .shell:not(.lobby-shell) .turn-actions { display: flex; gap: 5px; }
  .shell:not(.lobby-shell) .turn-actions .primary-button,
  .shell:not(.lobby-shell) .turn-actions .secondary-button { min-height: 38px; padding: 8px 10px; font-size: 10px; }
  .shell:not(.lobby-shell) .turn-actions .primary-button span { margin-left: 7px; }
}

/* The layout helper sets --board-scale; these dimensions also define its packing model. */
.table-topline { align-items: center; gap: 8px; }
.table-view-actions { display: flex; align-items: center; gap: 10px; }
.board-view-button { min-height: 22px; padding: 2px 7px; border: 1px solid #bbceb067; border-radius: 5px; background: #ffffff07; color: #d5dec2; font-size: 9px; line-height: 16px; letter-spacing: 0; white-space: nowrap; }
.board-view-button:hover, .board-view-button[aria-pressed="true"] { background: #ffffff16; color: #fffaf0; }
.shell:not(.lobby-shell) .board.auto-fit {
  --board-scale: 1;
  --board-tile-width: calc(38px * var(--board-scale));
  --board-tile-height: calc(54px * var(--board-scale));
  --board-tile-gap: calc(4px * var(--board-scale));
  --board-header-height: calc(14px * var(--board-scale));
  display: block;
  height: min(42vh, 360px);
  height: min(42dvh, 360px);
  min-height: 130px;
  min-width: 0;
  padding: 12px 0;
  overflow: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #9bafa270 transparent;
}
.shell:not(.lobby-shell) .board.auto-fit .meld {
  position: absolute;
  display: block;
  flex: 0 0 auto;
  width: max(calc((42px * var(--meld-count, 3) - 4px) * var(--board-scale)), calc(80px * var(--board-scale)));
  min-width: 0;
}
.shell:not(.lobby-shell) .board.auto-fit .meld-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 100%;
  height: var(--board-header-height);
  min-height: 0;
  margin: 0 0 var(--board-tile-gap);
  padding: 0;
  gap: var(--board-tile-gap);
  font-size: calc(10px * var(--board-scale));
  line-height: 1;
  white-space: nowrap;
}
.shell:not(.lobby-shell) .board.auto-fit .meld-header > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.shell:not(.lobby-shell) .board.auto-fit .meld-header small { flex-shrink: 0; font-size: calc(9px * var(--board-scale)); }
.shell:not(.lobby-shell) .board.auto-fit .meld-tiles {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: var(--board-tile-gap);
  min-width: 0;
  min-height: var(--board-tile-height);
}
.shell:not(.lobby-shell) .board.auto-fit .meld .tile {
  flex: 0 0 var(--board-tile-width);
  width: var(--board-tile-width);
  height: var(--board-tile-height);
  min-height: 0;
  font-size: calc(28px * var(--board-scale));
  border-width: calc(1px * var(--board-scale));
  border-bottom-width: calc(3px * var(--board-scale));
  border-radius: calc(5px * var(--board-scale));
}
.shell:not(.lobby-shell) .board.auto-fit .tile::before {
  top: calc(6px * var(--board-scale));
  left: calc(6px * var(--board-scale));
  width: calc(4px * var(--board-scale));
  height: calc(9px * var(--board-scale));
  border-radius: calc(2px * var(--board-scale));
}
.shell:not(.lobby-shell) .board.auto-fit .tile::after {
  bottom: calc(8px * var(--board-scale));
  width: calc(7px * var(--board-scale));
  height: calc(3px * var(--board-scale));
  border-radius: calc(2px * var(--board-scale));
}
.shell:not(.lobby-shell) .board.auto-fit .tile.joker::after { width: calc(16px * var(--board-scale)); }
.shell:not(.lobby-shell) .board.auto-fit .tile.selected { transform: translateY(calc(-3px * var(--board-scale))); }
.shell:not(.lobby-shell) .board.auto-fit .new-meld {
  position: absolute;
  flex: 0 0 auto;
  grid-column: auto;
  width: max(44px, calc(90px * var(--board-scale)));
  height: max(44px, calc(var(--board-tile-height) + var(--board-header-height) + var(--board-tile-gap)));
  min-height: 0;
  flex-direction: column;
  gap: calc(4px * var(--board-scale));
  padding: calc(3px * var(--board-scale));
  border-radius: calc(6px * var(--board-scale));
}
.shell:not(.lobby-shell) .board.auto-fit .new-meld b { font-size: max(10px, calc(20px * var(--board-scale))); }
.shell:not(.lobby-shell) .board.auto-fit .new-meld span { font-size: max(8px, calc(10px * var(--board-scale))); line-height: 1.15; }
.shell:not(.lobby-shell) .board.auto-fit.board-overview { --board-header-height: 10px; }
.shell:not(.lobby-shell) .board.auto-fit.board-overview .meld-header { font-size: 8px; }
.shell:not(.lobby-shell) .board.auto-fit.board-overview .meld-header small { display: none; }
.table-canvas { position: relative; min-width: 100%; min-height: 100%; }
.meld-header[data-group] { cursor: grab; touch-action: none; user-select: none; }
.meld-header[data-group]:active { cursor: grabbing; }
.group-grip { opacity: .65; font-size: .95em; }
.meld.group-dragging { opacity: .28; }
.meld.merge-active { border-radius: 5px; outline: 2px solid #f5dc93; outline-offset: 4px; }
.meld.merge-active::after { content: '松开拼接'; position: absolute; left: 50%; top: -22px; transform: translateX(-50%); padding: 3px 7px; border-radius: 4px; background: #f5dc93; color: #29483b; font-size: 10px; white-space: nowrap; pointer-events: none; }
.group-drop-preview { position: absolute; border: 1px dashed #e2dab2; border-radius: 5px; background: #f5dc9310; pointer-events: none; }
.shell:not(.lobby-shell) .board.auto-fit.group-drag-ghost { position: fixed; z-index: 110; min-height: 0; height: 0; padding: 0; overflow: visible; pointer-events: none; background: transparent; box-shadow: none; border: 0; opacity: .9; }
.group-drag-ghost .meld { filter: drop-shadow(0 7px 8px #153f3440); }
.split-group { position: absolute; top: 0; right: 0; width: max(10px,calc(16px * var(--board-scale))); height: var(--board-header-height); min-height: 0; padding: 0; border: 0; border-radius: 3px; background: #ffffff0b; color: #d5dec2; font-size: max(8px,calc(11px * var(--board-scale))); line-height: 1; }
.split-group:not(:disabled):hover,.split-group[aria-pressed=true] { background: #f5dc93; color: #29483b; }
.split-group:disabled { visibility: hidden; }
.shell:not(.lobby-shell) .board.auto-fit .meld-header small { margin-right: calc(17px * var(--board-scale)); }
.meld-tiles { position: relative; }
.split-gap { position: absolute; top: 50%; width: 22px; height: 34px; transform: translate(-50%,-50%); padding: 0; z-index: 5; border: 1px solid #d9b263; border-radius: 5px; background: #f5dc93; color: #315b50; font-size: 13px; }
.split-gap:hover { background: #fff4cd; }
.splitting .tile { opacity: .7; }
.splitting .meld-tiles { outline: 1px dashed #d9b263; outline-offset: 4px; }
@media (max-width: 600px) {
  .shell:not(.lobby-shell) .board.auto-fit { max-height: 285px; }
  .table-view-actions { gap: 6px; }
}
@media (min-width: 640px) and (max-width: 1000px) and (max-height: 600px) and (orientation: landscape) {
  .shell:not(.lobby-shell) .board.auto-fit {
    flex: 1;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 7px 3px 6px;
  }
}

/* Keep the table central while the single hand row and actions remain available. */
@media (min-width: 640px) and (max-width: 1000px) and (max-height: 600px) and (orientation: landscape) {
  .shell:not(.lobby-shell) { position: relative; min-height: 280px; }
  body.in-game .room-topbar { display: none; }
  .shell:not(.lobby-shell) .game-heading { display: none; }
  .shell:not(.lobby-shell) .room-players { margin-top: 3px; }
  .shell:not(.lobby-shell) .game-table { margin-top: 3px; }
  .shell:not(.lobby-shell) .rack-section { position: relative; padding-top: 4px; }
  .shell:not(.lobby-shell) .rack-heading { min-height: 18px; padding-bottom: 0; }
  .shell:not(.lobby-shell) .sort-controls { padding: 0; border: 0; }
  .shell:not(.lobby-shell) .sort-button { padding: 2px 7px; line-height: 12px; }
  .shell:not(.lobby-shell) .rack { height: 58px; min-height: 58px; padding: 3px 8px; }
  .shell:not(.lobby-shell) .rack .tile { height: 52px; width: 38px; flex-basis: 38px; font-size: 27px; }
  .shell:not(.lobby-shell) .rack-bottom { position: absolute; top: 5px; left: 100px; right: 130px; padding: 0; }
  .shell:not(.lobby-shell) .turn-bar { min-height: 38px; padding-top: 4px; }
  .shell:not(.lobby-shell) .turn-actions .primary-button,
  .shell:not(.lobby-shell) .turn-actions .secondary-button { min-height: 34px; padding: 6px 10px; }
}
/* The account panel belongs to the lobby; credentials stay in a host-only cookie. */
.account-panel {display:flex;align-items:center;justify-content:space-between;gap:24px;padding:24px 28px;margin:0 0 24px;border:1px solid #dddacc;border-radius:14px;background:#fffdf6;}
.account-panel h2 {font-size:22px;font-weight:500;margin:6px 0 10px;}
.account-panel p:not(.eyebrow) {font-size:14px;line-height:1.7;color:#616b62;margin:0;}
.account-actions {display:flex;align-items:center;gap:12px;flex-shrink:0;}
.account-actions a, #room-account-recover {text-decoration:none;display:inline-flex;align-items:center;}
@media(max-width:600px) {.account-panel {align-items:flex-start;flex-direction:column;padding:22px;gap:18px;}.account-panel h2 {font-size:20px;}.account-actions {flex-wrap:wrap;}}
