/* BGM Tools: Board Game Dice Roller. Prefix bgmt-. Square corners throughout. */
.bgmt {
	--bgmt-ink: #031441;
	--bgmt-paper: #fff;
	--bgmt-tint: #eef1f8;
	--bgmt-line: 2px solid var(--bgmt-ink);
	--bgmt-s: clamp(84px, 24vw, 128px);
	--bgmt-head: var(--wp--preset--font-family--tagesschrift, var(--wp--preset--font-family--heading, "Tagesschrift", Georgia, serif));
	box-sizing: border-box;
	max-width: 760px;
	margin: 0 auto;
	padding: 24px 16px 48px;
	color: var(--bgmt-ink);
	text-align: center;
}
.bgmt *, .bgmt *::before, .bgmt *::after { box-sizing: border-box; }

.bgmt-head { margin-bottom: 28px; }
.bgmt--embedded { padding-top: 0; }
.bgmt-logo { display: inline-block; max-width: min(360px, 80%); margin-bottom: 20px; line-height: 0; }
.bgmt-logo img { display: block; width: 100%; height: auto; }
.bgmt-title { margin: 0 0 12px; line-height: 1.1; }
.bgmt-intro { max-width: 56ch; margin: 0 auto; line-height: 1.55; }

/* Buttons: strictly square */
.bgmt-btn {
	appearance: none;
	min-height: 48px;
	padding: 10px 22px;
	border: var(--bgmt-line);
	border-radius: 0;
	background: var(--bgmt-paper);
	color: var(--bgmt-ink);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background-color .15s, color .15s;
}
.bgmt-btn:hover { background: var(--bgmt-tint); }
.bgmt-btn[aria-pressed="true"], .bgmt-btn--primary, .bgmt-btn.is-active { background: var(--bgmt-ink); color: var(--bgmt-paper); }
.bgmt-btn[aria-pressed="true"]:hover, .bgmt-btn--primary:hover, .bgmt-btn.is-active:hover { background: #0a2766; }
.bgmt-btn:focus-visible { outline: 3px solid #e0a800; outline-offset: 3px; }
.bgmt-btn[disabled] { opacity: .6; cursor: progress; }

.bgmt-controls { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 16px; }
.bgmt-group { display: flex; }
.bgmt-group .bgmt-btn + .bgmt-btn { margin-left: -2px; }

/* Special Cubes drawer */
.bgmt-special { margin: 0 auto 16px; padding: 16px; border: var(--bgmt-line); background: var(--bgmt-tint); text-align: left; }
.bgmt-special[hidden] { display: none; }
.bgmt-special h2 { margin: 0 0 10px; font-size: 1rem; }
.bgmt-special-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.bgmt-special-list .bgmt-btn { width: 100%; padding: 8px 12px; text-align: left; }
.bgmt-special-list small { display: block; font-weight: 400; opacity: .8; }

/* Stage */
.bgmt-stage { margin: 0 0 20px; padding: 28px 16px 24px; border: var(--bgmt-line); background: var(--bgmt-paper); }
.bgmt-kind { margin: 0 0 18px; font-size: .85rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.bgmt-dice-row { display: flex; flex-wrap: wrap; gap: calc(var(--bgmt-s) * .45); justify-content: center; align-items: flex-end; min-height: calc(var(--bgmt-s) * 1.5); padding-bottom: calc(var(--bgmt-s) * .2); perspective: 700px; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent; }
.bgmt-result { margin: 22px 0 4px; font-family: var(--bgmt-head); font-size: clamp(2rem, 8vw, 3.2rem); line-height: 1.1; }
.bgmt-detail { min-height: 1.5em; margin: 0; }

.bgmt-roll { width: min(100%, 320px); min-height: 60px; font-size: 1.15rem; }
.bgmt-noscript { margin-top: 16px; }

/* One die: toss wrapper (bounce) around a tilted 3D cube */
.bgmt-die { position: relative; width: var(--bgmt-s); height: var(--bgmt-s); }
.bgmt-toss { position: absolute; inset: 0; }
.bgmt-shadow { position: absolute; left: 8%; right: 8%; bottom: calc(var(--bgmt-s) * -.16); height: calc(var(--bgmt-s) * .1); background: rgba(3, 20, 65, .25); filter: blur(4px); }
.bgmt-tilt { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateX(-50deg) rotateY(-18deg); }
.bgmt-cube { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 1.05s cubic-bezier(.17, .8, .25, 1); }
.bgmt-face {
	position: absolute; inset: 0;
	display: grid; place-items: center;
	border: var(--bgmt-line);
	background: var(--bgmt-paper);
	color: var(--bgmt-ink);
	font-family: var(--bgmt-head);
	font-size: calc(var(--bgmt-s) * .3);
	line-height: 1;
	text-align: center;
	backface-visibility: hidden;
}
.bgmt-face[data-f="0"] { transform: translateZ(calc(var(--bgmt-s) / 2)); }
.bgmt-face[data-f="1"] { transform: rotateY(180deg) translateZ(calc(var(--bgmt-s) / 2)); }
.bgmt-face[data-f="2"] { transform: rotateY(90deg) translateZ(calc(var(--bgmt-s) / 2)); }
.bgmt-face[data-f="3"] { transform: rotateY(-90deg) translateZ(calc(var(--bgmt-s) / 2)); }
.bgmt-face[data-f="4"] { transform: rotateX(90deg) translateZ(calc(var(--bgmt-s) / 2)); }
.bgmt-face[data-f="5"] { transform: rotateX(-90deg) translateZ(calc(var(--bgmt-s) / 2)); }
.bgmt-face.is-word { font-size: calc(var(--bgmt-s) * .17); padding: 4px; }

/* Pips */
.bgmt-pips { display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); width: 70%; height: 70%; }
.bgmt-pip { align-self: center; justify-self: center; width: 68%; aspect-ratio: 1; border-radius: 50%; background: var(--bgmt-ink); }

/* Flat dice (d4 to d100, coin) */
.bgmt-flat { position: absolute; inset: 0; display: grid; place-items: center; border: var(--bgmt-line); background: var(--bgmt-paper); font-family: var(--bgmt-head); font-size: calc(var(--bgmt-s) * .42); }
.bgmt-flat small { position: absolute; top: 4px; left: 6px; font: 600 .7rem/1 system-ui, sans-serif; letter-spacing: .05em; }
.bgmt-flat.is-wide { font-size: calc(var(--bgmt-s) * .3); }

/* Roll motion */
.bgmt-die.is-rolling .bgmt-toss { animation: bgmt-toss 1.05s cubic-bezier(.3, .1, .4, 1); }
.bgmt-die.is-rolling .bgmt-shadow { animation: bgmt-shadow 1.05s ease-out; }
.bgmt-die.is-rolling .bgmt-flat { animation: bgmt-spin 1.05s cubic-bezier(.2, .7, .2, 1); }
@keyframes bgmt-toss {
	0%   { transform: translateY(0); }
	28%  { transform: translateY(calc(var(--bgmt-s) * -.7)) rotate(-6deg); }
	55%  { transform: translateY(0) rotate(3deg); }
	72%  { transform: translateY(calc(var(--bgmt-s) * -.18)) rotate(-1deg); }
	100% { transform: translateY(0); }
}
@keyframes bgmt-shadow { 0%, 55%, 100% { transform: scaleX(1); opacity: 1; } 28% { transform: scaleX(.6); opacity: .5; } 72% { transform: scaleX(.85); opacity: .8; } }
@keyframes bgmt-spin { from { transform: rotate(0); } to { transform: rotate(540deg); } }

@media (prefers-reduced-motion: reduce) {
	.bgmt-cube { transition: none; }
	.bgmt-die.is-rolling .bgmt-toss, .bgmt-die.is-rolling .bgmt-shadow, .bgmt-die.is-rolling .bgmt-flat { animation: none; }
	.bgmt-btn { transition: none; }
}

.bgmt-uses { margin: 18px 0 0; font-size: .9rem; opacity: .85; }

/* Stepper and many dice */
.bgmt-stepper { display: flex; align-items: stretch; }
.bgmt-step { min-width: 52px; padding: 10px 0; font-size: 1.4rem; line-height: 1; }
.bgmt-count-out { display: grid; place-items: center; min-width: 96px; padding: 0 12px; border-top: var(--bgmt-line); border-bottom: var(--bgmt-line); background: var(--bgmt-paper); font-weight: 600; }
.bgmt-stepper .bgmt-btn:first-child { border-right-width: 1px; }
.bgmt-stepper .bgmt-btn:last-child { border-left-width: 1px; }
.bgmt-btn[disabled]:not([aria-busy]) { opacity: .4; }
.bgmt-dice-row[data-n="3"], .bgmt-dice-row[data-n="4"] { --bgmt-s: clamp(64px, 17vw, 100px); }
.bgmt-dice-row[data-n="5"], .bgmt-dice-row[data-n="6"], .bgmt-dice-row[data-n="7"], .bgmt-dice-row[data-n="8"] { --bgmt-s: clamp(52px, 13vw, 82px); }
.bgmt-intro + .bgmt-intro { margin-top: 12px; }
.bgmt-intro a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
