모든 게임이 남는 화면 전체를 쓰도록: 게임별 폭 상한 제거, 판·카드·말을 --play-w/--play-h에 맞춰 키움

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-17 16:17:15 +09:00
parent adc3b5337a
commit ca8baf5cc8
40 changed files with 1025 additions and 403 deletions

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>
);
}