/*
 * Trophy Guessr, styled for a black, white and green brand.
 * The trophy stands on a black base with a green edge, like the site header.
 * The nameplate stays blank until the guess, then the name lights up.
 * Override any token in your theme, for example: .tg-game { --tg-green: #00ff66; }
 */

.tg-game {
	--tg-green: #62fa3c;
	--tg-green-dim: rgba(98, 250, 60, 0.14);
	--tg-black: #000000;
	--tg-surface: #0d0d0d;
	--tg-raised: #161616;
	--tg-white: #ffffff;
	--tg-text: #f2f2f2;
	--tg-muted: #a6a6a6;
	--tg-line: #2c2c2c;
	--tg-ocean: #05070d;
	--tg-land: #2a2a2a;
	--tg-border: #4a4a4a;
	--tg-radius: 8px;

	container-type: inline-size;
	/* Never wider than its column, whatever the theme does. */
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	overflow: hidden;
	color: var(--tg-text);
	background: var(--tg-surface);
	border: 1px solid var(--tg-line);
	border-radius: var(--tg-radius);
	padding: clamp(16px, 3cqi, 32px);
	margin: 1.5em 0;
	line-height: 1.5;
	text-align: left;
}

.tg-game *,
.tg-game *::before,
.tg-game *::after {
	box-sizing: border-box;
}

.tg-game p {
	margin: 0;
	color: inherit;
}

.tg-empty,
.tg-loading,
.tg-game .tg-note,
.tg-game .tg-hint {
	color: var(--tg-muted, #a6a6a6);
}

.tg-game .tg-error {
	color: #ff7a7a;
	margin-bottom: 12px;
}

.tg-game a {
	color: var(--tg-green);
}

/* Buttons */

.tg-game .tg-btn {
	appearance: none;
	font: inherit;
	font-weight: 700;
	line-height: 1.2;
	padding: 0.8em 1.4em;
	border-radius: 999px;
	border: 2px solid var(--tg-green);
	cursor: pointer;
	text-decoration: none;
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.tg-game .tg-primary {
	background: var(--tg-green);
	color: var(--tg-black);
}

.tg-game .tg-primary:hover:not(:disabled) {
	background: var(--tg-white);
	border-color: var(--tg-white);
	color: var(--tg-black);
}

.tg-game .tg-secondary {
	background: transparent;
	color: var(--tg-white);
	border-color: var(--tg-white);
}

.tg-game .tg-secondary:hover:not(:disabled) {
	background: var(--tg-white);
	color: var(--tg-black);
}

.tg-game .tg-btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.tg-game .tg-btn:focus-visible,
.tg-game input:focus-visible,
.tg-game a:focus-visible {
	outline: 3px solid var(--tg-white);
	outline-offset: 3px;
}

.tg-game .tg-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-top: 24px;
}

/* Intro */

.tg-game .tg-intro {
	max-width: 38em;
}

.tg-game .tg-cup {
	width: 52px;
	color: var(--tg-green);
	margin-bottom: 12px;
}

.tg-game .tg-cup svg {
	display: block;
	width: 100%;
	height: auto;
	fill: currentColor;
}

.tg-game .tg-title {
	font-family: inherit;
	font-size: clamp(2rem, 6cqi, 3rem);
	font-weight: 900;
	font-style: italic;
	line-height: 1;
	letter-spacing: -0.01em;
	margin: 0 0 12px;
	color: var(--tg-green);
}

.tg-game .tg-intro .tg-question {
	font-size: 1.2rem;
	font-weight: 700;
	color: var(--tg-white);
	margin-bottom: 8px;
}

.tg-game .tg-lede {
	color: var(--tg-muted);
	max-width: 34em;
}

.tg-game .tg-intro .tg-note {
	margin-top: 12px;
}

/* Play screen */

.tg-game .tg-bar {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	font-weight: 700;
	margin-bottom: 16px;
	font-variant-numeric: tabular-nums;
	color: var(--tg-white);
}

.tg-game .tg-running {
	color: var(--tg-green);
}

.tg-game .tg-stage {
	/* Flex with wrapping instead of grid: the photo and map sit side by side
	   when there is room, and stack when there is not. */
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	align-items: stretch;
}

.tg-game .tg-stage > .tg-plinth {
	flex: 1 1 300px;
	max-width: 100%;
	min-width: 0;
}

.tg-game .tg-stage > .tg-mapwrap {
	flex: 2 1 420px;
	max-width: 100%;
	min-width: 0;
}

/* The trophy stand: dark stage, black base, green edge */

.tg-game .tg-plinth {
	margin: 0;
	display: flex;
	flex-direction: column;
	border-radius: var(--tg-radius);
	overflow: hidden;
	background: var(--tg-black);
	border: 1px solid var(--tg-line);
}

.tg-game .tg-photo {
	flex: 1;
	min-height: 240px;
	display: grid;
	place-items: center;
	padding: 20px;
	background: radial-gradient(ellipse at 50% 35%, #2b2b2b 0%, #101010 70%);
}

.tg-game .tg-photo img {
	display: block;
	max-width: 100%;
	max-height: 220px;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
	transition: opacity 0.2s ease;
}

.tg-game .tg-photo.is-loading img {
	opacity: 0;
}

.tg-game .tg-base {
	padding: 16px;
	background: var(--tg-black);
	border-top: 3px solid var(--tg-green);
	display: flex;
	justify-content: center;
}

.tg-game .tg-plate {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	min-width: min(100%, 260px);
	max-width: 100%;
	padding: 10px 22px;
	border-radius: 4px;
	text-align: center;
	color: var(--tg-white);
	background: #111111;
	border: 1px solid var(--tg-green);
}

.tg-game .tg-plate-name {
	font-size: 1.25rem;
	font-weight: 800;
	line-height: 1.2;
	color: var(--tg-white);
	overflow-wrap: anywhere;
}

.tg-game .tg-plate-sub {
	font-size: 0.85rem;
	color: var(--tg-muted);
}

/* The one animated moment: the plate lights up green as the name appears */
.tg-game .tg-plate.is-engraved {
	animation: tg-light 1s ease-out 1;
}

.tg-game .tg-plate.is-engraved .tg-plate-name {
	animation: tg-reveal 0.45s ease-out 1;
}

@keyframes tg-light {
	0% { box-shadow: 0 0 0 0 rgba(98, 250, 60, 0.7); }
	100% { box-shadow: 0 0 0 14px rgba(98, 250, 60, 0); }
}

@keyframes tg-reveal {
	from { opacity: 0; transform: translateY(4px); }
	to { opacity: 1; transform: none; }
}

/* Map */

.tg-game .tg-mapwrap {
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-width: 0;
}

.tg-game .tg-mapwrap .tg-question {
	font-weight: 700;
	color: var(--tg-white);
}

.tg-game .tg-map-frame {
	position: relative;
	flex: 1;
	min-height: 300px;
}

.tg-game .tg-map {
	position: absolute;
	inset: 0;
	border-radius: var(--tg-radius);
	border: 1px solid var(--tg-line);
	background: var(--tg-ocean);
	cursor: crosshair;
}

@container (min-width: 760px) {
	.tg-game .tg-map-frame { min-height: 420px; }
	.tg-game .tg-photo img { max-height: 340px; }
}

.tg-game .tg-map:focus-visible {
	outline: 3px solid var(--tg-green);
	outline-offset: 2px;
}

/* Keep theme styles off the map controls */
.tg-game .leaflet-control-zoom a {
	background: var(--tg-raised);
	color: var(--tg-white);
	border-color: var(--tg-line);
	text-decoration: none;
}

.tg-game .leaflet-control-zoom a:hover {
	background: var(--tg-green);
	color: var(--tg-black);
}

.tg-game .leaflet-control-zoom a.leaflet-disabled {
	background: var(--tg-surface);
	color: #555555;
}

.tg-game .leaflet-control-attribution {
	background: rgba(0, 0, 0, 0.7);
	color: var(--tg-muted);
	font-size: 11px;
}

.tg-game .leaflet-control-attribution a {
	color: var(--tg-muted);
}

.tg-game .tg-crosshair {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 26px;
	height: 26px;
	margin: -13px 0 0 -13px;
	z-index: 500;
	pointer-events: none;
	opacity: 0;
	background:
		linear-gradient(var(--tg-green), var(--tg-green)) center / 2px 100% no-repeat,
		linear-gradient(var(--tg-green), var(--tg-green)) center / 100% 2px no-repeat;
}

.tg-game .tg-map:focus-visible + .tg-crosshair {
	opacity: 1;
}

.tg-game .tg-pin span {
	display: block;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: 3px solid var(--tg-black);
	box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.tg-game .tg-pin-guess span {
	background: var(--tg-white);
}

.tg-game .tg-pin-answer span {
	background: var(--tg-green);
	box-shadow: 0 0 0 4px rgba(98, 250, 60, 0.3);
}

/* Result panel */

.tg-game .tg-panel {
	margin-top: 18px;
	min-height: 3em;
}

.tg-game .tg-result {
	display: grid;
	gap: 6px;
	max-width: 42em;
}

.tg-game .tg-gain {
	font-size: 1.8rem;
	font-weight: 900;
	font-style: italic;
	line-height: 1.1;
	color: var(--tg-green);
	font-variant-numeric: tabular-nums;
}

.tg-game .tg-distance {
	font-weight: 700;
	color: var(--tg-white);
}

.tg-game .tg-fact {
	color: var(--tg-text);
}

.tg-game .tg-credit {
	font-size: 0.85rem;
	color: var(--tg-muted);
}

.tg-game .tg-credit a {
	color: inherit;
}

.tg-game .tg-actions {
	margin-top: 18px;
}

/* End screen */

.tg-game .tg-end {
	max-width: 42em;
	margin: 0 auto;
}

.tg-game .tg-plinth-final {
	max-width: 360px;
	margin: 0 auto 24px;
	align-items: stretch;
}

.tg-game .tg-plinth-final .tg-cup {
	width: 84px;
	margin: 0 auto;
	padding: 24px 0 12px;
}

.tg-game .tg-plinth-final .tg-plate-name {
	font-size: 2.2rem;
	font-weight: 900;
	font-style: italic;
	color: var(--tg-green);
	font-variant-numeric: tabular-nums;
}

.tg-game .tg-recap {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 12px;
}

.tg-game .tg-recap li {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 2px 12px;
	padding: 0 0 12px;
	margin: 0;
	border-bottom: 1px solid var(--tg-line);
}

.tg-game .tg-recap li::before,
.tg-game .tg-recap li::marker {
	content: none;
}

.tg-game .tg-recap-name {
	font-weight: 700;
	color: var(--tg-white);
}

.tg-game .tg-recap-pts {
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	text-align: right;
	color: var(--tg-green);
}

.tg-game .tg-recap-meta {
	grid-column: 1 / -1;
	color: var(--tg-muted);
	font-size: 0.9rem;
}

.tg-game .tg-meter {
	grid-column: 1 / -1;
	height: 6px;
	border-radius: 3px;
	background: var(--tg-raised);
	overflow: hidden;
	margin-top: 4px;
}

.tg-game .tg-meter span {
	display: block;
	height: 100%;
	background: var(--tg-green);
}

/* Leaderboard */

.tg-game .tg-board {
	margin-top: 32px;
}

.tg-game .tg-board h3 {
	font-family: inherit;
	font-size: 1.4rem;
	font-weight: 900;
	font-style: italic;
	margin: 0 0 12px;
	color: var(--tg-white);
}

.tg-game .tg-board-form {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 8px 10px;
	margin-bottom: 8px;
}

.tg-game .tg-board-form label {
	flex-basis: 100%;
	font-weight: 700;
	color: var(--tg-white);
}

.tg-game .tg-board-form input {
	flex: 1 1 200px;
	font: inherit;
	padding: 0.7em 0.9em;
	border: 1px solid var(--tg-border);
	border-radius: var(--tg-radius);
	background: var(--tg-black);
	color: var(--tg-white);
}

.tg-game .tg-board-msg {
	min-height: 1.5em;
	margin-bottom: 8px;
	font-weight: 700;
	color: var(--tg-green);
}

.tg-game .tg-board table {
	width: 100%;
	border-collapse: collapse;
	font-variant-numeric: tabular-nums;
	background: transparent;
	color: var(--tg-text);
	margin: 0;
}

.tg-game .tg-board th,
.tg-game .tg-board td {
	padding: 9px 10px;
	border: 0;
	border-bottom: 1px solid var(--tg-line);
	text-align: left;
	background: transparent;
	color: inherit;
}

.tg-game .tg-board th:last-child,
.tg-game .tg-board td:last-child {
	text-align: right;
}

.tg-game .tg-board th {
	font-size: 0.85rem;
	color: var(--tg-muted);
	font-weight: 700;
}

.tg-game .tg-board tr.is-you td {
	background: var(--tg-green-dim);
	color: var(--tg-white);
	font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
	.tg-game .tg-plate.is-engraved,
	.tg-game .tg-plate.is-engraved .tg-plate-name {
		animation: none;
	}
	.tg-game .tg-btn,
	.tg-game .tg-photo img {
		transition: none;
	}
}

/* Some themes recolor every SVG path; keep the trophy icon intact. */
.tg-game .tg-cup svg path[fill="currentColor"] {
	fill: currentColor !important;
	stroke: none !important;
}

.tg-game .tg-cup svg path[fill="none"] {
	fill: none !important;
	stroke: currentColor !important;
}

.tg-fallback {
	max-width: 100%;
	overflow: hidden;
}

.tg-game .leaflet-container {
	max-width: 100%;
}

.tg-game .tg-daily-note {
	margin-top: 12px;
	font-size: 0.9rem;
}
