/* Cozy tabletop theme: wooden table, parchment panels, warm brown ink, rounded friendly type. */

:root {
	--ink: #3b2a1e;
	--ink-soft: #7a6450;
	--wood: #8a5a34;
	--wood-dark: #5e3b20;
	--wood-light: #b07d4f;
	--parchment: #f3f3f1;
	--parchment-deep: #e7e7e4;
	--action-bg: #ffffff;
	--surface: #ffffff;
	--highlight: #fdf6dc;
	--line: #d9d9d5;
	--primary: #5a9e4b;
	--primary-dark: #3f7a33;
	--gold: #f2c14e;
	--gold-dark: #c9952a;
	--danger: #c8553d;
	--sea: #4aa3c7;
	--radius: 6px;
	--shadow: 0 2px 6px rgba(59, 42, 30, 0.12);
	--shadow-soft: 0 1px 2px rgba(59, 42, 30, 0.15);
	/* UI: bold, friendly, rounded face (Baloo 2: chunky, friendly; Google Fonts in index.html). */
	--font: "Baloo 2", "Varela Round", "Arial Rounded MT Bold", sans-serif;
	--font-title: "Baloo 2", "Varela Round", "Arial Rounded MT Bold", sans-serif;
	--side-width: 320px;
}

* { box-sizing: border-box; }

html, body, #root { height: 100%; margin: 0; }

body {
	font-family: var(--font);
	font-weight: 500;
	color: var(--ink);
	background: #7a5236;
	overflow: hidden;
	-webkit-tap-highlight-color: transparent;
	user-select: none;
}

/* Scrollbars: slim rounded wooden thumb on a parchment track, follows the theme. */
* { scrollbar-width: auto; scrollbar-color: var(--wood-light) transparent; }
::-webkit-scrollbar { width: 20px; height: 20px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--wood-light); border: 4px solid var(--parchment); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--wood); }
::-webkit-scrollbar-corner { background: transparent; }

img { display: block; }
button { font-family: inherit; font-weight: 800; color: inherit; }
input { font-family: inherit; font-weight: 700; color: var(--ink); }
h1, h2, h3 { font-family: var(--font-title); font-weight: 600; }

.panel {
	background: var(--parchment);
	border: 2px solid var(--wood-dark);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- buttons */

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	padding: 10px 18px;
	border: 2px solid var(--wood-dark);
	border-radius: 6px;
	background: var(--parchment-deep);
	box-shadow: 0 2px 0 var(--wood-dark);
	cursor: pointer;
	font-size: 16px;
	transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.button img { width: 26px; height: 26px; }
.button:hover:not(:disabled) { filter: brightness(1.05); }
.button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--wood-dark); }
.button:disabled { opacity: 0.45; cursor: default; }
.button--primary {
	background: var(--primary);
	border-color: var(--primary-dark);
	box-shadow: 0 2px 0 var(--primary-dark);
	color: #fff;
	text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.button--primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--primary-dark); }
.button--big { width: 100%; padding: 14px 18px; font-size: 19px; font-family: var(--font-title); font-weight: 600; }
.button--small { min-height: 32px; padding: 5px 12px; font-size: 14px; box-shadow: 0 2px 0 var(--wood-dark); }
.button--ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-soft); }
.button--ghost:active:not(:disabled) { box-shadow: none; }
.button--danger { background: var(--danger); border-color: #8f3524; box-shadow: 0 3px 0 #8f3524; color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.button--danger:active:not(:disabled) { box-shadow: 0 1px 0 #8f3524; }
.button--quiet { background: transparent; border: 2px solid rgba(128, 128, 128, 0.25); box-shadow: none; color: var(--ink-soft); font-weight: 400; }
.button--quiet:hover:not(:disabled) { background: rgba(128, 128, 128, 0.1); }
.button--quiet:active:not(:disabled) { box-shadow: none; }
.leave__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.icon-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 7px;
	border: none;
	background: transparent;
	cursor: pointer;
	border-radius: 5px;
}
.icon-button:hover { background: var(--parchment-deep); }
.icon-button img { width: 100%; height: 100%; object-fit: contain; }

.theme-toggle { font-size: 20px; line-height: 1; }
/* Dropdown (ui/Dropdown.tsx): button + floating list; the list is position: fixed so clipping parents never cut it. */
.dropdown { position: relative; display: inline-flex; color: var(--ink); }
.dropdown__button { display: inline-flex; align-items: center; gap: 6px; height: 100%; padding: 0 10px; border: none; background: none; color: inherit; font: inherit; font-weight: 700; cursor: pointer; border-radius: inherit; }
.dropdown__button:hover { background: var(--parchment-deep); }
.dropdown__button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.dropdown__caret { width: 7px; height: 7px; margin-top: -3px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); opacity: 0.6; transition: transform 0.15s ease, margin 0.15s ease; }
.dropdown--open .dropdown__caret { transform: rotate(225deg); margin-top: 3px; }
.dropdown__list {
	position: fixed; z-index: 200; min-width: 180px; max-height: min(360px, 70vh); overflow-y: auto; overscroll-behavior: contain; margin: 0; padding: 6px; list-style: none;
	background: var(--surface); color: var(--ink); border: 2px solid var(--wood-dark); border-radius: 10px;
	box-shadow: 0 10px 28px rgba(59, 42, 30, 0.28); animation: dropdown-in 0.14s ease-out; transform-origin: top;
}
@keyframes dropdown-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.dropdown__option { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 15px; white-space: nowrap; }
.dropdown__option--active { background: var(--highlight); }
.dropdown__option--selected { font-weight: 700; }
.dropdown__label { flex: 1; }
.dropdown__hint { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 4px; background: var(--parchment-deep); color: var(--ink-soft); }
.dropdown__check { width: 14px; color: var(--primary); font-weight: 700; visibility: hidden; }
.dropdown__option--selected .dropdown__check { visibility: visible; }

.lang-picker { height: 40px; }
.lang-picker__code { font-size: 14px; letter-spacing: 0.04em; }
.theme-toggle--corner { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); position: fixed; top: 10px; right: 10px; z-index: 50; }

/* Dark theme: night tabletop. Same structure, swapped surface and ink colors. */
:root[data-theme="dark"] {
	--ink: #f3e9d8;
	--ink-soft: #b9a990;
	--parchment: #2e2a33;
	--parchment-deep: #3b3642;
	--action-bg: #3b3642;
	--surface: #262229;
	--highlight: #4a3f26;
	--line: #4a4452;
	--wood-dark: #17141b;
	--shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
	--shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3);
}
:root[data-theme="dark"] body { background: #1d1a21; }
:root[data-theme="dark"] input { background: var(--parchment-deep); }

.tag {
	display: inline-block;
	padding: 1px 7px;
	border-radius: 4px;
	background: var(--parchment-deep);
	color: var(--ink-soft);
	font-size: 11px;
	margin-left: 4px;
}
.tag--no { color: var(--danger); }

.badge {
	display: inline-block;
	min-width: 18px;
	padding: 0 5px;
	border-radius: 4px;
	background: var(--danger);
	color: #fff;
	font-size: 11px;
	line-height: 18px;
}

.hint { margin: 6px 0; color: var(--ink-soft); font-size: 14px; }

/* ---------------------------------------------------------------- home & lobby */

.home {
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	overflow: auto;
}

.home__panel {
	width: 100%;
	max-width: 430px;
	padding: 26px 24px 20px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	animation: pop 0.25s ease-out;
}

.home__title {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin: 0;
	font-size: 46px;
	letter-spacing: 0.5px;
	color: var(--wood-dark);
	text-shadow: 0 2px 0 #fff;
}
.home__title img { width: 58px; height: 58px; filter: drop-shadow(0 3px 0 rgba(59, 42, 30, 0.3)); }

.home__cards { display: flex; justify-content: center; margin: 2px 0 4px; height: 82px; }
.home__cards img {
	width: 52px;
	margin: 0 -7px;
	filter: drop-shadow(0 4px 3px rgba(59, 42, 30, 0.35));
	transform-origin: 50% 120%;
}

.home__subtitle { margin: 0 0 4px; text-align: center; color: var(--ink-soft); line-height: 1.35; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink-soft); }
.field input, .home__join input, .feed__input input {
	min-height: 44px;
	padding: 10px 12px;
	border: 2px solid var(--line);
	border-radius: 5px;
	background: var(--surface);
	font-size: 17px;
	outline: none;
	min-width: 0;
}
.field input:focus, .home__join input:focus, .feed__input input:focus { border-color: var(--gold-dark); box-shadow: 0 0 0 3px rgba(242, 193, 78, 0.35); }

.home__join { display: flex; gap: 8px; }
.home__join input { flex: 1; text-transform: uppercase; letter-spacing: 5px; text-align: center; font-family: var(--font-title); }

.status { text-align: center; font-size: 13px; color: var(--ink-soft); }
.status::before { content: "● "; }
.status--online { color: var(--primary-dark); }
.status--offline { color: var(--danger); }

.lobby__code {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 14px;
	background: var(--parchment-deep);
	border: 2px dashed var(--wood-light);
	border-radius: 6px;
	color: var(--ink-soft);
}
.lobby__code strong { font-family: var(--font-title); font-size: 44px; letter-spacing: 10px; color: var(--ink); }
.lobby__seats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lobby__wait { text-align: center; color: var(--ink-soft); }

.seat {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 56px;
	padding: 6px 10px;
	background: var(--surface);
	border: 2px solid var(--line);
	border-radius: 6px;
}
.seat--empty { justify-content: center; border-style: dashed; background: transparent; color: var(--ink-soft); }
.seat__name { flex: 1; font-size: 16px; }
.seat__name em, .player__name em { color: var(--ink-soft); font-style: normal; font-weight: 600; }
.seat__tag { width: 22px; height: 22px; }

.avatar {
	flex: none;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: 3px solid #fff;
	box-shadow: 0 0 0 2px var(--wood-dark), var(--shadow-soft);
	display: flex;
	align-items: center;
	justify-content: center;
}
.piece-icon { position: relative; display: inline-block; flex: none; isolation: isolate; }
.piece-icon img { display: block; width: 100%; height: 100%; }
.piece-icon__tint { position: absolute; inset: 0; mix-blend-mode: multiply; mask-size: contain; mask-repeat: no-repeat; mask-position: center; -webkit-mask-size: contain; -webkit-mask-repeat: no-repeat; -webkit-mask-position: center; }
.player__home { display: flex; flex: none; }
.player__home .piece-icon { width: 44px; height: 44px; }
.avatar .piece-icon { width: 30px; height: 30px; }
.avatar--small .piece-icon { width: 22px; height: 22px; }
.action .piece-icon { width: 32px; height: 32px; }
.ranking .piece-icon, .home__title .piece-icon { width: 40px; height: 40px; }
.avatar img { width: 30px; height: 30px; filter: drop-shadow(0 0 1px #fff) brightness(1.15); }
.avatar--small { width: 32px; height: 32px; border-width: 2px; }
.avatar--small img { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- game layout */

.game {
	position: relative;
	height: 100%;
	display: grid;
	grid-template-columns: 1fr var(--side-width);
	grid-template-rows: 1fr auto;
}

/* The board fills the whole screen; side and bottom panels float over it as separate cards. */
.game__board { position: absolute; inset: 0; z-index: 0; }
.board { position: absolute; inset: 0; }
.board canvas { display: block; touch-action: none; } /* the board handles pan / pinch itself, the page must not scroll or zoom */

.game__side {
	grid-column: 2;
	grid-row: 1 / span 2;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 10px;
	min-height: 0;
	z-index: 1;
	pointer-events: none;
}
.game__side > * { pointer-events: auto; }

.game__hand { grid-column: 1; grid-row: 2; padding: 0 10px 10px; z-index: 1; pointer-events: none; }
.game__hand > * { pointer-events: auto; }

.side__header { padding: 6px 6px 6px 12px; background: var(--parchment); border: 2px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.side__header b { color: var(--ink); font-family: var(--font-title); letter-spacing: 2px; }
.side__exit { display: inline-flex; align-items: center; gap: 4px; }
.side__exit img { width: 20px; height: 20px; }

.topbar {
	position: absolute;
	top: 10px;
	left: 10px;
	right: calc(var(--overlay-right, 0px) + 10px);
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 8px;
	pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar .panel { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.topbar__right { display: flex; gap: 8px; }

.turn {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 16px 6px 8px;
	font-size: 16px;
	border-radius: 8px;
	max-width: 72%;
	transition: background 0.2s;
}
.turn b { font-family: var(--font-title); font-weight: 600; }
.turn--mine { background: var(--highlight); border-color: var(--gold-dark); animation: glow 1.6s ease-in-out infinite alternate; }
.turn__badge {
	display: inline-block;
	padding: 2px 10px;
	margin-right: 4px;
	border-radius: 8px;
	background: var(--primary);
	color: #fff;
	font-family: var(--font-title);
	font-weight: 600;
	font-size: 14px;
}
@keyframes glow {
	from { box-shadow: var(--shadow), 0 0 0 0 rgba(242, 193, 78, 0.0); }
	to { box-shadow: var(--shadow), 0 0 0 6px rgba(242, 193, 78, 0.45); }
}

.side-toggle { display: none; width: 50px; height: 50px; }

.dice { display: flex; gap: 8px; padding: 7px; }
.die {
	width: 42px;
	height: 42px;
	padding: 6px;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	grid-template-rows: repeat(3, 1fr);
	place-items: center;
	background: #fff;
	border: 2px solid var(--wood-dark);
	border-radius: 10px;
	box-shadow: 0 2px 0 var(--wood-dark);
}
.die span { width: 7px; height: 7px; border-radius: 50%; }
.die .die__pip { background: #1a1a1a; } /* dice are always white with black dots */

/* ---------------------------------------------------------------- players */

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.player {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	background: var(--surface);
	border: 2px solid var(--line);
	border-radius: 6px;
	transition: box-shadow 0.2s, background 0.2s;
}
.player--active { background: var(--highlight); border-color: var(--gold-dark); box-shadow: 0 0 0 3px rgba(242, 193, 78, 0.6); }
.player__main { flex: 1; min-width: 0; }
.player__name { display: flex; align-items: center; gap: 4px; font-size: 15px; white-space: nowrap; overflow: hidden; }
.player__name img { width: 16px; height: 16px; }
.player__turn { animation: pulse 1s infinite alternate; }
.clock { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.clock--low { color: #d33; font-weight: bold; }
.player__stats { display: flex; gap: 10px; margin-top: 2px; font-size: 13px; color: var(--ink-soft); }
.player__stats span { display: flex; align-items: center; gap: 3px; }
.player__stats img { width: 15px; height: 19px; object-fit: contain; }
.player__stats .award { color: var(--ink); background: var(--gold); border-radius: 4px; padding: 0 5px; }
.player__points {
	flex: none;
	width: 42px;
	height: 42px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--gold);
	border: 2px solid var(--wood-dark);
	box-shadow: var(--shadow-soft);
	font-family: var(--font-title);
	font-size: 19px;
	font-weight: 700;
}
@keyframes pulse { from { opacity: 1; } to { opacity: 0.4; } }

/* ---------------------------------------------------------------- feed */

.feed { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.feed__box { min-height: 90px; display: flex; flex-direction: column; border: 2px solid var(--line); border-radius: 6px; background: var(--parchment); color: var(--ink); overflow: hidden; }
.feed__box { min-height: 0; }
.feed__box--log { flex: 1; min-height: 70px; }
.feed__box--chat { flex: 3; }
.feed__resizer {
	flex: none;
	height: 14px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--parchment-deep);
	border-top: 1px solid var(--line);
	color: var(--ink-soft);
	font-size: 12px;
	line-height: 1;
	cursor: ns-resize;
	touch-action: none;
}
.feed__resizer:hover { color: var(--ink); background: var(--line); }
.feed__title { padding: 6px 10px; background: var(--parchment-deep); font-family: var(--font-title); font-weight: 600; font-size: 15px; }
.tabs { display: flex; background: var(--parchment-deep); }
.tabs__tab { flex: 1; min-height: 40px; padding: 8px; border: none; background: none; cursor: pointer; color: var(--ink-soft); font-family: var(--font-title); font-weight: 600; font-size: 15px; }
.tabs__tab--active { color: var(--ink); background: var(--surface); box-shadow: inset 0 3px 0 var(--gold); }
.feed__list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px; font-size: 15px; font-weight: 700; color: var(--ink); line-height: 1.4; user-select: text; }
.feed__line { padding: 2px 0; border-bottom: 1px dashed var(--line); }
.feed__word { white-space: nowrap; }
.feed__icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-right: 3px; vertical-align: -4px; font-size: 14px; }
.feed__icon img, .feed__icon .piece-icon { width: 18px; height: 18px; object-fit: contain; }
.feed__input { display: flex; gap: 6px; padding: 6px; border-top: 2px solid var(--line); }
.feed__input input { flex: 1; min-height: 38px; padding: 6px 10px; font-size: 15px; }

/* ---------------------------------------------------------------- hand */

.hand {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 12px;
	background: var(--parchment);
	border: 2px solid var(--wood-dark);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}
/* Desktop: whole bottom panel 1.5x (cards, buttons, text) without re-tuning each size. */
@media (min-width: 761px) { .hand { zoom: 1.35; } }
/* Settings > Graphics > Bottom panel background off: only the cards and buttons float over the board. */
:root[data-hand-bg="off"] .hand { background: none; border-color: transparent; box-shadow: none; }
.hand__cards { display: flex; gap: 2px; align-items: flex-end; flex-wrap: wrap; padding-top: 6px; }
.hand__cards .action { margin: 0 8px; }
.hand__actions { display: flex; gap: 6px; flex-wrap: wrap; }

.card-stack { display: flex; align-items: flex-end; }
/* Each extra card of a kind peeks out 10px on the left of the one in front; short on space, the peeks shrink (down to 3px).
   The layer is a slot narrower than its card, so the card art overflows to the right under the next one. */
.card-stack__layer { position: relative; flex: none; width: var(--peek, 10px); align-self: stretch; }
/* Out of the flow: only the slot (the peek) counts toward the stack's width, so the stack can shrink. */
.card-stack__layer img { position: absolute; left: 0; bottom: 0; display: block; width: 56px; max-width: none; filter: drop-shadow(0 1px 1px rgba(59, 42, 30, 0.25)); }
.card-stack > .card { flex-shrink: 0; position: relative; }
.fan-card { position: relative; transform-origin: 50% 140%; transition: transform 0.15s; }
.fan-card:hover { z-index: 1; }

:root { --card-width: 56px; }
.card { position: relative; width: var(--card-width); flex: none; transition: transform 0.15s; }
.card img { width: 100%; height: auto; filter: drop-shadow(0 1px 1px rgba(59, 42, 30, 0.25)); }
.card--small { width: 42px; }
.card--empty { opacity: 0.32; filter: grayscale(0.6); }
.card__count {
	position: absolute;
	right: 0;
	top: 0;
	/* White label tucked into the card's top-right corner. */
	min-width: 22px;
	padding: 1px 4px;
	background: #fff;
	border-radius: 0 3px 0 4px;
	color: #3b2a1e;
	font-family: var(--font-title);
	font-size: 22px;
	font-weight: 600;
	line-height: 1;
	text-align: center;
	pointer-events: none;
}

.gain {
	position: absolute;
	left: 50%;
	top: -10px;
	transform: translateX(-50%);
	padding: 1px 8px;
	border-radius: 8px;
	background: var(--primary);
	border: 2px solid #fff;
	color: #fff;
	font-family: var(--font-title);
	font-size: 16px;
	pointer-events: none;
	animation: gain 1.4s ease-out forwards;
}
@keyframes gain {
	0% { opacity: 0; transform: translate(-50%, 10px) scale(0.6); }
	20% { opacity: 1; transform: translate(-50%, -6px) scale(1.15); }
	70% { opacity: 1; transform: translate(-50%, -18px) scale(1); }
	100% { opacity: 0; transform: translate(-50%, -30px) scale(1); }
}

.devcard {
	position: relative;
	/* Same footprint as a resource card (72x100 artwork at .card width). */
	width: 56px;
	height: auto;
	aspect-ratio: 72 / 100;
	flex: none;
	padding: 5px;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	/* Flat like the resource card artwork: white frame, tiny corners, no shadow. */
	border: 3px solid #fff;
	border-radius: 3px;
	background: #7d55b8;
	outline: 1px solid #414042;
	color: #fff;
	cursor: pointer;
	font-family: var(--font-title);
	font-weight: 500;
	font-size: 10.5px;
	line-height: 1.1;
	text-align: center;
}
.devcard:disabled { cursor: default; filter: saturate(0.45) brightness(0.95); }
.devcard--playable { outline: 3px solid var(--gold); animation: lift 0.9s ease-in-out infinite alternate; }
@keyframes lift { from { transform: translateY(0); } to { transform: translateY(-4px); } }

.action {
	width: 84px;
	height: 84px;
	/* Fixed square: never shrink in a crowded row, and the same box for every state. */
	flex: none;
	box-sizing: border-box;
	padding: 6px 8px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 3px;
	border: 3px solid var(--wood-dark);
	border-radius: 20px;
	background: var(--action-bg);
	box-shadow: 0 2px 0 var(--wood-dark);
	cursor: pointer;
	transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.action img { width: 32px; height: 32px; object-fit: contain; filter: drop-shadow(0 2px 0 rgba(59, 42, 30, 0.25)); }
.action:hover:not(:disabled) { filter: brightness(1.05); }
.action:disabled { cursor: default; }
/* Disabled: the button fades, but the cost cards you already hold keep their true color. */
.action:disabled > :not(.resource-list) { opacity: 0.4; }
.action:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--wood-dark); }
.action--active { background: var(--gold); border-color: var(--gold-dark); }
.action--primary {
	background: var(--primary);
	border-color: var(--primary-dark);
	box-shadow: 0 2px 0 var(--primary-dark);
	color: #fff;
	text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.roll-button {
	position: absolute;
	right: calc(var(--overlay-right, 0px) + 16px);
	bottom: calc(var(--overlay-bottom, 0px) + 16px);
	z-index: 5;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 8px 8px 6px;
	border: 3px solid var(--primary-dark);
	border-radius: 8px;
	background: var(--primary);
	box-shadow: 0 2px 0 var(--primary-dark);
	color: #fff;
	cursor: pointer;
	font-family: var(--font-title);
	transform-origin: 100% 100%;
	animation: roll-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes roll-pulse { from { transform: scale(1); } to { transform: scale(1.08); } }
.roll-button.is-pressed:not(:disabled) { transform: translateY(2px); box-shadow: none; }
/* Holding Space or the mouse button (longer than ROLL_HOLD_MS) shakes the dice in the hand; releasing it rolls. A quick tap rolls at once. */
.roll-button.is-pressed:not(:disabled) { animation: none; }
.roll-button.is-pressed:not(:disabled) .die { animation: dice-tumble 0.32s linear infinite; }
.roll-button.is-pressed:not(:disabled) .die:nth-child(2) { animation-duration: 0.27s; animation-direction: reverse; }
@keyframes dice-tumble {
	0% { transform: rotate(0) translate(0, 0); }
	25% { transform: rotate(14deg) translate(3px, -4px); }
	50% { transform: rotate(-10deg) translate(-3px, 2px); }
	75% { transform: rotate(8deg) translate(2px, 3px); }
	100% { transform: rotate(0) translate(0, 0); }
}
.roll-button:disabled { cursor: default; animation: none; background: var(--parchment); border-color: var(--line); box-shadow: var(--shadow); color: var(--ink); }
.roll-button__dice { display: flex; gap: 8px; }
.roll-button .die { width: 152px; height: 152px; padding: 20px; border-radius: 24px; border-width: 3px; }
.roll-button .die span { width: 26px; height: 26px; }
/* Not your roll: smaller, slightly greyed dice (solid colors, no transparency). */
.roll-button:disabled .die { width: 96px; height: 96px; padding: 12px; border-radius: 16px; background: #e4e4e4; }
.roll-button:disabled .die span { width: 17px; height: 17px; }
.roll-button:disabled .die .die__pip { background: #666; }
.roll-button:disabled .roll-button__label { font-size: 22px; }
.roll-button__label { font-size: 30px; font-weight: 600; line-height: 1; letter-spacing: 1px; }
@media (max-width: 760px) {
	.roll-button { right: calc(var(--overlay-right, 0px) + 10px); bottom: calc(var(--overlay-bottom, 0px) + 10px); padding: 6px 6px 4px; }
	.roll-button .die { width: 96px; height: 96px; padding: 12px; border-radius: 16px; }
	.roll-button .die span { width: 17px; height: 17px; }
	.roll-button__label { font-size: 24px; }
	.roll-button:disabled .die { width: 62px; height: 62px; padding: 8px; border-radius: 12px; }
	.roll-button:disabled .die span { width: 11px; height: 11px; }
}
.action__label { font-size: 13px; }
.hand__actions .action { position: relative; justify-content: center; }
/* Cost cards pinned to the top edge so every icon (with or without a cost) sits at the same centre. */
.hand__actions .action .resource-list { position: absolute; z-index: 1; top: 3px; left: 50%; transform: translateX(-50%); }
.action__dice { font-size: 32px; line-height: 32px; }

.resource-list { display: inline-flex; gap: 1px; vertical-align: middle; }
.resource-list img { width: 13px; height: 18px; object-fit: contain; }
.action .resource-list { max-width: 100%; }
.action .resource-list img { width: 12px; height: 17px; flex: 0 1 auto; min-width: 0; }
.hand__actions .action { padding: 5px 4px; }
.hand__actions .action img:not(.resource-list img), .hand__actions .action .piece-icon { width: 68px; height: 68px; }
/* Dev card and end turn artworks fill more of their canvas: 25% smaller. */
.action--dev > :not(.resource-list), .hand__actions .action--end > :not(.resource-list) { transform: scale(0.75); }
.action--trade > img { transform: scale(0.8); }
/* Dev card sits with the cards on the left but looks like the action buttons. */
.hand__cards .action--dev { position: relative; justify-content: center; padding: 5px 4px; margin-right: 0; }
.hand__cards .action--dev img:not(.resource-list img), .hand__cards .action--trade img { width: 68px; height: 68px; }
.hand__cards .action--dev .resource-list { position: absolute; z-index: 1; top: 3px; left: 50%; transform: translateX(-50%); }
/* Cost cards stuck on top of the icon: held ones bright and lifted, missing ones grey and faded. */
.hand__actions .action .resource-list img, .action--dev .resource-list img { border-radius: 2px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45)); }
.hand__actions .action .resource-list img.resource-list__card--have, .action--dev .resource-list img.resource-list__card--have {
	transform: translateY(-1px); filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.5)); }
.hand__actions .action .resource-list img.resource-list__card--missing, .action--dev .resource-list img.resource-list__card--missing { filter: grayscale(0.6) brightness(0.85); opacity: 0.5; }
.fan-card { padding: 0; border: none; background: none; cursor: pointer; font: inherit; color: inherit; }
.trade__buttons { display: flex; gap: 8px; justify-content: flex-end; }
.resource-list .resource-list__card--missing { filter: brightness(0.45); }

/* ---------------------------------------------------------------- dialogs */

.dialog-backdrop {
	position: fixed;
	inset: 0;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(40, 25, 12, 0.5);
	backdrop-filter: blur(2px);
}
.dialog {
	width: 100%;
	max-width: 480px;
	max-height: 100%;
	overflow-y: auto;
	padding: 0 18px 18px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	animation: pop 0.2s ease-out;
}
.dialog__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0 -18px;
	padding: 12px 14px 12px 18px;
	background: var(--wood);
	border-bottom: 2px solid var(--wood-dark);
	border-radius: 5px 5px 0 0;
	color: #fff;
}
.dialog__header .icon-button { filter: brightness(10); }
.dialog__header .icon-button:hover { background: rgba(255, 255, 255, 0.15); }
.dialog h2 { margin: 0; font-size: 23px; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.dialog h3 { margin: 0 0 4px; font-size: 17px; }
.dialog p { margin: 0; line-height: 1.4; }
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.picker { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.picker__item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.picker__card { padding: 4px; border: none; background: none; cursor: pointer; border-radius: 5px; }
.picker__card:hover:not(:disabled) .card { transform: translateY(-4px); }
.picker__card:disabled { cursor: default; }
.picker__minus { width: 34px; height: 30px; border: 2px solid var(--wood-dark); border-radius: 4px; background: var(--parchment-deep); cursor: pointer; font-size: 16px; }
.picker__minus:disabled { opacity: 0.3; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.choices--cards { justify-content: center; }
.choice { flex: 1; min-width: 140px; border-width: 3px; }
.choice img { width: 28px; height: 28px; }
.card-button {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 6px;
	border: 2px solid transparent;
	border-radius: 5px;
	background: none;
	cursor: pointer;
	font-size: 13px;
}
.card-button:hover:not(:disabled) { background: var(--parchment-deep); }
.card-button--active { border-color: var(--gold-dark); background: var(--highlight); }
.card-button:disabled { opacity: 0.35; cursor: default; }

.trade__section { padding: 12px; background: var(--surface); border: 2px solid var(--line); border-radius: 6px; display: flex; flex-direction: column; gap: 8px; }
.offer { display: flex; flex-direction: column; gap: 8px; }
.offer__sides { display: flex; flex-direction: column; gap: 4px; }
.offer__sides .resource-list img, .incoming .resource-list img { width: 22px; height: 30px; }
.offer__responses { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.offer__responses li { display: flex; align-items: center; justify-content: space-between; min-height: 34px; }

.incoming {
	position: absolute;
	top: 74px;
	left: calc((100% - var(--overlay-right, 0px)) / 2);
	transform: translateX(-50%);
	z-index: 5;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 10px 16px;
	max-width: calc(100% - 20px);
	font-size: 15px;
	animation: pop 0.2s ease-out;
}
.incoming__side { display: inline-flex; align-items: center; gap: 4px; }
.incoming__buttons { display: flex; gap: 6px; }

.ranking { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ranking li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 5px; background: var(--surface); border: 2px solid var(--line); font-size: 16px; }
.ranking li:first-child { background: var(--gold); border-color: var(--gold-dark); font-size: 18px; }
.ranking img { width: 36px; height: 36px; }
.ranking span { flex: 1; }
.ranking b { font-family: var(--font-title); font-weight: 600; }

.notice {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	z-index: 20;
	padding: 12px 20px;
	border-radius: 6px;
	background: var(--wood-dark);
	border: 2px solid var(--gold);
	color: #fff;
	font-size: 15px;
	box-shadow: var(--shadow);
	animation: pop 0.18s ease-out;
	max-width: calc(100% - 32px);
}

/* ---------------------------------------------------------------- phones */

@media (max-width: 820px) {
	.game { grid-template-columns: 1fr; }
	.game__side {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		z-index: 8;
		width: min(var(--side-width), 88vw);
		background: var(--parchment);
		box-shadow: var(--shadow);
		pointer-events: auto;
		transform: translateX(105%);
		transition: transform 0.22s ease-out;
	}
	.game--side-open .game__side { transform: none; }
	.side-toggle { display: inline-flex; }
	.turn { font-size: 14px; padding: 5px 12px 5px 6px; max-width: none; flex: 1; }
	.turn__badge { font-size: 12px; padding: 1px 8px; }
	.game__hand { padding: 0 6px 6px; }
	.hand { padding: 8px; gap: 8px; }
	.hand__cards { width: 100%; justify-content: center; }
	:root { --card-width: 46px; }
	.card-stack__layer img { width: 46px; }
	.devcard { width: 46px; font-size: 9px; }
	.action { width: auto; height: auto; min-width: 0; min-height: 58px; flex: 1; padding: 4px 2px; }
	.action img { width: 26px; height: 26px; }
	.action__label { font-size: 11.5px; }
	.hand__actions { width: 100%; flex-wrap: nowrap; }
	.action .resource-list { display: none; }
	.hand__actions .action img:not(.resource-list img), .hand__actions .action .piece-icon { width: 44px; height: 44px; }
	.die { width: 34px; height: 34px; padding: 5px; }
	.die span { width: 5px; height: 5px; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}

.setting { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.setting input { width: 18px; height: 18px; }
.setting--range input { flex: 1; width: auto; }
.setting__value { min-width: 44px; text-align: right; color: var(--ink-soft); }

/* YOUR TURN banner: pops in, holds, fades up and away (BANNER_MS in GameScreen). */
.turn-banner {
	/* Centre of the gameplay area: the screen minus the side panel and the bottom bar. */
	position: fixed;
	top: calc((100vh - var(--overlay-bottom, 0px)) / 2);
	left: calc((100vw - var(--overlay-right, 0px)) / 2);
	z-index: 20;
	pointer-events: none;
	transform: translate(-50%, -50%);
}
.turn-banner span {
	display: block;
	padding: 14px 56px;
	/* Solid thick bottom border for the 3D edge (a hard box-shadow left see-through gaps at the corners). */
	border: 3px solid var(--primary-dark);
	border-bottom-width: 9px;
	border-radius: 14px;
	background: linear-gradient(180deg, #7cc46a, var(--primary)) padding-box, var(--primary-dark) border-box;
	box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
	color: #fff;
	font-family: var(--font-title);
	font-size: 44px;
	font-weight: 800;
	letter-spacing: 3px;
	text-transform: uppercase;
	text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
	white-space: nowrap;
	animation: turn-banner 1.7s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards;
}
@keyframes turn-banner {
	0% { opacity: 0; transform: scale(0.4); }
	18% { opacity: 1; transform: scale(1.08); }
	28% { transform: scale(1); }
	78% { opacity: 1; transform: translateY(0) scale(1); }
	100% { opacity: 0; transform: translateY(-30px) scale(0.95); }
}
@media (max-width: 760px) { .turn-banner span { font-size: 28px; padding: 10px 32px; } }

/* Bottom centre turn status (in the hand bar): who plays now, or your READY (end turn) button. */
@media (min-width: 761px) {
	.hand { display: grid; grid-template-columns: 1fr auto 1fr; }
	.hand__cards { justify-self: start; }
	.hand__actions { justify-self: end; }
	/* Bottom-aligned: when the cards or buttons wrap into a taller block, READY stays on the bottom edge. */
	.turn-status { align-self: end; }
}
.turn-status {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 64px;
	padding: 8px 14px 8px 8px;
	border: 3px solid var(--wood-dark);
	border-radius: 32px;
	background: var(--action-bg);
	box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18), 0 6px 14px rgba(0, 0, 0, 0.12);
	white-space: nowrap;
}
.turn-status__avatar { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2); }
.turn-status__avatar .piece-icon { width: 28px; height: 28px; }
.turn-status__text { display: flex; flex-direction: column; line-height: 1.2; }
.turn-status__text b { font-size: 17px; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); }
.turn-status__text small { font-size: 12.5px; color: var(--ink-soft); }
.turn-status__wait { width: 30px; height: 30px; animation: hourglass-flip 2.4s ease-in-out infinite; }
@keyframes hourglass-flip { 0%, 70% { transform: rotate(0); } 100% { transform: rotate(180deg); } }
.turn-status--ready {
	padding: 8px 36px;
	justify-content: center;
	border-color: var(--primary-dark);
	background: linear-gradient(180deg, #7cc46a, var(--primary));
	box-shadow: 0 4px 0 var(--primary-dark);
	color: #fff;
	cursor: pointer;
	font-size: 26px;
	letter-spacing: 2px;
	text-transform: uppercase;
	text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}
.turn-status--ready:hover:not(:disabled) { filter: brightness(1.06); }
.turn-status--ready:active:not(:disabled), .turn-status--ready.is-pressed:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--primary-dark); }
.turn-status--ready:disabled { cursor: default; filter: saturate(0.35) brightness(0.92); }
@media (max-width: 760px) {
	.turn-status { order: -1; width: 100%; justify-content: center; min-height: 48px; }
	.turn-status--ready { font-size: 20px; }
}

/* Trade window docked bottom-left, just above the hand bar; no backdrop so hand cards stay clickable. */
.dialog--docked {
	position: absolute;
	left: 12px;
	bottom: calc(var(--overlay-bottom, 0px) + 8px);
	width: min(420px, calc(100% - 24px));
	z-index: 15;
	max-height: calc(100% - var(--overlay-bottom, 0px) - 80px);
	overflow-y: auto;
}
.picker__minus:disabled { visibility: hidden; }
/* READY hops once when it becomes clickable. */
.turn-status--ready:not(:disabled) { animation: ready-bob 0.15s ease-in-out 1; }
.turn-status--ready:active:not(:disabled) { animation: none; }
@keyframes ready-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }

/* ---------------------------------------------------------------- scoreboard (floating player labels, LoL style, mirrored: VP left, home right by the side panel) */

.scoreboard {
	position: absolute; top: 64px; right: calc(var(--overlay-right, 0px) + 10px); z-index: 2; width: 420px;
	list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.score {
	display: flex; align-items: center; gap: 13px; padding: 9px 13px 9px 10px; pointer-events: auto;
	border-right: 6px solid var(--player); border-radius: 28px 4px 4px 28px; color: #f8ecd6;
	background: rgba(28, 20, 14, 0.86);
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4); transition: transform 0.2s, box-shadow 0.2s;
}
.score--active { box-shadow: 0 0 0 2px #f2c14e, 0 3px 10px rgba(242, 193, 78, 0.45); transform: translateX(-6px); }
.score__home { display: flex; flex: none; align-self: center; }
.score__home .piece-icon { width: 52px; height: 52px; }
/* Name + stat chips form one block centered on the VP coin (tight line boxes, no extra font leading). */
.score__main { flex: 1; min-width: 0; align-self: center; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 5px; }
.score__name { max-width: 100%; display: flex; align-items: center; gap: 4px; font-family: var(--font-title); font-size: 23px; font-weight: 700; line-height: 1.1; min-width: 0; }
.score__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score__name img { width: 22px; height: 22px; flex: none; }
.score--you .score__text { color: #fff3a8; }
.score__stats { display: flex; gap: 5px; line-height: 1; }
.score__stat { display: inline-flex; align-items: center; gap: 3px; padding: 1px 10px 1px 5px; border-radius: 13px; background: rgba(255, 255, 255, 0.1); font-size: 20px; font-weight: 700; line-height: 24px; }
.score__stat img { width: 19px; height: 23px; object-fit: contain; }
.score__stat--award { background: #f2c14e; color: #2d1c10; }
.score__vp {
	flex: none; display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%;
	background: #f2c14e; border: 2px solid #2d1c10; color: #2d1c10;
	font-family: var(--font-title); font-size: 32px; font-weight: 800;
}
/* Wide screens: players live on the scoreboard, the side panel keeps room, bank and chat. Phones keep the list in the drawer. */
@media (min-width: 821px) { .game__side .players { display: none; } }
/* Phones: a compact row under the top bar (home + VP per player, leader first); full stats stay in the side drawer. */
@media (max-width: 820px) {
	.scoreboard { top: calc(62px + env(safe-area-inset-top, 0px)); left: 10px; right: auto; width: auto; flex-direction: row; flex-wrap: wrap; gap: 6px; }
	.score { gap: 4px; padding: 3px 5px 3px 3px; border-right-width: 4px; border-radius: 18px 4px 4px 18px; }
	.score--active { transform: translateY(2px); }
	.score__main { display: none; }
	.score__home .piece-icon { width: 26px; height: 26px; }
	.score__vp { width: 32px; height: 32px; font-size: 18px; border-width: 2px; }
}

/* ---------------------------------------------------------------- trade wild card */
.trade__wanted { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: flex-start; }
.trade__wanted > .picker__item { padding-left: 8px; border-left: 2px dashed var(--line); }
/* Offered cards line up with the wild card: same top edge and the same 8px frame as a card button. */
.trade__offering { align-items: flex-start; }
.trade__offering > .picker__item { padding-left: 8px; border-left: 2px dashed var(--line); }
.trade__offering .picker__card { padding: 8px; }
.incoming__wild { display: flex; flex-direction: column; gap: 4px; }
.incoming__wild small { font-weight: 700; color: var(--ink-soft); }
.incoming__wild .picker { zoom: 0.7; }

/* ---------------------------------------------------------------- gained card flying from its field to the hand */
.card-flight { position: fixed; z-index: 300; height: auto; pointer-events: none; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4)); }

/* No focus rings in the game: clicks and Space would light one up on buttons or the canvas at random moments. */
.game :focus, .game :focus-visible, .game canvas:focus { outline: none; }

/* Pieces / cards left on an action button: the hand card's count label, in the bottom-right corner. */
.action { position: relative; }
.action__count {
	position: absolute; right: 0; bottom: 0; z-index: 1;
	min-width: 26px; padding: 2px 8px 3px 5px; background: #fff; border-radius: 6px 0 18px 0; /* follows the button's 20px corner */
	color: #3b2a1e; font-family: var(--font-title); font-size: 22px; font-weight: 600; line-height: 1; text-align: center; pointer-events: none;
}
/* Always opaque and full size, also on disabled buttons and on the scaled dev card art. */
.action > .action__count, .action:disabled > .action__count { opacity: 1; transform: none; }
/* Unavailable button: solid grey label (not see-through). */
.action:disabled > .action__count { background: #cfc9c0; color: #7a6e64; }
/* Quantity labels (hand cards, action buttons): a slight 1px shadow lifts them off the art. */
.card__count { box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3); }
/* The action label sits on the bottom edge (its lower side touches the button border), so its shadow falls inward: up and left. */
.action__count { box-shadow: -1px -1px 1px rgba(0, 0, 0, 0.3); }

/* ---------------------------------------------------------------- phones: notch / home bar, long-press */
.game { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.topbar { top: calc(10px + env(safe-area-inset-top, 0px)); }
.game__hand { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }

/* ---------------------------------------------------------------- hand: many cards squeeze instead of wrapping */
/* Short on space, same-kind cards pack closer (--peek, set by useCardPacking in HandBar); only when even the
   tightest packing does not fit does the row wrap. The row spans its whole column so its free width is known. */
.hand__cards { flex-wrap: nowrap; min-width: 0; }
/* Left side = two groups that never wrap together: the card stacks (wrap among themselves) and the dev card + trade buttons. */
.hand__cards > .hand__stacks { display: flex; gap: 2px; align-items: flex-end; flex: 0 1 auto; min-width: 0; }
.hand__stacks > * { flex-shrink: 0; }
.hand__cards--wrap .hand__stacks { flex-wrap: wrap; }
/* The hand never grows past the screen: a wide row must pack or wrap, not widen the page. */
.game__hand, .hand { min-width: 0; max-width: 100%; }
/* Dev card + trade: a row next to the cards; a column when space is short (before the row wraps). */
.hand__extras { display: flex; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.hand__cards--column .hand__extras { flex-direction: column; gap: 4px; }
/* Build buttons: a row, or one column when the row does not fit (measured, no ragged wrap). */
.hand__actions { flex-wrap: nowrap; min-width: 0; max-width: 100%; }
.hand__actions--column { flex-direction: column; align-items: stretch; }
.hand__cards > * { flex-shrink: 0; }
@media (min-width: 761px) { .hand .hand__cards { justify-self: stretch; } }

/* Phones (stacked hand): cards, then the build buttons, READY / turn status last at the bottom. */
@media (max-width: 760px) {
	.hand > .hand__cards { order: 1; }
	.hand > .hand__actions { order: 2; }
	.hand > .turn-status { order: 3; width: 100%; justify-content: center; }
}

@media (max-width: 760px) {
	.hand__stacks { justify-content: center; }
	/* Tight screens: your roll's dice sit at the bottom, over the turn status row (it only says "roll the dice" then). */
	.roll-button:not(:disabled) { right: auto; left: 50%; bottom: calc(6px + env(safe-area-inset-bottom, 0px)); transform-origin: 50% 100%; translate: -50% 0; }
}

/* ---------------------------------------------------------------- side panel fold (desktop) */
/* A tab on the panel's left edge folds it away; folded, the tab sits on the screen edge and the board takes the space. */
.side-fold {
	position: absolute; z-index: 3; top: 50%; translate: 0 -50%;
	/* Touches the panel cards: the side column has 10px padding around them. */
	right: calc(var(--overlay-right, 0px) - 10px);
	width: 26px; height: 56px; padding: 0 0 2px; border: 2px solid var(--line); border-right: none; border-radius: 10px 0 0 10px;
	background: var(--parchment); color: var(--ink-soft); font-family: var(--font-title); font-size: 26px; font-weight: 800; line-height: 1; cursor: pointer;
}
.side-fold:hover { color: var(--ink); background: var(--highlight); }
@media (min-width: 821px) {
	.game--side-folded { --side-width: 0px; }
	.game--side-folded .game__side { display: none; }
}
/* Phones use the slide-in drawer (players button) instead. */
.game--side-folded .side-fold { right: 10px; } /* folded: a CHAT button with the panel's own 10px margin */
.game--side-folded .side-fold {
	display: grid; place-items: center; width: 50px; height: 50px; padding: 0; border-right: 2px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.game--side-folded .side-fold img { width: 32px; height: 32px; }
@media (max-width: 820px) { .side-fold { display: none; } }

/* Clicking the offered cards of an open offer cancels it. */
.offer__give { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px; border: none; border-radius: 5px; background: none; color: inherit; font: inherit; cursor: pointer; }
.offer__give:hover { background: var(--parchment-deep); }
