/* =========================================================================
   Wheel of Names - spinner application
   Runs inside its own iframe document, so selectors stay simple and safe.

   Layout contract: the document is exactly as tall as the frame (100%), the
   wheel fills whatever square fits the stage, and only the side panel scrolls.
   Nothing here ever measures or reports a height, so the embed can never
   thrash the host page's layout.
   ========================================================================= */

:root {
	--brand: #3944fb;
	--brand-2: #6c76ff;
	--brand-3: #8f97ff;
	--bg: #070b18;
	--panel: #0e1330;
	--panel-2: #0a0e24;
	--line: rgba(120, 133, 255, .18);
	--line-strong: rgba(120, 133, 255, .34);
	--soft: rgba(120, 133, 255, .09);
	--soft-2: rgba(120, 133, 255, .15);
	--text: #eef1ff;
	--muted: #9aa4cf;
	--good: #22c55e;
	--bad: #f43f5e;
	--radius: 20px;
	--radius-sm: 13px;
	--radius-xs: 10px;
	--shadow: 0 24px 60px rgba(3, 6, 20, .55);
	--pageBg: #070b18;
	--stageBg: #3944fb;
	--gap: 16px;
	/* Headings use Schibsted Grotesk at 600, matching the pages around the app. */
	--headingFont: "Schibsted Grotesk", "Segoe UI", system-ui, Arial, sans-serif;
	--headingWeight: 600;
	color-scheme: dark;
}

.spw-brand-text b,
.spw-dialog-title,
.spw-win-name,
.spw-setting > label,
.spw-h {
	font-family: var(--headingFont);
	font-weight: var(--headingWeight);
	font-optical-sizing: auto;
}

* { box-sizing: border-box; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--soft-2); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

html, body {
	height: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden;
	background: var(--pageBg);
	color: var(--text);
	font: 400 15px/1.55 "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
	-webkit-text-size-adjust: 100%;
	-webkit-font-smoothing: antialiased;
	scrollbar-width: thin;
	scrollbar-color: var(--soft-2) transparent;
}

img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }

.spw-sr {
	position: absolute !important;
	width: 1px; height: 1px;
	margin: -1px; padding: 0;
	overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.spw-live { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; margin: 0; }

.spw-skip {
	position: absolute; left: 10px; top: -70px; z-index: 60;
	background: var(--brand); color: #fff; padding: 11px 18px;
	border-radius: 10px; text-decoration: none; font-weight: 700;
	transition: top .18s ease;
}
.spw-skip:focus { top: 10px; }

/* ---------- App shell ---------------------------------------------------- */

.spw-app {
	position: relative;
	height: 100%;
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 14px 16px 16px;
	background:
		radial-gradient(1100px 620px at 10% -14%, rgba(57, 68, 251, .34), transparent 62%),
		radial-gradient(880px 540px at 104% 2%, rgba(140, 120, 255, .20), transparent 58%),
		var(--pageBg);
	overflow: hidden;
}
.spw-app.spw-no-gradient { background: var(--pageBg); }

/* ---------- Top bar: brand + categories --------------------------------- */

.spw-topbar {
	display: flex;
	align-items: center;
	gap: 14px;
	flex: 0 0 auto;
	min-width: 0;
}

.spw-brand {
	display: inline-flex;
	align-items: center;
	gap: 11px;
	flex: 0 0 auto;
	padding-right: 14px;
	border-right: 1px solid var(--line);
	min-width: 0;
}
.spw-brand-mark {
	width: 40px; height: 40px; flex: 0 0 40px;
	display: inline-flex; align-items: center; justify-content: center;
	border-radius: 13px;
	background: linear-gradient(140deg, var(--brand), #8b5cf6);
	box-shadow: 0 8px 22px rgba(57, 68, 251, .45);
	color: #fff;
}
.spw-brand-mark svg { width: 23px; height: 23px; }
.spw-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.spw-brand-text b { font-size: 16px; font-weight: var(--headingWeight); letter-spacing: -.01em; white-space: nowrap; }
.spw-brand-text small { font-size: 11.5px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.spw-catbar {
	display: flex;
	gap: 8px;
	flex: 1 1 auto;
	min-width: 0;
	overflow-x: auto;
	overflow-y: hidden;
	padding: 3px 2px;
	scrollbar-width: none;
}
.spw-catbar::-webkit-scrollbar { height: 0; }

.spw-cat {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 42px;
	padding: 0 16px 0 8px;
	border-radius: 999px;
	border: 1px solid var(--line);
	background: var(--soft);
	color: var(--muted);
	font: 650 13.5px/1 inherit;
	cursor: pointer;
	white-space: nowrap;
	transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.spw-cat:hover { color: var(--text); border-color: var(--line-strong); background: var(--soft-2); transform: translateY(-1px); }
.spw-cat[aria-selected="true"] {
	background: linear-gradient(135deg, var(--brand), #7c3aed);
	border-color: transparent;
	color: #fff;
	box-shadow: 0 10px 24px rgba(57, 68, 251, .40);
}
.spw-cat-icon {
	width: 28px; height: 28px; flex: 0 0 28px;
	border-radius: 999px;
	display: inline-flex; align-items: center; justify-content: center;
	background: rgba(255, 255, 255, .07);
	border: 1px solid rgba(255, 255, 255, .09);
}
.spw-cat[aria-selected="true"] .spw-cat-icon { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .3); }

/* ---------- Main grid ---------------------------------------------------- */

.spw-main {
	flex: 1 1 auto;
	min-height: 0;
	display: grid;
	grid-template-columns: minmax(0, 1fr) 372px;
	gap: var(--gap);
	align-items: stretch;
}

/* ---------- Stage -------------------------------------------------------- */

.spw-stage {
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-width: 0;
	min-height: 0;
}

.spw-wheel-card {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: grid;
	place-items: center;
	padding: 16px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	overflow: hidden;
	background:
		radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--stageBg) 62%, transparent) 0%, color-mix(in srgb, var(--stageBg) 16%, transparent) 52%, transparent 74%),
		linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .012));
}
/* Fallback for browsers without color-mix(). */
@supports not (background: color-mix(in srgb, red 50%, blue)) {
	.spw-wheel-card { background: radial-gradient(circle at 50% 42%, var(--stageBg) 0%, transparent 66%), linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .012)); }
}
.spw-wheel-card.spw-no-shadow { box-shadow: none; }

/* The box is the measurable content area; the app sizes the square wrap inside
   it in pixels, which is the only way to keep a perfect circle when both axes
   are already constrained. */
.spw-wheel-box {
	position: relative;
	width: 100%;
	height: 100%;
	display: grid;
	place-items: center;
	min-width: 0;
	min-height: 0;
}

.spw-wheel-wrap {
	position: relative;
	width: 100%;
	height: 100%;
	margin: auto;
	touch-action: manipulation;
	transition: width .3s cubic-bezier(.22, 1, .36, 1), height .3s cubic-bezier(.22, 1, .36, 1);
}
.spw-wheel-wrap canvas {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	cursor: pointer;
	filter: drop-shadow(0 18px 40px rgba(0, 0, 0, .55));
	outline: none;
}
.spw-wheel-wrap canvas:focus-visible { outline: 3px solid var(--brand-3); outline-offset: 6px; }
.spw-no-shadow .spw-wheel-wrap canvas { filter: none; }

.spw-pointer {
	position: absolute;
	top: 50%;
	right: -2.2%;
	width: 10.5%;
	height: auto;
	transform: translateY(-50%);
	filter: drop-shadow(0 5px 12px rgba(0, 0, 0, .65));
	pointer-events: none;
	z-index: 3;
}

.spw-hub {
	position: absolute;
	left: 50%; top: 50%;
	transform: translate(-50%, -50%);
	width: 22%; height: 22%;
	min-width: 56px; min-height: 56px;
	border-radius: 50%;
	border: 0;
	background: transparent;
	color: transparent;
	cursor: pointer;
	z-index: 4;
	padding: 0;
}
.spw-hub:focus-visible { outline: 3px solid var(--brand-3); outline-offset: 4px; }
.spw-hub span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.spw-stage-foot {
	display: flex;
	flex: 0 0 auto;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	align-items: center;
	width: 100%;
	min-height: 32px;
}
.spw-chip {
	display: inline-flex; align-items: center; gap: 8px;
	padding: 6px 14px;
	border-radius: 999px;
	background: var(--soft);
	border: 1px solid var(--line);
	color: var(--muted);
	font-size: 12.5px; font-weight: 650;
	max-width: 100%;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.spw-chip[hidden] { display: none; }
.spw-chip-soft { background: rgba(34, 197, 94, .13); border-color: rgba(34, 197, 94, .36); color: #86efac; }
.spw-chip img { width: 21px; height: 15px; border-radius: 3px; object-fit: cover; flex: 0 0 21px; }

/* ---------- Panel -------------------------------------------------------- */

.spw-panel {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
	min-height: 0;
	padding: 14px;
	background: linear-gradient(180deg, var(--panel), var(--panel-2));
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}
.spw-panel-head { display: flex; flex-direction: column; gap: 10px; flex: 0 0 auto; }

.spw-control {
	width: 100%;
	min-height: 44px;
	padding: 10px 14px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--line);
	background: var(--soft);
	color: var(--text);
	font: 600 14px/1.4 inherit;
	appearance: none;
	-webkit-appearance: none;
	transition: border-color .16s ease, background .16s ease;
}
.spw-control:hover { border-color: var(--line-strong); }
select.spw-control {
	background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
	background-position: calc(100% - 19px) 50%, calc(100% - 13px) 50%;
	background-size: 6px 6px, 6px 6px;
	background-repeat: no-repeat;
	padding-right: 38px;
	cursor: pointer;
}
select.spw-control option, select.spw-control optgroup { background: #0e1330; color: var(--text); }
.spw-control:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }

.spw-toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.spw-panel-head .spw-toolbar .spw-btn:not(.icon) { flex: 1 1 68px; padding: 10px 8px; }

.spw-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	padding: 10px 18px;
	border-radius: var(--radius-sm);
	border: 1px solid transparent;
	background: linear-gradient(135deg, var(--brand), #6d28d9);
	color: #fff;
	font: 700 13.5px/1 inherit;
	cursor: pointer;
	white-space: nowrap;
	flex: 1 1 auto;
	overflow: hidden;
	transition: transform .16s cubic-bezier(.22, 1, .36, 1), box-shadow .16s ease, filter .16s ease, background .16s ease;
}
.spw-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(57, 68, 251, .36); filter: brightness(1.07); }
.spw-btn:active { transform: translateY(0); box-shadow: none; }
.spw-btn:focus-visible { outline: 2px solid var(--brand-3); outline-offset: 2px; }
.spw-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.spw-btn.secondary { background: var(--soft); border-color: var(--line); color: var(--text); }
.spw-btn.secondary:hover { background: var(--soft-2); border-color: var(--line-strong); box-shadow: 0 10px 22px rgba(3, 6, 20, .45); }
.spw-btn.danger { background: linear-gradient(135deg, #e11d48, #9f1239); }
.spw-btn.danger:hover { box-shadow: 0 12px 26px rgba(225, 29, 72, .34); }
.spw-btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.spw-btn.ghost:hover { color: var(--text); background: var(--soft); box-shadow: none; }
.spw-btn.icon { flex: 0 0 44px; width: 44px; padding: 0; }
.spw-btn.full { width: 100%; flex: 1 1 100%; }

.spw-tabs { display: flex; gap: 5px; background: var(--soft); padding: 5px; border-radius: var(--radius-sm); flex: 0 0 auto; border: 1px solid var(--line); }
.spw-tab {
	flex: 1 1 0;
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 38px;
	padding: 8px 4px;
	border: 0; border-radius: 9px;
	background: transparent;
	color: var(--muted);
	font: 700 12.5px/1 inherit;
	cursor: pointer;
	white-space: nowrap;
	transition: background .16s ease, color .16s ease;
}
.spw-tab:hover { color: var(--text); background: var(--soft); }
.spw-tab[aria-selected="true"] { background: linear-gradient(135deg, var(--brand), #6d28d9); color: #fff; box-shadow: 0 6px 16px rgba(57, 68, 251, .35); }
.spw-count {
	display: inline-flex; align-items: center; justify-content: center;
	min-width: 21px; height: 19px; padding: 0 6px;
	border-radius: 999px; background: rgba(255, 255, 255, .16);
	font-size: 11px; font-weight: 800;
}

.spw-pane { display: none; flex: 1 1 auto; min-height: 0; flex-direction: column; gap: 10px; }
.spw-pane.active { display: flex; }
.spw-scroll {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overflow-x: hidden;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding-right: 4px;
	scrollbar-width: thin;
	overscroll-behavior: contain;
}
.spw-pane-foot { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 2px; }

/* ---------- Entry rows --------------------------------------------------- */

.spw-entry {
	display: flex;
	align-items: center;
	gap: 7px;
	padding: 7px 9px;
	border-radius: 14px;
	background: var(--soft);
	border: 1px solid var(--line);
	min-height: 58px;
	/* Keeps a 200-row list cheap: off-screen rows skip layout and paint. */
	content-visibility: auto;
	contain-intrinsic-size: auto 58px;
	transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.spw-entry:hover { border-color: var(--line-strong); background: var(--soft-2); }
.spw-entry.dragging { opacity: .4; }
.spw-entry.dragover { border-color: var(--brand-2); box-shadow: 0 0 0 2px rgba(108, 118, 255, .34) inset; }

.spw-drag {
	width: 20px; flex: 0 0 20px; height: 38px;
	border: 0; background: transparent; color: #5b689b;
	cursor: grab; padding: 0;
	display: inline-flex; align-items: center; justify-content: center;
	touch-action: none;
}
.spw-drag:hover { color: var(--text); }
.spw-drag:active { cursor: grabbing; }

.spw-flag-img {
	width: 28px; height: 21px; flex: 0 0 28px;
	border-radius: 4px;
	object-fit: cover;
	border: 1px solid rgba(255, 255, 255, .2);
	background: rgba(255, 255, 255, .06);
}
.spw-swatch {
	width: 28px; height: 28px; flex: 0 0 28px;
	padding: 0; border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, .22);
	background: none;
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
	transition: transform .16s ease, border-color .16s ease;
}
.spw-swatch:hover { transform: scale(1.12); border-color: #fff; }
.spw-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.spw-swatch::-webkit-color-swatch { border: 0; border-radius: 50%; }
.spw-swatch::-moz-color-swatch { border: 0; border-radius: 50%; }
.spw-thumb { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(255, 255, 255, .18); }

.spw-name {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 38px;
	padding: 7px 8px;
	border-radius: 9px;
	border: 1px solid transparent;
	background: transparent;
	color: var(--text);
	font: 650 13.5px/1.3 inherit;
	text-overflow: ellipsis;
}
.spw-name:focus { background: rgba(0, 0, 0, .28); border-color: var(--line-strong); outline: none; }

.spw-icon {
	width: 34px; height: 34px; flex: 0 0 34px;
	display: inline-flex; align-items: center; justify-content: center;
	border-radius: 9px;
	border: 1px solid transparent;
	background: transparent;
	color: #6f7cad;
	cursor: pointer;
	padding: 0;
	transition: background .16s ease, color .16s ease, transform .16s ease;
}
.spw-icon:hover { background: var(--soft-2); color: var(--text); transform: translateY(-1px); }
.spw-icon.del:hover { color: #fda4af; background: rgba(244, 63, 94, .14); }

/* ---------- Results ------------------------------------------------------ */

.spw-result {
	display: flex; align-items: center; gap: 10px;
	padding: 9px 12px;
	border-radius: 12px;
	background: var(--soft);
	border: 1px solid var(--line);
	font-weight: 650; font-size: 13.5px;
	content-visibility: auto;
	contain-intrinsic-size: auto 44px;
	transition: border-color .16s ease, background .16s ease;
}
.spw-result:hover { border-color: var(--line-strong); background: var(--soft-2); }
.spw-result:first-child { border-color: rgba(34, 197, 94, .4); background: rgba(34, 197, 94, .1); }
.spw-result .spw-rank {
	width: 25px; height: 25px; flex: 0 0 25px;
	display: inline-flex; align-items: center; justify-content: center;
	border-radius: 999px; background: linear-gradient(135deg, var(--brand), #6d28d9); color: #fff;
	font-size: 11.5px; font-weight: 800;
}
.spw-result span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spw-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 26px 12px; margin: 0; }

/* ---------- Quick settings ---------------------------------------------- */

.spw-toggle {
	display: flex; align-items: center; gap: 10px;
	padding: 10px 12px;
	border-radius: 12px;
	background: var(--soft);
	border: 1px solid var(--line);
	font-size: 13.5px; font-weight: 620;
	cursor: pointer;
	transition: border-color .16s ease, background .16s ease;
}
.spw-toggle:hover { border-color: var(--line-strong); background: var(--soft-2); }
.spw-toggle input { width: 17px; height: 17px; accent-color: var(--brand-2); cursor: pointer; flex: 0 0 17px; }

.spw-setting { display: flex; flex-direction: column; gap: 6px; }
.spw-setting > label { font-size: 12.5px; font-weight: var(--headingWeight); color: var(--muted); }
.spw-setting output { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 700; font-size: 13px; }
.spw-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

input[type="range"] {
	width: 100%; height: 26px; margin: 0;
	background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: var(--soft-2); border: 1px solid var(--line); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--brand-2); border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 99px; background: var(--soft-2); border: 1px solid var(--line); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--brand-2); border: 2px solid #fff; }

/* ---------- Dialog ------------------------------------------------------- */

.spw-dialog-back {
	position: fixed; inset: 0; z-index: 90;
	background: rgba(3, 6, 20, .78);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	display: flex; align-items: center; justify-content: center;
	padding: 18px;
	animation: spwFade .16s ease;
}
.spw-dialog-back[hidden] { display: none; }
@keyframes spwFade { from { opacity: 0; } }
.spw-dialog {
	width: min(680px, 100%);
	max-height: calc(100% - 20px);
	background: linear-gradient(180deg, var(--panel), var(--panel-2));
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	box-shadow: 0 40px 90px rgba(0, 0, 0, .7);
	padding: 18px;
	display: flex; flex-direction: column; gap: 14px;
	min-height: 0;
	animation: spwPop .24s cubic-bezier(.22, 1, .36, 1);
}
@keyframes spwPop { from { transform: translateY(16px) scale(.96); opacity: 0; } }
.spw-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: 0 0 auto; }
.spw-dialog-title { margin: 0; font-size: 18px; font-weight: var(--headingWeight); }
.spw-x {
	width: 38px; height: 38px; flex: 0 0 38px;
	display: inline-flex; align-items: center; justify-content: center;
	border-radius: 10px; border: 1px solid var(--line);
	background: var(--soft); color: var(--text); cursor: pointer; padding: 0;
	transition: background .16s ease, transform .16s ease;
}
.spw-x:hover { background: var(--soft-2); transform: rotate(90deg); }
.spw-dialog-body { display: flex; flex-direction: column; gap: 13px; overflow-y: auto; min-height: 0; padding-right: 4px; }

.spw-adv-tabs { display: flex; gap: 5px; background: var(--soft); padding: 5px; border-radius: var(--radius-sm); flex-wrap: wrap; border: 1px solid var(--line); }
.spw-adv-tab {
	flex: 1 1 110px; min-height: 38px; border: 0; border-radius: 9px;
	background: transparent; color: var(--muted); font: 700 13px/1 inherit; cursor: pointer;
	transition: background .16s ease, color .16s ease;
}
.spw-adv-tab:hover { color: var(--text); background: var(--soft); }
.spw-adv-tab[aria-selected="true"] { background: linear-gradient(135deg, var(--brand), #6d28d9); color: #fff; }

.spw-theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 8px; }
.spw-theme {
	display: flex; flex-direction: column; gap: 7px;
	padding: 10px; border-radius: 12px;
	border: 1px solid var(--line); background: var(--soft);
	color: var(--text); font: 700 12.5px/1 inherit; cursor: pointer; text-align: left;
	transition: border-color .16s ease, transform .16s ease, background .16s ease;
}
.spw-theme:hover { transform: translateY(-2px); border-color: var(--line-strong); background: var(--soft-2); }
.spw-theme[aria-pressed="true"] { border-color: var(--brand-2); box-shadow: 0 0 0 2px rgba(108, 118, 255, .32) inset; }
.spw-theme-colors { display: flex; gap: 3px; }
.spw-theme-colors span { flex: 1 1 0; height: 10px; border-radius: 3px; }

.spw-textarea {
	width: 100%; min-height: 190px; resize: vertical;
	padding: 12px 14px; border-radius: var(--radius-sm);
	border: 1px solid var(--line); background: rgba(0, 0, 0, .3); color: var(--text);
	font: 500 13.5px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.spw-textarea:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }
.spw-hint { color: var(--muted); font-size: 12.5px; margin: 0; }

/* ---------- Country picker ---------------------------------------------- */

.spw-picker { display: flex; flex-direction: column; gap: 11px; min-height: 0; }

.spw-search { position: relative; display: flex; align-items: center; }
.spw-search .spw-ui-icon {
	position: absolute; left: 13px;
	color: var(--muted);
	pointer-events: none;
}
.spw-search .spw-control { padding-left: 40px; }

.spw-picker-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(186px, 1fr));
	gap: 7px;
	max-height: min(46vh, 380px);
	overflow-y: auto;
	padding: 3px 4px 3px 0;
	scrollbar-width: thin;
	overscroll-behavior: contain;
}
.spw-country {
	display: flex; align-items: center; gap: 9px;
	padding: 8px 11px;
	border-radius: 11px;
	border: 1px solid var(--line);
	background: var(--soft);
	color: var(--text);
	font: 640 13px/1.25 inherit;
	cursor: pointer;
	text-align: left;
	content-visibility: auto;
	contain-intrinsic-size: auto 40px;
	transition: border-color .14s ease, background .14s ease, transform .14s ease;
}
.spw-country[hidden] { display: none; }
.spw-country:hover { border-color: var(--brand-2); background: var(--soft-2); transform: translateY(-1px); }
.spw-country[aria-pressed="true"] { border-color: var(--brand-2); background: rgba(57, 68, 251, .24); }
.spw-country img { width: 26px; height: 19px; flex: 0 0 26px; border-radius: 3px; object-fit: cover; border: 1px solid rgba(255, 255, 255, .2); }
.spw-country span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tick badge: an empty ring until the country is on the wheel. */
.spw-country-mark {
	width: 18px; height: 18px; flex: 0 0 18px;
	border-radius: 50%;
	border: 1.5px solid var(--line-strong);
	position: relative;
}
.spw-country[aria-pressed="true"] .spw-country-mark {
	background: var(--brand-2);
	border-color: var(--brand-2);
}
.spw-country[aria-pressed="true"] .spw-country-mark::after {
	content: "";
	position: absolute;
	left: 5px; top: 2px;
	width: 5px; height: 9px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(43deg);
}

/* ---------- Winner popup ------------------------------------------------- */

.spw-winner { display: flex; flex-direction: column; align-items: center; gap: 13px; text-align: center; padding: 4px 0 2px; }
.spw-win-flag img { width: 148px; height: 111px; border-radius: 12px; object-fit: cover; border: 1px solid rgba(255, 255, 255, .24); box-shadow: 0 18px 40px rgba(0, 0, 0, .55); }
.spw-win-emoji { font-size: 60px; line-height: 1; }
.spw-win-img { width: 132px; height: 132px; border-radius: 50%; object-fit: cover; border: 3px solid rgba(255, 255, 255, .3); }
.spw-win-name { font-size: clamp(26px, 5.5vw, 44px); font-weight: var(--headingWeight); line-height: 1.12; overflow-wrap: anywhere; background: linear-gradient(135deg, #fff, var(--brand-3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.spw-win-sub { color: var(--muted); font-size: 14.5px; font-weight: 650; }
.spw-winner .spw-toolbar { justify-content: center; width: 100%; }

/* ---------- Confetti ----------------------------------------------------- */

.spw-confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 95; }
.spw-piece {
	position: absolute; top: -16px;
	width: 8px; height: 14px; border-radius: 2px;
	will-change: transform;
	animation: spwFall linear forwards;
}
@keyframes spwFall {
	to { transform: translate3d(var(--dx, 0), 105vh, 0) rotate(760deg); opacity: .1; }
}

/* ---------- Icons -------------------------------------------------------- */

.spw-ui-icon { width: 17px; height: 17px; flex: 0 0 17px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.spw-btn.icon .spw-ui-icon { width: 20px; height: 20px; flex-basis: 20px; }
.spw-cat-icon .spw-ui-icon { width: 15px; height: 15px; flex-basis: 15px; }

/* ---------- Spinning state ---------------------------------------------- */

.spw-app.spw-spinning .spw-btn:not(.secondary):not(.ghost) { opacity: .55; pointer-events: none; }
.spw-app.spw-spinning .spw-wheel-wrap canvas { cursor: default; }
.spw-app.spw-spinning .spw-wheel-wrap { transition: none; }

/* ---------- Fullscreen --------------------------------------------------- */

:fullscreen .spw-app,
:-webkit-full-screen .spw-app {
	padding: clamp(16px, 2.2vh, 28px) clamp(18px, 2vw, 34px);
	gap: clamp(12px, 1.6vh, 20px);
}
:fullscreen .spw-main { gap: clamp(16px, 1.6vw, 26px); grid-template-columns: minmax(0, 1fr) clamp(340px, 24vw, 430px); }
:fullscreen .spw-wheel-card { padding: clamp(14px, 2vh, 26px); }
:fullscreen .spw-brand-text b { font-size: 18px; }

/* ---------- Responsive --------------------------------------------------- */

@media (max-width: 1120px) {
	.spw-main { grid-template-columns: minmax(0, 1fr) 330px; }
	.spw-app { padding: 12px; }
}

@media (max-width: 900px) {
	.spw-app { gap: 10px; padding: 11px; }
	/* Stacked, the two halves each get a comfortable fixed slice and the column
	   itself scrolls. Splitting the frame's height between them instead would
	   crush the panel's controls on a short phone. */
	.spw-main {
		display: flex;
		flex-direction: column;
		gap: 10px;
		overflow-y: auto;
		overscroll-behavior: contain;
		scrollbar-width: thin;
	}
	.spw-stage { flex: 0 0 auto; gap: 8px; }
	.spw-wheel-card { height: 48vh; min-height: 250px; }
	.spw-panel { flex: 0 0 auto; height: 46vh; min-height: 340px; }
	.spw-brand { padding-right: 10px; }
	.spw-brand-text small { display: none; }
	.spw-panel { padding: 11px; }
	.spw-wheel-card { padding: 8px; }
	.spw-stage-foot { min-height: 0; }
	.spw-stage-foot .spw-chip { font-size: 11.5px; padding: 5px 11px; }
}

@media (max-width: 620px) {
	.spw-app { padding: 9px; gap: 9px; }
	.spw-brand-mark { width: 34px; height: 34px; flex-basis: 34px; border-radius: 11px; }
	.spw-brand-mark svg { width: 19px; height: 19px; }
	.spw-brand-text b { font-size: 14px; }
	.spw-cat { height: 38px; font-size: 12.5px; padding: 0 13px 0 6px; }
	.spw-cat-icon { width: 25px; height: 25px; flex-basis: 25px; }
	.spw-btn { font-size: 12.5px; padding: 10px 12px; min-height: 42px; }
	.spw-btn.icon { flex: 0 0 42px; width: 42px; }
	.spw-panel-head .spw-toolbar .spw-btn:not(.icon) { flex: 1 1 60px; }
	.spw-tab { font-size: 11.5px; gap: 4px; }
	.spw-entry { gap: 5px; padding: 6px 7px; min-height: 52px; }
	.spw-icon { width: 31px; height: 31px; flex-basis: 31px; }
	.spw-dialog { padding: 14px; }
	.spw-winner .spw-btn { flex: 1 1 100%; }
	.spw-picker-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
