* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Hiragino Sans", sans-serif; background: #12352a; color: #f2efe6; }
.hidden { display: none !important; }
.err { color: #ff9d8a; min-height: 1.2em; }

.lobby { max-width: 360px; margin: 10vh auto; padding: 24px; background: #1d4a3b; border-radius: 14px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 8px 30px #0008; }
.lobby h1 { margin: 0 0 8px; font-size: 26px; }
.lobby h1 small { font-size: 14px; opacity: .7; }
.lobby label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.lobby input { font-size: 16px; padding: 8px 10px; border-radius: 8px; border: none; }
button { font-size: 15px; padding: 8px 14px; border-radius: 8px; border: none; background: #e9b949; color: #2b1d00; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button.alt { background: #cfd8d3; }
button.hu { background: #e5533d; color: #fff; }
.hint { font-size: 12px; opacity: .7; margin: 0; }

.table { position: relative; width: 100vw; height: 100vh; overflow: hidden;
  background: radial-gradient(ellipse at center, #2c7a5c 0%, #1a5240 60%, #12352a 100%); }
.topbar { position: absolute; top: 6px; left: 10px; display: flex; gap: 16px; font-size: 13px; opacity: .9; z-index: 2; }

.seat { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.seat-bottom { bottom: 64px; left: 50%; transform: translateX(-50%); }
.seat-top { top: 28px; left: 50%; transform: translateX(-50%); }
.seat-left { left: 10px; top: 50%; transform: translateY(-50%); }
.seat-right { right: 10px; top: 50%; transform: translateY(-50%); }
.nameplate { font-size: 13px; background: #0006; padding: 2px 10px; border-radius: 10px; white-space: nowrap; }
.nameplate.turn { background: #e9b949; color: #2b1d00; }
.row { display: flex; gap: 2px; align-items: flex-end; flex-wrap: wrap; justify-content: center; }
.melds { gap: 8px; }
.meld { display: flex; gap: 1px; }

.tile { width: 34px; height: 46px; border-radius: 5px; background: linear-gradient(#fffdf6, #ece4cf); color: #222;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  box-shadow: 0 3px 0 #b9ad8c, 0 4px 6px #0005; font-weight: 700; user-select: none; position: relative; }
.tile .r { font-size: 17px; }
.tile .s { font-size: 11px; margin-top: 3px; }
.tile.m .s { color: #c0392b; } .tile.s .s { color: #1e8449; } .tile.p .s { color: #1f5fa8; }
.tile.honor { font-size: 22px; } .tile.hz { color: #d32f2f; } .tile.fa { color: #1e8449; }
.tile.bai { color: #1f5fa8; } .tile.bai::before { content: ''; position: absolute; inset: 7px 6px; border: 2px solid #1f5fa8; border-radius: 3px; }
.center .bonus { color: #ffd36b; font-weight: 700; }
.tile.laizi { outline: 2px solid #e9b949; }
.tile.laizi::after { content: '赖'; position: absolute; top: -6px; right: -6px; font-size: 9px; background: #e9b949; color: #2b1d00; border-radius: 6px; padding: 1px 3px; }
.tile.small { width: 24px; height: 32px; } .tile.small .r { font-size: 12px; } .tile.small .s { font-size: 8px; margin-top: 1px; }
.tile.small.honor { font-size: 15px; } .tile.small.bai::before { inset: 4px 4px; border-width: 1px; }
.tile.back { background: linear-gradient(#3e8f6f, #2a6b52); box-shadow: 0 3px 0 #1c4a38; }
.tile.mine { cursor: pointer; transition: transform .08s; }
.tile.mine:hover { transform: translateY(-6px); }
.tile.drawn { margin-left: 10px; }
.tile.mine.selected { transform: translateY(-14px); box-shadow: 0 3px 0 #b9ad8c, 0 8px 14px #000a; }
.tile.mine.ting::before { content: ''; position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%); width: 6px; height: 6px; border-radius: 50%; background: #6fe08a; }
.ting { position: absolute; bottom: 140px; left: 50%; transform: translateX(-50%); background: #0008; padding: 4px 12px; border-radius: 10px; font-size: 13px; z-index: 3; white-space: nowrap; }
.timer { position: absolute; left: 50%; top: 47%; transform: translate(-50%, 46px); font-size: 20px; font-weight: 700; background: #0006; border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; z-index: 2; }
.timer.mine { background: #e9b949; color: #2b1d00; }
.timer.urgent { background: #e5533d; color: #fff; }
.tile.last { outline: 2px solid #ff6b4a; }
.seat-left .row.hand, .seat-right .row.hand { max-width: 180px; }

.center { position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); width: min(56vw, 560px); height: min(42vh, 330px);
  display: grid; grid-template-areas: ". d2 ." "d3 info d1" ". d0 ."; grid-template-columns: 1fr 1.2fr 1fr; grid-template-rows: 1fr 1fr 1fr; gap: 4px; }
.center .info { grid-area: info; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; background: #0003; border-radius: 10px; gap: 4px; }
.center .d0 { grid-area: d0; } .center .d1 { grid-area: d1; } .center .d2 { grid-area: d2; } .center .d3 { grid-area: d3; }
.center .disc { display: flex; flex-wrap: wrap; gap: 1px; align-content: flex-start; justify-content: center; overflow: hidden; }

.actions { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; z-index: 3; }
.log { position: absolute; right: 10px; bottom: 10px; width: 220px; max-height: 140px; overflow-y: auto; font-size: 11px; background: #0004; padding: 6px 8px; border-radius: 8px; opacity: .85; }
.overlay { position: absolute; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 10; }
.panel { background: #1d4a3b; border-radius: 14px; padding: 20px 24px; min-width: 320px; max-width: 92vw; box-shadow: 0 10px 40px #000a; }
.panel h2 { margin-top: 0; }
.panel table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.panel td { padding: 4px 8px; border-bottom: 1px solid #fff2; }
.plus { color: #8fe3a1; } .minus { color: #ff9d8a; }
.toast { position: absolute; top: 40px; left: 50%; transform: translateX(-50%); background: #c0392b; padding: 8px 14px; border-radius: 8px; z-index: 20; }

@media (max-width: 760px) {
  .tile { width: 24px; height: 34px; } .tile .r { font-size: 12px; } .tile .s { font-size: 8px; }
  .tile.small { width: 16px; height: 22px; } .tile.small .r { font-size: 9px; } .tile.small .s { display: none; }
  .seat-left .row.hand, .seat-right .row.hand { max-width: 80px; }
  .log { display: none; }
}

.actions .blocked { align-self: center; font-size: 12px; background: #0008; color: #ffd36b; padding: 4px 10px; border-radius: 8px; }

/* 碰・杠・胡の大字提示 */
.callout { position: absolute; z-index: 15; font-size: 56px; font-weight: 900; color: #ffe08a; pointer-events: none;
  text-shadow: 0 0 6px #000, 0 4px 0 #8a5a00, 0 0 24px #ffb300; animation: pop 1.4s ease-out forwards; white-space: nowrap; }
.callout.k-hu { font-size: 84px; color: #ff6b4a; text-shadow: 0 0 6px #000, 0 4px 0 #7a1600, 0 0 30px #ff3d00; }
.callout.k-draw { color: #cfd8d3; text-shadow: 0 0 6px #000; }
.callout.pos0 { left: 50%; bottom: 170px; } .callout.pos2 { left: 50%; top: 110px; }
.callout.pos1 { right: 220px; top: 45%; } .callout.pos3 { left: 220px; top: 45%; } .callout.pos-center { left: 50%; top: 40%; }
.callout.pos0, .callout.pos2, .callout.pos-center { translate: -50% 0; }
@keyframes pop { 0% { opacity: 0; scale: .4; } 15% { opacity: 1; scale: 1.15; } 30% { scale: 1; } 80% { opacity: 1; } 100% { opacity: 0; scale: 1.05; } }

.mute { background: #0005; color: #fff; padding: 2px 8px; font-size: 13px; }
.settings { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 14px; margin: 10px 0; }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.settings input, .settings select { width: 80px; font-size: 14px; padding: 4px 6px; border-radius: 6px; border: none; }
.settings input:disabled, .settings select:disabled { opacity: .7; }
.btnrow { display: flex; gap: 10px; margin-top: 12px; }
.panel { max-height: 92vh; overflow-y: auto; }
.panel th { text-align: left; font-size: 12px; opacity: .7; padding: 4px 8px; }

/* 手机: 竖屏时提示横屏，横屏时缩小 */
.rotate { display: none; }
@media (orientation: portrait) and (max-width: 760px) {
  .rotate { display: flex; position: fixed; inset: 0; z-index: 100; background: #12352a; align-items: center; justify-content: center; text-align: center; font-size: 20px; line-height: 2; }
}
@media (max-height: 500px) {
  .tile { width: 26px; height: 36px; } .tile .r { font-size: 13px; } .tile .s { font-size: 8px; margin-top: 1px; }
  .tile.honor { font-size: 16px; }
  .tile.small { width: 17px; height: 23px; } .tile.small .r { font-size: 9px; } .tile.small .s { display: none; } .tile.small.honor { font-size: 11px; }
  .seat-bottom { bottom: 44px; } .seat-top { top: 22px; }
  .seat-left .row.hand, .seat-right .row.hand { max-width: 110px; }
  .center { width: 50vw; height: 46vh; top: 46%; }
  .actions { bottom: 4px; } button { padding: 5px 10px; font-size: 13px; }
  .ting { bottom: 96px; } .log { display: none; }
  .nameplate { font-size: 11px; padding: 1px 6px; }
  .callout { font-size: 40px; } .callout.k-hu { font-size: 56px; }
  .callout.pos0 { bottom: 110px; } .callout.pos1 { right: 120px; } .callout.pos3 { left: 120px; }
  .timer { width: 30px; height: 30px; font-size: 15px; transform: translate(-50%, 34px); }
}

.toast.ok { background: #2e8b57; }
.callout { z-index: 9; } .callout.k-hu { z-index: 20; }
