/* casino.css — the one stylesheet of the casino.
   The pages have no inline style: the CSP has no 'unsafe-inline' (src/http.js). Thus each page uses
   the classes of this file. docs/DESIGN.md §6.5 lists the classes that the parts use.
   The layout works from a width of 320 px. A wide table scrolls in its own box (.table-wrap).

   The look: a dark saloon with gold, as the Bidfighter game. The CSP has no font-src, thus the casino
   loads no web font. The headings use a serif font of the system, and the text a sans-serif font of
   the system. Each image is a CSS gradient: the CSP allows images only from this origin. */

:root {
	--bg: #0f0a07;
	--bg-2: #1a120c;
	--panel: #1e1510;
	--panel-2: #281c14;
	--panel-3: #33241a;
	--line: rgba(232, 184, 74, 0.16);
	--line-strong: rgba(232, 184, 74, 0.38);
	--text: #f4ecdf;
	--muted: #b8a891;
	--gold: #e8b84a;
	--gold-light: #f8dc8e;
	--gold-deep: #a8741f;
	--link: #f2c76a;
	--link-hover: #fde3a0;
	--accent-hover: #f6cd66;
	--on-gold: #1d1307;
	--warn: #f0b429;
	--bad: #ff7a6b;
	--ok: #6fd99a;
	--info: #7cb8ff;
	--radius: 14px;
	--radius-small: 8px;
	--gap: 16px;
	--shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 233, 180, 0.06) inset;
	--serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
	color-scheme: dark;
}

* { box-sizing: border-box; }

/* The hidden attribute wins over each display rule, for example .btn (the Full screen button). */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

/* The background: a warm light above the page, dark corners, and a faint grain of wood. */
body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--text);
	background-color: var(--bg);
	background-image:
		radial-gradient(ellipse 90% 55% at 50% -10%, rgba(232, 160, 60, 0.18), transparent 70%),
		radial-gradient(ellipse 60% 40% at 100% 100%, rgba(120, 60, 20, 0.16), transparent 70%),
		repeating-linear-gradient(90deg, rgba(255, 220, 160, 0.007) 0 1px, transparent 1px 7px, rgba(0, 0, 0, 0.05) 7px 8px, transparent 8px 13px),
		linear-gradient(180deg, var(--bg-2), var(--bg) 480px);
	background-attachment: fixed;
}

a { color: var(--link); text-underline-offset: 3px; text-decoration-color: rgba(242, 199, 106, 0.45); }
a:hover { color: var(--link-hover); text-decoration-color: currentColor; }
:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(232, 184, 74, 0.35); color: var(--text); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; font-family: var(--serif); font-weight: 700; letter-spacing: 0.01em; }
h1 {
	font-size: 2.1rem;
	color: var(--gold);
	background: linear-gradient(180deg, var(--gold-light), var(--gold) 55%, var(--gold-deep));
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
}
h2 { font-size: 1.35rem; margin-top: 30px; color: var(--gold-light); }
h3 { font-size: 1.15rem; color: var(--text); }
p { margin: 0 0 12px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }
code { background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; overflow-wrap: anywhere; color: #f1dfb8; }

.skip-link { position: absolute; left: -9999px; top: 0; }
.skip-link:focus { left: 8px; top: 8px; z-index: 20; background: var(--panel); padding: 8px 12px; border-radius: var(--radius-small); }

/* --- The shell: header, navigation, balance chip, main, footer, cookie notice ------------------ */

.site-header {
	position: sticky;
	top: 0;
	z-index: 10;
	display: flex;
	gap: 8px 14px;
	align-items: center;
	flex-wrap: wrap;
	padding: 10px var(--gap);
	background: linear-gradient(180deg, rgba(34, 24, 17, 0.97), rgba(22, 15, 11, 0.95));
	border-bottom: 1px solid transparent;
	border-image: linear-gradient(90deg, transparent, var(--gold-deep) 20%, var(--gold) 50%, var(--gold-deep) 80%, transparent) 1;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.brand {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-family: var(--serif);
	font-weight: 700;
	font-size: 1.12rem;
	letter-spacing: 0.02em;
	color: var(--gold-light);
	text-decoration: none;
}
/* The badge of the brand: a gold star. */
.brand::before {
	content: "★";
	display: inline-grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	font-size: 15px;
	color: var(--on-gold);
	background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 55%, var(--gold-deep));
	box-shadow: 0 0 0 2px rgba(232, 184, 74, 0.25), 0 2px 8px rgba(232, 184, 74, 0.35);
}
.brand:hover { color: #fff3d0; }
.tag {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--muted);
	border: 1px solid var(--line);
	background: rgba(0, 0, 0, 0.25);
	border-radius: 999px;
	padding: 3px 10px;
	white-space: nowrap;
}

.balance-chip {
	display: inline-flex;
	gap: 8px;
	align-items: baseline;
	padding: 4px 14px;
	border-radius: 999px;
	background: linear-gradient(180deg, rgba(232, 184, 74, 0.16), rgba(232, 184, 74, 0.05));
	border: 1px solid var(--line-strong);
	box-shadow: 0 0 18px rgba(232, 184, 74, 0.12);
	white-space: nowrap;
}
.balance-chip strong { color: var(--gold-light); font-variant-numeric: tabular-nums; }
.balance-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.site-nav { display: flex; gap: 4px 18px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.site-nav a { color: var(--text); text-decoration: none; padding: 4px 2px; border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s; }
.site-nav a:hover { color: var(--gold-light); border-bottom-color: var(--line-strong); }
.site-nav a[aria-current="page"] { color: var(--gold-light); border-bottom-color: var(--gold); }
.who { color: var(--muted); font-size: 14px; }
.inline-form { display: inline; margin: 0; }

main { flex: 1 0 auto; width: 100%; max-width: 1080px; margin: 0 auto; padding: 32px var(--gap) 40px; }

.site-footer {
	border-top: 1px solid var(--line);
	background: linear-gradient(180deg, rgba(20, 14, 10, 0.9), #0b0705);
	padding: 20px var(--gap) 24px;
	color: var(--muted);
	font-size: 14px;
}
.site-footer p { margin: 10px 0 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--gold-light); }

.cookie-notice {
	position: sticky;
	bottom: 0;
	z-index: 5;
	display: flex;
	gap: 12px;
	align-items: center;
	flex-wrap: wrap;
	padding: 12px var(--gap);
	background: rgba(30, 21, 16, 0.97);
	border-top: 1px solid var(--line-strong);
	box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
	font-size: 14px;
}
.cookie-notice p { flex: 1 1 280px; margin: 0; }
.cookie-notice form { margin: 0; }

/* --- Blocks ------------------------------------------------------------------------------------ */

/* A card: a dark panel with a thin gold edge and a light at the top. */
.card {
	position: relative;
	background:
		linear-gradient(180deg, rgba(255, 226, 160, 0.045), transparent 120px),
		linear-gradient(180deg, var(--panel-2), var(--panel));
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 20px 22px;
	margin-bottom: var(--gap);
	box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
/* auto-fit: one card (the one game) uses the full width. */
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid > .card { margin-bottom: 0; }
.prose { max-width: 760px; }
.prose li { margin: 4px 0; }
.problems li { margin: 4px 0; }

.summary { display: flex; flex-direction: column; gap: 4px; }
.balance-big {
	font-family: var(--serif);
	font-size: 2.8rem;
	font-weight: 700;
	line-height: 1.1;
	margin: 4px 0 6px;
	font-variant-numeric: tabular-nums;
	color: var(--gold-light);
	text-shadow: 0 0 24px rgba(232, 184, 74, 0.25);
}

/* The card of the game: a warm light, as the lamps of the saloon. */
.game-card {
	display: flex;
	flex-direction: column;
	background:
		radial-gradient(ellipse 120% 70% at 50% 0%, rgba(232, 160, 60, 0.22), transparent 65%),
		linear-gradient(180deg, var(--panel-3), var(--panel));
	border-color: var(--line-strong);
}
.game-card h3 {
	font-size: 1.6rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--gold-light);
	text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5), 0 0 18px rgba(232, 184, 74, 0.3);
}
.game-card p { max-width: 64ch; }
.game-card form { margin-top: auto; padding-top: 6px; }
.game-card .btn-primary { width: 100%; max-width: 340px; padding: 13px 18px; font-size: 1.05rem; letter-spacing: 0.08em; text-transform: uppercase; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.nowrap { white-space: nowrap; }

/* --- Messages and badges ----------------------------------------------------------------------- */

.alert { border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius-small); padding: 11px 15px; background: rgba(0, 0, 0, 0.3); }
.alert-error { border-color: var(--bad); background: rgba(255, 122, 107, 0.08); }
.alert-warn { border-color: var(--warn); background: rgba(240, 180, 41, 0.08); }
.alert-ok { border-color: var(--ok); background: rgba(111, 217, 154, 0.08); }
.alert-info { border-color: var(--info); background: rgba(124, 184, 255, 0.08); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.badge-ok { color: var(--ok); border-color: rgba(111, 217, 154, 0.6); background: rgba(111, 217, 154, 0.08); }
.badge-bad { color: var(--bad); border-color: rgba(255, 122, 107, 0.6); background: rgba(255, 122, 107, 0.08); }
.badge-warn { color: var(--warn); border-color: rgba(240, 180, 41, 0.6); background: rgba(240, 180, 41, 0.08); }

/* --- Tables ------------------------------------------------------------------------------------ */

.table-wrap {
	width: 100%;
	overflow-x: auto;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	margin-bottom: 12px;
	background: rgba(20, 14, 10, 0.75);
	box-shadow: var(--shadow);
}
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 10px 14px; border-bottom: 1px solid rgba(232, 184, 74, 0.09); vertical-align: top; }
table.data thead th {
	background: linear-gradient(180deg, rgba(232, 184, 74, 0.14), rgba(232, 184, 74, 0.06));
	color: var(--gold-light);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	white-space: nowrap;
	border-bottom: 1px solid var(--line-strong);
}
table.data tbody tr:nth-child(even) td { background: rgba(255, 226, 160, 0.02); }
table.data tbody tr:hover td { background: rgba(232, 184, 74, 0.06); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount-pos { color: var(--ok); }
.amount-neg { color: var(--bad); }

/* --- Forms and buttons ------------------------------------------------------------------------- */

.form-stack { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-stack button { margin-top: 12px; align-self: flex-start; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-bottom: 12px; }
.form-row > label { display: flex; flex-direction: column; gap: 4px; }
label { font-weight: 600; font-size: 14px; color: #e9dcc5; }

input, select, textarea {
	font: inherit;
	color: var(--text);
	background: rgba(0, 0, 0, 0.35);
	border: 1px solid rgba(232, 184, 74, 0.22);
	border-radius: var(--radius-small);
	padding: 9px 12px;
	max-width: 100%;
	transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232, 184, 74, 0.2); outline: none; }
textarea { width: 100%; min-height: 6rem; }

.btn {
	display: inline-block;
	font: inherit;
	font-weight: 700;
	line-height: 1.2;
	color: var(--text);
	background: linear-gradient(180deg, var(--panel-3), var(--panel-2));
	border: 1px solid var(--line-strong);
	border-radius: 999px;
	padding: 10px 20px;
	cursor: pointer;
	text-decoration: none;
	transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--gold); box-shadow: 0 0 14px rgba(232, 184, 74, 0.2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
	color: var(--on-gold);
	background: linear-gradient(180deg, var(--gold-light), var(--gold) 45%, #c99230);
	border-color: #f3cf74;
	box-shadow: 0 4px 14px rgba(232, 184, 74, 0.28), 0 1px 0 rgba(255, 255, 255, 0.45) inset;
	text-shadow: 0 1px 0 rgba(255, 240, 200, 0.4);
}
.btn-primary:hover { background: linear-gradient(180deg, #ffe7a6, var(--accent-hover) 45%, #d9a23c); border-color: #ffe08a; box-shadow: 0 6px 20px rgba(232, 184, 74, 0.4), 0 1px 0 rgba(255, 255, 255, 0.5) inset; }
.btn-secondary { background: transparent; }
.btn-danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); box-shadow: 0 0 14px rgba(255, 122, 107, 0.25); }
.btn-small { padding: 5px 14px; font-size: 14px; }

/* --- The play page and the history (part B4) -------------------------------------------------- */

.game-frame-wrap {
	width: 100%;
	aspect-ratio: 16 / 10;
	min-height: 480px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	overflow: hidden;
	background: #000;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 0 40px rgba(232, 160, 60, 0.14), 0 18px 40px rgba(0, 0, 0, 0.6);
}
.game-frame { display: block; width: 100%; height: 100%; border: 0; background: #000; }
pre.replay { white-space: pre-wrap; overflow-wrap: anywhere; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: var(--radius-small); padding: 14px; font-size: 13px; color: #eadcc4; }
.play-title { font-size: 1.3rem; margin: 0; }
.play-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 8px; }

/* The play page (main.main-wide). The main part has the full width of the window, less a side gap of
   var(--gap). The game frame fills the height of the window under the header and the play bar.
   --play-top is the top of the frame on the page, plus a gap of 8 px under the frame.
   public/static/play.js measures it. It sets it again when the header or the play bar changes its
   height. The values here are for a page without the script. Chromium measured a top of 114 px at
   1024 px and wider: the header and one line of play bar.
   The frame is 420 px high or more, but never higher than the window less 16 px: on a short window
   (a phone in landscape), a scroll then shows all of the frame. The text under the frame and the
   footer come after a scroll.
   100svh is the height of the window when the toolbar of a phone browser shows. Thus the frame keeps
   its height when the toolbar hides. A browser without svh uses the vh values: a declaration with
   var() always replaces the declaration before it, thus the svh values are in @supports. */
main.main-wide { max-width: none; padding: 8px var(--gap) 16px; --play-top: 122px; }
.main-wide .game-frame-wrap { aspect-ratio: auto; min-height: min(420px, calc(100vh - 16px)); height: calc(100vh - var(--play-top)); }
@supports (height: 100svh) {
	.main-wide .game-frame-wrap { min-height: min(420px, calc(100svh - 16px)); height: calc(100svh - var(--play-top)); }
}
.signature-check .badge { margin-right: 4px; }
.round h3 { overflow-wrap: anywhere; }
table.data.compact th, table.data.compact td { padding: 5px 12px; }
table.data.compact th[scope="row"] { width: 40%; font-weight: 600; color: #e9dcc5; text-transform: none; letter-spacing: 0; font-size: 14px; }

/* --- The admin pages (part B4) ----------------------------------------------------------------- */

.admin-nav { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 14px; margin-bottom: 18px; border-bottom: 1px solid var(--line); font-size: 14px; }
.admin-nav a { text-decoration: none; padding: 5px 13px; border-radius: 999px; border: 1px solid transparent; color: var(--text); }
.admin-nav a:hover { border-color: var(--line-strong); color: var(--gold-light); }
.admin-nav a[aria-current="page"] { color: var(--on-gold); background: linear-gradient(180deg, var(--gold-light), var(--gold)); border-color: var(--gold); font-weight: 700; }
pre.json { white-space: pre-wrap; overflow-wrap: anywhere; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: var(--radius-small); padding: 8px 10px; font-size: 12px; margin: 0; max-height: 24rem; overflow-y: auto; }
details > summary { cursor: pointer; color: var(--link); }
.form-row > label.checkbox, .checkbox { flex-direction: row; gap: 8px; align-items: center; font-weight: 400; }
.card > h2:first-child { margin-top: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* --- Small screens ----------------------------------------------------------------------------- */

@media (max-width: 640px) {
	h1 { font-size: 1.65rem; }
	main { padding-top: 20px; }
	/* A narrow header uses 3 lines or more. It scrolls with the page, thus it covers no content. */
	.site-header { position: static; }
	.site-nav { margin-left: 0; width: 100%; }
	.balance-big { font-size: 2.2rem; }
	.card { padding: 16px; }
	.form-stack button, .form-row button { width: 100%; }
	.game-frame-wrap { aspect-ratio: auto; height: calc(100vh - 140px); min-height: 420px; }
	/* Without the script: Chromium measured a top of 282 px at 390 px (the header uses 4 lines, and
	   the play bar 2 lines). */
	main.main-wide { --play-top: 290px; }
	.play-bar { gap: 6px 12px; }
	.play-bar .btn { padding: 6px 12px; font-size: 14px; }
	.play-title { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; }
}
