.kg-root {
	--ink: #2d3436;
	position: relative;
	max-width: 900px;
	margin: 24px auto;
	padding: 20px;
	box-sizing: border-box;
	font-family: "Trebuchet MS", "Chalkboard SE", "Comic Sans MS", system-ui, sans-serif;
	color: var(--ink);
	background: linear-gradient(135deg, #fff4d6 0%, #e4f6ff 55%, #ffe6f3 100%);
	border: 5px solid #ffd166;
	border-radius: 28px;
	box-shadow: 0 8px 0 #f4b942, 0 14px 30px rgba(0, 0, 0, .15);
	overflow: hidden;
}
.kg-root *, .kg-root *::before, .kg-root *::after { box-sizing: border-box; }
.kg-head { text-align: center; }
.kg-title {
	margin: 0 0 6px;
	font-size: clamp(1.7rem, 5vw, 2.6rem);
	font-weight: 900;
	line-height: 1.15;
	background: linear-gradient(90deg, #ff6b6b, #ff9f43, #f6c90e, #1dd1a1, #54a0ff, #a29bfe, #ff78c4);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	-webkit-text-fill-color: transparent;
}
.kg-instr { margin: 0 0 12px; font-size: clamp(1rem, 3vw, 1.25rem); font-weight: 700; }

/* buttons & status */
.kg-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 8px; }
.kg-stats { text-align: center; min-height: 1.6em; font-size: 1.15rem; font-weight: 800; margin-bottom: 10px; white-space: pre; }
.kg-btn {
	font: inherit;
	font-weight: 800;
	font-size: 1rem;
	padding: 10px 18px;
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	color: #fff;
	background: #54a0ff;
	box-shadow: 0 4px 0 rgba(0, 0, 0, .2);
	transition: transform .1s;
}
.kg-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.kg-btn:focus-visible, .kg-swatch:focus-visible { outline: 4px solid #2d3436; outline-offset: 2px; }
.kg-lv { background: #a29bfe; }
.kg-lv.on { background: #1dd1a1; transform: scale(1.06); }
.kg-restart { background: #ff9f43; }
.kg-big { font-size: 1.25rem; padding: 14px 26px; background: #ff6b6b; }
.kg-area { text-align: center; }
.kg-empty, .kg-loading { font-size: 1.2rem; font-weight: 700; padding: 20px; }

/* cards */
.kg-item {
	--c: #54a0ff;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: 70px;
	padding: 10px;
	background: #fff;
	border: 5px solid var(--c);
	border-radius: 20px;
	font-size: clamp(1.1rem, 3.6vw, 1.6rem);
	font-weight: 800;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
	box-shadow: 0 5px 0 rgba(0, 0, 0, .14);
	transition: transform .12s, background .2s;
	overflow-wrap: anywhere;
}
.kg-item img { max-width: 100%; max-height: 110px; border-radius: 12px; pointer-events: none; }
.kg-item.sel { background: #fff3b0; transform: scale(1.07); box-shadow: 0 0 0 6px rgba(246, 201, 14, .5); }
.kg-item.ok { background: #e6fbe9; cursor: default; position: relative; }
.kg-item.ok::after {
	content: "\2714";
	position: absolute;
	top: -12px;
	right: -8px;
	width: 30px;
	height: 30px;
	line-height: 30px;
	font-size: 18px;
	color: #fff;
	background: #1dd1a1;
	border-radius: 50%;
	box-shadow: 0 2px 0 rgba(0, 0, 0, .2);
}
.shake { animation: kg-shake .45s; }
@keyframes kg-shake {
	0%, 100% { transform: translateX(0); }
	20% { transform: translateX(-9px) rotate(-1deg); }
	40% { transform: translateX(9px) rotate(1deg); }
	60% { transform: translateX(-6px); }
	80% { transform: translateX(6px); }
}

/* matching & drag/drop */
.kg-match {
	position: relative;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0 clamp(36px, 12vw, 110px);
	max-width: 760px;
	margin: 0 auto;
}
.kg-col { display: flex; flex-direction: column; gap: 16px; }
.kg-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 2; }
.kg-draggable { touch-action: none; cursor: grab; }
.kg-lifted { opacity: .35; }
.kg-dragging { opacity: .95; transform: scale(1.08) rotate(-2deg); box-shadow: 0 14px 28px rgba(0, 0, 0, .3); cursor: grabbing; }
.kg-target { border-style: dashed; cursor: default; }
.kg-target.ok { border-style: solid; }
.kg-dropped { cursor: default; min-height: 0; margin-top: 4px; border-width: 3px; font-size: .9em; box-shadow: none; }
.kg-dropped.ok::after { display: none; }

/* jigsaw */
.kg-board {
	position: relative;
	margin: 0 auto 18px;
	background: #fff;
	border: 5px solid #54a0ff;
	border-radius: 12px;
	box-shadow: 0 5px 0 rgba(0, 0, 0, .15);
	box-sizing: content-box !important;
}
.kg-boardghost { position: absolute; inset: 0; opacity: .16; }
.kg-slot { position: absolute; border: 2px dashed #8395a7; border-radius: 6px; }
.kg-tray {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	padding: 14px;
	min-height: 90px;
	background: rgba(255, 255, 255, .6);
	border: 4px dashed #ff9f43;
	border-radius: 18px;
}
.kg-piece {
	position: relative;
	border: 2px solid #fff;
	border-radius: 8px;
	box-shadow: 0 3px 8px rgba(0, 0, 0, .35);
	background-repeat: no-repeat;
}
.kg-piece.kg-placed { border: 0; border-radius: 0; box-shadow: none; cursor: default; animation: kg-pop .35s; }
@keyframes kg-pop { 0% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* maze */
.kg-maze { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.kg-endcard { cursor: default; min-width: 160px; max-width: 320px; }
.kg-start { border-color: #1dd1a1; }
.kg-finish { border-color: #ff6b6b; }
.kg-badge { font-size: .8rem; font-weight: 900; padding: 3px 12px; border-radius: 999px; background: #2d3436; color: #fff; }
.kg-maze-cv {
	max-width: 100%;
	border: 5px solid #5f27cd;
	border-radius: 14px;
	background: #fff;
	touch-action: none;
	cursor: crosshair;
	box-shadow: 0 5px 0 rgba(0, 0, 0, .15);
}

/* word search */
.kg-ws {
	position: relative;
	display: grid;
	margin: 0 auto 16px;
	background: #fff;
	border: 5px solid #ff9f43;
	border-radius: 16px;
	box-sizing: content-box !important;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	cursor: pointer;
	box-shadow: 0 5px 0 rgba(0, 0, 0, .15);
	overflow: hidden;
}
.kg-wc { display: flex; align-items: center; justify-content: center; font-weight: 900; border: 1px solid #f1e3c4; transition: background .15s; }
.kg-wc.sel { background: #fff3b0; }
.kg-wc.found { background: #d6f8e2; }
.kg-ws1 .kg-wc { font-weight: 900; color: #5f27cd; }
.kg-wslines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.kg-words { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.kg-word {
	--c: #54a0ff;
	padding: 6px 16px;
	font-weight: 800;
	font-size: 1.05rem;
	background: #fff;
	border: 3px solid var(--c);
	border-radius: 999px;
}
.kg-words1 .kg-word { font-size: 1.5rem; padding: 8px 22px; }
.kg-word.found { text-decoration: line-through; background: #d6f8e2; opacity: .7; }

/* colouring */
.kg-palette { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 12px; }
.kg-swatch {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 4px solid #fff;
	box-shadow: 0 0 0 2px #b2bec3, 0 3px 0 rgba(0, 0, 0, .2);
	cursor: pointer;
	font-size: 20px;
	padding: 0;
}
.kg-swatch.on { transform: scale(1.22); box-shadow: 0 0 0 4px #2d3436, 0 3px 0 rgba(0, 0, 0, .2); }
.kg-colour-cv {
	display: block;
	max-width: 100%;
	height: auto;
	margin: 0 auto;
	background: #fff;
	border: 5px solid #2d3436;
	border-radius: 14px;
	cursor: pointer;
	touch-action: manipulation;
}
.kg-colour-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }

/* congratulations */
.kg-modal {
	position: absolute;
	inset: 0;
	z-index: 50;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(45, 52, 54, .55);
	overflow: hidden;
	animation: kg-fade .3s;
}
@keyframes kg-fade { from { opacity: 0; } to { opacity: 1; } }
.kg-modal-box {
	position: relative;
	z-index: 2;
	width: min(420px, 100%);
	padding: 24px 20px;
	text-align: center;
	background: #fff;
	border: 6px solid #f6c90e;
	border-radius: 28px;
	box-shadow: 0 10px 0 #f4b942;
	animation: kg-pop .5s;
}
.kg-trophy { font-size: 64px; line-height: 1.1; }
.kg-modal-box h3 { margin: 6px 0; font-size: 2rem; font-weight: 900; color: #ff6b6b; }
.kg-stars { font-size: 2.2rem; letter-spacing: 4px; }
.kg-final { margin: 8px 0; font-size: 1.3rem; font-weight: 800; }
.kg-note { margin: 0 0 12px; font-size: 1.05rem; font-weight: 700; }
.kg-confetti { position: absolute; top: -40px; z-index: 1; animation: kg-fall linear infinite; pointer-events: none; }
@keyframes kg-fall { to { transform: translateY(130vh) rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
	.kg-confetti { display: none; }
	.shake, .kg-modal, .kg-modal-box, .kg-piece.kg-placed { animation: none; }
}
@media (max-width: 480px) {
	.kg-root { padding: 12px; border-width: 4px; border-radius: 22px; }
	.kg-col { gap: 12px; }
	.kg-item { padding: 6px; border-width: 4px; }
}

/* trivia */
.kg-trivia, .kg-rearr { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.kg-qnum { padding: 4px 16px; font-weight: 900; font-size: .95rem; color: #fff; background: #5f27cd; border-radius: 999px; }
.kg-question { width: 100%; cursor: default; border-color: #5f27cd; font-size: clamp(1.2rem, 4.2vw, 1.8rem); padding: 18px; }
.kg-question img { max-height: 200px; }
.kg-opts { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kg-opt {
	display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 14px;
	font: inherit; font-size: clamp(1rem, 3.4vw, 1.35rem); font-weight: 800; text-align: left; color: #fff;
	border: 0; border-radius: 18px; cursor: pointer; box-shadow: 0 5px 0 rgba(0, 0, 0, .22); transition: transform .12s;
}
.kg-opt:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .22); }
.kg-o0 { background: #ff6b6b; } .kg-o1 { background: #54a0ff; } .kg-o2 { background: #f0a500; } .kg-o3 { background: #7b5cf0; }
.kg-letter { flex: none; width: 34px; height: 34px; line-height: 34px; text-align: center; font-weight: 900; color: var(--ink); background: #fff; border-radius: 50%; }
.kg-optt { overflow-wrap: anywhere; }
.kg-opts.locked .kg-opt { cursor: default; opacity: .55; }
.kg-opts.locked .kg-opt.right, .kg-opts.locked .kg-opt.wrong { opacity: 1; }
.kg-opt.right { background: #12b886 !important; box-shadow: 0 0 0 5px #b2f2bb, 0 5px 0 rgba(0, 0, 0, .22); }
.kg-opt.wrong { background: #e03131 !important; }
.kg-fb { min-height: 1.6em; font-size: 1.15rem; font-weight: 800; }
.kg-explain { margin-top: 6px; font-size: 1rem; font-weight: 700; color: #5f27cd; }
.kg-ractions { min-height: 10px; }
@media (max-width: 480px) { .kg-opts { grid-template-columns: 1fr; } }

/* rearrange */
.kg-hint { cursor: default; border-color: #ff9f43; }
.kg-rhelp { margin: 0; font-weight: 800; font-size: 1.1rem; }
.kg-slots, .kg-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; }
.kg-bank { min-height: 64px; padding: 12px; background: rgba(255, 255, 255, .65); border: 4px dashed #ff9f43; border-radius: 18px; }
.kg-slot2 { display: flex; align-items: center; justify-content: center; min-width: 56px; min-height: 60px; background: #fff; border: 4px dashed #8395a7; border-radius: 14px; }
.kg-m-words .kg-slot2 { min-width: 96px; }
.kg-slot2.filled { border-style: solid; border-color: #dfe6e9; }
.kg-slots.good .kg-slot2 { border-color: #12b886; background: #e6fcf5; }
.kg-tile {
	--c: #54a0ff; display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 48px; padding: 4px 12px;
	font-weight: 900; font-size: clamp(1.3rem, 5vw, 2rem); color: #fff; background: var(--c); border-radius: 12px;
	box-shadow: 0 4px 0 rgba(0, 0, 0, .22); user-select: none; -webkit-user-select: none;
}
.kg-m-words .kg-tile { font-size: clamp(1.05rem, 3.6vw, 1.5rem); }
.kg-slot2 .kg-tile { box-shadow: none; }
.kg-tile { text-shadow: 0 2px 0 rgba(0, 0, 0, .4); }

/* collection pagination: Pages: 1 2 3 ... */
.kgm-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 900px; margin: 16px auto; font-weight: 700; }
.kgm-pages .kgm-page-num {
	display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 10px;
	font-weight: 800; text-decoration: none; color: #5b4a1e; background: #fff9e6; border: 2px solid #f4d58d; border-radius: 6px;
}
.kgm-pages a.kgm-page-num:hover { background: #ffecb3; }
.kgm-pages .kgm-page-num.current { color: #fff; background: #ff9800; border-color: #ff9800; }
