.ntg-game-term {
	/* Theme-aware brass: light=#B8892E / dark=#D4B06A. Avoid fixed brown (fails on dark bg). */
	border-block-end: 1px dotted color-mix(in srgb, var(--ntg-brass, #b8892e) 70%, transparent);
	color: var(--ntg-brass, #b8892e);
	cursor: help;
	font-weight: 650;
	outline: none;
	text-decoration: none;
	text-underline-offset: .16em;
}

/* Wiki catalogue overlap badges (5e / Mystra). Not part of tooltip cards. */
.ntg-spell-overlap {
	background: color-mix(in srgb, var(--ntg-brass, #b8892e) 16%, transparent);
	border: 1px solid color-mix(in srgb, var(--ntg-brass, #b8892e) 45%, transparent);
	border-radius: 999px;
	color: color-mix(in srgb, var(--ntg-brass, #b8892e) 82%, var(--ntg-ink, #1a1c1e));
	display: inline-block;
	font-family: ui-sans-serif, system-ui, sans-serif;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .02em;
	line-height: 1;
	margin-inline-start: .35em;
	padding: .22em .55em;
	vertical-align: middle;
	white-space: nowrap;
}

.ntg-spell-overlap--5e {
	background: color-mix(in srgb, #3b82f6 14%, transparent);
	border-color: color-mix(in srgb, #3b82f6 42%, transparent);
	color: color-mix(in srgb, #2563eb 70%, var(--ntg-ink, #1a1c1e));
}

.ntg-spell-overlap--mystra {
	background: color-mix(in srgb, #a855f7 14%, transparent);
	border-color: color-mix(in srgb, #a855f7 42%, transparent);
	color: color-mix(in srgb, #7e22ce 70%, var(--ntg-ink, #1a1c1e));
}

.ntg-spell-overlap-legend {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	font-size: .92em;
	gap: .35em .5em;
	margin-block: .4em .8em;
}

.ntg-game-term:hover,
.ntg-game-term:focus-visible,
.ntg-game-term[aria-expanded="true"] {
	border-block-end-color: var(--ntg-brass, #b8892e);
	border-block-end-style: solid;
	color: color-mix(in srgb, var(--ntg-brass, #b8892e) 68%, var(--ntg-ink, #1a1c1e));
	text-shadow: 0 0 10px color-mix(in srgb, var(--ntg-brass, #b8892e) 28%, transparent);
}

.ntg-game-term:focus-visible {
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--ntg-brass, #b8892e) 55%, transparent);
}

.ntg-game-tooltip {
	/* Card is always BG3-dark UI; do not inherit site theme text colors. */
	--ntg-term-accent: #d2c49a;
	--ntg-term-fg: #f2ece0;
	--ntg-term-fg-muted: #d0c3a8;
	--ntg-term-fg-soft: #c4b59a;
	background: transparent;
	border: 0;
	box-sizing: border-box;
	color: var(--ntg-term-fg);
	color-scheme: dark;
	font-family: Georgia, "Times New Roman", serif;
	inline-size: min(420px, calc(100vw - 24px));
	inset: auto;
	left: 0;
	margin: 0;
	max-block-size: min(72vh, 620px);
	opacity: 0;
	overflow: auto;
	padding: 0;
	pointer-events: none;
	position: fixed;
	top: 0;
	transform: translateY(6px) scale(.985);
	transform-origin: 50% 0;
	transition:
		opacity 160ms cubic-bezier(.2, .8, .2, 1),
		transform 160ms cubic-bezier(.2, .8, .2, 1),
		visibility 0s linear 160ms;
	visibility: hidden;
	will-change: opacity, transform;
	z-index: 100000;
}

.ntg-game-tooltip[data-open="true"],
.ntg-game-tooltip--preview {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0) scale(1);
	transition-delay: 0s;
	visibility: visible;
}

.ntg-game-tooltip[data-positioning="true"] {
	transition: none;
	visibility: hidden;
}

.ntg-game-tooltip--preview {
	position: relative;
	left: auto;
	top: auto;
	transform: none;
}

.ntg-game-tooltip__card {
	background:
		linear-gradient(180deg, rgb(55 43 34 / .97), rgb(24 21 20 / .99) 72%, rgb(39 24 48 / .99)),
		var(--nettoge-retro-core-card-bg, #241f1c);
	border: 1px solid #8c7049;
	border-block-end-color: #695082;
	border-radius: 4px;
	box-shadow: 0 14px 38px rgb(0 0 0 / .58), inset 0 0 0 1px rgb(231 196 128 / .12);
	min-block-size: 150px;
	overflow: hidden;
	position: relative;
}

.ntg-game-tooltip__card::after {
	background: linear-gradient(90deg, transparent, #9367b4 48%, transparent);
	block-size: 2px;
	content: "";
	inset: auto 0 0;
	opacity: .9;
	position: absolute;
}

.ntg-game-tooltip__card[data-rarity="uncommon"] { --ntg-term-accent: #55bd78; }
.ntg-game-tooltip__card[data-rarity="rare"] { --ntg-term-accent: #72a9e8; }
.ntg-game-tooltip__card[data-rarity="very-rare"] { --ntg-term-accent: #d983ef; }
.ntg-game-tooltip__card[data-rarity="legendary"] { --ntg-term-accent: #e5b249; }

.ntg-game-tooltip__header {
	align-items: flex-start;
	border-block-end: 1px solid rgb(189 157 101 / .28);
	display: flex;
	justify-content: space-between;
	min-block-size: 82px;
	padding: 18px 106px 12px 20px;
	position: relative;
}

.ntg-game-tooltip__title {
	color: var(--ntg-term-accent);
	font-size: clamp(21px, 4vw, 28px);
	font-weight: 500;
	line-height: 1.12;
	margin: 0;
}

.ntg-game-tooltip__subtitle {
	color: var(--ntg-term-fg-muted);
	font-size: 14px;
	margin: 4px 0 0;
}

.ntg-game-tooltip__icon {
	filter: drop-shadow(0 0 7px color-mix(in srgb, var(--ntg-term-accent) 58%, transparent));
	block-size: 94px;
	inline-size: 94px;
	inset: 4px 8px auto auto;
	object-fit: contain;
	position: absolute;
}

.ntg-game-tooltip__summary,
.ntg-game-tooltip__description {
	color: var(--ntg-term-fg);
	font-size: 16px;
	line-height: 1.45;
	margin: 0;
	padding: 14px 20px;
}

.ntg-game-tooltip__description {
	border-block-start: 1px solid rgb(176 145 96 / .19);
	color: var(--ntg-term-fg-soft);
	font-size: 14px;
	font-style: italic;
}

.ntg-game-tooltip__description > :first-child { margin-block-start: 0; }
.ntg-game-tooltip__description > :last-child { margin-block-end: 0; }

.ntg-game-tooltip__effects,
.ntg-game-tooltip__facts,
.ntg-game-tooltip__sections,
.ntg-game-tooltip__actions {
	border-block-start: 1px solid rgb(176 145 96 / .19);
	padding: 10px 20px;
}

.ntg-game-tooltip__facts {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ntg-game-tooltip__actions {
	background: linear-gradient(90deg, rgb(70 40 80 / .34), rgb(34 25 37 / .12));
}

.ntg-game-tooltip__row {
	align-items: center;
	display: flex;
	font-size: 15px;
	gap: .5em;
	line-height: 1.35;
	min-inline-size: 0;
	padding: 4px 0;
}

.ntg-game-tooltip__row strong {
	color: var(--ntg-term-fg-muted);
	flex: 0 0 auto;
	font-weight: 600;
	white-space: nowrap;
}

.ntg-game-tooltip__row span {
	color: var(--ntg-term-fg);
	min-inline-size: 0;
	overflow-wrap: anywhere;
}

.ntg-game-tooltip__resource-icon {
	background-image: var(--ntg-resource-icon);
	background-position: center;
	background-repeat: no-repeat;
	background-size: contain;
	block-size: 22px;
	display: inline-block;
	filter: drop-shadow(0 1px 2px rgb(0 0 0 / .82));
	flex: 0 0 22px;
	inline-size: 22px;
}

.ntg-game-tooltip__actions .ntg-game-tooltip__resource-icon {
	block-size: 26px;
	flex-basis: 26px;
	inline-size: 26px;
}

.ntg-game-tooltip__resource-icon[data-icon="action"] {
	--ntg-resource-icon: url("icons/action.png");
}

.ntg-game-tooltip__resource-icon[data-icon="bonus-action"] {
	--ntg-resource-icon: url("icons/bonus-action.png");
}

.ntg-game-tooltip__resource-icon[data-icon="reaction"] {
	--ntg-resource-icon: url("icons/reaction.png");
}

.ntg-game-tooltip__resource-icon[data-icon="movement"] {
	--ntg-resource-icon: url("icons/movement.png");
}

.ntg-game-tooltip__resource-icon[data-icon="range"] {
	--ntg-resource-icon: url("icons/range.png");
}

.ntg-game-tooltip__resource-icon[data-icon="duration"] {
	--ntg-resource-icon: url("icons/duration.png");
}

.ntg-game-tooltip__resource-icon[data-icon="concentration"] {
	--ntg-resource-icon: url("icons/concentration.png");
}

.ntg-game-tooltip__resource-icon[data-icon="saving-throw"] {
	--ntg-resource-icon: url("icons/saving-throw.png");
}

.ntg-game-tooltip__resource-icon[data-icon="spell-slot"] {
	--ntg-resource-icon: url("icons/spell-slot.png");
}

.ntg-game-tooltip__close {
	background: rgb(10 9 9 / .7);
	border: 1px solid #9b8158;
	border-radius: 2px;
	color: var(--ntg-term-fg);
	cursor: pointer;
	display: none;
	font: 700 18px/1 sans-serif;
	inset: 7px 7px auto auto;
	min-block-size: 32px;
	min-inline-size: 32px;
	position: absolute;
	z-index: 2;
}

@media (hover: none), (pointer: coarse) {
	.ntg-game-tooltip__close { display: block; }
	.ntg-game-tooltip__header { padding-inline-end: 100px; }
}

@media (max-width: 480px) {
	.ntg-game-tooltip { inline-size: calc(100vw - 16px); }
	.ntg-game-tooltip__header { padding-inline-start: 16px; }
	.ntg-game-tooltip__summary,
	.ntg-game-tooltip__description,
	.ntg-game-tooltip__effects,
	.ntg-game-tooltip__facts,
	.ntg-game-tooltip__sections,
	.ntg-game-tooltip__actions { padding-inline: 16px; }
	.ntg-game-tooltip__facts { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
	.ntg-game-tooltip { transition: none; }
}
