Compare commits

...

2 Commits

Author SHA1 Message Date
EJClaw
ca8baf5cc8 모든 게임이 남는 화면 전체를 쓰도록: 게임별 폭 상한 제거, 판·카드·말을 --play-w/--play-h에 맞춰 키움
- 카드 게임: 펠트가 남는 높이를 채우고 손패·가운데 더미·자리 크기가 화면에 따라 커짐
- 판 게임: 체스·바둑·오목 등은 높이를 다 쓰고, 장기·쿼리도·젬블로는 넓은 화면에서 조작판을 판 옆으로
- 섯다: 자리를 판 크기에 맞춘 타원 위에 고르게 두고, 많을 때 자리 크기를 줄여 8명에서도 겹치지 않게
- 바퀴벌레 포커 6명·야단법석 달리기 5명 선수 뽑기가 PC에서 넘치지 않게
- 휴대폰·태블릿(1100px 아래) 배치는 그대로
- layout-survey: 컴퓨터 넣기 버튼 기다림, 넘친 높이(px) 표시

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 16:17:15 +09:00
EJClaw
adc3b5337a 게임 화면 공통 틀: 1600px 상한 없애고 창 폭 전체 사용, 판 크기 변수(--play-w/--play-h), 화면 채움 측정 스크립트
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 15:01:46 +09:00
44 changed files with 1197 additions and 406 deletions

View File

@@ -137,6 +137,12 @@ const CSS = `
@keyframes ap-count { 0% { transform: scale(1.8); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { transform: scale(.85); opacity: .85; } }
@keyframes ap-pop { 0% { transform: scale(1); opacity: 1; } 40% { transform: scale(1.25); opacity: .9; } 100% { transform: scale(.2) translateY(-30px); opacity: 0; } }
@keyframes ap-flash { 0% { opacity: 0; transform: translateX(-50%) scale(.8); } 15% { opacity: 1; transform: translateX(-50%) scale(1.05); } 70% { opacity: 1; } 100% { opacity: 0; } }
/* PC: the 17x10 board is the largest that fits the play column after the score rows, buttons and key help (~150px). */
@media (min-width: 1100px) {
.ap-wrap { width: min(100%, calc((var(--play-h) - 150px) * 1.7)); }
.ap-pill { font-size: clamp(1rem, calc(var(--play-h) * .017), 1.2rem); }
.ap-others li { font-size: clamp(.85rem, calc(var(--play-h) * .014), 1rem); }
}
@media (prefers-reduced-motion: reduce) { .ap-hint { animation: none; } .ap-pop { animation-duration: .01s; } .ap-flash, .ap-in, .ap-burst, .ap-over.count b { animation: none; } .ap-burst { display: none; } }
`;

View File

@@ -66,6 +66,8 @@ type MarkMode = 'dead' | 'seki';
const BADUK_CSS = `
.bd-own { transform-box: fill-box; transform-origin: center; animation: bd-own .32s cubic-bezier(.3, 1.5, .5, 1) both; animation-delay: var(--d, 0ms); }
@keyframes bd-own { from { opacity: 0; transform: scale(.2); } }
/* PC: the board takes the whole play-area height minus the rows that can show under it (--bd-rows). */
@media (min-width: 1100px) { .board-wrap.bd-fit { max-width: min(100%, calc(var(--play-h) - var(--bd-rows, 0px))); } }
`;
/**
@@ -262,7 +264,11 @@ function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>
const lastColor: Color | null = v.lastMove ? (at(v.lastMove) === 1 ? 'black' : 'white') : null;
const pad = 0.95;
return (
<div className="board-wrap stack" style={{ gap: 10 }}>
<div
className="board-wrap stack bd-fit"
// Room under the board: the illegal-move note, the dead-stone marking card while scoring, touch tap-confirm buttons.
style={{ gap: 10, '--bd-rows': `calc(1.5rem + 30px${marking ? ' + 2.7rem + 90px' : ''}${tapConfirm ? ' + var(--btn-h) + 10px' : ''})` } as React.CSSProperties}
>
<style>{BOARD_MOTION_CSS + BADUK_CSS}</style>
<svg
ref={svgRef}

View File

@@ -78,7 +78,7 @@ const faceAria = (f: CardFace) => `${CARD_INFO[f.kind].name}, ${SUIT_KO[f.suit]}
// ---------------------------------------------------------------- styles
const CSS = `
.bg { width: 100%; max-width: 1180px; display: flex; flex-direction: column; gap: 12px; align-self: center; }
.bg { width: 100%; display: flex; flex-direction: column; gap: 12px; align-self: stretch; }
.bg-table { position: relative; width: 100%; aspect-ratio: 16 / 8.2; min-height: 460px; border-radius: 200px; border: 10px solid var(--wood);
background: radial-gradient(ellipse at center, rgba(255,255,255,.13), rgba(255,255,255,0) 62%), var(--felt); box-shadow: var(--shadow); }
.bg-seat { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); width: var(--sw, 178px); z-index: 1;
@@ -160,6 +160,16 @@ button.bg-card:focus-visible { outline: 3px solid var(--focus); outline-offset:
.bg-log { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 3px; max-height: 300px; overflow: auto; }
.bg-rules td, .bg-rules th { padding: 4px 6px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.bg-last { font-size: .86rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
/* PC: fill the play column; the table takes the height my area leaves, hand cards grow a little with the screen. */
@media (min-width: 1100px) {
.bg { flex: 1 1 auto; min-height: 0; }
.bg-table { flex: 1 1 auto; aspect-ratio: auto; min-height: 400px; }
.bg-me .bg-card:not(.sm) { --cw: clamp(96px, calc(var(--play-h) * .11), 124px); }
}
/* Very large screens: seats and the centre piles grow with the bigger table (scaled around their own centre). */
@media (min-width: 2200px) and (min-height: 1200px) {
.bg-seat, .bg-center { transform: translate(-50%, -50%) scale(1.3); }
}
@media (max-width: 719px) {
.bg-table { aspect-ratio: auto; min-height: 0; border-radius: 18px; border-width: 6px; padding: 8px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.bg-seat { position: static; transform: none; width: auto; padding: 4px 5px; font-size: .76rem; gap: 2px; border-width: 2px; }

View File

@@ -26,7 +26,7 @@ const HAND_KO: Record<HandView['status'], string> = { playing: '', stand: '', bu
const OUTCOME_KO: Record<NonNullable<HandView['outcome']>, string> = { win: '승', lose: '패', push: '푸시', blackjack: '블랙잭', bonus: '보너스' };
const CSS = `
.bj-wrap { width: 100%; max-width: 1180px; display: flex; flex-direction: column; gap: 12px; align-self: center; }
.bj-wrap { width: 100%; display: flex; flex-direction: column; gap: 12px; align-self: stretch; }
.bj-table { position: relative; width: 100%; aspect-ratio: 16 / 8.4; min-height: 460px; border: 12px solid var(--wood); border-radius: 48px 48px 50% 50% / 48px 48px 34% 34%;
background:
radial-gradient(ellipse at 50% 20%, rgba(255,255,255,.14) 0%, rgba(255,255,255,0) 55%),
@@ -40,7 +40,7 @@ const CSS = `
.bj-print::after { content: ''; display: block; width: 420px; height: 120px; margin: -64px auto 0; border: 2px solid rgba(255,255,255,.12); border-top: 0; border-radius: 0 0 50% 50% / 0 0 100% 100%; }
.bj-dealer { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 2; }
.bj-dealer .who { display: flex; gap: 8px; align-items: center; font-weight: 900; font-size: .9rem; }
.bj-shoe { position: absolute; right: 7%; top: 20px; width: 70px; height: 92px; z-index: 1; }
.bj-shoe { position: absolute; right: 7%; top: 20px; width: 70px; height: 92px; z-index: 1; transform: scale(var(--bjs, 1)); transform-origin: top right; }
.bj-shoe i { position: absolute; inset: 0; border-radius: 8px; background: linear-gradient(160deg, #3b82f6, #1e3a8a); border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,.35); }
.bj-shoe i:nth-child(2) { transform: translate(-4px, 4px); } .bj-shoe i:nth-child(3) { transform: translate(-8px, 8px); }
.bj-shoe::after { content: ''; position: absolute; left: -16px; right: -6px; bottom: -12px; height: 34px; border-radius: 8px; background: linear-gradient(180deg, #4b5563, #1f2937); box-shadow: 0 3px 6px rgba(0,0,0,.4); }
@@ -117,6 +117,12 @@ const CSS = `
.bj-act:active { transform: translateY(1px); }
:root[data-theme='dark'] .bj-act { color: color-mix(in srgb, var(--c) 55%, #fff); }
.bj-help { margin: 0; text-align: center; min-height: 1.4em; }
/* PC: the table takes all the height the dock leaves (cards grow with it, see BlackjackBoard). */
@media (min-width: 1100px) {
.bj-wrap { flex: 1 1 auto; min-height: 0; justify-content: center; }
.bj-table { flex: 1 1 0; aspect-ratio: auto; max-height: calc(var(--play-w) * .62); }
.bj-print b { font-size: calc(1.5rem * var(--bjs, 1)); }
}
@media (max-width: 719px) {
.bj-table { aspect-ratio: auto; min-height: 0; border-width: 7px; border-radius: 24px; padding: 12px 8px; display: flex; flex-direction: column; gap: 14px; }
.bj-print, .bj-shoe { display: none; }
@@ -643,12 +649,14 @@ export function BlackjackBoard({ view: v, me, players, act, pending, deadline }:
const dealerCards = d.cards.map((c) => c ?? holeKey(v)).filter((k) => q.shown(k));
const dealerReal = d.cards.filter((c): c is string => !!c && q.shown(c));
const slots = seatLayout(v, me);
const otherW = phone ? 40 : 56;
const myW = phone ? 56 : 76;
const dealerW = phone ? 56 : 66;
// Table width for fitting cards into each seat's share (phone: my seat a full row, others two per row).
const tableRef = useRef<HTMLDivElement | null>(null);
const [[tableW, tableH], setTableSize] = useState([990, 520]);
// Cards grow with the table on PC (1 at the old 990×520 table, up to 1.7×).
const scale = phone ? 1 : Math.min(1.7, Math.max(1, Math.min(tableW / 990, tableH / 520)));
const otherW = phone ? 40 : Math.round(56 * scale);
const myW = phone ? 56 : Math.round(76 * scale);
const dealerW = phone ? 56 : Math.round(66 * scale);
useLayoutEffect(() => {
const el = tableRef.current;
if (!el) return undefined;
@@ -715,7 +723,7 @@ export function BlackjackBoard({ view: v, me, players, act, pending, deadline }:
return (
<div className="bj-wrap">
<style>{CSS}</style>
<div className="bj-table" ref={tableRef} role="region" aria-label="블랙잭 테이블">
<div className="bj-table" ref={tableRef} role="region" aria-label="블랙잭 테이블" style={{ ['--bjs' as string]: scale.toFixed(2) }}>
<div className="bj-print" aria-hidden>
<b>BLACKJACK</b>
<span>

View File

@@ -69,6 +69,20 @@ const CSS = `
.cf-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.cf-table td, .cf-table th { border-bottom: 1px solid var(--border); padding: 6px 4px; text-align: left; vertical-align: top; }
.cf-memo { width: 100%; min-height: 220px; font: inherit; font-size: max(16px, 1rem); line-height: 1.6; padding: 10px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.cf-main { display: flex; flex-direction: column; gap: 12px; }
/* PC: use the whole play column. Reading (briefing / last clue) sits in a left column of readable width, choices on the right. */
@media (min-width: 1100px) {
.cf { max-width: none; }
.cf-main { flex-direction: row; align-items: flex-start; }
.cf-main > * { flex: 1 1 0; min-width: 0; }
.cf-main > .cf-read { flex-grow: 1.15; }
.cf-brief { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-content: start; align-items: start; }
.cf-brief > .cf-bar { grid-column: 1 / -1; }
.cf-brief > .cf-paper { grid-row: 2 / span 3; }
.cf-brief > :not(.cf-bar):not(.cf-paper) { grid-column: 2; }
.cf-memo { min-height: max(220px, calc(var(--play-h) - 260px)); }
.cf-doc { font-size: clamp(16px, calc(var(--play-h) * .0185), 20px); }
}
`;
// ---------------------------------------------------------------- device-only notes (§9)
@@ -284,11 +298,16 @@ function LeadsTab({ v, players, act, titles }: { v: CaseFileView; players: Playe
const meSeat = v.seats.find((s) => s.id === v.me);
const here = v.seats.filter((s) => !s.left && s.idle === 0);
return (
<div className="stack" style={{ gap: 12 }}>
{today && inv.hour === 9 && (
<div className="cf-paper"><span className="cf-stamp">📰 {today.day}일째 아침 소식</span><Doc text={today.text} /></div>
<div className="cf-main">
{((today && inv.hour === 9) || last) && (
<div className="stack cf-read" style={{ gap: 12 }}>
{today && inv.hour === 9 && (
<div className="cf-paper"><span className="cf-stamp">📰 {today.day}일째 아침 소식</span><Doc text={today.text} /></div>
)}
{last && <ReadCard e={last} v={v} players={players} chooser={chooser} titles={titles} />}
</div>
)}
{last && <ReadCard e={last} v={v} players={players} chooser={chooser} titles={titles} />}
<div className="stack" style={{ gap: 12 }}>
<section aria-label="지도">
<div className="small" style={{ marginBottom: 4 }}>📍 지금 위치: <strong>{inv.placeName}</strong> ({inv.zoneName})</div>
<div className="cf-zones">
@@ -335,6 +354,7 @@ function LeadsTab({ v, players, act, titles }: { v: CaseFileView; players: Playe
{inv.hints.length > 0 && (
<div className="cf-paper"><span className="cf-stamp">💡 반장님 조언</span><ol className="cf-doc" style={{ margin: 0, paddingLeft: '1.3em' }}>{inv.hints.map((h, i) => <li key={i}>{h}</li>)}</ol></div>
)}
</div>
</div>
);
}
@@ -550,7 +570,7 @@ function Board({ view: v, me, players, act, deadline }: BoardProps<CaseFileView>
if (v.phase === 'briefing') {
const ready = v.seats.filter((s) => s.ready).length;
return (
<div className="cf">
<div className="cf cf-brief">
<style>{CSS}</style>
<CaseBar v={v} players={players} deadline={deadline} />
<article className="cf-paper" aria-label="의뢰">

View File

@@ -1,5 +1,5 @@
/** 버건디의 성 화면 (docs/games/castles-of-burgundy.md §9). Everything is drawn from the view; art is own SVG. */
import { useEffect, useMemo, useState, type ReactNode } from 'react';
import { useEffect, useMemo, useState, type CSSProperties, type ReactNode } from 'react';
import type { CobAction, CobOptions, CobPlayerView, CobView, LogEntry, Pending } from '@bg/games/castles-of-burgundy';
import {
ANIMAL_KO,
@@ -102,6 +102,21 @@ button.cob-shield.on { background: var(--primary); color: #fff; border-color: va
.cob-sticky { display: block; position: sticky; bottom: 0; z-index: 5; background: var(--surface); border-top: 2px solid var(--border); padding: 6px; margin: 0 -4px; border-radius: 12px 12px 0 0; box-shadow: 0 -4px 12px rgba(0,0,0,.12); }
.cob-depots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* PC: fill the whole play column. Depots (2 x 3) and the duchy share it; tile / duchy sizes follow --play-w / --play-h.
--cob-n (tiles per depot) is set on .cob-root. */
@media (min-width: 1100px) {
.cob-root { max-width: none; align-self: stretch; flex: 1 0 auto; --cob-col: calc((var(--play-w) - 10px) / 2);
--cob-hex: clamp(43px, min(calc(((var(--cob-col) - 36px) / 2 - 16px) / var(--cob-n, 4) - 2px), calc((var(--play-h) - 540px) / 4)), 170px); }
.cob-wide { flex: 1 0 auto; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
.cob-wide > .cob-pane > .cob-card { height: 100%; }
.cob-depots { grid-template-columns: repeat(2, minmax(0, 1fr)); flex: 1 1 auto; grid-auto-rows: 1fr; }
.cob-slots { justify-content: center; align-items: center; flex: 1 1 auto; }
.cob-depots .cob-hexbtn svg { width: var(--cob-hex); height: auto; }
.cob-black .cob-hexbtn svg { width: min(calc(var(--cob-hex) * .7), calc((var(--cob-col) - 40px) / 9)); height: auto; }
.cob-wide .cob-duchy { flex: 1 1 0; min-height: 260px; }
.cob-root > .cob-card .cob-duchy { height: max(260px, calc(var(--play-h) - 330px)); }
.cob-bar .cob-diebtn svg { width: clamp(40px, calc(var(--play-h) * .05), 60px); height: auto; }
}
`;
let cssDone = false;
@@ -801,7 +816,7 @@ function CobBoard({ view: v, me, players, act, pending: busy, tapConfirm }: Boar
const depots = <DepotBoard v={v} t={t} onTile={onTile} onShield={onShield} buyMode={sel?.kind === 'buy'} />;
return (
<div className="cob-root">
<div className="cob-root" style={{ '--cob-n': v.depots[0]?.slots.length ?? 4 } as CSSProperties}>
{banner}
{bannerBox}
{!myPv && (

View File

@@ -90,7 +90,7 @@ const cmSound = {
};
const CSS = `
.cm { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 8px; align-self: center; }
.cm { width: 100%; display: flex; flex-direction: column; gap: 8px; align-self: stretch; }
.cm-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: space-between; font-weight: 700; }
.cm-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px; background: var(--surface); box-shadow: var(--shadow); font-size: .92rem; font-variant-numeric: tabular-nums; }
.cm-hint { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 48px; }
@@ -102,8 +102,9 @@ const CSS = `
.cm-bar { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.cm-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; transition: width .25s linear; }
.cm-stage { display: flex; gap: 12px; align-items: flex-start; justify-content: center; }
.cm-paper { position: relative; width: min(100%, calc(100vh - 290px)); min-width: 280px; aspect-ratio: 1 / 1; border-radius: 14px; background: #fff; box-shadow: var(--shadow);
border: 3px solid var(--border); overflow: hidden; flex: 0 0 auto; }
/* Square paper: as tall as the play column allows after the pills, hint and time rows above it (PC). */
.cm-paper { position: relative; width: min(100%, var(--play-h, 100vh) - 150px); min-width: 280px; aspect-ratio: 1 / 1; border-radius: 14px; background: #fff; box-shadow: var(--shadow);
border: 3px solid var(--border); overflow: hidden; flex: 0 1 auto; }
.cm-paper canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: auto; }
.cm-paper[data-draw='true'] canvas { touch-action: none; cursor: crosshair; }
.cm-over { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; text-align: center;
@@ -167,6 +168,12 @@ const CSS = `
.cm-away { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--warning-soft); color: var(--text); border-radius: 12px; padding: 8px 12px; }
@keyframes cm-pop { 0% { transform: translate(-50%, -50%) scale(.5); opacity: 0; } 70% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } }
@keyframes cm-shake { 0%,100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
/* PC: the guess chat in the side panel takes the height left under the scores. */
@media (min-width: 1100px) {
.cm-side { flex: 1 1 auto; min-height: 0; }
.cm-side .cm-chat { flex: 1 1 auto; min-height: 260px; }
.cm-side .cm-chat-list { flex: 1 1 auto; max-height: none; }
}
@media (max-width: 1099px) {
.cm-stage { flex-direction: column; align-items: stretch; }
.cm-paper { width: 100%; min-width: 0; }

View File

@@ -86,6 +86,8 @@ const CHESS_CSS = `
@keyframes ch-fade { from { opacity: 0; } }
:root[data-theme='dark'] .ch-icon-dark { filter: drop-shadow(0 0 .6px #e5e7eb) drop-shadow(0 0 .6px #e5e7eb); }
@media (prefers-color-scheme: dark) { :root[data-theme='auto'] .ch-icon-dark { filter: drop-shadow(0 0 .6px #e5e7eb) drop-shadow(0 0 .6px #e5e7eb); } }
/* PC: the board takes the whole play-area height minus the row(s) that can show under it (--ch-rows). */
@media (min-width: 1100px) { .board-wrap.ch-fit { max-width: min(100%, calc(var(--play-h) - var(--ch-rows, 0px))); } }
`;
function ChessBoard({ view: v, act, pending }: BoardProps<ChessView>) {
@@ -229,7 +231,11 @@ function ChessBoard({ view: v, act, pending }: BoardProps<ChessView>) {
const cursorSq = squareAt(cursor.x, cursor.y, bottom);
return (
<div className="board-wrap stack" style={{ gap: 10 }}>
<div
className="board-wrap stack ch-fit"
// Room for what can show under the board: the castling hint (2 lines in 960) for players, [판 돌리기] for watchers.
style={{ gap: 10, '--ch-rows': v.myColor ? (v.chess960Index === null ? 'calc(1.35rem + 10px)' : 'calc(2.7rem + 10px)') : 'calc(var(--tap) + 10px)' } as React.CSSProperties}
>
<style>{BOARD_MOTION_CSS + CHESS_CSS}</style>
<svg
ref={svgRef}

View File

@@ -193,6 +193,26 @@ button.cl-card.can { box-shadow: 0 0 0 3px var(--primary); }
.cl-note { grid-template-columns: minmax(0, 1fr); }
.cl-card { width: 66px; min-height: 78px; }
}
/* PC: fill the play column. Wide screens put the map on the left and the actions, my cards and notes on the right;
room text, tokens and cards grow with the play area. */
@media (min-width: 1100px) {
.cl-board { max-width: none; align-self: stretch; flex: 1 1 auto; min-height: 0; }
.cl-rname { font-size: clamp(.92rem, calc(var(--play-h) * .017), 1.25rem); }
.cl-tok { width: clamp(24px, calc(var(--play-h) * .03), 34px); height: clamp(24px, calc(var(--play-h) * .03), 34px); font-size: clamp(.72rem, calc(var(--play-h) * .013), .95rem); }
.cl-weap { font-size: clamp(1rem, calc(var(--play-h) * .024), 1.6rem); }
.cl-mid { font-size: clamp(.8rem, calc(var(--play-h) * .014), 1rem); }
.cl-card { width: clamp(74px, calc(var(--play-w) * .055), 100px); min-height: clamp(86px, calc(var(--play-w) * .064), 116px); }
}
@media (min-width: 1700px) {
.cl-board { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr);
grid-template-areas: "map act" "map cards" "map note"; }
.cl-top { display: contents; }
.cl-map { grid-area: map; grid-template-rows: repeat(4, minmax(84px, 1fr)); }
.cl-top > .cl-panel { grid-area: act; }
.cl-board > section.cl-sec { grid-area: cards; }
.cl-board > details.cl-sec { grid-area: note; }
.cl-note li { min-height: clamp(34px, calc((var(--play-h) - 400px) / 11), 48px); }
}
/* Tokens / weapons on the map are lifted above the rooms while they slide (see slideFrom). */
.cl-map [data-tok], .cl-map [data-weap] { position: relative; }
.fx-ghost.cl-ghost { display: flex; align-items: center; justify-content: center; border-radius: 8px; background: linear-gradient(160deg, #fffaf0, #f1e6cf);

View File

@@ -211,7 +211,7 @@ function BackCard({ size = 'md', fx }: { size?: 'sm' | 'md' | 'lg'; fx?: string
// ---------------------------------------------------------------- styles
const CSS = `
.cp-board { width: 100%; max-width: 1120px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 370px); gap: 12px; align-items: start; padding: 2px; }
.cp-board { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 370px); gap: 12px; align-items: start; padding: 2px; }
.cp-felt { position: relative; border-radius: 26px; border: 8px solid var(--wood); box-shadow: var(--shadow); color: #fff; padding: 12px; display: flex; flex-direction: column; gap: 12px; min-height: 540px;
background: radial-gradient(ellipse at 50% 45%, rgba(255,255,255,.14), rgba(255,255,255,0) 60%), var(--felt); }
.cp-actions { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
@@ -347,6 +347,16 @@ ${KINDS.map((k) => `.fx-ghost.cp-face-${k} { background: ${KIND_COLOR[k].bg}; co
.cp-say button:disabled { opacity: .45; cursor: not-allowed; }
.cp-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .9rem; }
.cp-log li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* PC: the felt fills the play column's height and its cards grow with it. */
@media (min-width: 1100px) {
.cp-board { flex: 1 1 auto; min-height: 0; align-items: stretch; grid-template-columns: minmax(0, 1fr) clamp(320px, 26%, 400px); }
.cp-felt .cp-card.lg { --w: clamp(92px, calc(var(--play-h) * .13), 180px); }
.cp-myhand .cp-card { --w: clamp(60px, min(calc(var(--play-h) * .085), calc(var(--play-w) * .06)), 120px); }
.cp-chip .cp-mini { --w: clamp(30px, calc(var(--play-h) * .04), 52px); }
.cp-seat { flex-basis: 140px; max-width: 340px; }
.cp-center { min-height: 0; }
.cp-speech { font-size: clamp(1.15rem, calc(var(--play-h) * .022), 1.5rem); max-width: 240px; }
}
@media (max-width: 899px) {
.cp-board { grid-template-columns: minmax(0, 1fr); }
.cp-felt { min-height: 0; }

View File

@@ -33,6 +33,9 @@ const CSS = `
:root[data-theme='dark'] .c4-svg { --c4-frame: #1e40af; --c4-frame-edge: #172554; }
@media (prefers-color-scheme: dark) { :root[data-theme='auto'] .c4-svg { --c4-frame: #1e40af; --c4-frame-edge: #172554; } }
@media (prefers-reduced-motion: reduce) { .c4-drop, .c4-win { animation: none; } }
.board-wrap.c4-fit { max-width: min(100%, calc((100vh - var(--site-h, 56px) - 180px) * var(--c4-ar))); }
/* PC: the board takes the whole play-area height minus the row that can show under it (--c4-rows). */
@media (min-width: 1100px) { .board-wrap.c4-fit { max-width: min(100%, calc((var(--play-h) - var(--c4-rows, 0px)) * var(--c4-ar))); } }
`;
function Disc({ color, cx, cy, r, ghost }: { color: Color; cx: number; cy: number; r: number; ghost?: boolean }) {
@@ -134,7 +137,11 @@ function C4Board({ view: v, act, pending, tapConfirm }: BoardProps<ConnectFourVi
const pad = 0.15;
const cells = Array.from({ length: cols * rows }, (_, i) => i);
return (
<div className="board-wrap stack" style={{ gap: 10, maxWidth: `min(100%, calc((100vh - var(--site-h, 56px) - 180px) * ${(cols + 2 * pad) / (rows + 1.6)}))` }}>
<div
className="board-wrap stack c4-fit"
// --c4-ar: board width per height of the svg below; touch tap-confirm also shows [두기][취소] under it.
style={{ gap: 10, '--c4-ar': (cols + 2 * pad) / (rows + 1.7), '--c4-rows': tapConfirm ? 'calc(var(--btn-h) + 10px)' : '0px' } as React.CSSProperties}
>
<style>{CSS}</style>
<svg
className="c4-svg"

View File

@@ -181,6 +181,21 @@ const CSS = `
@media (prefers-reduced-motion: reduce) {
.dm *, .dm-seat, .dm-rev, .dm-bubble, .dm-draw, .dm-flip { animation: none !important; transition: none !important; }
}
/* PC: fill the play column. The felt takes the spare height; seats, trick cards and the hand grow with the play area. */
@media (min-width: 1100px) {
.dm { max-width: none; align-self: stretch; flex: 1 1 auto; min-height: 0; justify-content: center; gap: 12px; }
.dm-seats { flex-wrap: nowrap; gap: 8px; }
.dm-seat { flex: 0 1 220px; min-width: 0; padding: 8px 12px; font-size: clamp(.88rem, calc(var(--play-h) / 64), 1.08rem); }
.dm-seat .ttl, .dm-badge, .dm-bubble { font-size: .88em; }
.dm-order { font-size: .86rem; }
.dm-table { flex: 1 1 auto; padding: 20px; font-size: clamp(1rem, calc(var(--play-h) / 62), 1.2rem); }
.dm-now { font-size: 1.6em; } .dm-now small { font-size: .6em; }
.dm-table .dm-card { --w: clamp(60px, calc(var(--play-h) * .11), 150px); }
/* The previous sets carry an inline 30px width; scale them too. */
.dm-table .dm-prev .dm-card { --w: clamp(30px, calc(var(--play-h) * .05), 60px) !important; }
.dm-hand { justify-content: center; }
.dm-hand .dm-card { --w: clamp(60px, min(var(--play-h) * .09, (var(--play-w) - 40px) / 13 - 22px), 130px); }
}
@media (max-width: 719px) {
.dm { gap: 8px; }
.dm-seat { flex: 1 1 30%; min-width: 0; padding: 4px 6px; font-size: .82rem; }

View File

@@ -105,7 +105,11 @@ const CSS = `
.dv-banner { position: fixed; z-index: 40; top: 34%; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: 92vw; text-align: center;
padding: 12px 26px; border-radius: 18px; font-size: clamp(1.4rem, 5vw, 2.2rem); font-weight: 900;
background: linear-gradient(160deg, #42454d, #141519); color: #fff; border: 2px solid #050505; box-shadow: 0 4px 0 rgba(0,0,0,.45), 0 12px 30px rgba(0,0,0,.35); }
.dv-board { width: 100%; max-width: 980px; max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px; }
.dv-board { width: 100%; max-height: 100%; overflow: auto; display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 2px;
flex: 1 1 auto; min-height: 0;
/* Tile width grows with the play area: 13 tiles must fit a row, and all rows (--rows) + the middle panel the height. */
--tw: clamp(46px, min(var(--play-w) / 19, (var(--play-h) - 420px - var(--rows, 2) * 90px) / (var(--rows, 2) * 2.2)), 112px); }
.dv-board > * { flex: none; }
.dv-opps { display: grid; gap: 10px; }
.dv-player { background: var(--surface); border-radius: var(--radius-lg); padding: 10px 12px; box-shadow: var(--shadow); border: 3px solid transparent; }
.dv-player.turn { border-color: var(--focus); }
@@ -116,11 +120,11 @@ const CSS = `
.dv-badge.turn { background: var(--focus); color: #1c1e21; }
.dv-badge.out { background: var(--danger-soft); color: var(--danger); }
.dv-badge.ok { background: var(--success-soft); color: var(--success); }
.dv-row { --lift: 34px; display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; padding-top: calc(8px + var(--lift)); }
.dv-me .dv-row { --lift: 40px; }
.dv-row { --lift: calc(var(--tw, 46px) * .74); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; align-items: flex-end; padding-top: calc(8px + var(--lift)); }
.dv-me .dv-row { --lift: calc(var(--tw, 46px) * .87); }
.dv-slot { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dv-pos { font-size: .75rem; color: var(--text-sub); font-variant-numeric: tabular-nums; line-height: 1; }
.dv-tile { --w: 46px; width: var(--w); height: calc(var(--w) * 1.42); border-radius: 8px; display: flex; align-items: center; justify-content: center;
.dv-tile { --w: var(--tw, 46px); width: var(--w); height: calc(var(--w) * 1.42); border-radius: 8px; display: flex; align-items: center; justify-content: center;
font-weight: 900; font-size: calc(var(--w) * .56); line-height: 1; position: relative; user-select: none; font-variant-numeric: tabular-nums;
box-shadow: 0 3px 0 rgba(0,0,0,.35); transition: transform .15s ease; }
.dv-tile.black { background: linear-gradient(160deg, #42454d, #141519); color: #fff; border: 2px solid color-mix(in srgb, var(--text) 30%, #050505); }
@@ -131,8 +135,8 @@ const CSS = `
.dv-slot.open > .dv-pick { position: relative; top: calc(-1 * var(--lift)); }
.dv-slot.open > .dv-pick::after { content: ''; position: absolute; left: 12%; right: 12%; bottom: -7px; height: 5px; border-radius: 3px; background: #f59e0b; }
.dv-tile.secret { outline: 3px dashed var(--primary); outline-offset: 2px; }
.dv-tile.sm { --w: 30px; }
.dv-tile.lg { --w: 54px; }
.dv-tile.sm { --w: calc(var(--tw, 46px) * .65); }
.dv-tile.lg { --w: calc(var(--tw, 46px) * 1.17); }
.dv-tile.hit { animation: dv-flip .5s ease-out both, dv-hit 1.2s ease-out both; }
.dv-tile.miss { animation: dv-flip .5s ease-out both, dv-miss 1.2s ease-out both; animation-delay: var(--anim-delay, 0ms); }
.dv-tile.new { animation: dv-drop .38s ease-out both; animation-delay: var(--anim-delay, 0ms); }
@@ -153,7 +157,7 @@ const CSS = `
.dv-gap { align-self: stretch; min-width: 28px; min-height: 48px; border: 2px dashed var(--primary); background: var(--primary-soft); color: var(--text);
border-radius: 8px; font-weight: 800; cursor: pointer; padding: 0 2px; font-size: .8rem; }
.dv-gap:focus-visible { outline: 3px solid var(--focus); }
.dv-mid { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 12px; align-items: start; }
.dv-mid { display: grid; grid-template-columns: minmax(0, clamp(260px, 24%, 360px)) minmax(0, 1fr); gap: 12px; align-items: start; }
.dv-center { background: var(--felt); color: #fff; border-radius: var(--radius-lg); padding: 12px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.dv-piles { display: flex; gap: 12px; justify-content: center; }
.dv-pile { display: flex; flex-direction: column; align-items: center; gap: 4px; background: rgba(0,0,0,.18); border: 2px solid transparent; border-radius: 12px;
@@ -161,7 +165,7 @@ const CSS = `
.dv-pile:disabled { cursor: default; opacity: .8; }
.dv-pile.can { border-color: #fde047; background: rgba(253,224,71,.15); }
.dv-pile:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.dv-stack { position: relative; width: 44px; height: 50px; }
.dv-stack { position: relative; width: calc(var(--tw, 46px) * .96); height: calc(var(--tw, 46px) * 1.09); }
.dv-stack .dv-tile { position: absolute; left: 0; }
.dv-pending { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.dv-panel { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
@@ -365,7 +369,7 @@ function DavinciBoard({ view: v, me, players, act, pending, deadline }: BoardPro
};
return (
<div className="dv-board" role="region" aria-label="다빈치 코드 판">
<div className="dv-board" role="region" aria-label="다빈치 코드 판" style={{ '--rows': v.seats.length } as CSSProperties}>
<style>{CSS}</style>
<div className="dv-opps">
{opponentsOf(v, me).map((p) => (

View File

@@ -39,7 +39,9 @@ const dbSound = {
};
const CSS = `
.db { width: 100%; max-width: 1060px; display: flex; flex-direction: column; gap: 10px; align-self: center; --cd: min(440px, 50vh, calc(50% - 14px)); }
/* Fills the play column: the two cards are as big as the column allows (width split in two, height minus the rows around the table). */
.db { width: 100%; display: flex; flex-direction: column; gap: 10px; align-self: stretch; flex: 1 1 auto; min-height: 0;
--cd: clamp(200px, min(calc((var(--play-w) - 76px) / 2), calc(var(--play-h) - 250px)), 960px); }
.db-top { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; justify-content: space-between; font-weight: 700; }
.db-top .grp { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.db-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px; background: var(--surface); box-shadow: var(--shadow); font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
@@ -58,7 +60,7 @@ button.db-seat { cursor: pointer; }
.db-tag { border-radius: 999px; padding: 0 6px; font-size: .72rem; font-weight: 800; line-height: 1.6; white-space: nowrap; color: #fff; background: #6b7280; }
.db-tag.ok { background: #15803d; }
.db-tag.warn { background: #f59e0b; color: #111827; }
.db-table { position: relative; display: flex; gap: 24px; justify-content: center; align-items: flex-start; padding: 14px; border-radius: 26px; background: radial-gradient(ellipse at center, rgba(255,255,255,.12), rgba(255,255,255,0) 65%), var(--felt); border: 6px solid var(--wood); box-shadow: var(--shadow); touch-action: manipulation; }
.db-table { position: relative; flex: 1 1 auto; display: flex; gap: 24px; justify-content: center; align-items: center; padding: 14px; border-radius: 26px; background: radial-gradient(ellipse at center, rgba(255,255,255,.12), rgba(255,255,255,0) 65%), var(--felt); border: 6px solid var(--wood); box-shadow: var(--shadow); touch-action: manipulation; }
.db-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; width: var(--cd); }
.db-slot .cap { color: #fff; font-weight: 800; font-size: .95rem; text-shadow: 0 1px 2px rgba(0,0,0,.4); display: flex; gap: 6px; align-items: center; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.db-card { position: relative; width: 100%; aspect-ratio: 1; border-radius: 50%; background: #fffdf6; border: 4px solid #d6c7a1; box-shadow: 0 6px 0 rgba(0,0,0,.18), 0 10px 22px rgba(0,0,0,.28); }

View File

@@ -148,6 +148,9 @@ const CSS = `
.gm-chip.done { opacity: .55; }
.gm-left { display: flex; flex-wrap: wrap; gap: 2px; }
@media (prefers-reduced-motion: reduce) { .gm-link { animation: none; } }
.gm-root.gm-side { flex-direction: row; align-items: center; justify-content: center; gap: 20px; }
.gm-side > .gm-rows { flex: 0 1 380px; min-width: 0; }
.gm-rows:empty { display: none; }
`;
// ---------------------------------------------------------------- board layers
@@ -226,6 +229,22 @@ function GembloBoard({ view: v, me, players, act, pending }: BoardProps<GembloVi
return () => ro.disconnect();
}, []);
const narrow = width < 600;
// PC play-area size (.game-main, px), null under 1100px where the page scrolls and the rows stay under the board.
const [main, setMain] = useState<{ w: number; h: number } | null>(null);
useLayoutEffect(() => {
const el = wrapRef.current?.closest<HTMLElement>('.game-main');
if (!el) return;
const wide = matchMedia('(min-width: 1100px)');
const update = () => setMain(wide.matches ? { w: el.clientWidth, h: el.clientHeight } : null);
update();
const ro = new ResizeObserver(update);
ro.observe(el);
wide.addEventListener('change', update);
return () => {
ro.disconnect();
wide.removeEventListener('change', update);
};
}, []);
const turnColor = v.colors[v.turn]!;
const myTurn = v.phase === 'playing' && v.turnPlayer === me && v.legal !== null;
@@ -661,138 +680,151 @@ function GembloBoard({ view: v, me, players, act, pending }: BoardProps<GembloVi
: `${pieceName(preview.pieceId)} 놓을 수 있어요${cycle ? ` (${cycle.k + 1}/${cycle.list.length})` : ''}`;
const aspect = box.w / box.h;
// PC: the board fills the play-area height (under the 44px top strip). The hint, tray and buttons go beside it when
// that gives a bigger board than stacking them under it (about 220px of height).
const besideW = main ? Math.floor(Math.min(main.w - 340, (main.h - 44) * aspect)) : 0;
const stackW = main ? Math.floor(Math.min(main.w, (main.h - 264) * aspect)) : 0;
const beside = !!main && besideW > stackW;
return (
<div ref={wrapRef} className="stack" style={{ gap: 8, width: '100%', maxWidth: narrow ? '100%' : `min(100%, calc((100vh - var(--site-h) - 360px) * ${aspect.toFixed(3)}))`, minWidth: 'min(100%, 300px)', alignSelf: 'center' }}>
<div
ref={wrapRef}
className={`stack gm-root${beside ? ' gm-side' : ''}`}
style={{ gap: 8, width: '100%', maxWidth: beside ? 'none' : main ? `min(100%, ${stackW}px)` : narrow ? '100%' : `min(100%, calc((100vh - var(--site-h) - 360px) * ${aspect.toFixed(3)}))`, minWidth: 'min(100%, 300px)', alignSelf: 'center' }}
>
<style>{BOARD_MOTION_CSS + CSS}</style>
<div className="gm-top">
<div className="gm-strip small" role="status">
{strip}
<div className="stack" style={{ gap: 8, ...(beside && { flex: '0 0 auto', width: besideW }) }}>
<div className="gm-top">
<div className="gm-strip small" role="status">
{strip}
</div>
<button
type="button"
className="btn btn-secondary btn-sm gm-zoom"
onClick={() => setZoom(z > 1 ? { z: 1, cx: box.x + box.w / 2, cy: box.y + box.h / 2 } : { z: 2, cx: focus.x, cy: focus.y })}
aria-label={z > 1 ? '판 전체 보기' : '내 블록 근처 확대'}
>
{z > 1 ? '🔍 전체' : '🔍 확대'}
</button>
</div>
<button
type="button"
className="btn btn-secondary btn-sm gm-zoom"
onClick={() => setZoom(z > 1 ? { z: 1, cx: box.x + box.w / 2, cy: box.y + box.h / 2 } : { z: 2, cx: focus.x, cy: focus.y })}
aria-label={z > 1 ? '판 전체 보기' : '내 블록 근처 확대'}
>
{z > 1 ? '🔍 전체' : '🔍 확대'}
</button>
</div>
<div style={{ position: 'relative' }}>
<svg
ref={svgRef}
className={`gm-board${z <= 1 ? ' fit' : ''}`}
viewBox={`${cx - vw / 2} ${cy - vh / 2} ${vw} ${vh}`}
style={{ width: '100%', display: 'block', background: 'var(--wood)', borderRadius: 14, boxShadow: 'var(--shadow)', aspectRatio: `${box.w} / ${box.h}`, cursor: placing ? 'pointer' : 'default' }}
tabIndex={0}
role="grid"
aria-label={`젬블로 판. 방향키로 칸을 옮기고, R 돌리기(Shift+R 반대로), F 뒤집기, [ ] 블록 바꾸기, N 이음점에서 놓는 방법 차례로 보기, Enter 놓기, Esc 취소.`}
data-my-turn={placing ? '1' : '0'}
data-preview={preview ? (preview.why ? 'bad' : 'ok') : ''}
data-zoom={z.toFixed(2)}
data-placements={v.placements.length}
onKeyDown={onKey}
onPointerDown={onPointerDown}
onPointerMove={onPointerMove}
onPointerUp={onPointerUp}
onPointerCancel={(e) => {
pointers.current.delete(e.pointerId);
gesture.current = { kind: 'none' };
}}
onPointerLeave={(e) => e.pointerType === 'mouse' && setHover(null)}
>
<BoardCells layout={v.layout} board={v.board} placements={v.placements} starts={starts} fresh={fresh} lastSeq={v.lastSeq} glow={glowKey} />
{placing === 'color' &&
v.showHints &&
links.map((c) => (
<circle key={`l${c}`} className="gm-link" cx={CELL_XY[c]![0]} cy={CELL_XY[c]![1]} r={0.3} fill={GEM[turnColor.color].fill} stroke="#fff" strokeWidth={0.1} data-link={c} />
))}
{preview && (
<g key={`pv${shake}`} className={shake && preview.why ? 'gm-shake' : undefined} data-preview-cells={preview.cells.join(',')}>
{preview.cells.map((c) => (
<GemCell key={c} color={drawColor} cx={CELL_XY[c]![0]} cy={CELL_XY[c]![1]} ghost={!preview.why} bad={!!preview.why} />
<div style={{ position: 'relative' }}>
<svg
ref={svgRef}
className={`gm-board${z <= 1 ? ' fit' : ''}`}
viewBox={`${cx - vw / 2} ${cy - vh / 2} ${vw} ${vh}`}
style={{ width: '100%', display: 'block', background: 'var(--wood)', borderRadius: 14, boxShadow: 'var(--shadow)', aspectRatio: `${box.w} / ${box.h}`, cursor: placing ? 'pointer' : 'default' }}
tabIndex={0}
role="grid"
aria-label={`젬블로 판. 방향키로 칸을 옮기고, R 돌리기(Shift+R 반대로), F 뒤집기, [ ] 블록 바꾸기, N 이음점에서 놓는 방법 차례로 보기, Enter 놓기, Esc 취소.`}
data-my-turn={placing ? '1' : '0'}
data-preview={preview ? (preview.why ? 'bad' : 'ok') : ''}
data-zoom={z.toFixed(2)}
data-placements={v.placements.length}
onKeyDown={onKey}
onPointerDown={onPointerDown}
onPointerMove={onPointerMove}
onPointerUp={onPointerUp}
onPointerCancel={(e) => {
pointers.current.delete(e.pointerId);
gesture.current = { kind: 'none' };
}}
onPointerLeave={(e) => e.pointerType === 'mouse' && setHover(null)}
>
<BoardCells layout={v.layout} board={v.board} placements={v.placements} starts={starts} fresh={fresh} lastSeq={v.lastSeq} glow={glowKey} />
{placing === 'color' &&
v.showHints &&
links.map((c) => (
<circle key={`l${c}`} className="gm-link" cx={CELL_XY[c]![0]} cy={CELL_XY[c]![1]} r={0.3} fill={GEM[turnColor.color].fill} stroke="#fff" strokeWidth={0.1} data-link={c} />
))}
{preview.links.map(([a, b], i) => {
const [x1, y1] = CELL_XY[a]!;
const [x2, y2] = CELL_XY[b]!;
return <line key={`ln${i}`} x1={x1 + (x2 - x1) * 0.28} y1={y1 + (y2 - y1) * 0.28} x2={x1 + (x2 - x1) * 0.72} y2={y1 + (y2 - y1) * 0.72} stroke="#fff" strokeWidth={0.22} strokeLinecap="round" opacity={0.95} />;
})}
{preview.crosses.map(([m1, m2], i) => {
const x = (CELL_XY[m1]![0] + CELL_XY[m2]![0]) / 2;
const y = (CELL_XY[m1]![1] + CELL_XY[m2]![1]) / 2;
return <path key={`x${i}`} d={`M${x - 0.4} ${y - 0.4}L${x + 0.4} ${y + 0.4}M${x + 0.4} ${y - 0.4}L${x - 0.4} ${y + 0.4}`} stroke="#b91c1c" strokeWidth={0.22} strokeLinecap="round" />;
})}
</g>
)}
{kbd && placing && <polygon points={hexPoints(CELL_XY[cursor]![0], CELL_XY[cursor]![1], 1.02)} fill="none" stroke="var(--focus)" strokeWidth={0.18} />}
</svg>
{preview && (
<g key={`pv${shake}`} className={shake && preview.why ? 'gm-shake' : undefined} data-preview-cells={preview.cells.join(',')}>
{preview.cells.map((c) => (
<GemCell key={c} color={drawColor} cx={CELL_XY[c]![0]} cy={CELL_XY[c]![1]} ghost={!preview.why} bad={!!preview.why} />
))}
{preview.links.map(([a, b], i) => {
const [x1, y1] = CELL_XY[a]!;
const [x2, y2] = CELL_XY[b]!;
return <line key={`ln${i}`} x1={x1 + (x2 - x1) * 0.28} y1={y1 + (y2 - y1) * 0.28} x2={x1 + (x2 - x1) * 0.72} y2={y1 + (y2 - y1) * 0.72} stroke="#fff" strokeWidth={0.22} strokeLinecap="round" opacity={0.95} />;
})}
{preview.crosses.map(([m1, m2], i) => {
const x = (CELL_XY[m1]![0] + CELL_XY[m2]![0]) / 2;
const y = (CELL_XY[m1]![1] + CELL_XY[m2]![1]) / 2;
return <path key={`x${i}`} d={`M${x - 0.4} ${y - 0.4}L${x + 0.4} ${y + 0.4}M${x + 0.4} ${y - 0.4}L${x - 0.4} ${y + 0.4}`} stroke="#b91c1c" strokeWidth={0.22} strokeLinecap="round" />;
})}
</g>
)}
{kbd && placing && <polygon points={hexPoints(CELL_XY[cursor]![0], CELL_XY[cursor]![1], 1.02)} fill="none" stroke="var(--focus)" strokeWidth={0.18} />}
</svg>
</div>
</div>
<p className="sr-only" aria-live="polite">
{announce}
</p>
{(placing || myPick) && (
<p className={`gm-hint small${preview?.why ? ' bad' : ''}`} data-hint>
{hintText}
</p>
)}
{trayIds.length > 0 && v.phase !== 'finished' && (placing || myPick || trayColor) && (
<div className={`gm-tray ${narrow ? 'gm-line' : 'gm-grid'}`} role="group" aria-label={myPick ? '장애물 고르기' : placing === 'obstacle' ? '내 장애물 블록' : placing ? '내 블록' : '내 남은 블록(차례가 오면 고를 수 있어요)'}>
{trayIds.map((id) => {
const used = placing === 'color' ? !hand.includes(id) : !placing && !myPick && trayColor ? !trayColor.left.includes(id) : false;
const locked = placing === 'color' && !used && !placeable.has(id);
const can = myPick ? !pending : !!placing && !used;
return (
<button
key={id}
type="button"
className={`gm-piece${used ? ' used' : ''}`}
aria-pressed={sel === id}
disabled={!can}
data-piece={id}
data-locked={locked ? '1' : undefined}
title={`${pieceName(id)} (${PIECE_SIZE[id]}칸)${locked ? ' · 지금은 놓을 곳이 없어요' : ''}`}
aria-label={`${pieceName(id)} ${PIECE_SIZE[id]}칸${used ? ', 이미 씀' : locked ? ', 놓을 곳 없음' : ''}`}
onClick={() => (myPick ? act({ type: 'pickObstacle', pieceId: id }) : choose(id))}
>
<PieceIcon id={id} orient={sel === id ? orient : 0} color={locked ? 'gold' : trayOwnerColor} size={narrow ? 44 : 46} dim={locked} />
{locked && (
<span className="gm-lock" aria-hidden>
🔒
</span>
)}
</button>
);
})}
</div>
)}
{placing && (
<div className={`gm-ctrl${narrow ? '' : ' wide'}`} role="group" aria-label="블록 돌리기·놓기">
<button type="button" className="btn btn-secondary" disabled={!sel} onClick={() => rotate(-1)} aria-label="왼쪽으로 돌리기">
⟲ 왼쪽
</button>
<button type="button" className="btn btn-secondary" disabled={!sel} onClick={() => rotate(1)} aria-label="오른쪽으로 돌리기">
⟳ 오른쪽
</button>
<button type="button" className="btn btn-secondary" disabled={!sel || !allowFlip} onClick={flip} title={allowFlip ? undefined : '이 방은 뒤집기를 쓰지 않아요'}>
↔ 뒤집기
</button>
<button
type="button"
className="btn btn-ghost"
disabled={!sel && !pin}
onClick={() => {
setSel(null);
setPin(null);
setCycle(null);
}}
>
취소
</button>
<button type="button" className="btn btn-primary gm-go" disabled={!preview || !!preview.why || pending} onClick={() => commit(preview)}>
{preview && !preview.why ? `놓기 · ${pieceName(preview.pieceId)}` : '놓기'}
</button>
</div>
)}
{v.phase === 'finished' && <LeftPieces view={v} players={players} />}
<div className="stack gm-rows" style={{ gap: 8 }}>
{(placing || myPick) && (
<p className={`gm-hint small${preview?.why ? ' bad' : ''}`} data-hint>
{hintText}
</p>
)}
{trayIds.length > 0 && v.phase !== 'finished' && (placing || myPick || trayColor) && (
<div className={`gm-tray ${narrow ? 'gm-line' : 'gm-grid'}`} role="group" aria-label={myPick ? '장애물 고르기' : placing === 'obstacle' ? '내 장애물 블록' : placing ? '내 블록' : '내 남은 블록(차례가 오면 고를 수 있어요)'}>
{trayIds.map((id) => {
const used = placing === 'color' ? !hand.includes(id) : !placing && !myPick && trayColor ? !trayColor.left.includes(id) : false;
const locked = placing === 'color' && !used && !placeable.has(id);
const can = myPick ? !pending : !!placing && !used;
return (
<button
key={id}
type="button"
className={`gm-piece${used ? ' used' : ''}`}
aria-pressed={sel === id}
disabled={!can}
data-piece={id}
data-locked={locked ? '1' : undefined}
title={`${pieceName(id)} (${PIECE_SIZE[id]}칸)${locked ? ' · 지금은 놓을 곳이 없어요' : ''}`}
aria-label={`${pieceName(id)} ${PIECE_SIZE[id]}칸${used ? ', 이미 씀' : locked ? ', 놓을 곳 없음' : ''}`}
onClick={() => (myPick ? act({ type: 'pickObstacle', pieceId: id }) : choose(id))}
>
<PieceIcon id={id} orient={sel === id ? orient : 0} color={locked ? 'gold' : trayOwnerColor} size={narrow ? 44 : 46} dim={locked} />
{locked && (
<span className="gm-lock" aria-hidden>
🔒
</span>
)}
</button>
);
})}
</div>
)}
{placing && (
<div className={`gm-ctrl${narrow || beside ? '' : ' wide'}`} role="group" aria-label="블록 돌리기·놓기">
<button type="button" className="btn btn-secondary" disabled={!sel} onClick={() => rotate(-1)} aria-label="왼쪽으로 돌리기">
⟲ 왼쪽
</button>
<button type="button" className="btn btn-secondary" disabled={!sel} onClick={() => rotate(1)} aria-label="오른쪽으로 돌리기">
⟳ 오른쪽
</button>
<button type="button" className="btn btn-secondary" disabled={!sel || !allowFlip} onClick={flip} title={allowFlip ? undefined : '이 방은 뒤집기를 쓰지 않아요'}>
↔ 뒤집기
</button>
<button
type="button"
className="btn btn-ghost"
disabled={!sel && !pin}
onClick={() => {
setSel(null);
setPin(null);
setCycle(null);
}}
>
취소
</button>
<button type="button" className="btn btn-primary gm-go" disabled={!preview || !!preview.why || pending} onClick={() => commit(preview)}>
{preview && !preview.why ? `놓기 · ${pieceName(preview.pieceId)}` : '놓기'}
</button>
</div>
)}
{v.phase === 'finished' && <LeftPieces view={v} players={players} />}
</div>
</div>
);
}

View File

@@ -1,5 +1,5 @@
/** 고스톱 / 맞고 화면 (docs/games/gostop.md §9). Points are room-only play points. */
import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
import type { BakKind, CardView, GostopOptions, GostopView, HandCardView, OutcomeView, SeatView, TurnTag } from '@bg/games/gostop';
import type { PublicUser } from '@bg/shared/lite';
import { Avatar, Sheet } from '../../components/ui';
@@ -49,6 +49,15 @@ function useNarrow(): boolean {
return narrow;
}
/** Card size factor for the board (PC: grows with the play area, see GostopBoard). */
const CardScale = createContext(1);
const HW = { sm: 40, md: 60, lg: 84 } as const;
/** Card width in px for a HwatuCard size, scaled for the play area. */
function useCardW(): (size: keyof typeof HW) => number {
const k = useContext(CardScale);
return (size) => Math.round(HW[size] * k);
}
function totalMsOf(v: GostopView): number {
if (v.phase === 'roundResult') return 10_000;
const who = v.step === 'sell' ? v.sell?.current : v.turn;
@@ -93,7 +102,7 @@ function statusText(v: GostopView, me: string | null, players: Record<string, Pu
}
const CSS = `
.gs { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 8px; align-self: center; margin: auto 0; }
.gs { width: 100%; display: flex; flex-direction: column; gap: 8px; align-self: center; margin: auto 0; }
.gs-opps { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; list-style: none; margin: 0; padding: 0; }
.gs-seat { background: var(--surface); color: var(--text); border-radius: 12px; padding: 6px 10px; border: 3px solid transparent;
box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
@@ -116,20 +125,20 @@ const CSS = `
.gs-pile { display: flex; flex-direction: column; gap: 1px; min-width: 40px; }
.gs-pile b { font-size: .78rem; font-weight: 800; color: var(--text-sub); white-space: nowrap; }
.gs-pile-cards { display: flex; }
.gs-pile-cards > * + * { margin-left: var(--ov, -30px); }
.gs-pile-cards > * + * { margin-left: calc(var(--ov, -30px) * var(--gk, 1)); }
.gs-cap[aria-expanded='true'] .gs-pile-cards > * + * { --ov: -14px; }
.gs-table { border-radius: 20px; border: 8px solid var(--wood); box-shadow: var(--shadow); color: #fff; padding: 10px;
background: radial-gradient(ellipse at center, rgba(255,255,255,.12), rgba(255,255,255,0) 65%), var(--felt);
display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 10px; align-items: stretch; }
display: grid; grid-template-columns: minmax(0, 1fr) calc(210px * var(--gk, 1)); gap: 10px; align-items: stretch; }
.gs-floor { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; list-style: none; margin: 0; padding: 0; }
.gs-slot { min-height: 104px; border-radius: 10px; border: 2px dashed rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; position: relative; }
.gs-slot { min-height: calc(104px * var(--gk, 1)); border-radius: 10px; border: 2px dashed rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; position: relative; }
.gs-slot .m { position: absolute; top: 1px; left: 6px; font-size: .72rem; font-weight: 700; color: rgba(255,255,255,.55); }
.gs-slot.has { border-style: solid; border-color: rgba(255,255,255,.28); }
.gs-slot.ppeok { border: 3px solid #f87171; background: rgba(239,68,68,.18); }
.gs-slot.ppeok::after { content: '뻑'; position: absolute; right: 4px; top: 2px; font-size: .75rem; font-weight: 900; color: #fecaca; }
.gs-slot.natural::after { content: '3장'; }
.gs-slot-cards { display: flex; }
.gs-slot-cards > * + * { margin-left: var(--sov, -40px); }
.gs-slot-cards > * + * { margin-left: var(--sov, calc(-40px * var(--gk, 1))); }
.gs-glow { animation: gs-blink .9s ease-in-out infinite; border-radius: 8px; }
@keyframes gs-blink { 0%, 100% { filter: drop-shadow(0 0 2px #fde047); } 50% { filter: drop-shadow(0 0 10px #fde047) brightness(1.08); } }
.gs-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
@@ -166,6 +175,11 @@ const CSS = `
.gs-res td { padding: 3px 4px; border-bottom: 1px solid var(--border); }
.gs-res td.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.gs-notice { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; margin: 0; }
/* PC: fill the play column; the floor takes the height the seats leave (cards grow with the area, see GostopBoard). */
@media (min-width: 1100px) {
.gs { align-self: stretch; flex: 1 1 auto; min-height: 0; margin: 0; }
.gs-table { flex: 1 1 auto; }
}
@media (max-width: 719px) {
.gs-opps { grid-template-columns: 1fr; }
.gs-table { grid-template-columns: 1fr; border-width: 5px; padding: 8px; }
@@ -182,18 +196,20 @@ const CSS = `
function Card({ c, size = 'sm', className, style }: { c: CardView | null; size?: 'sm' | 'md' | 'lg'; className?: string; style?: React.CSSProperties }) {
const card = c as HwatuInfo | null;
const cw = useCardW();
return className ? (
<span className={className} style={{ display: 'inline-flex', ...style }}>
<HwatuCard card={card} size={size} />
<HwatuCard card={card} width={cw(size)} />
</span>
) : (
<HwatuCard card={card} size={size} style={style} />
<HwatuCard card={card} width={cw(size)} style={style} />
);
}
function CapturedRow({ seat, label }: { seat: SeatView; label: string }) {
const [open, setOpen] = useState(false);
const groups = (['gwang', 'yeol', 'tti', 'pi'] as const).filter((k) => seat.captured[k].length > 0);
const cw = useCardW();
if (groups.length === 0)
return (
<span className="small muted" data-fx-cap={seat.id}>
@@ -210,7 +226,7 @@ function CapturedRow({ seat, label }: { seat: SeatView; label: string }) {
<span className="gs-pile-cards">
{seat.captured[k].map((c) => (
<span key={c.key} data-gs-cap={c.key} style={{ display: 'inline-flex' }}>
<HwatuCard card={c as HwatuInfo} size="sm" />
<HwatuCard card={c as HwatuInfo} width={cw('sm')} />
</span>
))}
</span>
@@ -310,9 +326,28 @@ function SeatBox({ seat, v, players, me, deadline }: { seat: SeatView; v: Gostop
function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>; narrow: boolean; players: Record<string, PublicUser> }) {
const months = Array.from({ length: 12 }, (_, i) => i + 1);
const pf = v.pendingFlip;
const cw = useCardW();
// PC: floor cards fill their month slot (3 overlapping cards across, one card high), never smaller than the base size.
const floorRef = useRef<HTMLUListElement | null>(null);
const [fit, setFit] = useState(0);
useLayoutEffect(() => {
const el = floorRef.current;
if (!el) return undefined;
const measure = () => {
if (window.innerWidth < 1100) return setFit(0);
const slotW = (el.clientWidth - 5 * 6) / 6;
const slotH = (el.clientHeight - 6) / 2;
setFit(Math.floor(Math.min(150, (slotW - 10) / 1.66, (slotH - 24) / 1.63)));
};
const ro = new ResizeObserver(measure);
ro.observe(el);
measure();
return () => ro.disconnect();
}, []);
const fw = narrow ? 40 : Math.max(cw('md'), fit);
return (
<div className="gs-table" role="region" aria-label="바닥">
<ul className="gs-floor" data-fx="gs-floor" aria-label="바닥 패(월별)">
<ul className="gs-floor" ref={floorRef} data-fx="gs-floor" aria-label="바닥 패(월별)" style={fit ? ({ '--sov': `${-Math.round(fw * 0.67)}px` } as React.CSSProperties) : undefined}>
{months.map((m) => {
const g = v.floor.find((x) => x.month === m);
const cls = `gs-slot${g ? ' has' : ''}${g && g.cards.length === 3 ? (g.natural ? ' ppeok natural' : ' ppeok') : ''}`;
@@ -328,7 +363,7 @@ function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>;
<span className="gs-slot-cards">
{g.cards.map((c) => (
<span key={c.key} className={glow.has(c.id) ? 'gs-glow' : undefined} data-gs-floor={c.key} style={{ display: 'inline-flex' }}>
<HwatuCard card={c as HwatuInfo} size={narrow ? 'sm' : 'md'} />
<HwatuCard card={c as HwatuInfo} width={fw} />
</span>
))}
</span>
@@ -340,7 +375,7 @@ function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>;
<div className="gs-side">
<div className="gs-deck">
<div data-fx="gs-deck" aria-label={`더미 ${v.deckCount}장`} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 2 }}>
<HwatuCard card={null} size={narrow ? 'sm' : 'md'} />
<HwatuCard card={null} width={narrow ? 40 : cw('md')} />
<strong>{v.deckCount}장</strong>
</div>
<div className="gs-info">
@@ -358,7 +393,7 @@ function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>;
<div aria-label={`뒤집은 패 ${pf.flipped.name}`} style={{ textAlign: 'center' }}>
<div className="small">뒤집은 패</div>
<span className="gs-glow" data-fx="gs-pflip" style={{ display: 'inline-flex' }}>
<HwatuCard card={pf.flipped as HwatuInfo} size="sm" />
<HwatuCard card={pf.flipped as HwatuInfo} width={cw('sm')} />
</span>
</div>
)}
@@ -426,6 +461,7 @@ function MyHand({ v, act, pending, tapConfirm, onFocusCard }: { v: GostopView; a
const [ask, setAsk] = useState<Ask>(null);
const canPlay = v.step === 'play' && v.turn === v.me && !pending;
const hints = v.rules.hints;
const cw = useCardW();
useEffect(() => {
setLifted(null);
setAsk(null);
@@ -476,7 +512,7 @@ function MyHand({ v, act, pending, tapConfirm, onFocusCard }: { v: GostopView; a
onFocus={() => onFocusCard(h)}
onBlur={() => onFocusCard(null)}
>
<HwatuCard card={h.card as HwatuInfo} size="md" />
<HwatuCard card={h.card as HwatuInfo} width={cw('md')} />
{tag && <span className={`tag${h.canShake ? ' shake' : ''}`}>{tag}</span>}
</button>
);
@@ -1115,6 +1151,23 @@ function useGostopFx(v: GostopView, me: string | null, players: Record<string, P
function GostopBoard(props: BoardProps<GostopView>) {
const { view: v, me, players } = props;
const narrow = useNarrow();
// PC: cards grow with the play area (1 at the old 1100 px column, up to 1.7×; the height check keeps it on screen).
const rootRef = useRef<HTMLDivElement | null>(null);
const [k, setK] = useState(1);
useLayoutEffect(() => {
const el = rootRef.current;
if (!el) return undefined;
const wide = matchMedia('(min-width: 1100px)');
const measure = () => setK(wide.matches ? Math.min(1.7, Math.max(1, Math.min(el.clientWidth / 1100, el.clientHeight / 640))) : 1);
const ro = new ResizeObserver(measure);
ro.observe(el);
wide.addEventListener('change', measure);
measure();
return () => {
ro.disconnect();
wide.removeEventListener('change', measure);
};
}, []);
const [focus, setFocus] = useState<HandCardView | null>(null);
const [announce, setAnnounce] = useState('');
const mine = isMyTurn(v, me);
@@ -1149,22 +1202,24 @@ function GostopBoard(props: BoardProps<GostopView>) {
const glow = new Set<number>(v.rules.hints && focus ? focus.matches : []);
if (v.pendingFlip) for (const c of v.pendingFlip.options) glow.add(c.id);
return (
<div className="gs">
<style>{CSS}</style>
<ul className="gs-opps" aria-label={me ? '다른 사람' : '플레이어'}>
{others.map((s) => (
<SeatBox key={s.id} seat={s} v={v} players={players} me={me} deadline={props.deadline} />
))}
</ul>
<Floor v={v} glow={glow} narrow={narrow} players={players} />
<RoundResult {...props} />
<MyArea {...props} onFocusCard={setFocus} />
<Decisions {...props} />
{banner}
<p className="sr-only" aria-live="polite">
{announce}
</p>
</div>
<CardScale.Provider value={k}>
<div className="gs" ref={rootRef} style={{ '--gk': k.toFixed(2) } as React.CSSProperties}>
<style>{CSS}</style>
<ul className="gs-opps" aria-label={me ? '다른 사람' : '플레이어'}>
{others.map((s) => (
<SeatBox key={s.id} seat={s} v={v} players={players} me={me} deadline={props.deadline} />
))}
</ul>
<Floor v={v} glow={glow} narrow={narrow} players={players} />
<RoundResult {...props} />
<MyArea {...props} onFocusCard={setFocus} />
<Decisions {...props} />
{banner}
<p className="sr-only" aria-live="polite">
{announce}
</p>
</div>
</CardScale.Provider>
);
}

View File

@@ -10,6 +10,7 @@ import type { BoardProps, GameUI, OptionsProps } from '../types';
import { helpNow } from './help';
import { quickStart } from './quick';
import { fxMs } from '../../lib/motion';
import { useWide } from '../../lib/media';
const FRUITS: Fruit[] = ['strawberry', 'banana', 'lime', 'plum'];
const FRUIT_KO: Record<Fruit, string> = { strawberry: '딸기', banana: '바나나', lime: '라임', plum: '자두' };
@@ -36,7 +37,8 @@ const hgSound = {
};
const CSS = `
.hg { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 10px; align-self: center; }
/* Fills the play column; on PC the table takes all the height the top row and my deck row leave. */
.hg { width: 100%; display: flex; flex-direction: column; gap: 10px; align-self: stretch; flex: 1 1 auto; min-height: 0; }
.hg-top { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: space-between; font-weight: 700; }
.hg-top .grp { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hg-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px; background: var(--surface); box-shadow: var(--shadow); font-size: .92rem; font-variant-numeric: tabular-nums; }
@@ -144,6 +146,12 @@ const CSS = `
@keyframes hg-pop { 0% { transform: translateX(-50%) scale(.6); opacity: 0; } 70% { transform: translateX(-50%) scale(1.06); opacity: 1; } 100% { transform: translateX(-50%) scale(1); } }
@keyframes hg-ring { 0%,100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(5deg); } }
@keyframes hg-fly { from { left: var(--fx); top: var(--fy); opacity: 1; } 85% { opacity: .9; } to { left: var(--tx); top: var(--ty); opacity: 0; transform: translate(-50%, -50%) scale(.6); } }
@media (min-width: 720px) {
.hg-table { flex: 1 1 auto; height: auto; min-height: clamp(440px, 64vh, 600px); }
}
@media (min-width: 1100px) {
.hg-table { min-height: 440px; }
}
@media (max-width: 719px) {
.hg-table { height: 450px; border-width: 6px; border-radius: 22px; }
.hg-seat { padding: 3px 3px 4px; gap: 2px; }
@@ -331,7 +339,7 @@ const CENTER: Pos = { left: '50%', top: '50%' };
* "half the table minus half a seat", so seats always stay inside the felt whatever its size.
* `tall` (narrow phone table): seats that are not level with the bell move further up/down so they clear it.
*/
function seatPositions(n: number, seat: { w: number; h: number }, maxRx: number, tall: boolean): Pos[] {
function seatPositions(n: number, seat: { w: string; h: string }, maxRx: string, tall: boolean): Pos[] {
const f = (x: number) => (Math.abs(x) < 1e-9 ? 0 : Number(x.toFixed(4)));
return Array.from({ length: n }, (_, k) => {
const t = (2 * Math.PI * k) / n;
@@ -339,8 +347,8 @@ function seatPositions(n: number, seat: { w: number; h: number }, maxRx: number,
const y = tall && c !== 0 ? Math.sign(c) * Math.max(Math.abs(c), 0.75) : c;
const sn = f(Math.sin(t));
return {
left: `calc(50% - ${sn} * min(50% - ${seat.w / 2 + 6}px, ${maxRx}px))`,
top: `calc(50% + ${y} * (50% - ${seat.h / 2 + 6}px))`,
left: `calc(50% - ${sn} * min(50% - ${seat.w} / 2 - 6px, ${maxRx}))`,
top: `calc(50% + ${y} * (50% - ${seat.h} / 2 - 6px))`,
side: sn > 0.2 ? 'left' : sn < -0.2 ? 'right' : 'mid',
dir: [-sn, y],
};
@@ -546,6 +554,7 @@ function bellText(v: HalliGalliView, players: Record<string, PublicUser>): Bubbl
function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<HalliGalliView>) {
const now = useServerNow(100);
const phone = usePhone();
const wide = useWide();
const rtt = useRoom((s) => s.rttMs);
const [bubble, setBubble] = useState<Bubble | null>(null);
const [ghosts, setGhosts] = useState<Ghost[]>([]);
@@ -563,9 +572,16 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<Hall
const myIdx = v.seats.findIndex((s) => s.id === me);
const rot = myIdx < 0 ? v.seats : [...v.seats.slice(myIdx), ...v.seats.slice(0, myIdx)];
const many = rot.length >= 5;
const cw = phone ? (many ? 40 : 50) : many ? 64 : 80;
const sw = Math.round(cw * 1.72 + 6 + 12);
const pos = seatPositions(rot.length, { w: sw, h: cw * 1.4 + (phone ? 50 : 58) + 8 }, phone ? 400 : 400, phone);
// Card width: fixed on phones/tablets; on PC it grows with the play area (CSS length, so seats and fly-ins follow live resizes).
const cwPx = phone ? (many ? 40 : 50) : many ? 64 : 80;
const cw = !wide
? `${cwPx}px`
: many
? 'clamp(64px, min(var(--play-w) * .056, var(--play-h) * .088), 128px)'
: 'clamp(80px, min(var(--play-w) * .07, var(--play-h) * .11), 160px)';
const sw = wide ? 'calc(var(--cw) * 1.72 + 18px)' : `${Math.round(cwPx * 1.72 + 18)}px`;
const seatH = wide ? 'calc(var(--cw) * 1.4 + 66px)' : `${cwPx * 1.4 + (phone ? 50 : 58) + 8}px`;
const pos = seatPositions(rot.length, { w: sw, h: seatH }, wide ? 'max(400px, var(--bell) * 2.4)' : '400px', phone);
const posOf = (id: string) => pos[rot.findIndex((s) => s.id === id)] ?? CENTER;
const mine = v.seats.find((s) => s.id === me) ?? null;
const playing = v.phase === 'playing';
@@ -709,7 +725,14 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<Hall
return () => clearTimeout(t);
}, [bubble]);
const bellSize = phone ? (rot.length >= 5 ? 128 : 'min(40vw, 156px)') : 'clamp(140px, 20vh, 190px)';
// PC: the bell (and its dashed ring, 1.55x) grows too, but stays clear of the top and bottom seats (table ≈ play height - 130px).
const bellSize = phone
? rot.length >= 5
? 128
: 'min(40vw, 156px)'
: wide
? 'clamp(140px, min(var(--play-h) * .26, var(--play-w) * .2, (var(--play-h) - 142px - 2 * (var(--cw) * 1.4 + 66px)) / 1.55), 320px)'
: 'clamp(140px, 20vh, 190px)';
const countdown = v.phase === 'countdown' ? Math.max(0, Math.ceil((v.countdownEndsAt - now) / 1000)) : 0;
const totals = FRUITS.map((f) => ({ f, n: v.seats.reduce((a, s) => a + (s.top && s.top.fruit === f ? s.top.count : 0), 0) }));
const timeLeft = v.endsAt !== null ? Math.max(0, v.endsAt - Math.max(now, v.countdownEndsAt)) : null;
@@ -755,7 +778,7 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<Hall
className="hg-table"
role="region"
aria-label="카드 테이블"
style={{ '--bell': typeof bellSize === 'number' ? `${bellSize}px` : bellSize, '--cw': `${cw}px`, '--sw': `${sw}px` } as CSSProperties}
style={{ '--bell': typeof bellSize === 'number' ? `${bellSize}px` : bellSize, '--cw': cw, '--sw': sw } as CSSProperties}
>
<ul style={{ listStyle: 'none', margin: 0, padding: 0 }} aria-label="사람들의 펼친 카드">
{rot.map((s, i) => (

View File

@@ -133,6 +133,12 @@ const CSS = `
.hs-seg-row { display: flex; gap: 6px; flex-wrap: wrap; }
.hs-seg-row .btn { flex: 1 1 0; min-width: 64px; }
.hs-seg-row .btn[aria-pressed='true'] { outline: 3px solid var(--primary); outline-offset: 1px; }
/* PC: use the whole play column width. The track grows with it but stays short enough that head, panel, track and
deck list (~620px) still fit the column height. */
@media (min-width: 1100px) {
.hs-wrap { max-width: none; }
.hs-box { max-width: min(100%, calc((var(--play-h) - 620px) * ${(WIDE.w / WIDE.h).toFixed(3)})); margin: 0 auto; }
}
@media (max-width: 899px) {
.hs-stacks { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

View File

@@ -1,5 +1,5 @@
/** 장기 화면 (docs/games/janggi.md §9). */
import { useEffect, useMemo, useRef, useState } from 'react';
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
import type { Arrangement, JanggiMove, JanggiOptions, JanggiView, Piece, PieceKind, Side, Sq } from '@bg/games/janggi';
import type { PublicUser } from '@bg/shared/lite';
import { Avatar, ConfirmSheet, Sheet } from '../../components/ui';
@@ -168,14 +168,38 @@ const JANGGI_CSS = `
@keyframes jg-check { 0% { opacity: 0; transform: scale(.5); } 30% { opacity: 1; transform: scale(1.22); } 55% { transform: scale(.95); } 78% { transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }
.jg-fade { animation: jg-fade .3s ease-out both; }
@keyframes jg-fade { from { opacity: 0; } }
.board-wrap.jg-side { flex-direction: row; align-items: center; justify-content: center; gap: 20px; }
.jg-side > .jg-rows { flex: 0 1 320px; min-width: 0; }
`;
/** PC play-area size (.game-main, px), null under 1100px where the page scrolls and rows stay under the board. */
function useWideMain(ref: React.RefObject<HTMLElement | null>) {
const [size, setSize] = useState<{ w: number; h: number } | null>(null);
useLayoutEffect(() => {
const main = ref.current?.closest<HTMLElement>('.game-main');
if (!main) return;
const wide = matchMedia('(min-width: 1100px)');
const update = () => setSize(wide.matches ? { w: main.clientWidth, h: main.clientHeight } : null);
update();
const ro = new ResizeObserver(update);
ro.observe(main);
wide.addEventListener('change', update);
return () => {
ro.disconnect();
wide.removeEventListener('change', update);
};
}, [ref]);
return size;
}
function JanggiBoard({ view: v, act, pending, tapConfirm }: BoardProps<JanggiView>) {
const flip = v.mySide === 'han';
const toScreen = (q: Sq) => (flip ? { x: 8 - q.f, y: q.r } : { x: q.f, y: 9 - q.r });
const fromScreen = (x: number, y: number): Sq => (flip ? { f: 8 - x, r: y } : { f: x, r: 9 - y });
const myTurn = v.phase === 'playing' && v.mySide === v.turn;
const [hangul, setHangul] = useHangulLabels();
const wrapRef = useRef<HTMLDivElement>(null);
const main = useWideMain(wrapRef);
const [selected, setSelected] = useState<number | null>(null);
const [hover, setHover] = useState<number | null>(null);
const [preview, setPreview] = useState<number | null>(null);
@@ -341,11 +365,22 @@ function JanggiBoard({ view: v, act, pending, tapConfirm }: BoardProps<JanggiVie
const last = v.lastMove;
const pad = 0.95;
const setupMaxW = v.phase === 'setup' ? 'min(100%, calc((100vh - 400px) * 0.9))' : 'min(100%, calc((100vh - 250px) * 0.9))';
// PC: the board fills the play-area height. The rows (alerts, setup picker, hangul toggle) go beside it when that
// gives a bigger board than stacking them under it (which needs about `under` px of height).
const ar = (8 + 2 * pad) / (9 + 2 * pad);
const under = v.phase === 'setup' ? 320 : 170;
const besideW = main ? Math.floor(Math.min(main.w - 320, main.h * ar)) : 0;
const stackW = main ? Math.floor(Math.min(main.w, (main.h - under) * ar)) : 0;
const side = !!main && besideW > stackW;
return (
<div className="board-wrap stack" style={{ gap: 10, maxWidth: setupMaxW, minWidth: 'min(100%, 300px)' }}>
<div
ref={wrapRef}
className={`board-wrap stack${side ? ' jg-side' : ''}`}
style={{ gap: 10, maxWidth: side ? 'none' : main ? `min(100%, ${stackW}px)` : setupMaxW, minWidth: 'min(100%, 300px)' }}
>
<style>{BOARD_MOTION_CSS + JANGGI_CSS}</style>
<div style={{ position: 'relative' }}>
<div style={{ position: 'relative', ...(side && { flex: '0 0 auto', width: besideW }) }}>
<svg
ref={svgRef}
viewBox={`${-pad} ${-pad} ${8 + 2 * pad} ${9 + 2 * pad}`}
@@ -495,46 +530,48 @@ function JanggiBoard({ view: v, act, pending, tapConfirm }: BoardProps<JanggiVie
<p className="sr-only" aria-live="polite">
{announce}
</p>
{v.phase === 'playing' && v.inCheck && (
<div className="card" role="alert" style={{ padding: '8px 12px', background: 'var(--danger-soft)', color: 'var(--danger)', fontWeight: 700, textAlign: 'center' }}>
{v.inCheck === v.mySide ? '장군이에요! 궁을 지켜야 해요.' : `${SIDE_KO[v.inCheck]} 장군!`}
</div>
)}
{v.phase === 'playing' && v.bikjang && (
<div className="card" style={{ padding: '8px 12px', background: 'var(--warning-soft)', color: 'var(--warning)', fontWeight: 700, textAlign: 'center' }}>
{v.bikjang.calledBy === v.mySide
? '빅장을 불렀어요. 상대가 막지 못하면 점수로 판정해요.'
: v.mySide
? '빅장이에요! 궁 사이를 막거나 궁을 옆으로 옮기지 않으면 점수로 판정해요.'
: `${SIDE_KO[v.bikjang.calledBy]} 빅장!`}
</div>
)}
{myTurn && v.repeatWarning && (
<div className="card" style={{ padding: '8px 12px', background: 'var(--warning-soft)', color: 'var(--warning)', fontWeight: 700, textAlign: 'center' }}>
{v.rules.repetition === 'forbid'
? '같은 국면이 3번 나왔어요. 한 번 더 반복하는 수는 둘 수 없어요.'
: v.rules.repetition === 'lose'
? '같은 국면이 3번 나왔어요. 한 번 더 반복하면 실격패예요!'
: '같은 국면이 3번 나왔어요. 한 번 더 반복하면 점수로 판정해요.'}
</div>
)}
{preview !== null && selected !== null && myTurn && (
<div className="row" style={{ justifyContent: 'center' }}>
<button className="btn btn-primary" style={{ flex: 2 }} disabled={pending} onClick={() => doMove(selected, preview)}>
{`${v.board[selected] ? pieceName(v.board[selected]!) : ''} ${sqCode(fromKey(preview))}로 두기`}
</button>
<button className="btn btn-secondary" style={{ flex: 1 }} onClick={() => setPreview(null)}>
취소
</button>
</div>
)}
{v.phase === 'setup' && (
<SetupPicker view={v} act={act} pending={pending} tapConfirm={tapConfirm} mustChoose={mustChoose} onHover={setSetupHover} />
)}
<label className="row small muted" style={{ justifyContent: 'center', gap: 6, cursor: 'pointer' }}>
<input type="checkbox" checked={hangul} onChange={(e) => setHangul(e.target.checked)} />
기물에 한글 이름 같이 보기
</label>
<div className="stack jg-rows" style={{ gap: 10 }}>
{v.phase === 'playing' && v.inCheck && (
<div className="card" role="alert" style={{ padding: '8px 12px', background: 'var(--danger-soft)', color: 'var(--danger)', fontWeight: 700, textAlign: 'center' }}>
{v.inCheck === v.mySide ? '장군이에요! 궁을 지켜야 해요.' : `${SIDE_KO[v.inCheck]} 장군!`}
</div>
)}
{v.phase === 'playing' && v.bikjang && (
<div className="card" style={{ padding: '8px 12px', background: 'var(--warning-soft)', color: 'var(--warning)', fontWeight: 700, textAlign: 'center' }}>
{v.bikjang.calledBy === v.mySide
? '빅장을 불렀어요. 상대가 막지 못하면 점수로 판정해요.'
: v.mySide
? '빅장이에요! 궁 사이를 막거나 궁을 옆으로 옮기지 않으면 점수로 판정해요.'
: `${SIDE_KO[v.bikjang.calledBy]} 빅장!`}
</div>
)}
{myTurn && v.repeatWarning && (
<div className="card" style={{ padding: '8px 12px', background: 'var(--warning-soft)', color: 'var(--warning)', fontWeight: 700, textAlign: 'center' }}>
{v.rules.repetition === 'forbid'
? '같은 국면이 3번 나왔어요. 한 번 더 반복하는 수는 둘 수 없어요.'
: v.rules.repetition === 'lose'
? '같은 국면이 3번 나왔어요. 한 번 더 반복하면 실격패예요!'
: '같은 국면이 3번 나왔어요. 한 번 더 반복하면 점수로 판정해요.'}
</div>
)}
{preview !== null && selected !== null && myTurn && (
<div className="row" style={{ justifyContent: 'center' }}>
<button className="btn btn-primary" style={{ flex: 2 }} disabled={pending} onClick={() => doMove(selected, preview)}>
{`${v.board[selected] ? pieceName(v.board[selected]!) : ''} ${sqCode(fromKey(preview))}로 두기`}
</button>
<button className="btn btn-secondary" style={{ flex: 1 }} onClick={() => setPreview(null)}>
취소
</button>
</div>
)}
{v.phase === 'setup' && (
<SetupPicker view={v} act={act} pending={pending} tapConfirm={tapConfirm} mustChoose={mustChoose} onHover={setSetupHover} />
)}
<label className="row small muted" style={{ justifyContent: 'center', gap: 6, cursor: 'pointer' }}>
<input type="checkbox" checked={hangul} onChange={(e) => setHangul(e.target.checked)} />
기물에 한글 이름 같이 보기
</label>
</div>
</div>
);
}

View File

@@ -174,6 +174,30 @@ button.lv-casino:hover { border-color: var(--primary); }
@media (max-width: 1099px) {
.lv-lower { grid-template-columns: minmax(0, 1fr); }
}
/* PC: fill the play column; casinos take the spare height and everything on the table scales with --lv-u (1px at ~1100x760). */
@media (min-width: 1100px) {
.lv-wrap { --lv-u: clamp(1px, min(var(--play-w) / 1100, var(--play-h) / 760), 1.7px); max-width: none; flex: 1 1 auto; min-height: 0; justify-content: center; gap: calc(var(--lv-u) * 10); }
.lv-help span { font-size: calc(var(--lv-u) * 16); }
.lv-casinos { flex: 1 1 auto; min-height: 0; gap: calc(var(--lv-u) * 10); }
.lv-casino { min-height: 196px; padding: calc(var(--lv-u) * 10); gap: calc(var(--lv-u) * 8); }
.lv-ctop .lv-die { width: calc(var(--lv-u) * 30); height: calc(var(--lv-u) * 30); }
.lv-cnum { font-size: calc(var(--lv-u) * 26); }
.lv-cname { font-size: calc(var(--lv-u) * 13); }
/* Bills stack down the casino as full-width notes, so the tall casinos are not empty. */
.lv-casinos .lv-bills { flex-direction: column; flex-wrap: nowrap; gap: calc(var(--lv-u) * 6); }
.lv-casinos .lv-bill { width: 100%; height: calc(var(--lv-u) * 40); font-size: calc(var(--lv-u) * 22); border-radius: calc(var(--lv-u) * 7); }
.lv-casinos .lv-bill::before { font-size: calc(var(--lv-u) * 11); left: calc(var(--lv-u) * 6); top: 50%; transform: translateY(-50%); }
.lv-stacks { gap: calc(var(--lv-u) * 5); }
.lv-stack { font-size: calc(var(--lv-u) * 14); }
.lv-pips { gap: calc(var(--lv-u) * 3); }
.lv-casinos .lv-dot { width: calc(var(--lv-u) * 19); height: calc(var(--lv-u) * 19); border-radius: calc(var(--lv-u) * 4); }
.lv-tag { font-size: calc(var(--lv-u) * 13); }
.lv-group { min-width: calc(var(--lv-u) * 100); padding: calc(var(--lv-u) * 7) calc(var(--lv-u) * 12); }
.lv-group b { font-size: calc(var(--lv-u) * 19); }
.lv-tray .lv-die { width: calc(var(--lv-u) * 32); height: calc(var(--lv-u) * 32); }
.lv-tray .lv-die.lg { width: calc(var(--lv-u) * 46); height: calc(var(--lv-u) * 46); }
.lv-roll { min-height: calc(var(--lv-u) * 64); font-size: calc(var(--lv-u) * 19); }
}
@media (max-width: 719px) {
.lv-casinos { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.lv-casino { min-height: 132px; padding: 6px; gap: 4px; }

View File

@@ -78,7 +78,7 @@ const CSS = `
.lg-bar .tr { height: 14px; border-radius: 7px; background: var(--surface-2); overflow: hidden; }
.lg-bar .tr i { display: block; height: 100%; background: #8b5cf6; border-radius: 7px; animation: lg-grow .7s ease-out; transform-origin: left; }
.lg-bar[data-top='true'] .tr i { background: #dc2626; }
.lg-grid { flex: 1; min-height: 0; display: grid; gap: 10px; grid-template-columns: 236px minmax(0, 1fr) 290px; grid-template-areas: 'players talk actions'; }
.lg-grid { flex: 1; min-height: 0; display: grid; gap: 10px; grid-template-columns: clamp(236px, 17%, 340px) minmax(0, 1fr) clamp(290px, 20%, 400px); grid-template-areas: 'players talk actions'; }
.lg-col { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.lg-players { grid-area: players; }
.lg-talk { grid-area: talk; }

View File

@@ -114,7 +114,7 @@ const CSS = `
.mf-bar .tr { height: 14px; border-radius: 7px; background: var(--surface-2); overflow: hidden; }
.mf-bar .tr i { display: block; height: 100%; background: #f97316; border-radius: 7px; animation: mf-grow .7s ease-out; transform-origin: left; }
.mf-bar[data-top='true'] .tr i { background: #dc2626; }
.mf-grid { flex: 1; min-height: 0; display: grid; gap: 10px; grid-template-columns: 236px minmax(0, 1fr) 280px; grid-template-areas: 'players chat actions'; }
.mf-grid { flex: 1; min-height: 0; display: grid; gap: 10px; grid-template-columns: clamp(236px, 17%, 340px) minmax(0, 1fr) clamp(280px, 20%, 400px); grid-template-areas: 'players chat actions'; }
.mf-col { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.mf-players { grid-area: players; }
.mf-chatwrap { grid-area: chat; }

View File

@@ -314,6 +314,25 @@ button.ma-card:hover:not(:disabled) { border-color: var(--primary); transform: t
.ma-card small { font-size: .78rem; }
.ma-legend { grid-template-columns: minmax(0, 1fr); }
}
/* PC: fill the play column. The race board is as big as the column height allows and the log + racer list sit beside it
when there is room (otherwise they wrap below as before). Without a board (draft) the panel fills the column. */
@media (min-width: 1100px) {
.ma-wrap { max-width: none; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: flex-start; align-content: flex-start; }
.ma-wrap > .ma-track { width: min(100%, calc((var(--play-h) - 86px) * ${(BW / WIDE.bh).toFixed(3)})); }
.ma-box { max-width: 100%; }
.ma-wrap > .ma-lower { flex: 1 1 340px; width: auto; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.ma-die3d { --ds: clamp(64px, calc(var(--play-h) * .07), 96px); }
.ma-wrap:not(:has(> .ma-track)) { flex: 1 1 auto; min-height: 0; flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
.ma-wrap:not(:has(> .ma-track)) > .ma-panel { flex: 1 1 auto; min-height: 0; }
/* Rows grow up to a third of the column but share the height when there are many cards (5 players: 10 in the draft). */
.ma-panel > .ma-cards { flex: 1 1 auto; min-height: 0; align-content: center; justify-content: center; gap: 14px;
grid-template-columns: repeat(auto-fit, minmax(clamp(190px, calc(var(--play-w) * .19), 360px), clamp(190px, calc(var(--play-w) * .22), 360px)));
grid-auto-rows: minmax(auto, clamp(104px, calc(var(--play-h) * .32), 380px)); }
.ma-panel > .ma-cards .ma-card { padding: clamp(10px, calc(var(--play-h) * .02), 24px); gap: 10px; }
.ma-panel > .ma-cards .ma-card .em { font-size: clamp(1.6rem, calc(var(--play-h) * .06), 4rem); }
.ma-panel > .ma-cards .ma-card b { font-size: clamp(1.05rem, calc(var(--play-h) * .022), 1.6rem); }
.ma-panel > .ma-cards .ma-card small { font-size: clamp(.875rem, calc(var(--play-h) * .016), 1.2rem); }
}
@media (prefers-reduced-motion: reduce) {
.ma-tok { transition: none; }
.ma-hop, .ma-fly, .ma-trip-anim, .ma-ring, .ma-trail, .ma-float, .ma-conf, .ma-ticker div, .ma-die3d.rolling .ma-cube, .ma-die3d.rolling .ma-die-shadow { animation: none; }

View File

@@ -158,7 +158,7 @@ function Bump({ value, children }: { value: number; children?: ReactNode }) {
const CSS = `
.game-main:has(> .mj) { justify-content: flex-start; }
.mj { position: relative; width: 100%; max-width: 1080px; display: flex; flex-direction: column; gap: 8px; align-self: center; }
.mj { position: relative; width: 100%; display: flex; flex-direction: column; gap: 8px; align-self: center; }
.mj.wide { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: 'table side' 'me me'; align-items: start; gap: 8px 12px; }
.mj.wide .mj-opps { grid-area: side; flex-direction: column; flex-wrap: nowrap; }
.mj.wide .mj-seat { max-width: none; flex: none; }
@@ -443,7 +443,7 @@ const ROT = [0, -90, 180, 90];
function Table({ v, players, width, callout, seen }: { v: MahjongView; players: Record<string, PublicUser>; width: number; callout: ReactNode; seen: Seen | null }) {
// Pond: 6 tiles per row (+ room for one sideways riichi tile) × 4 rows. Table = H + W + H.
// Total width ≈ 2H + W + padding/border = 17·tw + 37.
const tw = Math.max(14, Math.min(30, Math.floor((width - 37) / 17)));
const tw = Math.max(14, Math.min(64, Math.floor((width - 37) / 17)));
const th = Math.round((tw * 4) / 3);
const W = 5 * (tw + 1) + th + 2;
const H = 4 * (th + 1) + 2;
@@ -560,7 +560,7 @@ function MyArea({
const beginner = my.prefs.beginner && v.options.beginnerMode;
const phone = width > 0 && width < 600;
const meldW = phone ? 18 : 26;
const tw = width > 0 ? Math.max(20, Math.min(phone ? 40 : 48, Math.floor((width - 14 - n) / n))) : 40;
const tw = width > 0 ? Math.max(20, Math.min(phone ? 40 : 60, Math.floor((width - 14 - n) / n))) : 40;
const send = (code: string) => {
if (pending) return;
@@ -1153,15 +1153,15 @@ function MahjongBoard({ view: v, me, players, act, pending, deadline, tapConfirm
const phone = width > 0 && width < 600;
// PC: table on the left sized to the screen height, other players on the right, my hand below.
const wide = width >= 900;
const reserve = v.my ? 290 : 20;
const tableWidth = wide ? Math.max(380, Math.min(width - 330, mainH > 0 && wide ? mainH - reserve : 560, 600)) : width || 360;
const reserve = v.my ? 300 : 20;
const tableWidth = wide ? Math.max(380, Math.min(width - 330, mainH > 0 && wide ? mainH - reserve : 560)) : width || 360;
const showTable = v.phase === 'playing' || (v.phase === 'handResult' && !wide);
return (
<div className={`mj${wide ? ' wide' : ''}`} ref={ref}>
<style>{CSS}</style>
<ul className="mj-opps" aria-label="다른 사람">
{others.map((s) => (
<SeatChip key={s.seat} v={v} s={s} players={players} me={me} deadline={deadline} w={phone ? 13 : 18} seen={seen} />
<SeatChip key={s.seat} v={v} s={s} players={players} me={me} deadline={deadline} w={phone ? 13 : wide ? 24 : 18} seen={seen} />
))}
</ul>
<div className="mj-main" style={wide ? { width: tableWidth, maxHeight: mainH > 0 ? mainH - 12 : undefined } : undefined}>

View File

@@ -166,6 +166,15 @@ const CSS = `
@media (prefers-reduced-motion: reduce) {
.mb-cell.pick .mb-pick, .mb-trail, .mb-hop, .mb-die.rolling, .mb-card, .mb-pop, .mb-fly, .mb-ring { animation: none; }
}
/* PC: the square board is as large as the play column allows; the centre (dice, prompt, title) grows with it. */
@media (min-width: 1100px) {
.mb-box { max-width: min(100%, var(--play-h)); }
.mb-title { font-size: clamp(1.5rem, calc(var(--play-h) * .03), 2.4rem); }
.mb-die { width: clamp(60px, calc(var(--play-h) * .07), 92px); height: clamp(60px, calc(var(--play-h) * .07), 92px); }
.mb-dice { min-height: clamp(64px, calc(var(--play-h) * .074), 96px); }
.mb-prompt { max-width: clamp(420px, calc(var(--play-h) * .5), 620px); }
.mb-card { width: min(100%, clamp(320px, calc(var(--play-h) * .36), 440px)); }
}
`;
// ---------------------------------------------------------------- geometry (viewBox 0..1000)

View File

@@ -159,6 +159,18 @@ const CSS = `
.nn-opps { flex-wrap: wrap; justify-content: center; overflow: visible; width: 100%; max-width: calc(var(--cols) * 184px - 4px); margin: 0 auto; }
.nn-seat { flex: 0 1 calc((100% - (var(--cols) - 1) * 8px) / var(--cols)); min-width: 0; max-width: 176px; }
}
/* PC: fill the play column. The felt takes the spare height; dial, hand cards (--nn-dial / --nn-cw) and seats grow with the play area. */
@media (min-width: 1100px) {
.nn { max-width: none; align-self: stretch; flex: 1 1 auto; min-height: 0; gap: 12px;
--nn-dial: min(var(--play-h) * .34, 420px); --nn-cw: min(var(--play-h) * .17, 200px); }
.nn-opps { max-width: calc(var(--cols) * 256px - 4px); }
.nn-seat { max-width: 248px; padding: 8px 12px; font-size: clamp(.9rem, calc(var(--play-h) / 62), 1.1rem); }
.nn-table { flex: 1 1 auto; padding: 20px 28px; font-size: clamp(1rem, calc(var(--play-h) / 62), 1.2rem); }
.nn-hand { gap: clamp(10px, 1.2vw, 20px); }
.nn-table .nn-chip { font-size: .9em; }
.nn-recent li { font-size: .88em; }
.nn-recent .who { max-width: 140px; }
}
@media (max-width: 719px) {
.nn-table { grid-template-columns: 1fr auto; grid-template-areas: 'dial left' 'right right'; padding: 10px; gap: 8px 10px; border-width: 6px; }
.nn-dial { grid-area: dial; }
@@ -273,7 +285,7 @@ function SeatChip({ s, v, players, me, deadline }: { s: SeatView; v: NinetyNineV
function Table({ v, players, me, deadline }: { v: NinetyNineView; players: Record<string, PublicUser>; me: string | null; deadline: number | null }) {
const shown = useCountUp(v.total);
const dial = 'clamp(150px, 20vw, 196px)';
const dial = 'max(clamp(150px, 20vw, 196px), var(--nn-dial, 0px))';
const r = 44;
const c = 2 * Math.PI * r;
const frac = Math.min(1, v.total / 99);
@@ -445,7 +457,7 @@ function MyHand({ v, act, pending }: { v: NinetyNineView; act: (a: unknown) => v
btns[(i + (e.key === 'ArrowRight' ? 1 : btns.length - 1)) % btns.length]?.focus();
};
const n = my.hand.length;
const cw = n <= 3 ? 'clamp(84px, 24vw, 104px)' : n === 4 ? 'clamp(72px, 20vw, 96px)' : 'clamp(62px, 16.5vw, 90px)';
const cw = `max(${n <= 3 ? 'clamp(84px, 24vw, 104px)' : n === 4 ? 'clamp(72px, 20vw, 96px)' : 'clamp(62px, 16.5vw, 90px)'}, var(--nn-cw, 0px))`;
const meSeat = v.seats.find((s) => s.id === v.me);
const legalCount = my.hand.filter((c) => c.legal).length;
return (

View File

@@ -131,8 +131,10 @@ function logText(e: LogEntry, players: Record<string, PublicUser>, me: string |
// ---------------------------------------------------------------- styles
const CSS = `
.om-board { width: 100%; max-width: 1040px; max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px; }
.om-seats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; padding-top: 6px; }
.om-board { width: 100%; max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px; flex: 1 1 auto; min-height: 0; }
.om-board > * { flex: none; }
.om-board > .om-table { flex: 1 0 auto; }
.om-seats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 260px)); justify-content: center; gap: 10px; padding-top: 6px; }
.om-seat { position: relative; background: var(--surface); border-radius: var(--radius-lg); padding: 8px 10px; box-shadow: var(--shadow); border: 3px solid transparent; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.om-seat.turn { border-color: var(--focus); }
.om-seat.target { border-color: var(--primary); border-style: dashed; }
@@ -156,7 +158,7 @@ const CSS = `
.om-mini.empty i { background: none; border-style: dashed; border-color: var(--border); box-shadow: none; }
.om-mini.empty i::after { display: none; }
.om-bubble { position: absolute; right: 8px; top: -12px; background: var(--text); color: var(--surface); border-radius: 12px; padding: 2px 10px; font-weight: 800; font-size: .8rem; box-shadow: var(--shadow); animation: om-pop .25s ease-out; z-index: 2; }
.om-table { position: relative; color: #fff; border-radius: 22px; padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; align-items: center; min-height: 200px;
.om-table { position: relative; color: #fff; border-radius: 22px; padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; min-height: 200px;
background: radial-gradient(ellipse 75% 60% at 50% 36%, rgba(255,255,255,.15), rgba(255,255,255,0) 70%), var(--felt);
border: 6px solid var(--wood); box-shadow: inset 0 0 0 2px rgba(255,255,255,.07), inset 0 0 48px rgba(0,0,0,.32), var(--shadow); }
.om-table .small { color: #fff; opacity: .92; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
@@ -241,8 +243,10 @@ button.om-back[aria-pressed='true'] > .om-face { box-shadow: 0 0 0 3px #fde047,
// ---------------------------------------------------------------- pieces
/** Width of an element, kept up to date (a callback ref, so it follows the element when it is re-created). */
function useWidth<T extends HTMLElement>(): [(node: T | null) => void, number, { current: T | null }] {
/** Width of the node + the play area height on PC (`--play-h` of .game-main, 0 when the page scrolls instead). */
function useWidth<T extends HTMLElement>(): [(node: T | null) => void, number, { current: T | null }, number] {
const [w, setW] = useState(0);
const [h, setH] = useState(0);
const el = useRef<T | null>(null);
const ro = useRef<ResizeObserver | null>(null);
const ref = useCallback((node: T | null) => {
@@ -250,13 +254,28 @@ function useWidth<T extends HTMLElement>(): [(node: T | null) => void, number, {
ro.current = null;
el.current = node;
if (!node) return;
setW(node.clientWidth);
const measure = () => {
setW(node.clientWidth);
setH(parseFloat(getComputedStyle(node).getPropertyValue('--play-h')) || 0);
};
measure();
if (typeof ResizeObserver === 'function') {
ro.current = new ResizeObserver(() => setW(node.clientWidth));
ro.current = new ResizeObserver(measure);
ro.current.observe(node);
const main = node.closest('.game-main');
if (main) ro.current.observe(main);
}
}, []);
return [ref, w, el];
return [ref, w, el, h];
}
/**
* How much bigger than the base size the two card rows (table fan + my hand) can be on a big PC play area: both rows
* share the height left after the seats, titles, notes and buttons (~520px + a row of seats per extra seat line).
*/
function cardGrow(v: OldMaidView, width: number, playH: number): number {
const seatRows = Math.ceil(Math.max(1, v.order.length - 1) / Math.max(1, Math.floor((width + 50) / 270)));
return Math.min(2, Math.max(1, Math.min(width / 900, (playH - 520 - (seatRows - 1) * 110) / 200)));
}
const rowStyle = (l: FanLayout): CSSProperties => ({ '--cw': `${l.cw}px`, '--sw': `${l.step}px` }) as CSSProperties;
@@ -405,7 +424,7 @@ function Fan({ v, me, players, act, pending, tapConfirm, riffle }: { v: OldMaidV
const mine = !!v.my?.canDraw && v.my.from === target;
const count = mine ? v.my!.count : (v.handCounts[target] ?? 0);
const [sel, setSel] = useState<number | null>(null);
const [ref, width, box] = useWidth<HTMLDivElement>();
const [ref, width, box, playH] = useWidth<HTMLDivElement>();
// A new turn, or the owner shuffled / the fan changed: start over.
useEffect(() => setSel(null), [v.turnNo, target, count, v.shuffles[target]]);
// Where every card sits now (relative to the table), so a draw by someone else lifts that very card (useOldMaidFx).
@@ -421,7 +440,8 @@ function Fan({ v, me, players, act, pending, tapConfirm, riffle }: { v: OldMaidV
}),
};
});
const l = fanLayout(count, width, width > 0 && width < 520 ? FAN_PHONE : { ...FAN_PC, wrapCw: count > 12 ? 50 : 60 });
const g = cardGrow(v, width, playH);
const l = fanLayout(count, width, width > 0 && width < 520 ? FAN_PHONE : { cw: Math.round(FAN_PC.cw * g), prefer: Math.round(FAN_PC.prefer * g), wrapCw: Math.round((count > 12 ? 50 : 60) * g) });
const draw = (index: number) => {
if (pending) return;
myDrawRect = box.current?.querySelectorAll('button.om-back')[index]?.querySelector('.om-face')?.getBoundingClientRect() ?? null;
@@ -591,9 +611,11 @@ function MyArea({ v, me, players, act, pending, deadline, fresh, bubble }: { v:
const hand = v.myHand ?? [];
const st = v.status[me];
const cls = ['om-me', v.turn === me ? 'turn anim-glow' : '', v.target === me ? 'target' : ''].filter(Boolean).join(' ');
const [ref, width, box] = useWidth<HTMLDivElement>();
const [ref, width, box, playH] = useWidth<HTMLDivElement>();
const narrow = width > 0 && width < 520;
const l = fanLayout(hand.length, width, { ...(narrow ? HAND_PHONE : HAND_PC), wrapCw: narrow ? (hand.length > 12 ? 44 : 50) : hand.length > 12 ? 52 : 64 });
const g = narrow ? 1 : cardGrow(v, width, playH);
const base = narrow ? HAND_PHONE : HAND_PC;
const l = fanLayout(hand.length, width, { cw: Math.round(base.cw * g), prefer: Math.round(base.prefer * g), wrapCw: Math.round((narrow ? (hand.length > 12 ? 44 : 50) : hand.length > 12 ? 52 : 64) * g) });
// Shuffled (same cards, new order): every card slides with a little hop from its old place to its new one.
const order = hand.join(',');
const pos = useRef<{ order: string; at: Map<string, [number, number]> }>({ order: '', at: new Map() });

View File

@@ -43,6 +43,8 @@ const OMOK_CSS = `
@keyframes om-forbid { 0% { transform: scale(.3); opacity: 0; } 18% { transform: scale(1.25); opacity: 1; } 32% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }
.om-forbid-t { animation: om-forbid-t .9s ease-out both; pointer-events: none; }
@keyframes om-forbid-t { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-.9px); opacity: 0; } }
/* PC: the board takes the whole play-area height minus the row that can show under it (--om-rows). */
@media (min-width: 1100px) { .board-wrap.om-fit { max-width: min(100%, calc(var(--play-h) - var(--om-rows, 0px))); } }
`;
function OmokBoard({ view: v, act, pending, tapConfirm }: BoardProps<OmokView>) {
@@ -153,7 +155,8 @@ function OmokBoard({ view: v, act, pending, tapConfirm }: BoardProps<OmokView>)
const ghost = preview ?? (hover && canPlace(hover) ? hover : null);
const pad = 0.9;
return (
<div className="board-wrap stack" style={{ gap: 10 }}>
// Touch with tap-confirm shows [두기][취소] under the board: keep room for it.
<div className="board-wrap stack om-fit" style={{ gap: 10, '--om-rows': tapConfirm ? 'calc(var(--btn-h) + 10px)' : '0px' } as React.CSSProperties}>
<style>{BOARD_MOTION_CSS + OMOK_CSS}</style>
<svg
ref={svgRef}

View File

@@ -127,6 +127,15 @@ const CSS = `
.oc-opps { flex-wrap: wrap; justify-content: center; overflow: visible; width: 100%; max-width: calc(var(--cols) * 184px - 4px); margin: 0 auto; }
.oc-seat { flex: 0 1 calc((100% - (var(--cols) - 1) * 8px) / var(--cols)); min-width: 0; max-width: 176px; }
}
/* PC: fill the play column. The felt takes the spare height, piles and hand cards grow with the play area, seats get bigger. */
@media (min-width: 1100px) {
.oc { max-width: none; align-self: stretch; flex: 1 1 auto; min-height: 0; gap: 12px; }
.oc-opps { max-width: calc(var(--cols) * 256px - 4px); }
.oc-seat { max-width: 248px; padding: 8px 12px; font-size: clamp(.9rem, calc(var(--play-h) / 62), 1.1rem); }
.oc-table { flex: 1 1 auto; grid-template-columns: 1fr auto auto 1fr; gap: clamp(16px, 2vw, 40px); padding: 20px 28px; font-size: clamp(1rem, calc(var(--play-h) / 62), 1.2rem); }
.oc-table > .oc-pile { grid-column: 2; }
.oc-hand { justify-content: center; }
}
@media (max-width: 719px) {
.oc-table { grid-template-columns: auto auto; padding: 10px; gap: 10px; border-width: 6px; justify-content: center; }
.oc-info { grid-column: 1 / -1; align-items: center; }
@@ -230,7 +239,7 @@ function AttackCount({ n, uno }: { n: number; uno: boolean }) {
function TableArea({ v, players, canDraw, onDraw, onDropCard, fx }: { v: OneCardView; players: Record<string, PublicUser>; canDraw: boolean; onDraw: () => void; onDropCard: (id: string) => void; fx: Fx }) {
const [over, setOver] = useState(false);
const from = fx.playFrom && fx.playFrom.discard === v.discardCount ? fx.playFrom : null;
const pw = 'clamp(64px, 9vw, 92px)';
const pw = 'clamp(64px, min(9vw, var(--play-h) * .15), 210px)';
const recent = v.recent;
const top = recent[recent.length - 1];
const drawText = v.pendingAttack > 0 ? `${v.pendingAttack}장 먹기` : '1장 먹기';
@@ -333,18 +342,26 @@ function TableArea({ v, players, canDraw, onDraw, onDropCard, fx }: { v: OneCard
// ---------------------------------------------------------------- my hand
function useWidth<T extends HTMLElement>(): [React.RefObject<T | null>, number] {
/** Element width plus the PC play-area height (--play-h on .game-main; 0 under 1100px where it is not measured). */
function useWidth<T extends HTMLElement>(): [React.RefObject<T | null>, number, number] {
const ref = useRef<T>(null);
const [w, setW] = useState(0);
const [h, setH] = useState(0);
useLayoutEffect(() => {
const el = ref.current;
if (!el) return;
setW(el.clientWidth);
const ro = new ResizeObserver(() => setW(el.clientWidth));
const main = el.closest('.game-main');
const update = () => {
setW(el.clientWidth);
setH(main && matchMedia('(min-width: 1100px)').matches ? parseFloat(getComputedStyle(main).getPropertyValue('--play-h')) || 0 : 0);
};
update();
const ro = new ResizeObserver(update);
ro.observe(el);
if (main) ro.observe(main);
return () => ro.disconnect();
}, []);
return [ref, w];
return [ref, w, h];
}
interface PickState {
@@ -359,7 +376,7 @@ function MyHand({ v, act, pending, players, arrived }: { v: OneCardView; act: (a
const [hints, setHints] = useState(true);
const [pick, setPick] = useState<PickState | null>(null);
const [note, setNote] = useState('');
const [ref, width] = useWidth<HTMLDivElement>();
const [ref, width, playH] = useWidth<HTMLDivElement>();
const hand = sortHand(my.hand, sortBy);
const legal = new Set(my.legalCardIds);
const turnKey = `${v.turnNo}-${v.phase}`;
@@ -417,7 +434,7 @@ function MyHand({ v, act, pending, players, arrived }: { v: OneCardView; act: (a
// Layout: one overlapping row on wide screens, wrapped rows on phones (cards ≥ 48 × 68).
const n = hand.length;
const phone = width > 0 && width < 600;
const cw = phone ? 54 : 78;
const cw = phone ? 54 : Math.round(Math.min(156, Math.max(78, playH * 0.12)));
let ov = 6;
if (!phone && n > 1) ov = Math.max(-cw * 0.6, Math.min(6, (width - cw * n) / (n - 1)));
if (phone) ov = n > 12 ? -14 : 4;

View File

@@ -33,7 +33,9 @@ const CSS = `
@media (prefers-reduced-motion: reduce) {
.oth-flip { animation: none; }
.oth-old { display: none; }
}`;
}
/* PC: the board takes the whole play-area height minus the disc-count bar and the row that can show under it (--oth-rows). */
@media (min-width: 1100px) { .board-wrap.oth-fit { max-width: min(100%, calc(var(--play-h) - var(--oth-rows, 0px))); } }`;
/** Disc set down, then one light click per disc as it turns over (staggered like the animation). */
function placeSound(flipDelays: number[]) {
@@ -190,7 +192,8 @@ function OthelloBoard({ view: v, act, pending, tapConfirm }: BoardProps<OthelloV
const pad = 0.55;
return (
<div className="board-wrap stack" style={{ gap: 10 }}>
// Disc bar (30px) above; with touch tap-confirm also [두기][취소] under the board.
<div className="board-wrap stack oth-fit" style={{ gap: 10, '--oth-rows': tapConfirm ? 'calc(var(--btn-h) + 50px)' : '40px' } as React.CSSProperties}>
<style>{BOARD_MOTION_CSS + CSS}</style>
<div
aria-label={`돌 수: 흑 ${v.discs.black}개, 백 ${v.discs.white}개`}

View File

@@ -1,5 +1,5 @@
/** 포커 화면 (docs/games/poker.md §9). Chips are room-only play points. */
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
import type { BetActionType, LegalBetView, LogEntry, PokerMode, PokerOptions, PokerView, SeatView, Side, ViewCard } from '@bg/games/poker';
import type { PublicUser } from '@bg/shared/lite';
import { Avatar, ConfirmSheet, Sheet } from '../../components/ui';
@@ -7,6 +7,7 @@ import { TurnTimer } from '../../components/TurnTimer';
import { PLAYING_CARD_CREDIT, PlayingCard } from '../../components/cards/PlayingCard';
import { Chips, PlayChipNotice, formatChips } from '../../components/cards/Chips';
import { haptic, noise, sfx, sounds, tone } from '../../lib/feedback';
import { useWide } from '../../lib/media';
import { bump, cssEsc, flyFrom, flyGhost, fxEl, reducedMotion, seatEl, useBanner, useChange } from '../card-fx';
import type { BoardProps, GameUI, OptionsProps } from '../types';
import { helpNow } from './help';
@@ -60,12 +61,15 @@ const isDrawMode = (m: PokerMode) => m === 'badugi' || m === 'fiveDraw';
/** Rank of a card id for the client-side "A를 남기면 4장" check. */
const isAce = (c: string) => c[0] === 'A';
/** Width of my own (large) cards: 88 px, more on wide PC screens (see PokerBoard). */
const MyCardW = createContext(88);
const CSS = `
.pk-table { position: relative; width: 100%; aspect-ratio: 16 / 11; border-radius: 180px; border: 10px solid var(--wood);
background: radial-gradient(ellipse at center, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 60%), var(--felt); box-shadow: var(--shadow); }
.pk-seat { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); width: var(--seat-w, 172px); z-index: 1;
background: var(--surface); color: var(--text); border-radius: 12px; padding: 6px 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.25);
border: 3px solid transparent; display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; transition: border-color .2s; }
border: 3px solid transparent; display: flex; flex-direction: column; gap: 4px; font-size: calc(0.85rem * var(--pkf, 1)); transition: border-color .2s; }
.pk-seat.turn { border-color: var(--focus); }
.pk-seat.me { border-color: var(--primary); }
.pk-seat.me.turn { border-color: var(--focus); }
@@ -73,7 +77,7 @@ const CSS = `
.pk-seat.out { opacity: 0.6; }
.pk-center { position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%); text-align: center; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); max-width: 52%; }
.pk-board { display: flex; gap: 6px; justify-content: center; margin: 6px 0; }
.pk-slot { width: 64px; height: 90px; border-radius: 8px; border: 2px dashed rgba(255,255,255,.35); flex: none; }
.pk-slot { width: calc(64px * var(--pks, 1)); height: calc(90px * var(--pks, 1)); border-radius: 8px; border: 2px dashed rgba(255,255,255,.35); flex: none; }
.pk-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pk-actions .btn { min-height: 64px; flex-direction: column; gap: 0; padding: 0 8px; line-height: 1.15; font-size: 1.1rem; }
.pk-actions .btn small { font-weight: 600; font-size: .85rem; opacity: .9; }
@@ -83,6 +87,11 @@ const CSS = `
.pk-x::after { content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; color: #dc2626; font-size: 3rem; font-weight: 900; pointer-events: none; }
.pk-raise { display: grid; gap: 8px; }
.pk-raise input[type=range] { width: 100%; min-height: 40px; }
/* PC: the table is as wide as the play column and takes the height my area leaves (seats and cards grow, see PokerBoard). */
@media (min-width: 1100px) {
.pk-wrap.board-wrap { max-width: none; align-self: stretch; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.pk-table { flex: 1 1 0; aspect-ratio: auto; min-height: 420px; }
}
@media (max-width: 719px) {
.pk-table { aspect-ratio: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; border-radius: 20px; border-width: 6px; }
.pk-seat { position: static; transform: none; width: auto; }
@@ -114,7 +123,7 @@ function seatBadges(seat: SeatView, v: PokerView): [string, string][] {
return b;
}
function SeatCards({ seat, v, me }: { seat: SeatView; v: PokerView; me: string | null }) {
function SeatCards({ seat, v, me, k }: { seat: SeatView; v: PokerView; me: string | null; k: number }) {
const sd = v.showdown?.find((e) => e.id === seat.id);
const cards: { c: ViewCard; key: string; title?: string }[] = [];
if (seat.forehead !== undefined) cards.push({ c: seat.forehead, key: 'f', title: seat.forehead ? undefined : seat.id === me ? '내 이마 카드(나만 못 봐요)' : '이마 카드' });
@@ -130,17 +139,17 @@ function SeatCards({ seat, v, me }: { seat: SeatView; v: PokerView; me: string |
<PlayingCard
key={x.key}
card={x.c}
size="sm"
width={Math.round(44 * k)}
highlight={!!x.c && best.has(x.c)}
title={x.title}
style={i > 0 ? { marginLeft: cards.length > 5 ? -24 : -16 } : undefined}
style={i > 0 ? { marginLeft: Math.round((cards.length > 5 ? -24 : -16) * k) } : undefined}
/>
))}
</div>
);
}
function SeatBox({ seat, v, players, me, deadline, x, y }: { seat: SeatView; v: PokerView; players: Record<string, PublicUser>; me: string | null; deadline: number | null; x: number; y: number }) {
function SeatBox({ seat, v, players, me, deadline, x, y, k }: { seat: SeatView; v: PokerView; players: Record<string, PublicUser>; me: string | null; deadline: number | null; x: number; y: number; k: number }) {
const u = userOf(players, seat.id);
const badges = seatBadges(seat, v);
const waiting = v.waiting.includes(seat.id) && v.handPhase !== 'handEnd';
@@ -187,7 +196,7 @@ function SeatBox({ seat, v, players, me, deadline, x, y }: { seat: SeatView; v:
))}
</div>
)}
<SeatCards seat={seat} v={v} me={me} />
<SeatCards seat={seat} v={v} me={me} k={k} />
{!sd && v.foldShown?.id === seat.id && <strong style={{ color: 'var(--primary)', textAlign: 'center' }}>{v.foldShown.handName}</strong>}
{sd && (
<strong style={{ color: 'var(--primary)', textAlign: 'center' }}>
@@ -199,7 +208,7 @@ function SeatBox({ seat, v, players, me, deadline, x, y }: { seat: SeatView; v:
);
}
function CenterInfo({ v, players }: { v: PokerView; players: Record<string, PublicUser> }) {
function CenterInfo({ v, players, k }: { v: PokerView; players: Record<string, PublicUser>; k: number }) {
const limit = v.options.endCondition === 'hands' ? `/${v.options.handLimit}` : '';
const penalty = v.penalties.reduce((a, p) => a + p.amount, 0);
return (
@@ -207,11 +216,11 @@ function CenterInfo({ v, players }: { v: PokerView; players: Record<string, Publ
{v.streetName && <div className="pk-badge" style={{ background: '#fde047', color: '#422006', fontSize: '0.95rem', padding: '2px 12px' }}>{v.streetName}</div>}
{isCommunity(v.mode) && (
<div className="pk-board" aria-label="공용 카드" data-fx="poker-board">
{Array.from({ length: 5 }, (_, i) => (v.board[i] ? <PlayingCard key={v.board[i]} card={v.board[i]!} size="md" /> : <span key={`e${i}`} className="pk-slot" aria-hidden />))}
{Array.from({ length: 5 }, (_, i) => (v.board[i] ? <PlayingCard key={v.board[i]} card={v.board[i]!} width={Math.round(64 * k)} /> : <span key={`e${i}`} className="pk-slot" aria-hidden />))}
</div>
)}
<div style={{ fontSize: '0.95rem', opacity: 0.9 }}>모인 칩</div>
<div style={{ fontSize: '2.2rem', fontWeight: 900, fontVariantNumeric: 'tabular-nums' }} aria-live="polite" data-fx="poker-pot">
<div style={{ fontSize: `${(2.2 * (1 + (k - 1) / 2)).toFixed(2)}rem`, fontWeight: 900, fontVariantNumeric: 'tabular-nums' }} aria-live="polite" data-fx="poker-pot">
{formatChips(v.pot)}
</div>
{v.pots.length > 1 && (
@@ -249,6 +258,24 @@ function PokerBoard({ view: v, me, players, act, pending, deadline }: BoardProps
const showKey = `${v.handNo}-${v.handPhase}`;
const [banner, showBanner] = useBanner();
usePokerFx(v, me, players, showBanner);
// PC: seats, cards and the pot grow with the table (1 at the old 890×600 table, up to 1.6×).
const wide = useWide();
const tableRef = useRef<HTMLDivElement | null>(null);
const [[tableW, tableH], setTableSize] = useState([890, 600]);
useLayoutEffect(() => {
const el = tableRef.current;
if (!el) return undefined;
const measure = () => setTableSize([el.clientWidth, el.clientHeight]);
const ro = new ResizeObserver(measure);
ro.observe(el);
measure();
return () => ro.disconnect();
}, []);
const k = wide ? Math.min(1.6, Math.max(1, Math.min(tableW / 890, tableH / 600))) : 1;
// My cards follow the width only (my area's height decides the table's height, so no loop).
const lgW = Math.round(88 * (wide ? Math.min(1.4, Math.max(1, tableW / 1300)) : 1));
// Seats (≈170 px × k tall, centred on the oval) stay inside the felt when the table is short and wide.
const ry = wide ? Math.max(28, Math.min(38, 50 - ((85 * k + 6) / Math.max(1, tableH)) * 100)) : 38;
useEffect(() => {
if (mine && !prevWaiting.current) {
@@ -266,22 +293,35 @@ function PokerBoard({ view: v, me, players, act, pending, deadline }: BoardProps
}, [showKey]); // eslint-disable-line react-hooks/exhaustive-deps
return (
<div className="board-wrap stack" style={{ gap: 12 }}>
<style>{CSS}</style>
<div className="pk-table" role="region" aria-label="포커 테이블" style={{ '--seat-w': n > 6 ? '150px' : '176px' } as React.CSSProperties}>
{v.seats.map((s, i) => {
const rel = (i - myIdx + n) % n;
const ang = Math.PI / 2 + (rel * 2 * Math.PI) / n;
return <SeatBox key={s.id} seat={s} v={v} players={players} me={me} deadline={deadline} x={50 + 40 * Math.cos(ang)} y={50 + 38 * Math.sin(ang)} />;
})}
<CenterInfo v={v} players={players} />
<MyCardW.Provider value={lgW}>
<div className="pk-wrap board-wrap stack" style={{ gap: 12 }}>
<style>{CSS}</style>
<div
className="pk-table"
ref={tableRef}
role="region"
aria-label="포커 테이블"
style={{ '--seat-w': `${Math.round((n > 6 ? 150 : 176) * k)}px`, '--pks': k.toFixed(2), '--pkf': (1 + (k - 1) / 2).toFixed(2) } as React.CSSProperties}
>
{v.seats.map((s, i) => {
const rel = (i - myIdx + n) % n;
const ang = Math.PI / 2 + (rel * 2 * Math.PI) / n;
// PC: pull side seats toward the table's corners so a short, wide table keeps them apart.
const c = Math.cos(ang);
const sn = Math.sin(ang);
const cx = wide ? Math.sign(c) * Math.abs(c) ** 0.7 : c;
const sy = wide ? Math.sign(sn) * Math.abs(sn) ** 0.7 : sn;
return <SeatBox key={s.id} seat={s} v={v} players={players} me={me} deadline={deadline} x={50 + 40 * cx} y={50 + ry * sy} k={k} />;
})}
<CenterInfo v={v} players={players} k={k} />
</div>
<MyArea v={v} me={me} players={players} act={act} pending={pending} />
<p className="sr-only" aria-live="polite">
{announce}
</p>
{banner}
</div>
<MyArea v={v} me={me} players={players} act={act} pending={pending} />
<p className="sr-only" aria-live="polite">
{announce}
</p>
{banner}
</div>
</MyCardW.Provider>
);
}
@@ -693,25 +733,26 @@ function RevealBox({ v, act, pending }: { v: PokerView; act: (a: unknown) => voi
}
function MyCards({ v, seat }: { v: PokerView; seat: SeatView }) {
const lgW = useContext(MyCardW);
const sd = v.showdown?.find((e) => e.id === seat.id);
const best = new Set(sd?.best ?? []);
return (
<div className="pk-mine" aria-label="내 카드" data-fx="poker-mine">
{seat.forehead !== undefined && (
<div className="stack" style={{ gap: 2, alignItems: 'center' }} data-slot="f">
<PlayingCard card={seat.forehead} size="lg" title={seat.forehead ? undefined : '내 이마 카드(나만 못 봐요)'} />
<PlayingCard card={seat.forehead} width={lgW} title={seat.forehead ? undefined : '내 이마 카드(나만 못 봐요)'} />
<span className="small muted">이마</span>
</div>
)}
{seat.hole.map((c, i) => (
<div key={`h${i}`} className="stack" style={{ gap: 2, alignItems: 'center' }} data-slot={c ?? `h${i}`}>
<PlayingCard card={c} size="lg" highlight={!!c && best.has(c)} />
<PlayingCard card={c} width={lgW} highlight={!!c && best.has(c)} />
{(isSevenMode(v.mode) || v.mode === 'indian') && <span className="small muted">{v.mode === 'indian' ? '손' : '나만 봄'}</span>}
</div>
))}
{seat.up.map((c, i) => (
<div key={`u${i}`} className="stack" style={{ gap: 2, alignItems: 'center' }} data-slot={c ?? `u${i}`}>
<PlayingCard card={c} size="lg" highlight={!!c && best.has(c)} />
<PlayingCard card={c} width={lgW} highlight={!!c && best.has(c)} />
<span className="small muted">공개</span>
</div>
))}
@@ -723,6 +764,7 @@ function MyCards({ v, seat }: { v: PokerView; seat: SeatView }) {
function ChoicePicker({ cards, act, pending }: { cards: string[]; act: (a: unknown) => void; pending: boolean }) {
const [discard, setDiscard] = useState<string | null>(null);
const [open, setOpen] = useState<string | null>(null);
const lgW = useContext(MyCardW);
const tap = (c: string) => {
sfx.select();
if (!discard) setDiscard(c);
@@ -741,7 +783,7 @@ function ChoicePicker({ cards, act, pending }: { cards: string[]; act: (a: unkno
<div className="pk-mine" data-fx="poker-mine">
{cards.map((c) => (
<span key={c} className={c === discard ? 'pk-x' : undefined} data-slot={c}>
<PlayingCard card={c} size="lg" selected={c === open} dimmed={c === discard} onClick={() => tap(c)} title={c === discard ? '버릴 카드(다시 누르면 취소)' : c === open ? '보여 줄 카드' : undefined} />
<PlayingCard card={c} width={lgW} selected={c === open} dimmed={c === discard} onClick={() => tap(c)} title={c === discard ? '버릴 카드(다시 누르면 취소)' : c === open ? '보여 줄 카드' : undefined} />
</span>
))}
</div>
@@ -768,6 +810,7 @@ function ChoicePicker({ cards, act, pending }: { cards: string[]; act: (a: unkno
/** 교환(바둑이 / 5카드 드로우): tap to lift the cards to change. */
function DrawPicker({ v, hole, act, pending }: { v: PokerView; hole: string[]; act: (a: unknown) => void; pending: boolean }) {
const [sel, setSel] = useState<string[]>([]);
const lgW = useContext(MyCardW);
const { drawMax, drawAceBonus } = v.my;
const keepsAce = hole.some((c) => isAce(c) && !sel.includes(c));
const limit = drawAceBonus && keepsAce ? drawMax + 1 : drawMax;
@@ -785,7 +828,7 @@ function DrawPicker({ v, hole, act, pending }: { v: PokerView; hole: string[]; a
</p>
<div className="pk-mine">
{hole.map((c) => (
<PlayingCard key={c} card={c} size="lg" selected={sel.includes(c)} onClick={() => {
<PlayingCard key={c} card={c} width={lgW} selected={sel.includes(c)} onClick={() => {
sfx.select();
setSel((s) => (s.includes(c) ? s.filter((x) => x !== c) : [...s, c]));
}}

View File

@@ -68,7 +68,31 @@ const CSS = `
@media (prefers-reduced-motion: reduce) {
.qd-pawn { transition: none; }
.qd-wall-new, .qd-turn-ring { animation: none; }
}`;
}
.board-wrap.qd-side { flex-direction: row; align-items: center; justify-content: center; gap: 20px; }
.qd-side > .qd-rows { flex: 0 1 380px; min-width: 0; }
.qd-side .qd-modes { grid-template-columns: 1fr; }
.qd-rows:empty { display: none; }`;
/** PC play-area size (.game-main, px), null under 1100px where the page scrolls and rows stay under the board. */
function useWideMain(ref: React.RefObject<HTMLElement | null>) {
const [size, setSize] = useState<{ w: number; h: number } | null>(null);
useLayoutEffect(() => {
const main = ref.current?.closest<HTMLElement>('.game-main');
if (!main) return;
const wide = matchMedia('(min-width: 1100px)');
const update = () => setSize(wide.matches ? { w: main.clientWidth, h: main.clientHeight } : null);
update();
const ro = new ResizeObserver(update);
ro.observe(main);
wide.addEventListener('change', update);
return () => {
ro.disconnect();
wide.removeEventListener('change', update);
};
}, [ref]);
return size;
}
/** 판 돌리기: 모델 좌표(x 오른쪽, y 위쪽, 0~9) ↔ 화면 좌표(y 아래쪽). 네 가지 모두 자기 자신이 역변환. */
function makeTf(seat: Seat | null) {
@@ -159,6 +183,8 @@ function QuoridorBoard({ view: v, players, act, pending, tapConfirm }: BoardProp
const [cursor, setCursor] = useState<Pt>({ x: 4, y: 8 });
const [kbd, setKbd] = useState(false);
const [announce, setAnnounce] = useState('');
const wrapRef = useRef<HTMLDivElement>(null);
const main = useWideMain(wrapRef);
const svgRef = useRef<SVGSVGElement>(null);
const prevCount = useRef(v.moveCount);
const [shake, setShake] = useState(0);
@@ -383,14 +409,25 @@ function QuoridorBoard({ view: v, players, act, pending, tapConfirm }: BoardProp
return { x: N - off - w, y: 0, width: w, height: N };
};
// PC: the board fills the play-area height. The rows (mode buttons, wall tray, hint) go beside it when that gives a
// bigger board than stacking them under it (which needs about `under` px of height).
const under = me ? (tapConfirm ? 190 : 175) : 60;
const besideW = main ? Math.floor(Math.min(main.w - 320, main.h)) : 0;
const stackW = main ? Math.floor(Math.min(main.w, main.h - under)) : 0;
const beside = !!main && besideW > stackW;
return (
<div className="board-wrap stack" style={{ gap: 10, maxWidth: 'min(100%, calc(100vh - 340px))', minWidth: 'min(100%, 300px)' }}>
<div
ref={wrapRef}
className={`board-wrap stack${beside ? ' qd-side' : ''}`}
style={{ gap: 10, maxWidth: beside ? 'none' : main ? `min(100%, ${stackW}px)` : 'min(100%, calc(100vh - 340px))', minWidth: 'min(100%, 300px)' }}
>
<style>{BOARD_MOTION_CSS + CSS}</style>
<svg
ref={svgRef}
className="qd-board"
viewBox={`${-PAD} ${-PAD} ${N + 2 * PAD} ${N + 2 * PAD}`}
style={{ width: '100%', display: 'block', background: 'var(--wood)', borderRadius: 14, touchAction: 'manipulation', cursor: myTurn ? 'pointer' : 'default', boxShadow: 'var(--shadow)' }}
style={{ width: '100%', display: 'block', background: 'var(--wood)', borderRadius: 14, touchAction: 'manipulation', cursor: myTurn ? 'pointer' : 'default', boxShadow: 'var(--shadow)', ...(beside && { flex: '0 0 auto', width: besideW }) }}
data-my-seat={v.mySeat ?? ''}
data-mode={mode}
data-path={path && v.myShortestPath ? v.myShortestPath.map(label).join(' ') : ''}
@@ -564,61 +601,63 @@ function QuoridorBoard({ view: v, players, act, pending, tapConfirm }: BoardProp
<p className="sr-only" aria-live="polite">
{announce}
</p>
{me && v.phase === 'playing' && me.status === 'playing' && (
<div className="qd-modes" role="group" aria-label="할 일 고르기">
<button type="button" className={`btn ${mode === 'move' ? 'btn-primary' : 'btn-secondary'}`} aria-pressed={mode === 'move'} disabled={!myTurn} onClick={() => setModeTo('move')}>
🚶 말 움직이기
</button>
<button type="button" className={`btn ${mode === 'wall' ? 'btn-primary' : 'btn-secondary'}`} aria-pressed={mode === 'wall'} disabled={!canWall} onClick={() => setModeTo('wall')}>
🧱 벽 세우기 ({wallsLeft}개)
</button>
</div>
)}
{myTurn && mode === 'wall' && (
<div className="qd-tray">
<span className={`qd-hint small${preview?.why ? ' bad' : ''}`} role="status">
{!preview
? '판의 홈(칸 사이) 교차점을 눌러 벽 자리를 골라요.'
: preview.why
? `${wallText(preview.wall, t.swap)}: ${preview.why}`
: `${wallText(preview.wall, t.swap)} · 상대 길 +${preview.legal!.opp}칸${preview.legal!.me ? ` · 내 길 +${preview.legal!.me}칸` : ''}`}
</span>
<button type="button" className="btn btn-secondary qd-rotate" onClick={() => {
const o = orient === 'h' ? 'v' : 'h';
setOrient(o);
if (wallAt) pinWall(wallAt, o);
}} aria-label={`벽 방향 바꾸기, 지금 ${orient === 'h' ? '가로' : '세로'}`}>
↻ {orient === 'h' ? '가로' : '세로'}
</button>
<button type="button" className="btn btn-primary qd-confirm" disabled={!previewAnchor || !!preview?.why || pending} onClick={() => previewAnchor && doWall(previewAnchor)}>
벽 세우기 확인
</button>
</div>
)}
{myTurn && mode === 'move' && movePreview && (
<div className="row">
<button className="btn btn-primary" style={{ flex: 2 }} disabled={pending} onClick={() => doMove(movePreview)}>
{label(t.screenToCell(movePreview))}으로 이동
</button>
<button className="btn btn-secondary" style={{ flex: 1 }} onClick={() => setMovePreview(null)}>
취소
</button>
</div>
)}
{me && v.phase === 'playing' && !(myTurn && mode === 'wall') && (
<p className="small muted" style={{ margin: 0, textAlign: 'center' }}>
{me.status === 'playing'
? `내 말은 ${COLOR_KO[me.seat]}(${SEAT_KO[me.seat]})이에요. ${myGoal} 줄(${COLOR_KO[me.seat]} 띠)에 먼저 닿으면 이겨요.`
: me.status === 'finished'
? '목표에 도착했어요! 남은 사람들의 순위가 정해질 때까지 지켜봐요.'
: '게임에서 빠졌어요. 계속 지켜볼 수 있어요.'}
</p>
)}
{!me && (
<p className="small muted" style={{ margin: 0, textAlign: 'center' }}>
{v.seats.map((x) => `${nick(x.playerId)}: ${COLOR_KO[x.seat]} → ${SIDE_KO[t.goalSide(x.seat)]} 줄`).join(' · ')}
</p>
)}
<div className="stack qd-rows" style={{ gap: 10 }}>
{me && v.phase === 'playing' && me.status === 'playing' && (
<div className="qd-modes" role="group" aria-label="할 일 고르기">
<button type="button" className={`btn ${mode === 'move' ? 'btn-primary' : 'btn-secondary'}`} aria-pressed={mode === 'move'} disabled={!myTurn} onClick={() => setModeTo('move')}>
🚶 말 움직이기
</button>
<button type="button" className={`btn ${mode === 'wall' ? 'btn-primary' : 'btn-secondary'}`} aria-pressed={mode === 'wall'} disabled={!canWall} onClick={() => setModeTo('wall')}>
🧱 벽 세우기 ({wallsLeft}개)
</button>
</div>
)}
{myTurn && mode === 'wall' && (
<div className="qd-tray">
<span className={`qd-hint small${preview?.why ? ' bad' : ''}`} role="status">
{!preview
? '판의 홈(칸 사이) 교차점을 눌러 벽 자리를 골라요.'
: preview.why
? `${wallText(preview.wall, t.swap)}: ${preview.why}`
: `${wallText(preview.wall, t.swap)} · 상대 길 +${preview.legal!.opp}칸${preview.legal!.me ? ` · 내 길 +${preview.legal!.me}칸` : ''}`}
</span>
<button type="button" className="btn btn-secondary qd-rotate" onClick={() => {
const o = orient === 'h' ? 'v' : 'h';
setOrient(o);
if (wallAt) pinWall(wallAt, o);
}} aria-label={`벽 방향 바꾸기, 지금 ${orient === 'h' ? '가로' : '세로'}`}>
↻ {orient === 'h' ? '가로' : '세로'}
</button>
<button type="button" className="btn btn-primary qd-confirm" disabled={!previewAnchor || !!preview?.why || pending} onClick={() => previewAnchor && doWall(previewAnchor)}>
벽 세우기 확인
</button>
</div>
)}
{myTurn && mode === 'move' && movePreview && (
<div className="row">
<button className="btn btn-primary" style={{ flex: 2 }} disabled={pending} onClick={() => doMove(movePreview)}>
{label(t.screenToCell(movePreview))}으로 이동
</button>
<button className="btn btn-secondary" style={{ flex: 1 }} onClick={() => setMovePreview(null)}>
취소
</button>
</div>
)}
{me && v.phase === 'playing' && !(myTurn && mode === 'wall') && (
<p className="small muted" style={{ margin: 0, textAlign: 'center' }}>
{me.status === 'playing'
? `내 말은 ${COLOR_KO[me.seat]}(${SEAT_KO[me.seat]})이에요. ${myGoal} 줄(${COLOR_KO[me.seat]} 띠)에 먼저 닿으면 이겨요.`
: me.status === 'finished'
? '목표에 도착했어요! 남은 사람들의 순위가 정해질 때까지 지켜봐요.'
: '게임에서 빠졌어요. 계속 지켜볼 수 있어요.'}
</p>
)}
{!me && (
<p className="small muted" style={{ margin: 0, textAlign: 'center' }}>
{v.seats.map((x) => `${nick(x.playerId)}: ${COLOR_KO[x.seat]} → ${SIDE_KO[t.goalSide(x.seat)]} 줄`).join(' · ')}
</p>
)}
</div>
</div>
);
}

View File

@@ -175,6 +175,9 @@ button.rk-tile:disabled { cursor: default; }
.rk-result { display: grid; gap: 6px; }
.rk-result-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rk-mini { display: inline-flex; gap: 2px; flex-wrap: wrap; }
@media (min-width: 1100px) {
.rk-rack .rk-tile { --w: clamp(44px, var(--play-w) * .036, 58px); --h: calc(var(--w) * 1.36); }
}
@media (max-width: 1099px) {
.rk-table { min-height: 160px; }
}
@@ -331,7 +334,7 @@ function RummikubBoard({ view: v, me, players, act, pending, deadline }: BoardPr
const z = Number(localStorage.getItem('rk-zoom'));
return ZOOMS.includes(z) ? z : null;
});
const [boxW, setBoxW] = useState(0);
const [box, setBox] = useState({ w: 0, h: 0 });
const [msg, setMsg] = useState('');
const [confirm, setConfirm] = useState<null | 'draw' | 'commit'>(null);
const [announce, setAnnounce] = useState('');
@@ -383,19 +386,23 @@ function RummikubBoard({ view: v, me, players, act, pending, deadline }: BoardPr
// First-meld progress from what is on the board right now (new sets made of rack tiles only).
const meldNow = groups.filter((g) => g.ok && g.tileIds.every((id) => !onTable0.has(id))).reduce((a, g) => a + g.points, 0);
// Grid size: fit the width, zoom in on small screens (the board scrolls).
// Grid size: fit the width, zoom in on small screens (the board scrolls). On PC (fixed-height play area) the cells
// may grow past 64px as long as the first MIN_ROWS rows still fit the height.
useLayoutEffect(() => {
const el = boxRef.current;
if (!el) return;
setBoxW(el.clientWidth);
const wide = window.matchMedia('(min-width: 1100px)');
const update = () => setBox({ w: el.clientWidth, h: wide.matches ? el.clientHeight : 0 });
update();
if (typeof ResizeObserver === 'undefined') return;
const ro = new ResizeObserver(() => setBoxW(el.clientWidth));
const ro = new ResizeObserver(update);
ro.observe(el);
return () => ro.disconnect();
}, []);
const fit = boxW ? Math.floor((boxW - 2) / BOARD_COLS) : 36;
const fit = box.w ? Math.floor((box.w - 2) / BOARD_COLS) : 36;
const fitH = box.h ? Math.floor((box.h - 2) / MIN_ROWS / 1.36) : 0;
const z = zoom ?? (fit >= 30 ? 1 : fit >= 21 ? 1.5 : 2);
const cw = Math.max(16, Math.min(64, Math.round(fit * z)));
const cw = Math.max(16, Math.min(100, Math.round(Math.max(Math.min(fit, 64), Math.min(fit, fitH)) * z)));
const ch = Math.round(cw * 1.36);
const lowest = cells.reduce((m, x) => Math.max(m, x.r), -1);
const rows = Math.min(BOARD_ROWS, Math.max(MIN_ROWS, lowest + 2 + (hand ? 1 : 0)));

View File

@@ -86,7 +86,7 @@ function bannerOf(v: SeotdaView): string | null {
const isBig = (name: string) => /광땡|땡$|장땡/.test(name) && name !== '땡잡이';
const CSS = `
.sd-wrap { width: 100%; max-width: 1060px; display: flex; flex-direction: column; gap: 12px; align-self: center; container: sd / inline-size; }
.sd-wrap { width: 100%; display: flex; flex-direction: column; gap: 12px; align-self: stretch; container: sd / inline-size; }
/* 테이블: 사이트 공용 펠트·나무 색(다크 모드 따라감) 위에 화투판 담요 같은 마름모 무늬. */
.sd-table { position: relative; width: 100%; aspect-ratio: 16 / 7.2; min-height: 370px; border-radius: 36px; border: 10px solid var(--wood);
background:
@@ -95,18 +95,18 @@ const CSS = `
repeating-linear-gradient(-45deg, rgba(255,255,255,.045) 0 2px, transparent 2px 18px),
var(--felt);
box-shadow: inset 0 0 0 2px var(--wood-line), inset 0 0 50px rgba(0,0,0,.28), var(--shadow); }
.sd-table::before { content: ''; position: absolute; left: 50%; top: 48%; width: 300px; height: 190px; transform: translate(-50%, -50%); border-radius: 50%;
.sd-table::before { content: ''; position: absolute; left: 50%; top: 48%; width: calc(300px * var(--sds, 1)); height: calc(190px * var(--sds, 1)); transform: translate(-50%, -50%); border-radius: 50%;
border: 2px dashed rgba(255,255,255,.16); background: rgba(0,0,0,.08); pointer-events: none; }
.sd-seat { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); width: 160px; z-index: 2;
.sd-seat { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); width: calc(160px * var(--sdseat, 1)); z-index: 2;
background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 7px 9px; display: flex; flex-direction: column; gap: 3px;
border: 2px solid transparent; box-shadow: var(--shadow), 0 4px 14px rgba(0,0,0,.18); font-size: .82rem; transition: border-color .2s, opacity .2s, box-shadow .2s; }
border: 2px solid transparent; box-shadow: var(--shadow), 0 4px 14px rgba(0,0,0,.18); font-size: calc(.82rem * var(--sdf, 1)); transition: border-color .2s, opacity .2s, box-shadow .2s; }
.sd-seat.turn { border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 35%, transparent), 0 4px 14px rgba(0,0,0,.18); }
.sd-seat.out { opacity: .6; }
.sd-seat.win { border-color: #eab308; box-shadow: 0 0 0 4px rgba(234,179,8,.4), 0 0 22px rgba(234,179,8,.45); }
.sd-seat .nm { font-weight: 800; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-seat .sub { color: var(--text-sub); }
.sd-money { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--warning); white-space: nowrap; }
.sd-cards { display: flex; justify-content: center; min-height: 52px; align-items: flex-end; margin-top: -26px; }
.sd-cards { display: flex; justify-content: center; min-height: 52px; align-items: flex-end; margin-top: calc(-26px * var(--sdseat, 1)); }
.sd-tag { display: inline-block; border-radius: 999px; padding: 0 7px; font-weight: 800; font-size: .74rem; line-height: 1.5; white-space: nowrap; }
.sd-act { position: absolute; top: -12px; right: -8px; z-index: 3; border-radius: 999px; padding: 1px 10px; font-weight: 900; font-size: .85rem; color: #fff;
box-shadow: 0 2px 6px rgba(0,0,0,.3); pointer-events: none; }
@@ -120,7 +120,7 @@ const CSS = `
.sd-delta.plus { color: var(--success); } .sd-delta.minus { color: var(--danger); }
.sd-center { position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%); text-align: center; color: #fff; z-index: 1; min-width: 220px; }
.sd-pot-label { display: inline-block; font-size: .85rem; font-weight: 800; letter-spacing: .12em; background: rgba(255,255,255,.18); border-radius: 999px; padding: 1px 12px; }
.sd-pot { font-size: 2.3rem; font-weight: 900; font-variant-numeric: tabular-nums; color: #fde68a; text-shadow: 0 2px 6px rgba(0,0,0,.45); line-height: 1.15; }
.sd-pot { font-size: calc(2.3rem * var(--sdf, 1)); font-weight: 900; font-variant-numeric: tabular-nums; color: #fde68a; text-shadow: 0 2px 6px rgba(0,0,0,.45); line-height: 1.15; }
.sd-pile { position: relative; height: 34px; width: 120px; margin: 0 auto 2px; }
.sd-pile i { position: absolute; bottom: 0; width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff7c2, #f5b301 55%, #b45309);
border: 2px solid #92400e; box-shadow: 0 2px 3px rgba(0,0,0,.4); }
@@ -196,6 +196,11 @@ button.sd-combo[aria-pressed='true'] { outline: 3px solid #93c5fd; outline-offse
.sd-bet.on:active { transform: translateY(1px); }
:root[data-theme='dark'] .sd-bet.on .lb { color: color-mix(in srgb, var(--c) 55%, #fff); }
.sd-help { margin: 0; text-align: center; min-height: 1.4em; }
/* PC: the table takes all the height the dock leaves (seats and cards grow with it, see SeotdaBoard). */
@media (min-width: 1100px) {
.sd-wrap { flex: 1 1 auto; min-height: 0; }
.sd-table { flex: 1 1 0; aspect-ratio: auto; }
}
@container sd (max-width: 899px) {
.sd-dock { flex-wrap: wrap; }
.sd-jokbo { order: 3; flex: 1 1 100%; }
@@ -230,11 +235,45 @@ button.sd-combo[aria-pressed='true'] { outline: 3px solid #93c5fd; outline-offse
// ---------------------------------------------------------------- table positions
/** Seats other than mine around the table (mine is the bar below it): from my left, over the top, to my right (PC). */
function seatPos(rel: number, others: number): { x: number; y: number } {
const t = rel / (others + 1);
const ang = ((160 + t * 220) * Math.PI) / 180;
return { x: 50 + 39 * Math.cos(ang), y: 52 + 33 * Math.sin(ang) };
/**
* Seats other than mine around the table (mine is the bar below it): from my left, over the top, to my right (PC).
* They sit on an ellipse kept inside the W×H felt for a seat of `seatW` px, spaced evenly by arc length (equal angles
* would bunch them up at the left and right ends of a wide table). Returns percentages of the table.
*/
function seatPos(rel: number, others: number, w = 1040, h = 457, seatW = 160): { x: number; y: number } {
const rx = Math.max(10, w / 2 - seatW / 2 - 12);
const ry = Math.max(10, h / 2 - seatW * 0.56 - 8); // box ≈ 0.8 × seatW tall, cards stick out 0.16 × seatW above
const a0 = (135 * Math.PI) / 180;
const span = (270 * Math.PI) / 180;
const at = (k: number) => [rx * Math.cos(a0 + span * k), ry * Math.sin(a0 + span * k)] as const;
const steps = 96;
const len: number[] = [0];
for (let i = 1; i <= steps; i++) {
const [x0, y0] = at((i - 1) / steps);
const [x1, y1] = at(i / steps);
len.push(len[i - 1]! + Math.hypot(x1 - x0, y1 - y0));
}
const goal = (len[steps]! * rel) / (others + 1);
let i = 1;
while (i < steps && len[i]! < goal) i++;
const k = (i - 1 + (goal - len[i - 1]!) / (len[i]! - len[i - 1]! || 1)) / steps;
const [x, y] = at(k);
return { x: 50 + (x / w) * 100, y: 50 + (y / h) * 100 };
}
/**
* Widest seat (px) at which neighbouring seats on a W×H table don't overlap: apart sideways by the width or
* up/down by the height (a seat with its cards is about 0.8 as tall as wide), with an 8px gap.
*/
function seatFit(w: number, h: number, rels: number[], others: number, seatW: number): number {
const pts = rels.map((r) => seatPos(r, others, w, h, seatW)).map((p) => [(p.x * w) / 100, (p.y * h) / 100] as const);
let fit = Infinity;
for (let i = 1; i < pts.length; i++) {
const dx = Math.abs(pts[i]![0] - pts[i - 1]![0]);
const dy = Math.abs(pts[i]![1] - pts[i - 1]![1]);
fit = Math.min(fit, Math.max(dx - 8, (dy - 8) / 0.8));
}
return fit;
}
/** Pile of coins in the middle; more coins for a bigger 판돈 (up to 9). */
@@ -620,6 +659,8 @@ interface DockProps {
winner: boolean;
setRef: SeatProps['setRef'];
phone: boolean;
/** My card size factor (PC: grows with the table width). */
scale: number;
}
/**
@@ -627,7 +668,7 @@ interface DockProps {
* them, then the number-key bet buttons. In 3장 섯다 the cards themselves are clicked to pick the open card / the two
* cards to use, and the bet buttons make room for that step's button.
*/
function Dock({ view: v, seat, players, act, pending, deadline, winner, setRef, phone }: DockProps) {
function Dock({ view: v, seat, players, act, pending, deadline, winner, setRef, phone, scale }: DockProps) {
const [pick, setPick] = useState<number[]>([]);
useEffect(() => setPick([]), [v.handNo, v.rematchNo, v.handPhase]);
const [hover, setHover] = useState<BetType | null>(null);
@@ -645,7 +686,7 @@ function Dock({ view: v, seat, players, act, pending, deadline, winner, setRef,
const choosing = !!seat && v.handPhase === 'choose' && seat.chosen === false;
const revealing = !!v.reveal?.mine;
const playing = !!seat && seat.inHand && !seat.folded;
const w = phone ? (cards.length > 2 ? 62 : 74) : cards.length > 2 ? 76 : 88;
const w = phone ? (cards.length > 2 ? 62 : 74) : Math.round((cards.length > 2 ? 76 : 88) * scale);
const tag = `${v.handNo}-${v.rematchNo}`;
// While a card is still face down, don't give away the new 족보.
const h = peeking ? null : v.myHand;
@@ -900,7 +941,25 @@ export function SeotdaBoard({ view: v, me, players, act, pending, deadline }: Bo
if (v.foldWin) winners.add(v.foldWin.winner);
for (const p of v.showdown?.pots ?? []) if (p.type !== 'rematch') for (const w of p.winners) winners.add(w);
}
const cardW = phone ? (v.threeCard ? 24 : 28) : v.threeCard ? 38 : 46;
// PC: seats, cards and the pot grow with the table (1 at the old 1040×457 felt, up to 1.8×); my cards with its width.
const [[tableW, tableH], setTableSize] = useState([1040, 457]);
useLayoutEffect(() => {
const el = tableRef.current;
if (!el) return undefined;
const measure = () => setTableSize([el.clientWidth, el.clientHeight]);
const ro = new ResizeObserver(measure);
ro.observe(el);
measure();
return () => ro.disconnect();
}, []);
const scale = phone ? 1 : Math.min(1.8, Math.max(1, Math.min(tableW / 1040, tableH / 457)));
const dockScale = phone ? 1 : Math.min(1.35, Math.max(1, tableW / 1040));
// Seats (and their cards) shrink below that when many of them would overlap on the arc (7–8 players).
const seatRel = (rel: number) => (mySeat ? rel : rel + 1);
const seatOthers = mySeat ? n - 1 : n;
const rels = others.map((o) => seatRel(o.rel));
const seatScale = phone ? 1 : Math.max(0.7, Math.min(scale, seatFit(tableW, tableH, rels, seatOthers, 160 * scale) / 160));
const cardW = phone ? (v.threeCard ? 24 : 28) : Math.round((v.threeCard ? 38 : 46) * seatScale);
const cols = phone ? (others.length > 4 ? 3 : 2) : 0;
const othersEls: ReactNode = others.map(({ s, rel }) => (
<Seat
@@ -910,7 +969,7 @@ export function SeotdaBoard({ view: v, me, players, act, pending, deadline }: Bo
players={players}
me={me}
deadline={deadline}
pos={phone ? null : seatPos(mySeat ? rel : rel + 1, mySeat ? n - 1 : n)}
pos={phone ? null : seatPos(seatRel(rel), seatOthers, tableW, tableH, 160 * seatScale)}
cardW={cardW}
winner={winners.has(s.id)}
setRef={setRef}
@@ -919,7 +978,7 @@ export function SeotdaBoard({ view: v, me, players, act, pending, deadline }: Bo
return (
<div className="sd-wrap">
<style>{CSS}</style>
<div className="sd-table" ref={tableRef} role="region" aria-label="섯다 테이블">
<div className="sd-table" ref={tableRef} role="region" aria-label="섯다 테이블" style={{ '--sds': scale.toFixed(2), '--sdseat': seatScale.toFixed(2), '--sdf': (1 + (scale - 1) / 2).toFixed(2) } as CSSProperties}>
{phone ? (
<div className="sd-others" style={{ '--cols': cols } as CSSProperties}>
{othersEls}
@@ -937,7 +996,7 @@ export function SeotdaBoard({ view: v, me, players, act, pending, deadline }: Bo
</div>
)}
</div>
<Dock view={v} seat={mySeat} players={players} act={act} pending={pending} deadline={deadline} winner={!!mySeat && winners.has(mySeat.id)} setRef={setRef} phone={phone} />
<Dock view={v} seat={mySeat} players={players} act={act} pending={pending} deadline={deadline} winner={!!mySeat && winners.has(mySeat.id)} setRef={setRef} phone={phone} scale={dockScale} />
<p className="sr-only" aria-live="polite">
{announce}
</p>

View File

@@ -840,7 +840,14 @@ function Rules({ options }: { options?: SixNimmtOptions }) {
// ---------------------------------------------------------------- styles
const CSS = `
.sx-wrap { width: 100%; max-width: 980px; display: flex; flex-direction: column; gap: 10px; }
.sx-wrap { width: 100%; display: flex; flex-direction: column; gap: 10px;
/* Card width: the 4 rows + the hand share the play height left after the bars, hints and buttons. */
--sx-c: clamp(64px, (var(--play-h) - 400px) / 7, 140px); }
@media (min-width: 1100px) {
.sx-wrap { flex: 1 1 auto; min-height: 0; }
.sx-wrap > * { flex: none; }
.sx-wrap > .sx-rows { flex: 1 0 auto; justify-content: center; }
}
.game-main:has(> .sx-wrap) { justify-content: flex-start; }
.sx-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; padding: 8px 14px; }
.sx-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
@@ -860,7 +867,7 @@ const CSS = `
.sx-player.timed { padding-right: 40px; }
.sx-rows { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--felt); border-radius: 16px; padding: 8px; }
.sx-row { width: 100%; max-width: 480px; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 4px; align-items: center; border-radius: 10px; padding: 2px; transition: background .2s; }
.sx-row { width: 100%; max-width: calc(var(--sx-c) * 6 + 96px); display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 4px; align-items: center; border-radius: 10px; padding: 2px; transition: background .2s; }
.sx-row.glow { background: rgba(255, 255, 255, .16); }
.sx-row.take { animation: sx-shake .45s ease both; background: rgba(239, 68, 68, .35); }
@keyframes sx-shake { 0%,100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@@ -869,10 +876,10 @@ const CSS = `
.sx-rowbulls { white-space: nowrap; }
.sx-mark { border-radius: 6px; padding: 1px 3px; font-weight: 900; font-size: .72rem; background: #fff; color: #1c1e21; white-space: nowrap; }
.sx-mark.mountain { background: #d9f99d; }
.sx-slots { display: grid; grid-template-columns: repeat(6, minmax(0, 64px)); gap: 4px; }
.sx-slots { display: grid; grid-template-columns: repeat(6, minmax(0, var(--sx-c))); gap: 4px; }
.sx-takebtn { grid-column: 2; justify-self: start; min-height: 40px; }
@media (min-width: 720px) {
.sx-row:has(.sx-takebtn) { max-width: 680px; grid-template-columns: 30px minmax(0, 1fr) auto; }
.sx-row:has(.sx-takebtn) { max-width: calc(var(--sx-c) * 6 + 296px); grid-template-columns: 30px minmax(0, 1fr) auto; }
.sx-row .sx-takebtn { grid-column: 3; }
}
.sx-card { position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 8px; border: 2px solid #3b3f46; color: #1c1e21; background: #fff; font-weight: 900; user-select: none; box-sizing: border-box; }
@@ -886,8 +893,8 @@ const CSS = `
.sx-card.cow { background: #f1f5f9; border-style: dashed; }
.sx-card.new { animation: sx-in .35s ease-out both; box-shadow: 0 0 0 3px var(--focus); }
@keyframes sx-in { from { transform: translateY(-14px) scale(1.15); opacity: .3; } }
.sx-bulls { position: absolute; top: 2px; left: 0; right: 0; text-align: center; font-size: .62rem; font-weight: 700; line-height: 1; }
.sx-n { font-size: clamp(.95rem, 4.2vw, 1.5rem); line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.sx-bulls { position: absolute; top: 2px; left: 0; right: 0; text-align: center; font-size: clamp(.62rem, calc(var(--sx-c) * .15), .95rem); font-weight: 700; line-height: 1; }
.sx-n { font-size: clamp(.95rem, min(4.2vw, calc(var(--sx-c) * .37)), 2.6rem); line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.sx-card.mini .sx-n { font-size: 1.05rem; }
.sx-card.mini .sx-bulls { font-size: .55rem; }
.sx-orig { position: absolute; bottom: 2px; font-size: .55rem; font-weight: 700; color: #334155; }
@@ -910,7 +917,7 @@ const CSS = `
.sx-hand-wrap { display: flex; flex-direction: column; gap: 6px; }
.sx-hint { margin: 0; }
.sx-hand { display: grid; grid-template-columns: repeat(10, minmax(0, 72px)); gap: 6px; justify-content: center; padding-top: 12px; }
.sx-hand { display: grid; grid-template-columns: repeat(10, minmax(0, calc(var(--sx-c) + 8px))); gap: 6px; justify-content: center; padding-top: 12px; }
@media (max-width: 720px) { .sx-hand { grid-template-columns: repeat(5, minmax(0, 64px)); } }
.sx-hcard { all: unset; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; border-radius: 10px; transition: transform .15s; min-width: 0; }
.sx-hcard:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

View File

@@ -191,6 +191,25 @@ button.sp-noble { cursor: pointer; }
.sp-help { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .9rem; }
.sp-help b { background: var(--primary-soft); border-radius: 8px; padding: 2px 8px; }
/* PC: cards, decks, nobles and tokens grow with the play area (3 market rows + help strip + my dock fill the height). */
@media (min-width: 1100px) {
.sp-root { --ch: clamp(136px, min((var(--play-h) - 390px) / 3, (var(--play-w) - 340px) / 3.5), 260px); --cw: calc(var(--ch) * .735); --dw: calc(var(--ch) * .53);
--tok: clamp(58px, calc(var(--ch) * .42), 96px); max-width: none; align-self: stretch; flex: 1 1 auto; min-height: 0; justify-content: center; }
.sp-root > * { flex: none; }
.sp-table { gap: clamp(22px, 2vw, 40px); }
.sp-card:not(.mini) .sp-card-top .sp-gem { width: calc(var(--ch) * .162); height: calc(var(--ch) * .162); }
.sp-card:not(.mini) .sp-cost .sp-gem { width: calc(var(--ch) * .103); height: calc(var(--ch) * .103); }
.sp-card:not(.mini) .sp-tierdots, .sp-card:not(.mini) .sp-flag { font-size: clamp(.64rem, calc(var(--ch) * .068), .9rem); }
.sp-deck .n { font-size: clamp(1.25rem, calc(var(--ch) * .15), 2rem); }
.sp-deck .t { font-size: clamp(.74rem, calc(var(--ch) * .062), 1rem); }
.sp-nobles .sp-noble { width: calc(var(--ch) * .68); min-height: calc(var(--ch) * .54); }
.sp-nobles .sp-noble .nm { font-size: clamp(.7rem, calc(var(--ch) * .06), .95rem); }
.sp-nobles .sp-noble .rq { font-size: clamp(.8rem, calc(var(--ch) * .072), 1.1rem); }
.sp-nobles .sp-noble .rq .sp-gem { width: calc(var(--ch) * .096); height: calc(var(--ch) * .096); }
.sp-nobles .sp-noble .np { font-size: clamp(.95rem, calc(var(--ch) * .088), 1.35rem); }
.sp-bank .sp-token .sp-gem { width: calc(var(--tok) * .45); height: calc(var(--tok) * .45); }
.sp-bank .sp-token .lt { font-size: clamp(.7rem, calc(var(--tok) * .19), .95rem); }
}
@media (max-width: 1099px) {
.sp-root { max-width: 720px; }
.sp-table { grid-template-columns: minmax(0, 1fr); }

View File

@@ -176,6 +176,23 @@ button.tc-c { cursor: pointer; }
.tc-actions .btn { min-height: 48px; font-size: .98rem; min-width: 56px; padding: 0 6px; }
}
@media (min-width: 720px) { .tc-ring .tc-row.mobile-only { display: none; } }
/* PC: fill the play column. The ring takes the spare height (felt grows), seats, trick cards and the hand grow with the play area. */
@media (min-width: 1100px) {
.tc { max-width: none; align-self: stretch; flex: 1 1 auto; min-height: 0; gap: 12px; }
.tc-ring { flex: 1 1 auto; min-height: 0; grid-template-rows: auto minmax(0, 1fr); align-items: stretch; gap: 12px; }
.tc-pos-top, .tc-pos-left, .tc-pos-right { align-self: center; }
.tc-pos-top .tc-seat { min-width: 240px; }
.tc-seat { padding: 8px 12px; font-size: clamp(.86rem, calc(var(--play-h) / 64), 1.08rem); }
.tc-badge, .tc-bubble { font-size: .86em; }
.tc-tablewrap { display: flex; flex-direction: column; justify-content: center; }
.tc-tablewrap > .tc-table { flex: 1 1 auto; padding: 20px; font-size: clamp(1rem, calc(var(--play-h) / 62), 1.2rem); }
.tc-now { font-size: 1.25em; } .tc-now small { font-size: .72em; } .tc-dir { font-size: .78em; }
.tc-set { --cw: clamp(56px, calc(var(--play-h) * .1), 150px); }
.tc-set.prev { --cw: clamp(34px, calc(var(--play-h) * .055), 66px); }
.tc-hand { justify-content: center; gap: 6px; --cw: clamp(58px, min(var(--play-h) * .085, (var(--play-w) - 40px) / 14.5 - 6px), 120px); }
.tc-panel .tc-hand { --cw: clamp(58px, min(var(--play-h) * .075, (var(--play-w) * .52 - 40px) / 7.5 - 6px), 92px); }
.tc-slot { --cw: clamp(50px, calc(var(--play-h) * .065), 76px); }
}
`;
// ---------------------------------------------------------------- seats

View File

@@ -154,6 +154,15 @@ const CSS = `
.un-opps { flex-wrap: wrap; justify-content: center; overflow: visible; width: 100%; max-width: calc(var(--cols) * 184px - 4px); margin: 0 auto; }
.un-seat { flex: 0 1 calc((100% - (var(--cols) - 1) * 8px) / var(--cols)); min-width: 0; max-width: 176px; }
}
/* PC: fill the play column. The felt takes the spare height, piles and hand cards grow with the play area, seats get bigger. */
@media (min-width: 1100px) {
.un { max-width: none; align-self: stretch; flex: 1 1 auto; min-height: 0; gap: 12px; }
.un-opps { max-width: calc(var(--cols) * 256px - 4px); }
.un-seat { max-width: 248px; padding: 8px 12px; font-size: clamp(.9rem, calc(var(--play-h) / 62), 1.1rem); }
.un-table { flex: 1 1 auto; grid-template-columns: 1fr auto auto 1fr; gap: clamp(18px, 2vw, 40px); padding: 20px 28px; font-size: clamp(1rem, calc(var(--play-h) / 62), 1.2rem); }
.un-table > .un-pile { grid-column: 2; }
.un-hand { justify-content: center; }
}
@media (max-width: 719px) {
.un-table { grid-template-columns: auto auto; padding: 12px 10px 10px; gap: 14px; border-width: 6px; justify-content: center; }
.un-info { grid-column: 1 / -1; align-items: center; }
@@ -216,7 +225,7 @@ function SeatChip({ s, v, players, me, deadline, next }: { s: SeatView; v: UnoVi
function TableArea({ v, players, canDraw, onDraw, onDropCard }: { v: UnoView; players: Record<string, PublicUser>; canDraw: boolean; onDraw: () => void; onDropCard: (id: string) => void }) {
const [over, setOver] = useState(false);
const pw = 'clamp(64px, 9vw, 92px)';
const pw = 'clamp(64px, min(9vw, var(--play-h) * .15), 210px)';
const recent = v.recent;
const top = recent[recent.length - 1];
const drawText = `${v.my?.drawCount ?? 1}장 뽑기`;
@@ -286,18 +295,26 @@ function TableArea({ v, players, canDraw, onDraw, onDropCard }: { v: UnoView; pl
// ---------------------------------------------------------------- my hand
function useWidth<T extends HTMLElement>(): [React.RefObject<T | null>, number] {
/** Element width plus the PC play-area height (--play-h on .game-main; 0 under 1100px where it is not measured). */
function useWidth<T extends HTMLElement>(): [React.RefObject<T | null>, number, number] {
const ref = useRef<T>(null);
const [w, setW] = useState(0);
const [h, setH] = useState(0);
useLayoutEffect(() => {
const el = ref.current;
if (!el) return;
setW(el.clientWidth);
const ro = new ResizeObserver(() => setW(el.clientWidth));
const main = el.closest('.game-main');
const update = () => {
setW(el.clientWidth);
setH(main && matchMedia('(min-width: 1100px)').matches ? parseFloat(getComputedStyle(main).getPropertyValue('--play-h')) || 0 : 0);
};
update();
const ro = new ResizeObserver(update);
ro.observe(el);
if (main) ro.observe(main);
return () => ro.disconnect();
}, []);
return [ref, w];
return [ref, w, h];
}
function ColorSheet({ title, onPick, onClose }: { title: string; onPick: (c: Color) => void; onClose: () => void }) {
@@ -326,7 +343,7 @@ function MyHand({ v, act, pending, players }: { v: UnoView; act: (a: unknown) =>
const [hints, setHints] = useState(true);
const [pick, setPick] = useState<string | null>(null);
const [note, setNote] = useState('');
const [ref, width] = useWidth<HTMLDivElement>();
const [ref, width, playH] = useWidth<HTMLDivElement>();
const hand = sortHand(my.hand, sortBy);
const legal = new Set(my.playable);
const bluff = new Set(my.bluff);
@@ -379,7 +396,7 @@ function MyHand({ v, act, pending, players }: { v: UnoView; act: (a: unknown) =>
// One overlapping row on wide screens, wrapped rows on phones (cards ≥ 54 × 76).
const n = hand.length;
const phone = width > 0 && width < 600;
const cw = phone ? 54 : 78;
const cw = phone ? 54 : Math.round(Math.min(156, Math.max(78, playH * 0.12)));
let ov = 6;
if (!phone && n > 1) ov = Math.max(-cw * 0.6, Math.min(6, (width - cw * n) / (n - 1)));
if (phone) ov = n > 12 ? -14 : 4;

View File

@@ -130,12 +130,27 @@ const CSS = `
.yt-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.yt-bar > span { display: block; height: 100%; background: var(--success); transition: width .3s; }
.yt-pname { display: inline-block; max-width: 72px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
/* PC: fill the play column. Dice tray (left) and score sheet (right) take the full height; dice grow with the tray,
the sheet's rows stretch to the column height and its text grows with it. */
@media (min-width: 1100px) {
.yt-wrap { display: grid; grid-template-columns: 380px minmax(0, 1fr); align-items: start; max-height: 100%; }
.yt-die { --s: 64px; }
.yt-sheet { max-height: calc(100vh - var(--site-h) - 52px - 40px); }
.yt-wrap { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
max-width: none; flex: 1 1 auto; min-height: 0; align-self: stretch; }
/* Head on top; dice, roll button and notes centred in the rest of the tray. */
.yt-tray > :last-child { margin-bottom: auto; }
.yt-dice { --s: clamp(64px, min(calc((var(--play-w) - 12px) * .5 / 6.4), calc(var(--play-h) * .12)), 150px); margin-top: auto;
gap: clamp(8px, calc(var(--play-w) * .008), 18px); padding-bottom: calc(var(--s) * .3); }
.yt-die { --s: inherit; border-radius: calc(var(--s) * .22); }
.yt-die.held { transform: translateY(calc(var(--s) * .2)); }
.yt-lock { font-size: clamp(.72rem, calc(var(--s) * .14), .95rem); bottom: calc(var(--s) * -.14); }
.yt-roll { min-height: clamp(64px, calc(var(--play-h) * .075), 84px); font-size: clamp(1.2rem, calc(var(--play-h) * .022), 1.5rem); }
.yt-sheet { max-height: 100%; }
.yt-table { height: 100%; font-size: clamp(1rem, calc(var(--play-h) * .017), 1.25rem); }
.yt-table th, .yt-table td { height: 34px; }
.yt-cell { height: 30px; }
.yt-table thead th { font-size: .9em; }
.yt-table td.mine { font-size: 1.08em; }
.yt-table tr.yt-sum th, .yt-table tr.yt-sum td { font-size: .92em; }
.yt-table tr.yt-total th, .yt-table tr.yt-total td { font-size: 1.1em; }
.yt-cell { height: clamp(30px, calc(var(--play-h) * .04), 44px); }
}
@media (prefers-reduced-motion: reduce) {
.yt-die, .yt-die.held { transition: none; }

View File

@@ -0,0 +1,27 @@
import { useLayoutEffect, type RefObject } from 'react';
/**
* Keeps `--play-w` / `--play-h` (px) on the game column (.game-main) so every game can size its table to the space
* the room actually leaves it: PC uses the measured width and height; under 1100px the page scrolls, so only the
* width is measured and the height keeps the CSS default (the visible window under the room bar, global.css).
*/
export function usePlayArea(ref: RefObject<HTMLElement | null>) {
useLayoutEffect(() => {
const el = ref.current;
if (!el) return;
const wide = matchMedia('(min-width: 1100px)');
const update = () => {
el.style.setProperty('--play-w', `${el.clientWidth}px`);
if (wide.matches) el.style.setProperty('--play-h', `${el.clientHeight}px`);
else el.style.removeProperty('--play-h');
};
update();
const ro = new ResizeObserver(update);
ro.observe(el);
wide.addEventListener('change', update);
return () => {
ro.disconnect();
wide.removeEventListener('change', update);
};
}, [ref]);
}

View File

@@ -12,6 +12,7 @@ import { useSession } from '../store/session';
import { loadGameUI } from '../games/registry';
import type { GameUI } from '../games/types';
import { useWide } from '../lib/media';
import { usePlayArea } from '../lib/play-area';
import { fxMs, useMotionScope } from '../lib/motion';
const STEP_MS = 1000;
@@ -109,6 +110,8 @@ function Player({ data, ui, onBack }: { data: ReplayData; ui: GameUI; onBack: ()
const at = useRef(0);
const layout = useRef<HTMLDivElement>(null);
useMotionScope(layout);
const playArea = useRef<HTMLDivElement>(null);
usePlayArea(playArea);
const go = (n: number, keepPlaying = false) => {
const t = Math.max(0, Math.min(last, n));
@@ -240,7 +243,7 @@ function Player({ data, ui, onBack }: { data: ReplayData; ui: GameUI; onBack: ()
</div>
</nav>
<div className={`game-layout${wide ? '' : ' replay-narrow'}`} ref={layout}>
<div className="game-main">
<div className="game-main" ref={playArea}>
{!wide && status}
<div {...readOnly}>
<ui.Board key={mount} {...props} />

View File

@@ -18,6 +18,7 @@ import { ChatPanel, EmoteBubbles, useChatSeen } from '../components/ChatPanel';
import { BotActivity } from '../components/BotActivity';
import { VolumeControl } from '../components/VolumeControl';
import { useWide } from '../lib/media';
import { usePlayArea } from '../lib/play-area';
import { GameHelp } from '../components/GameHelp';
import { PlayerName } from '../components/PlayerCard';
import { useMotionScope } from '../lib/motion';
@@ -664,6 +665,8 @@ function GameView({ room, ui, me, players, pending, slow }: { room: RoomView; ui
const wide = useWide();
const layout = useRef<HTMLDivElement>(null);
useMotionScope(layout);
const playArea = useRef<HTMLDivElement>(null);
usePlayArea(playArea);
const myTurn = ui.isMyTurn(game.view, me.id);
const isPlayer = room.seats.some((s) => s?.user.id === me.id) && game.active !== undefined;
const props = {
@@ -717,7 +720,7 @@ function GameView({ room, ui, me, players, pending, slow }: { room: RoomView; ui
);
return (
<div className="game-layout" ref={layout}>
<div className="game-main">
<div className="game-main" ref={playArea}>
{!wide && statusRow}
<ui.Board {...props} />
</div>

View File

@@ -835,7 +835,6 @@ button.header-user {
border-bottom: 1px solid var(--border);
}
.room-bar-inner {
max-width: 1600px;
height: 100%;
margin: 0 auto;
padding: 0 24px;
@@ -862,11 +861,10 @@ button.header-user {
}
}
/* Game screen: board + right panel, fits the viewport height on PC */
/* Game screen: board + right panel, fits the viewport height on PC and uses the whole window width
(no max width: the board column takes everything the side panel leaves). */
.game-layout {
max-width: 1600px;
margin: 0 auto;
padding: 16px 24px;
padding: 16px 20px;
display: grid;
grid-template-columns: minmax(0, 1fr) 380px;
gap: 20px;
@@ -876,6 +874,10 @@ button.header-user {
.game-main {
min-width: 0;
min-height: 0;
/* Play area size for games to fit their table to (px; kept up to date by usePlayArea in lib/play-area.ts).
Under 1100px the page scrolls, so the height is the visible window under the room bar. */
--play-w: calc(100vw - 24px);
--play-h: calc(100dvh - var(--site-h) - 52px - 24px);
display: flex;
flex-direction: column;
align-items: center;

135
e2e/layout-survey.ts Normal file
View File

@@ -0,0 +1,135 @@
/**
* Layout survey: opens every game as a practice room against computers on a wide PC screen and measures how much
* of the play area (.game-main) the game actually covers. Screenshots go to test-results/layout-<game>-<w>.png.
* Run: bun e2e/layout-survey.ts [gameId...] (needs apps/web/dist built)
* Games without computer players are opened as a friend room with extra human players (SURVEY_BOTS players in all).
* Env: SURVEY_SIZES="1920x1080,1440x900" SURVEY_BOTS=3 SURVEY_WAIT=3500 STATIC_DIR=<built web dist>
*/
import { chromium, type Page } from 'playwright-core';
import { mkdirSync, mkdtempSync, readdirSync } from 'node:fs';
import { join } from 'node:path';
import { loadConfig } from '../apps/server/src/config';
import { startServer } from '../apps/server/src/server';
const PORT = Number(process.env.E2E_PORT ?? 4561);
const ORIGIN = `http://localhost:${PORT}`;
const SHOTS = process.env.E2E_SHOTS ?? join(import.meta.dir, '../test-results');
mkdirSync(SHOTS, { recursive: true });
const SIZES = (process.env.SURVEY_SIZES ?? '1920x1080').split(',').map((s) => s.split('x').map(Number) as [number, number]);
const BOTS = Number(process.env.SURVEY_BOTS ?? 3);
const all = readdirSync(join(import.meta.dir, '../apps/web/src/games'), { withFileTypes: true })
.filter((d) => d.isDirectory())
.map((d) => d.name);
const games = process.argv.slice(2).length ? process.argv.slice(2) : all;
const dbDir = mkdtempSync(join(process.env.TMPDIR ?? '/tmp', 'bg-survey-'));
const app = startServer({
config: loadConfig({ PORT: String(PORT), DB_PATH: join(dbDir, 'app.db'), PUBLIC_ORIGIN: ORIGIN, LOADTEST_NO_HTTP_LIMITS: '1' }),
log: () => {},
staticDir: process.env.STATIC_DIR ?? join(import.meta.dir, '../apps/web/dist'),
});
const browser = await chromium.launch({ executablePath: process.env.CHROME ?? '/usr/bin/google-chrome', headless: true });
/** Union box of everything visible inside .game-main, plus the .game-main box itself. */
async function measure(p: Page) {
return p.evaluate(() => {
const main = document.querySelector('.game-main') as HTMLElement | null;
if (!main) return null;
const m = main.getBoundingClientRect();
let l = Infinity, t = Infinity, r = -Infinity, b = -Infinity;
for (const el of main.querySelectorAll('*')) {
const box = el.getBoundingClientRect();
if (box.width < 2 || box.height < 2) continue;
const cs = getComputedStyle(el);
if (cs.visibility === 'hidden' || cs.display === 'none') continue;
// Ignore transparent wrappers: only count boxes that paint something (background, border, text, media).
const paints =
(cs.backgroundColor !== 'rgba(0, 0, 0, 0)' && cs.backgroundColor !== 'transparent') ||
cs.backgroundImage !== 'none' ||
parseFloat(cs.borderTopWidth) > 0 ||
cs.boxShadow !== 'none' ||
['svg', 'canvas', 'img', 'button', 'input'].includes(el.tagName.toLowerCase()) ||
[...el.childNodes].some((n) => n.nodeType === 3 && n.textContent!.trim());
if (!paints) continue;
l = Math.min(l, Math.max(box.left, m.left));
t = Math.min(t, Math.max(box.top, m.top));
r = Math.max(r, Math.min(box.right, m.right));
b = Math.max(b, Math.min(box.bottom, m.bottom));
}
const side = document.querySelector('.game-side')?.getBoundingClientRect();
return {
main: [Math.round(m.width), Math.round(m.height)],
used: [Math.round(r - l), Math.round(b - t)],
left: Math.round(l - m.left),
right: Math.round(m.right - r),
bottom: Math.round(m.bottom - b),
side: side ? Math.round(side.width) : 0,
scroll: Math.max(main.scrollHeight - main.clientHeight, document.documentElement.scrollHeight - innerHeight),
};
});
}
let n = 0;
for (const g of games) {
for (const [w, h] of SIZES) {
const ctx = await browser.newContext({ viewport: { width: w, height: h }, locale: 'ko-KR' });
await ctx.addInitScript((ids) => {
for (const id of ids) localStorage.setItem(`bg:qs:${id}`, '1');
}, all);
const p = await ctx.newPage();
const extra: Awaited<ReturnType<typeof browser.newContext>>[] = [];
try {
await p.goto(`${ORIGIN}/g/${g}`);
const practice = p.getByRole('button', { name: '🤖 컴퓨터와 연습하기' });
await p.getByRole('button', { name: /친구랑 하기/ }).waitFor({ timeout: 5000 });
const bots = (await practice.count()) > 0;
await (bots ? practice : p.getByRole('button', { name: /친구랑 하기/ })).click();
await p.getByLabel('내 이름(닉네임)').fill(`측정${n++}`);
await p.getByRole('button', { name: '이 이름으로 시작하기' }).click();
await p.waitForURL(/\/r\/\d{6}$/);
if (bots) {
const add = p.getByLabel('자리').getByRole('button', { name: '🤖 컴퓨터 넣기' });
await add.first().waitFor({ timeout: 5000 }).catch(() => {}); // the lobby renders the button a moment later
for (let i = 1; i < BOTS; i++) {
if (!(await add.count()) || !(await add.first().isEnabled().catch(() => false))) break;
await add.first().click();
await p.getByLabel('자리').getByText(`컴퓨터 ${i + 1}`).waitFor({ timeout: 3000 });
}
} else {
const code = p.url().slice(-6);
for (let i = 1; i < BOTS; i++) {
const c = await browser.newContext({ viewport: { width: 1280, height: 800 }, locale: 'ko-KR' });
extra.push(c);
const q = await c.newPage();
await q.goto(`${ORIGIN}/r/${code}`);
const nick = `친구${n++}`;
await q.getByLabel('내 이름(닉네임)').fill(nick);
await q.getByRole('button', { name: '이 이름으로 입장하기' }).click();
const joined = await p.getByLabel('자리').getByText(nick, { exact: true }).waitFor({ timeout: 4000 }).then(() => true, () => false);
if (!joined) break; // room full
}
}
await p.getByRole('button', { name: '▶ 게임 시작' }).click();
const confirm = p.getByRole('button', { name: '시작하기' });
if (await confirm.waitFor({ timeout: 1500 }).then(() => true, () => false)) await confirm.click();
await p.locator('.game-main').waitFor({ timeout: 8000 });
await p.waitForTimeout(Number(process.env.SURVEY_WAIT ?? 3500));
const r = await measure(p);
await p.screenshot({ path: join(SHOTS, `layout-${g}-${w}.png`) });
if (!r) throw new Error('no .game-main');
const fw = r.used[0] / r.main[0];
const fh = r.used[1] / r.main[1];
console.log(
`${g.padEnd(20)} ${w}x${h} main ${r.main.join('x')} used ${r.used.join('x')} (${Math.round(fw * 100)}% x ${Math.round(fh * 100)}%) gap L${r.left} R${r.right} B${r.bottom} side ${r.side}${r.scroll > 2 ? ` SCROLL ${r.scroll}px` : ''}`,
);
} catch (e) {
console.log(`${g.padEnd(20)} ${w}x${h} ERROR ${(e as Error).message.split('\n')[0]}`);
await p.screenshot({ path: join(SHOTS, `layout-${g}-${w}-error.png`) }).catch(() => {});
}
await ctx.close();
for (const c of extra) await c.close();
}
}
await browser.close();
app.stop?.();
process.exit(0);