모든 게임이 남는 화면 전체를 쓰도록: 게임별 폭 상한 제거, 판·카드·말을 --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

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