/* style.css - the cabinet around the well.
   Dark, jewel-lit, and out of the way: everything that matters is in the
   canvas, so the chrome stays quiet. */

:root {
	--ink: #080b12;
	--case: #101725;
	--case-2: #16203141;
	--rule: #23314a;
	--text: #d7e2f2;
	--dim: #7d8ea6;
	--gold: #ffd93d;
	--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	--disp: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
	height: 100%;
	margin: 0;
	background: radial-gradient(ellipse at 50% 0%, #131c2e 0%, var(--ink) 62%);
	color: var(--text);
	font-family: var(--disp);
	overflow: hidden;
	padding-top: env(safe-area-inset-top, 0px);
	padding-bottom: env(safe-area-inset-bottom, 0px);
}

#game {
	height: 100%;
	display: flex;
	gap: 18px;
	padding: 16px;
	align-items: stretch;
	justify-content: center;
}

/* ---- the well ------------------------------------------------------ */

#well {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	max-width: 640px;
	border-radius: 10px;
	overflow: hidden;
	background: #05070c;
	box-shadow: 0 0 0 1px var(--rule), 0 26px 70px rgba(0, 0, 0, .65);
}

#stage {
	display: block;
	width: 100%;
	height: 100%;
	touch-action: manipulation;
}

#toast {
	position: absolute;
	top: 18px;
	left: 50%;
	transform: translate(-50%, -12px);
	font-family: var(--disp);
	font-size: 15px;
	font-weight: 700;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--gold);
	text-shadow: 0 0 18px rgba(255, 217, 61, .55);
	opacity: 0;
	pointer-events: none;
	transition: opacity .18s, transform .18s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- overlay ------------------------------------------------------- */

#overlay {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 18px;
	background: rgba(5, 7, 12, .82);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	transition: opacity .2s;
}
#overlay.hidden { opacity: 0; pointer-events: none; }

.box {
	width: min(360px, 100%);
	text-align: center;
	background: var(--case);
	border: 1px solid var(--rule);
	border-radius: 10px;
	padding: 24px 22px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, .6);
}
.box h1 {
	margin: 0 0 10px;
	font-size: 27px;
	letter-spacing: .20em;
	color: #fff;
	text-shadow: 0 0 26px rgba(120, 180, 255, .5);
}
.box .big {
	margin: 4px 0 2px;
	font-family: var(--mono);
	font-size: 38px;
	font-weight: 700;
	color: var(--gold);
	font-variant-numeric: tabular-nums;
}
.box .sub { margin: 0 0 16px; font-size: 13px; line-height: 1.6; color: var(--dim); }
.box table { width: 100%; border-collapse: collapse; margin: 14px 0 18px; }
.box td { padding: 5px 6px; font-size: 12.5px; text-align: left; color: var(--dim); }
.box td:first-child {
	font-family: var(--mono);
	color: var(--text);
	white-space: nowrap;
	width: 42%;
}
.box button {
	width: 100%;
	padding: 11px 16px;
	font-family: var(--disp);
	font-size: 14px;
	font-weight: 700;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: #06111f;
	background: linear-gradient(180deg, #7fd3ff, #34a2e8);
	border: 0;
	border-radius: 6px;
	cursor: pointer;
	transition: filter .15s;
}
.box button:hover { filter: brightness(1.12); }
.box button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---- side panel ---------------------------------------------------- */

#panel {
	flex: 0 0 216px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 16px;
	background: var(--case);
	border: 1px solid var(--rule);
	border-radius: 10px;
	overflow-y: auto;
}
#panel h1 {
	margin: 0;
	font-size: 19px;
	letter-spacing: .22em;
	text-align: center;
	color: #fff;
	text-shadow: 0 0 20px rgba(120, 180, 255, .45);
}

.readout { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
	background: #0b1220;
	border: 1px solid #1b2740;
	border-radius: 6px;
	padding: 8px 10px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}
.stat.wide { grid-column: 1 / -1; }
.label {
	font-size: 9.5px;
	letter-spacing: .15em;
	text-transform: uppercase;
	color: var(--dim);
}
.value {
	font-family: var(--mono);
	font-size: 18px;
	font-weight: 700;
	color: #fff;
	font-variant-numeric: tabular-nums;
	overflow: hidden;
	text-overflow: ellipsis;
}
.stat.wide .value { font-size: 24px; color: var(--gold); }

.next-block {
	background: #0b1220;
	border: 1px solid #1b2740;
	border-radius: 6px;
	padding: 9px 10px 11px;
}
#next {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 5px;
	margin-top: 7px;
	min-height: 84px;
	justify-content: center;
}

/* The next-piece chips carry the same cut as the gem they stand for, so the
   preview tells you the shape and not only the colour. */
.chip {
	width: 24px;
	height: 24px;
	display: block;
	box-shadow: 0 0 12px currentColor;
}
.cut-ruby     { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.cut-topaz    { clip-path: polygon(18% 0, 82% 0, 100% 50%, 82% 100%, 18% 100%, 0 50%); }
.cut-citrine  { clip-path: polygon(50% 4%, 100% 96%, 0 96%); }
.cut-emerald  { clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); }
.cut-sapphire { clip-path: polygon(50% 0, 100% 38%, 81% 100%, 19% 100%, 0 38%); }
.cut-amethyst { clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); }
.cut-magic    { clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }

/* ---- controls ------------------------------------------------------ */

#pad {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 6px;
}
#pad button {
	aspect-ratio: 1 / 1;
	font-size: 19px;
	color: var(--text);
	background: #16203a;
	border: 1px solid #253451;
	border-radius: 6px;
	cursor: pointer;
	transition: background .12s, border-color .12s;
	touch-action: manipulation;
	-webkit-user-select: none;
	user-select: none;
}
#pad button:hover { background: #1e2b4b; border-color: #38507a; }
#pad button:active { background: #2a3c66; }
#pad button:focus-visible { outline: 2px solid #7fd3ff; outline-offset: 2px; }

.panel-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.panel-foot button {
	padding: 8px 6px;
	font-family: var(--disp);
	font-size: 11px;
	letter-spacing: .08em;
	color: var(--dim);
	background: transparent;
	border: 1px solid var(--rule);
	border-radius: 5px;
	cursor: pointer;
	transition: color .12s, border-color .12s;
}
.panel-foot button:hover { color: var(--text); border-color: #38507a; }
.panel-foot button:focus-visible { outline: 2px solid #7fd3ff; outline-offset: 2px; }

.hint {
	margin: 0;
	font-size: 11px;
	line-height: 1.6;
	color: var(--dim);
}

/* ---- narrow ---------------------------------------------------------- */

@media (max-width: 760px) {
	#game { flex-direction: column; gap: 12px; padding: 10px; }
	#well { max-width: none; flex: 1 1 auto; min-height: 0; }
	#panel {
		flex: 0 0 auto;
		display: grid;
		grid-template-columns: 1fr auto;
		grid-template-areas: "readout pad" "next pad" "foot pad";
		gap: 8px 12px;
		align-items: start;
	}
	#panel h1, .hint { display: none; }
	.readout { grid-area: readout; grid-template-columns: repeat(4, 1fr); }
	.stat.wide { grid-column: span 2; }
	.value { font-size: 15px; }
	.stat.wide .value { font-size: 18px; }
	.next-block { grid-area: next; display: flex; align-items: center; gap: 10px; }
	#next { flex-direction: row; margin-top: 0; min-height: 0; }
	.chip { width: 19px; height: 19px; }
	.panel-foot { grid-area: foot; }
	#pad { grid-area: pad; width: 156px; }
	#pad button { font-size: 16px; }
}

@media (max-width: 420px) {
	#pad { width: 132px; }
	.readout { grid-template-columns: repeat(2, 1fr); }
}

/* site-nav:start (stripped from the downloadable copy) */
.site-back {
	position: fixed;
	top: calc(10px + env(safe-area-inset-top, 0px));
	left: 12px;
	z-index: 20;
	font-family: var(--mono);
	font-size: 11px;
	letter-spacing: .12em;
	text-transform: uppercase;
	text-decoration: none;
	color: var(--dim);
	background: var(--case);
	padding: 7px 13px;
	border: 1px solid var(--rule);
	border-radius: 5px;
	transition: color .18s, border-color .18s;
}
.site-back:hover { color: var(--text); border-color: #3c5178; }
.site-back:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (max-width: 900px) { .site-back { position: static; display: inline-block; margin: 8px 0 0 10px; } }
/* site-nav:end */
