/* ---- Tiles ---- */
.tile { position: relative; overflow: hidden; width: var(--tile-w); height: var(--tile-h); background: linear-gradient(170deg, #fffbe9, var(--ivory) 60%, #e6dfc3); border-radius: 7px; border: 1px solid #c9bf9c; box-shadow: 0 3px 0 #b8ae8a, 0 6px 12px rgba(0,0,0,.35); display: grid; place-items: center; color: #1a1a1a; font-weight: 800; user-select: none; cursor: pointer; transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s; flex-shrink: 0; }
.tile .t-main { font-size: calc(var(--tile-h) * .42); line-height: 1; font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans', var(--font-body); }
.tile .t-num { position: absolute; top: 3px; left: 5px; font-size: calc(var(--tile-h) * .22); line-height: 1; color: #333; }
.tile .t-hint { position: absolute; bottom: 3px; right: 5px; font-size: calc(var(--tile-h) * .17); color: #666; font-weight: 700; }
.tile[data-key^="m"] .t-main { color: #b3261e; }
.tile[data-key^="p"] .t-main { color: #1e4fb3; font-size: calc(var(--tile-h) * .26); letter-spacing: -2px; max-width: 100%; }
.tile[data-key^="s"] .t-main { color: #1f7a3a; font-size: calc(var(--tile-h) * .36); }
.tile[data-key^="w"] .t-main { color: #1a1a1a; }
.tile[data-key="dR"] .t-main { color: #b3261e; } .tile[data-key="dG"] .t-main { color: #1f7a3a; }
.tile[data-key="dW"] .t-main { color: #1e4fb3; font-size: calc(var(--tile-h) * .3); border: 2px solid #1e4fb3; border-radius: 4px; padding: 3px 5px; }
.tile.selectable:hover { transform: translateY(-8px); box-shadow: 0 3px 0 #b8ae8a, 0 14px 22px rgba(0,0,0,.45); }
.tile.selected { transform: translateY(-16px); box-shadow: 0 3px 0 #b8ae8a, 0 0 0 3px var(--gold), 0 14px 26px rgba(0,0,0,.5); }
.tile.drawn { margin-left: .8rem; }
.tile.just-drawn { animation: dealIn .35s ease both; }
.tile.highlight { box-shadow: 0 3px 0 #b8ae8a, 0 0 0 3px var(--gold), 0 0 24px rgba(212,175,55,.6); animation: glow 1.4s ease-in-out infinite; }
.tile.back { background: linear-gradient(160deg, #1b6b52, #0E4D3B); border-color: #0a3529; box-shadow: 0 3px 0 #062419, 0 4px 8px rgba(0,0,0,.4); cursor: default; }
.tile.back::after { content: ''; position: absolute; inset: 4px; border: 1px solid rgba(212,175,55,.35); border-radius: 4px; }
.tile-lg { --tile-w: 62px; --tile-h: 86px; }
.tile-sm { --tile-w: 28px; --tile-h: 40px; border-radius: 4px; }
.tile-xs { --tile-w: 22px; --tile-h: 31px; border-radius: 3px; }
.tile.static { cursor: default; }
.tile.static:hover { transform: none; }
@keyframes dealIn { from { opacity: 0; transform: translateY(-20px) rotate(-6deg); } to { opacity: 1; transform: none; } }
@keyframes flyIn { from { opacity: 0; transform: scale(1.5); } to { opacity: 1; transform: none; } }

/* ---- Game page ---- */
.game-page { overflow: hidden; height: 100vh; height: 100dvh; }
.game-page .page { max-width: none; padding: 0; height: 100%; }
.game { display: flex; flex-direction: column; height: 100%; }
.game-top { display: flex; align-items: center; gap: 1rem; padding: .45rem 1rem; background: rgba(7,28,21,.85); border-bottom: 1px solid rgba(212,175,55,.18); flex-shrink: 0; }
.game-info { display: flex; gap: 1.25rem; font-size: .82rem; color: var(--muted); font-weight: 600; }
.game-info span b { color: var(--gold-2); }
.game-top-right { margin-left: auto; display: flex; gap: .4rem; align-items: center; }
.conn { font-size: .75rem; padding: .25rem .6rem; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--muted); }
.conn.ok { color: #7be0b5; } .conn.bad { color: #ffb3b3; background: rgba(224,90,90,.18); animation: pulse 1.2s ease-in-out infinite; }
.game-layout { flex: 1; display: grid; grid-template-columns: 1fr 300px; gap: .75rem; padding: .75rem; min-height: 0; }
.game-chat { min-height: 0; }
.table { position: relative; display: grid; grid-template-columns: 150px 1fr 150px; grid-template-rows: 110px 1fr 90px; grid-template-areas: "tl top tr" "left center right" "bl bottom br"; background: radial-gradient(ellipse at center, #156450 0%, #0E4D3B 50%, #0a3529 100%); border-radius: 26px; border: 8px solid #3b2a12; box-shadow: inset 0 0 80px rgba(0,0,0,.5), var(--shadow); padding: .6rem; min-height: 0; overflow: hidden; }
.opp { display: flex; align-items: center; gap: .6rem; }
.opp-top { grid-area: top; justify-content: center; flex-direction: row; }
.opp-left { grid-area: left; flex-direction: column; justify-content: center; }
.opp-right { grid-area: right; flex-direction: column; justify-content: center; }
.seat-card { display: flex; align-items: center; gap: .5rem; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.1); border-radius: 12px; padding: .4rem .7rem; transition: border-color .25s, box-shadow .25s; min-width: 0; }
.seat-card .name { font-weight: 700; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.seat-card .sub { font-size: .7rem; color: var(--muted); }
.seat-card.active { border-color: var(--gold); box-shadow: 0 0 22px rgba(212,175,55,.45); }
.seat-card.disconnected { opacity: .55; border-style: dashed; }
.seat-card .wind { font-family: var(--font-display); color: var(--gold); font-size: .8rem; }
.seat-card .score { font-weight: 800; color: var(--gold-2); font-size: .85rem; }
.hidden-hand { display: flex; gap: 2px; }
.opp-left .hidden-hand, .opp-right .hidden-hand { flex-direction: column; }
.opp-left .hidden-hand .tile, .opp-right .hidden-hand .tile { --tile-w: 30px; --tile-h: 14px; }
.opp-top .hidden-hand .tile { --tile-w: 20px; --tile-h: 30px; }
.opp-melds { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: center; }
.opp-left .opp-melds, .opp-right .opp-melds { flex-direction: column; }
.meld { display: flex; gap: 1px; padding: 2px; background: rgba(0,0,0,.25); border-radius: 5px; }

.center { grid-area: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; text-align: center; }
.turn-banner { font-family: var(--font-display); font-size: 1.35rem; color: var(--gold-2); letter-spacing: .08em; text-shadow: 0 2px 12px rgba(0,0,0,.5); transition: transform .3s; }
.turn-banner.mine { color: #fff; animation: pulse 1.6s ease-in-out infinite; font-size: 1.7rem; text-shadow: 0 0 24px rgba(212,175,55,.8); }
.timer { width: 200px; height: 5px; background: rgba(0,0,0,.35); border-radius: 999px; overflow: hidden; }
.timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width .5s linear; }
.timer-bar.urgent { background: var(--danger); }
.last-discard { min-height: 70px; display: flex; align-items: center; gap: .5rem; }
.last-discard .tile { animation: flyIn .3s ease both; }
.last-discard .from { font-size: .72rem; color: var(--muted); }

.discards { display: flex; flex-wrap: wrap; gap: 2px; align-content: flex-start; overflow: hidden; }
.discards .tile { --tile-w: 26px; --tile-h: 36px; border-radius: 3px; cursor: default; }
.discards .tile:hover { transform: none; }
.discards-top { grid-area: top; align-self: end; justify-content: center; margin-top: 78px; max-height: 40px; }
.discards-bottom { grid-area: bottom; justify-content: center; align-self: start; max-height: 80px; }
.discards-left { grid-area: left; align-self: start; justify-content: flex-start; margin-top: 4px; max-width: 150px; }
.discards-right { grid-area: right; align-self: start; justify-content: flex-end; margin-top: 4px; max-width: 150px; }
.opp-left, .opp-right { align-self: center; }
.me-info { grid-area: bottom; align-self: end; justify-self: start; display: flex; gap: .6rem; align-items: center; font-size: .8rem; color: var(--muted); }
.me-info .score { color: var(--gold-2); font-weight: 800; }
.waits { display: flex; gap: 2px; align-items: center; }

/* Hand area */
.hand-area { flex-shrink: 0; background: rgba(7,28,21,.92); border-top: 1px solid rgba(212,175,55,.18); padding: .5rem .75rem .6rem; display: flex; flex-direction: column; gap: .5rem; }
.melds-row { display: flex; gap: .5rem; min-height: 0; }
.hand { display: flex; gap: 4px; justify-content: center; align-items: flex-end; padding-top: 18px; min-height: calc(var(--tile-h) + 18px); flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; min-height: 44px; }
.actions .btn { min-width: 110px; }
.actions .btn-claim { background: linear-gradient(135deg, #2f9e79, #146B52); animation: glow 1.5s ease-in-out infinite; }
.actions .btn-win { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #1a1500; animation: glow 1s ease-in-out infinite; }
.chow-options { display: flex; gap: .5rem; justify-content: center; }
.chow-option { display: flex; gap: 2px; padding: 4px; border: 2px solid transparent; border-radius: 8px; cursor: pointer; background: rgba(255,255,255,.06); transition: border-color .15s; }
.chow-option:hover { border-color: var(--gold); }

/* Result modal */
.result-card { text-align: center; }
.result-title { font-size: 2rem; color: var(--gold); }
.result-sub { color: var(--muted); }
.result-hand { display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; margin: .75rem 0; }
.result-patterns { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }
.result-patterns li { background: rgba(212,175,55,.15); border: 1px solid rgba(212,175,55,.4); border-radius: 999px; padding: .2rem .7rem; font-size: .8rem; }
.result-scores { width: 100%; font-size: .92rem; }
.result-scores td { padding: .35rem .5rem; border-bottom: 1px solid rgba(255,255,255,.06); }
.result-scores td:last-child { text-align: right; font-weight: 800; color: var(--gold-2); }
.result-scores tr.winner td { color: var(--gold-2); }
.result-actions { display: flex; gap: .5rem; justify-content: center; margin-top: .75rem; flex-wrap: wrap; }
.rules-card { font-size: .9rem; color: var(--muted); }
.rules-card li { margin-bottom: .35rem; }
.log-list { max-height: 260px; overflow: auto; font-size: .8rem; font-family: ui-monospace, monospace; background: rgba(0,0,0,.3); padding: .5rem; border-radius: 8px; }
