/* Domino Game (ต่อโดมิโน่) — mobile-first base styles, desktop widened
 * via the @media (min-width:1024px) block at the bottom, same
 * convention as the sibling uno-game / phom-sib-game plugins' own
 * game.css files (both widened to a 1000px desktop cap). */

:root {
	--dg-felt: #0b6e4f;
	--dg-tile-back: #1c1c1c;
	--dg-ink: #1a1a1a;
	--dg-accent: #2472c8;
	/* Admin-configurable outside-box text colour (see DG_Background::
	 * text_color()); the live value is also written straight into
	 * :root via an inline <style> from layer_html(), so it's correct
	 * even before this stylesheet finishes loading. Defaults to the
	 * plugin's original ink tone -- an untouched install looks exactly
	 * as before. */
	--dg-text: #1a1a1a;
}

#dg-app, #dg-app * { box-sizing: border-box; }

.dg-bg-layer {
	position: fixed;
	inset: 0;
	z-index: -1;
	background-repeat: no-repeat;
	background-size: auto 100%;
	background-position: center;
}

#dg-app,
#dg-app *:not(h1, h2, h3, h4, h5, p) {
	font-family: 'db', 'SF Thonburi', 'Sarabun', sans-serif !important;
	font-weight: normal !important;
}

#dg-app {
	/* Outside-box text colour: falls back to the fixed ink tone if
	 * somehow unset. Elements that sit on their own white card/button
	 * background pin their own colour back to --dg-ink explicitly
	 * further down, so this only ever reaches text directly on the
	 * page background. */
	color: var( --dg-text, var( --dg-ink ) );
	max-width: 480px;
	margin: 0 auto;
	min-height: 100vh;
	padding: 16px 14px 28px;
	display: flex;
	flex-direction: column;
}

.dg-loading {
	text-align: center;
	padding: 60px 0;
	/* Outside-box text colour, not a fixed gray: sits directly on the
	 * page background, no card behind it. */
	color: var( --dg-text, var( --dg-ink ) );
}

.dg-screen.dg-enter { animation: dg-fade-in .25s ease; }
@keyframes dg-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------
 * Home screen
 * ------------------------------------------------------------- */
.dg-logo {
	text-align: center;
	font-size: 40px;
	font-weight: 800;
	margin: 14px 0 4px;
	letter-spacing: 1px;
}
.dg-logo img { max-width: 220px; width: 220px; height: auto; display: block; margin: 0 auto; }
.dg-home-title {
	text-align: center;
	font-size: 24px;
	font-weight: 800;
	margin: 10px 0 4px;
}
/* Outside-box text colour, not a fixed gray: both sit directly on the
 * home-screen background, no card behind either. */
.dg-subtitle {
	text-align: center;
	color: var( --dg-text, var( --dg-ink ) );
	opacity: 0.75;
	margin-bottom: 22px;
	font-size: 14px;
}
/* Snug white pill, rounded corners, black ink, centered under the mode
 * list (user request 2026-09-27: unify "กลับหน้าหลัก" across
 * uno-game/domino-game/phom-sib-game as a white/rounded/black-text
 * button sized to its own text, kept centered) -- was a plain
 * underline-free text link with a top divider border. `display:flex`
 * + `width:fit-content` + `margin:auto` centers a shrink-to-fit block
 * without needing a wrapper element. Same border/shadow as
 * .dg-back-btn, for consistency. */
.dg-home-link {
	display: flex;
	align-items: center;
	justify-content: center;
	width: fit-content;
	margin: 18px auto 0;
	background: #ffffff;
	border: 1.5px solid #d8dde3;
	border-radius: 999px;
	color: var( --dg-ink );
	font-size: 14px;
	font-weight: 600;
	padding: 10px 18px;
	text-decoration: none;
	box-shadow: 0 3px 10px rgba(0,0,0,.08);
}

.dg-home-btn-row { display: flex; gap: 10px; margin: 18px 0 0; }
.dg-home-btn-row .dg-home-link,
.dg-customize-toggle {
	flex: 1;
	display: flex; align-items: center; justify-content: center; gap: 6px;
	width: auto; margin: 0;
	background: #ffffff;
	border: 1.5px solid #d8dde3;
	border-radius: 999px;
	color: var( --dg-ink );
	font-size: 14px; font-weight: 600;
	padding: 10px 18px;
	text-decoration: none;
	box-shadow: 0 3px 10px rgba(0,0,0,.08);
	cursor: pointer;
}

/* ---------- Customize overlay (same panel as phom-sib-game) ---------- */
.dg-overlay {
	position: fixed; inset: 0; background: rgba(0,0,0,.45);
	display: flex; align-items: center; justify-content: center; z-index: 60; padding: 18px;
}
.dg-overlay-panel {
	background: #faf5ec; width: 100%; max-width: 560px; border-radius: 18px;
	padding: 18px; max-height: 80vh; overflow-y: auto; color: #2c2416;
}
.dg-overlay-panel h3 { margin-top: 0; color: #2c2416; }
.dg-preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.dg-preset-swatch { height: 44px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
.dg-preset-swatch.dg-active { border-color: #2c2416; }
.dg-color-row { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; color: #2c2416; }
.dg-color-row input[type="color"] { width: 46px; height: 34px; border: none; background: none; cursor: pointer; }

.dg-mode-list { display: flex; flex-direction: column; gap: 12px; }
.dg-mode-btn {
	display: flex;
	align-items: center;
	gap: 14px;
	background: #fff;
	border: 1.5px solid #e2e8f0;
	border-radius: 14px;
	padding: 16px 16px;
	text-align: left;
	cursor: pointer;
	box-shadow: 0 2px 6px rgba(0,0,0,.06);
	transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.dg-mode-btn:active { transform: scale(.98); }
.dg-mode-btn:hover { box-shadow: 0 6px 16px rgba(36,114,200,.16); border-color: var(--dg-accent); transform: translateY(-1px); }
.dg-mode-icon {
	flex: 0 0 auto;
	width: 46px; height: 46px;
	border-radius: 12px;
	background: #ffffff;
	border: 1px solid #e2e8f0;
	box-shadow: 0 2px 6px rgba(0,0,0,.08);
	color: var(--dg-accent);
	display: flex; align-items: center; justify-content: center;
}
.dg-mode-icon svg { width: 24px; height: 24px; }

/* Mode-select icons (2026-09-30): white line icon on a diagonal
 * (top-left -> bottom-right) gradient disc, same in all card games.
 * vs computer = blue-green, same device = yellow-orange, online = pink-purple. */
.dg-mode-icon.dg-mode-icon--computer, .dg-mode-icon.dg-mode-icon--phone, .dg-mode-icon.dg-mode-icon--globe { color: #ffffff; border-color: transparent; }
.dg-mode-icon.dg-mode-icon--computer { background: linear-gradient(135deg, #29b6f6 0%, #12c98b 100%); box-shadow: 0 3px 8px rgba(18,201,139,.35); }
.dg-mode-icon.dg-mode-icon--phone { background: linear-gradient(135deg, #ffd23f 0%, #ff8a1f 100%); box-shadow: 0 3px 8px rgba(255,138,31,.35); }
.dg-mode-icon.dg-mode-icon--globe { background: linear-gradient(135deg, #ff5fa2 0%, #8b5cf6 100%); box-shadow: 0 3px 8px rgba(139,92,246,.35); }
.dg-mode-title { font-weight: 700; font-size: 16px; color: var(--dg-ink); }
.dg-mode-hint { font-size: 13px; color: #667; margin-top: 2px; }

/* ---------------------------------------------------------------
 * Buttons / forms (shared)
 * ------------------------------------------------------------- */
.dg-primary-btn, .dg-secondary-btn {
	display: inline-flex; align-items: center; justify-content: center;
	border: 1.5px solid transparent; border-radius: 12px;
	padding: 14px 18px;
	font-size: 16px; font-weight: 700;
	cursor: pointer;
	width: 100%;
	transition: transform .12s ease, box-shadow .12s ease, filter .12s ease, border-color .12s ease;
}
.dg-primary-btn { background: var( --dg-accent ); color: #fff; }
.dg-primary-btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 14px rgba(36,114,200,.28); }
.dg-primary-btn:disabled { opacity: .45; cursor: not-allowed; }
.dg-secondary-btn { background: #eef1f5; color: #333; }
.dg-overlay-actions { display: flex; gap: 10px; margin-top: 12px; }
.dg-overlay-actions .dg-secondary-btn { flex: 1; width: auto; margin: 0; }
.dg-secondary-btn:hover { border-color: var(--dg-accent); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,.10); }
/* Setup/lobby screens only (not the table or game-over screen, which
 * keep their own layouts): user-requested (2026-09-27) — move the
 * back button to the very bottom of the pre-game setup screens and
 * restyle it as a snug white pill (width fits its own text) with
 * normal ink text and rounded corners, instead of the plain-text link
 * sitting above the form. Flex column + order, not a markup change,
 * since .dg-back-btn is always the first direct child of .dg-screen
 * (see game.js) and the primary/secondary button(s) the last. */
.dg-screen:not(.dg-screen--table):not(.dg-gameover) {
	display: flex;
	flex-direction: column;
}
.dg-screen:not(.dg-screen--table):not(.dg-gameover) > .dg-back-btn {
	order: 2;
	align-self: flex-start;
}
.dg-back-btn {
	background: #ffffff; border: 1.5px solid #d8dde3; border-radius: 999px;
	/* Fixed ink, not --dg-text: this is now a white pill button with its
	 * own background, so it stays legible regardless of the outside-box
	 * text colour setting. */
	color: var( --dg-ink ); font-size: 14px; font-weight: 600;
	padding: 10px 18px; margin-top: 14px; margin-bottom: 0; cursor: pointer;
	box-shadow: 0 3px 10px rgba(0,0,0,.08);
}

.dg-field { margin-bottom: 14px; }
/* Labels sit directly on the page background (no card), so they follow the
 * admin outside-box text colour (2026-09-30). */
.dg-field label { display: block; font-size: 13px; color: var( --dg-text, var( --dg-ink ) ); margin-bottom: 6px; font-weight: 600; }
.dg-field input[type="text"], .dg-field select {
	width: 100%; padding: 12px 14px; border: 1px solid #d8dde3; border-radius: 10px; font-size: 16px;
}
.dg-field input[type="range"] { width: 100%; }

.dg-error-box {
	background: #fdeceb; color: #b3261e; border-radius: 10px;
	padding: 10px 12px; margin-bottom: 12px; font-size: 14px;
}

/* ---------------------------------------------------------------
 * Online lobby
 * ------------------------------------------------------------- */
.dg-room-code-box { text-align: center; margin: 10px 0 20px; }
/* Fixed ink, not --dg-text: white box (2026-09-27 outside-text-colour
 * follow-up). */
.dg-room-code-box .dg-room-code {
	font-size: 40px; font-weight: 800; letter-spacing: 8px;
	background: #fff; border-radius: 12px; padding: 14px 10px; border: 1px dashed #b9c2cc;
	color: var( --dg-ink );
}
.dg-lobby-players { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
/* Fixed ink, not --dg-text: white box. */
.dg-lobby-player {
	display: flex; align-items: center; justify-content: space-between;
	background: #fff; border-radius: 10px; padding: 10px 14px; border: 1px solid #e2e8f0;
	color: var( --dg-ink );
}
.dg-lobby-player .dg-tag { font-size: 12px; color: #667; }

/* ---------------------------------------------------------------
 * Table screen
 * ------------------------------------------------------------- */
.dg-screen--table {
	background: radial-gradient(ellipse at top, var(--dg-felt-light, #0f8a63), var(--dg-felt, #0b6e4f) 70%);
	position: relative; isolation: isolate; /* holds the optional photo layer below, behind the content */
	border-radius: 18px;
	padding: 14px 10px 16px;
	margin: 0;
	flex: 1;
	display: flex; flex-direction: column;
	color: #fff;
}

/* Admin-configured table photo (--dg-felt-image is set in game.js's
 * applyTheme(): 'none' unless a photo is configured and the player hasn't
 * chosen their own felt color). */
.dg-screen--table::before {
	content: ''; position: absolute; inset: 0; z-index: -1;
	border-radius: inherit; pointer-events: none;
	background-image: var(--dg-felt-image, none);
	background-size: cover; background-position: center; background-repeat: no-repeat;
}

.dg-topbar { display: flex; justify-content: flex-end; align-items: center; margin-bottom: 8px; }
.dg-topbar .dg-boneyard-count { font-size: 13px; opacity: .9; }
.dg-timer {
	font-variant-numeric: tabular-nums;
	font-weight: 700; font-size: 14px;
	background: rgba(0,0,0,.25); padding: 4px 10px; border-radius: 999px;
}
.dg-timer.dg-timer--low { background: #b3261e; }

.dg-opponents { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 10px; }
.dg-opponent {
	background: rgba(0,0,0,.22); border-radius: 12px; padding: 8px 10px;
	min-width: 78px; max-width: 220px; text-align: center;
	border: 2px solid transparent;
}
.dg-opponent.dg-opponent--turn { border-color: #ffd166; box-shadow: 0 0 0 2px rgba(255,209,102,.35); }
.dg-opponent .dg-nickname { font-size: 12px; font-weight: 600; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-opponent .dg-tile-count { font-size: 11px; opacity: .85; }
.dg-opp-info { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
/* Opponent's hand: small upright tile backs, one per remaining tile. */
.dg-opp-backs { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; margin-top: 5px; }
.dg-opponents--one .dg-opponent { width: 100%; max-width: none; }
.dg-back-tile {
	position: relative;
	display: block; width: var( --bs, 9px ); height: calc( var( --bs, 9px ) * 2 );
	border-radius: calc( var( --bs, 9px ) * .2 );
	background: #111;
	border: 1px solid rgba(255,255,255,.22);
	box-shadow: 0 2px 4px rgba(0,0,0,.35);
}
.dg-back-tile::after { content: ''; position: absolute; left: 14%; right: 14%; top: 50%; height: 1px; background: rgba(255,255,255,.14); }
.dg-knock { color: #ffd166; font-weight: 700; opacity: 1 !important; animation: dg-knock-pulse 1s ease-in-out infinite; }
@keyframes dg-knock-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
/* Placement flight: a black tile back (real board-tile size) travels from
 * the hand / opponent to the board, then the real tile fades in. */
.dg-fly {
	position: fixed; z-index: 70; pointer-events: none;
	background: #111; border: 1px solid rgba(255,255,255,.25); border-radius: 6px;
	box-shadow: 0 6px 14px rgba(0,0,0,.4);
}
.dg-btile--flying { opacity: 0; }
.dg-btile--land { animation: dg-land .2s ease; }
@keyframes dg-land { from { opacity: 0; } to { opacity: 1; } }
.dg-opponent .dg-mini-back {
	width: 26px; height: 16px; border-radius: 3px; margin: 4px auto 0;
	background: var( --dg-tile-back, #1c1c1c ); border: 1px solid rgba(255,255,255,.25);
}

.dg-board-wrap {
	position: relative;
	flex: none;
	height: clamp(210px, 38vh, 400px);
	background: rgba(0,0,0,.15);
	border-radius: 14px;
	overflow: hidden;
}
/* Board tiles are persistent absolutely-positioned elements: moving one
 * (when the snake re-flows) is a CSS transition, and only a freshly
 * placed tile plays the fade-in -- nothing else restarts on a re-render. */
.dg-btile {
	position: absolute;
	transition: left .28s ease, top .28s ease;
	will-change: left, top;
}
.dg-btile--new { animation: dg-tile-place .28s ease; }
@keyframes dg-tile-place {
	from { opacity: 0; transform: scale(.6); }
	to { opacity: 1; transform: scale(1); }
}

.dg-end-drop {
	position: absolute;
	width: calc(var(--dg-s, 26px) * 2);
	height: var(--dg-s, 26px);
	border-radius: 6px;
	display: flex; align-items: center; justify-content: center;
	font-size: 18px; line-height: 1; color: #ffd166;
	opacity: 0;
	pointer-events: auto;
	transition: left .28s ease, top .28s ease, opacity .15s ease;
}
.dg-end-drop.dg-end-drop--active {
	opacity: 1;
	background: rgba(255,209,102,.22);
	border: 2px dashed #ffd166;
	cursor: pointer;
	animation: dg-end-pulse 1.1s ease-in-out infinite;
}
.dg-end-drop.dg-end-drop--hover {
	background: rgba(255,209,102,.55);
	animation: none;
}
@keyframes dg-end-pulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(255,209,102,.5); }
	50% { box-shadow: 0 0 0 6px rgba(255,209,102,0); }
}

.dg-hint-text { text-align: center; font-size: 12.5px; color: rgba(255,255,255,.85); margin: 6px 0 10px; min-height: 16px; }

/* ---------------------------------------------------------------
 * Tiles -- a domino is two SQUARE halves (S x S), so a tile is a 2:1
 * strip (horizontal on the board, upright in the hand) and every pip is
 * a fixed-size perfect circle (never stretched by the grid cell).
 * Size comes from --dg-s, set per container by game.js.
 * ------------------------------------------------------------- */
.dg-tile {
	--s: var(--dg-s, 26px);
	position: relative;
	flex: 0 0 auto;
	display: flex;
	width: calc(var(--s) * 2);
	height: var(--s);
	background: linear-gradient(160deg, #303030, #151515);
	border: 1px solid #050505;
	border-radius: calc(var(--s) * .2);
	box-shadow: 0 2px 4px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.06);
	overflow: hidden;
}
.dg-tile--v { flex-direction: column; width: var(--s); height: calc(var(--s) * 2); }
.dg-tile-half {
	flex: 1 1 0;
	min-width: 0; min-height: 0;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	grid-template-rows: repeat(3, 1fr);
	place-items: center;
	padding: calc(var(--s) * .12);
}
.dg-tile-divider {
	position: absolute;
	background: rgba(255,255,255,.22);
	left: 50%; top: 14%; bottom: 14%; width: 1px;
}
.dg-tile--v .dg-tile-divider { left: 14%; right: 14%; top: 50%; bottom: auto; width: auto; height: 1px; }
.dg-dot {
	width: calc(var(--s) * .19);
	height: calc(var(--s) * .19);
	border-radius: 50%;
	box-shadow: inset 0 -1px 1px rgba(0,0,0,.25);
}
.dg-dot--empty { visibility: hidden; }

/* ---------------------------------------------------------------
 * Hand
 * ------------------------------------------------------------- */
.dg-hand-wrap { margin-top: 8px; }
.dg-hand-label { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; opacity: .9; margin-bottom: 2px; }
/* Upright tiles wrapping onto up to 2 rows -- no scrolling. */
.dg-hand {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px;
	padding: 8px 4px 4px;
}
.dg-hand-tile-wrap {
	position: relative;
	touch-action: none;
	cursor: grab;
}
.dg-hand-tile-wrap .dg-tile { transition: box-shadow .15s ease, transform .15s ease; }
.dg-hand-tile-wrap.dg-selected .dg-tile {
	box-shadow: 0 0 0 2px #ffd166, 0 2px 4px rgba(0,0,0,.35);
	transform: translateY(-5px);
}
.dg-hand-tile-wrap.dg-legal .dg-tile { box-shadow: 0 0 0 2px rgba(255,255,255,.55), 0 2px 4px rgba(0,0,0,.35); }
.dg-hand-tile-wrap.dg-illegal .dg-tile { opacity: .45; }
.dg-hand-tile-wrap.dg-dragging { z-index: 30; cursor: grabbing; }

.dg-action-row { display: flex; gap: 8px; margin-top: 4px; }
.dg-action-row button {
	flex: 1;
	border: none; border-radius: 10px; padding: 12px; font-weight: 700; font-size: 14px; cursor: pointer;
}
.dg-btn-place { background: linear-gradient(135deg, #2196f3, #1de9b6); color: #04262b; }
.dg-btn-place:disabled { opacity: .4; cursor: not-allowed; }
.dg-btn-draw { background: linear-gradient(135deg, #ffd400, #ff8a00); color: #3a2000; }
/* Same pulsing glow as the "+" end marker, while a draw is actually required. */
.dg-btn-draw:not(:disabled) { animation: dg-end-pulse 1.1s ease-in-out infinite; }
.dg-btn-draw:disabled { opacity: .4; cursor: not-allowed; }
.dg-btn-pass { background: linear-gradient(135deg, #ff8a3d, #e53935); color: #fff; }
.dg-btn-pass:disabled { opacity: .4; cursor: not-allowed; }

.dg-turn-banner {
	text-align: center;
	font-weight: 700;
	font-size: 14px;
	margin-bottom: 6px;
	padding: 6px;
	border-radius: 8px;
	background: rgba(255,255,255,.12);
}
.dg-turn-banner.dg-turn-banner--mine { background: #ffd166; color: #3a2a00; }
.dg-turn-banner--extra { animation: dg-extra-glow 1.4s ease-in-out infinite; }
@keyframes dg-extra-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,209,102,.7); } 50% { box-shadow: 0 0 0 7px rgba(255,209,102,0); } }
.dg-turn-banner.dg-turn-banner--alert { background: #ff6b3d; color: #fff; animation: dg-alert-shake .7s ease-in-out infinite; }
@keyframes dg-alert-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.dg-hand--alert .dg-hand-tile-wrap.dg-legal .dg-tile { animation: dg-legal-pulse .9s ease-in-out infinite; }
@keyframes dg-legal-pulse { 0%, 100% { box-shadow: 0 0 0 2px rgba(255,255,255,.55), 0 2px 4px rgba(0,0,0,.35); } 50% { box-shadow: 0 0 0 4px #ffd166, 0 2px 4px rgba(0,0,0,.35); } }

/* Full-width black "ย้อนกลับ" (leave game) bar under the table box --
 * same look as the sibling games. */
.dg-leave-bar {
	display: block; width: fit-content; margin: 14px auto 0;
	background: #000; color: #fff; border: none; border-radius: 999px;
	padding: 10px 22px; text-align: center; font-size: 15px; font-weight: 600; line-height: 1.2;
	cursor: pointer;
}
.dg-leave-bar:hover { background: #1c1c1c; }

/* ---------------------------------------------------------------
 * Pass-and-play reveal gate
 * ------------------------------------------------------------- */
.dg-reveal-gate {
	flex: 1;
	display: flex; flex-direction: column; align-items: center; justify-content: center;
	text-align: center; gap: 16px; padding: 30px 10px;
}
.dg-reveal-gate .dg-reveal-title { font-size: 20px; font-weight: 800; }
.dg-reveal-gate .dg-reveal-hint { font-size: 13px; opacity: .85; max-width: 260px; }

/* ---------------------------------------------------------------
 * Game over
 * ------------------------------------------------------------- */
.dg-gameover { text-align: center; padding: 30px 10px; }
.dg-gameover .dg-result-title { font-size: 24px; font-weight: 800; margin-bottom: 10px; animation: dg-winner-pop .3s ease; }
@keyframes dg-winner-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
.dg-pip-table { margin: 16px auto; border-collapse: collapse; width: 100%; max-width: 320px; }
.dg-pip-table td, .dg-pip-table th { padding: 6px 10px; border-bottom: 1px solid #e2e8f0; font-size: 14px; text-align: left; }
.dg-pip-table .dg-pip-winner { font-weight: 800; color: #0b6e4f; }


/* ---------------------------------------------------------------
 * Small screens
 * ------------------------------------------------------------- */
@media (max-width: 360px) {
	.dg-logo { font-size: 32px; }
}

/* On mobile (below the desktop breakpoint below), no left/right padding
 * on the outer container -- user-requested 2026-09-26, same change as
 * the sibling thai-checkers-game/atari-go-game/uno-game plugins. Only
 * horizontal padding is dropped; top (16px) and bottom (28px) padding
 * are untouched. */
@media (max-width: 1023px) {
	#dg-app { padding-left: 0; padding-right: 0; }
}

/* ---------- Desktop (>=1024px): wider table + larger tiles/text ----------
 * Matches the same convention already used across this suite (uno-game,
 * phom-sib-game): on screens wide enough to be "a computer" the app grows
 * from the mobile 480px cap to 1000px. Everything below the breakpoint is
 * untouched. */
@media (min-width: 1024px) {
	#dg-app { max-width: 1000px; }
	.dg-logo { font-size: 56px; }
	.dg-subtitle { font-size: 16px; }
	.dg-mode-btn { padding: 20px 22px; }
	.dg-mode-icon { width: 56px; height: 56px; }
	.dg-mode-icon svg { width: 28px; height: 28px; }
	.dg-mode-title { font-size: 19px; }
	.dg-mode-hint { font-size: 14px; }
	.dg-room-code-box .dg-room-code { font-size: 52px; letter-spacing: 10px; }
	.dg-primary-btn, .dg-secondary-btn { font-size: 18px; padding: 16px; }
	.dg-opponent { min-width: 96px; padding: 10px 14px; }
	.dg-board-wrap { height: clamp(260px, 42vh, 460px); }
	.dg-action-row button { font-size: 16px; padding: 14px; }
	.dg-turn-banner { font-size: 16px; }
}

/* ---------- Shared room chat (2026-09-28 request, ported from the
 * phom-sib-game/atari-go-game/thai-checkers-game/uno-game sibling
 * plugins), online mode only ---------- */
/* #dg-chat-root sits OUTSIDE #dg-app (a sibling — see game.js) so its
 * own <input> never gets torn down by #dg-app's frequent full innerHTML
 * rebuilds. Being outside #dg-app also means it does NOT inherit that
 * element's CSS custom properties or fonts, so everything here uses
 * fixed colors/fonts instead. */
#dg-chat-root, #dg-chat-root * {
	font-family: 'db', 'SF Thonburi', 'Sarabun', 'Noto Sans Thai', sans-serif;
	box-sizing: border-box;
}
#dg-chat-root { position: fixed; right: 16px; bottom: 16px; z-index: 55; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.dg-chat-fab {
	position: relative; width: 56px; height: 52px; border: none; cursor: pointer;
	background: transparent; padding: 0; display: flex; align-items: flex-start; justify-content: center;
	isolation: isolate; overflow: visible;
}
.dg-chat-fab-icon { position: relative; z-index: 1; display: block; width: 52px; height: 47px; }
.dg-chat-fab-icon svg { width: 100%; height: 100%; display: block; }
/* Orange glow burst instead of the old up/down bob (no layout/transform
 * jitter on the button itself): every 5s a soft orange light spreads out
 * from behind the bubble and fades, then stays still until the next
 * burst. Only opacity/transform are animated, so it stays on the
 * compositor and never stutters. */
.dg-chat-fab::before,
.dg-chat-fab::after {
	content: ""; position: absolute; left: 50%; top: 45%; width: 56px; height: 56px;
	margin: -28px 0 0 -28px; border-radius: 50%; pointer-events: none; z-index: 0;
	background: radial-gradient(circle, rgba(255,150,30,.85) 0%, rgba(255,122,0,.45) 40%, rgba(255,122,0,0) 70%);
	opacity: 0; transform: scale(.7); will-change: transform, opacity;
	animation: dg-chat-glow 5s ease-out infinite;
}
.dg-chat-fab::after { animation-delay: .35s; }
@keyframes dg-chat-glow {
	0%   { opacity: 0;   transform: scale(.7); }
	6%   { opacity: .9;  transform: scale(1.1); }
	26%  { opacity: 0;   transform: scale(2.8); }
	100% { opacity: 0;   transform: scale(2.8); }
}
@media (prefers-reduced-motion: reduce) {
	.dg-chat-fab::before, .dg-chat-fab::after { animation: none; opacity: 0; }
}
.dg-chat-badge {
	position: absolute; top: -2px; right: 0; min-width: 18px; height: 18px; padding: 0 4px;
	background: #ff5a36; color: #000; font-size: 11px; font-weight: 800; line-height: 18px;
	border-radius: 999px; text-align: center; box-shadow: 0 0 0 2px #fff;
}
.dg-chat-panel {
	width: 300px; max-width: calc(100vw - 32px); height: 380px; max-height: 60vh;
	background: #fff; color: #2c2416; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.35);
	display: flex; flex-direction: column; overflow: hidden;
}
.dg-chat-header {
	display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
	background: #2c2416; color: #fff; font-weight: 700; font-size: 14px;
}
.dg-chat-close { background: none; border: none; color: #fff; font-size: 12px; line-height: 1; cursor: pointer; padding: 0 4px; }
.dg-chat-messages { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.dg-chat-empty { color: #9a8f7a; font-size: 13px; text-align: center; margin-top: 20px; }
.dg-chat-msg { max-width: 82%; background: #f3ede0; border-radius: 10px; padding: 6px 10px; align-self: flex-start; }
.dg-chat-msg--mine { background: #fff1c4; align-self: flex-end; }
.dg-chat-msg-name { font-size: 11px; font-weight: 800; color: #7a6f5c; margin-bottom: 2px; }
.dg-chat-msg-text { font-size: 14px; word-break: break-word; white-space: pre-wrap; }
.dg-chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #eee2cc; }
.dg-chat-input {
	flex: 1; min-width: 0; border: 1px solid #e0d6bd; border-radius: 999px; padding: 8px 12px; font-size: 16px; color: #2c2416; background: #fff;
}
.dg-chat-input:focus { outline: none; border-color: #c7bb9e; }
.dg-chat-send {
	border: none; border-radius: 999px; padding: 8px 16px; background: #ffb600; color: #fff; font-weight: normal; font-size: 14px; cursor: pointer;
}
.dg-chat-send:hover { background: linear-gradient(135deg, #ffd400, #ff7a00); }
.dg-chat-send:active { transform: scale(.97); }
@media (max-width: 1023px) {
	#dg-chat-root { right: 12px; bottom: 12px; }
	.dg-chat-panel { width: calc(100vw - 24px); height: 50vh; }
}

/* Home screen (2026-09-30): the 3 mode cards and the 2 buttons below them
 * (🎨 ปรับแต่งสี / กลับหน้าหลัก) all lift 3px on hover and take the accent-colored
 * border (all keep a visible border at rest). */
.dg-home-btn-row .dg-home-link,
.dg-customize-toggle {
	transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.dg-mode-btn:hover,
.dg-home-btn-row .dg-home-link:hover,
.dg-customize-toggle:hover {
	transform: translateY(-3px);
	border-color: var(--dg-accent);
	box-shadow: 0 6px 16px rgba(36,114,200,.16);
}
.dg-mode-btn:active { transform: scale(.98); }
