/* CCU Colors — styles apply only inside .ccu-colors, plus the drag ghost. */

.ccu-colors {
	--ccu-ink: #4a3428;
	--ccu-muted: #7d6556;
	--ccu-line: rgba(120, 78, 40, 0.14);
	--ccu-focus: #1d4ed8;
	box-sizing: border-box;
	width: 100%;
	max-width: 560px;
	margin: 1.25rem auto;
	padding: 16px 14px 14px;
	color: var(--ccu-ink);
	font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	background:
		radial-gradient(120% 70% at 50% -10%, #fffaf3 0%, rgba(255, 250, 243, 0) 46%),
		linear-gradient(180deg, #fbf6ee 0%, #f3e7d8 100%);
	border: 1px solid var(--ccu-line);
	border-radius: 28px;
	box-shadow: 0 18px 40px rgba(92, 58, 28, 0.08);
	position: relative;
	-webkit-tap-highlight-color: transparent;
	user-select: none;
	-webkit-user-select: none;
}

.ccu-colors *,
.ccu-colors *::before,
.ccu-colors *::after {
	box-sizing: border-box;
}

.ccu-colors button,
.ccu-colors input {
	font-family: inherit;
}

.ccu-colors[hidden],
.ccu-colors [hidden] {
	display: none !important;
}

.ccu-colors__fallback {
	margin: 0;
	padding: 18px 8px;
	text-align: center;
	color: var(--ccu-muted);
}

.ccu-colors__header {
	text-align: center;
}

.ccu-colors__brand {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
}

.ccu-colors__minis {
	display: flex;
	gap: 4px;
	flex: none;
}

.ccu-colors h2.ccu-colors__title {
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	font-size: clamp(1.35rem, 4.6vw, 1.85rem);
	font-weight: 800;
	letter-spacing: 0.06em;
	line-height: 1.15;
	text-align: left;
	color: #5c3828;
}

.ccu-colors__en {
	margin: 2px 0 0;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: #8d6b52;
}

.ccu-colors__howto {
	margin: 8px auto 0;
	max-width: 36em;
	text-align: left;
}

.ccu-colors__howto p {
	margin: 0;
	font-size: clamp(12px, 3.1vw, 13.5px);
	line-height: 1.45;
	color: var(--ccu-muted);
}

.ccu-colors__howto p + p {
	margin-top: 2px;
}

.ccu-colors__statusline {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: 10px;
	padding: 0 4px;
}

.ccu-colors__status {
	margin: 0;
	font-size: 13px;
	font-weight: 700;
	color: #6b4a38;
}

.ccu-colors__progress {
	display: flex;
	gap: 6px;
	flex: none;
}

.ccu-colors__dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #e6d5c4;
	box-shadow: inset 0 1px 2px rgba(80, 50, 20, 0.18);
}

.ccu-colors__dot.is-done {
	background: radial-gradient(circle at 35% 30%, #fff4c8, #e2b15a 42%, #b9832e);
}

.ccu-colors.is-won .ccu-colors__dot.is-done {
	background: radial-gradient(circle at 35% 30%, #e9ffe9, #3dce6e 45%, #1a9d48);
}

.ccu-colors__dot.is-now {
	box-shadow: 0 0 0 2px #e2b15a;
}

.ccu-colors__board {
	margin-top: 10px;
	padding: 12px 10px 14px;
	border-radius: 18px;
	background-color: #c99658;
	background-image:
		linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 30%),
		repeating-linear-gradient(
			90deg,
			rgba(120, 72, 28, 0.07) 0 2px,
			rgba(255, 255, 255, 0.05) 2px 8px,
			rgba(90, 48, 16, 0.05) 8px 12px
		),
		linear-gradient(180deg, #e4c08c 0%, #d0a266 42%, #c08d4e 100%);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.5),
		inset 0 -10px 16px rgba(110, 64, 24, 0.12),
		0 12px 22px rgba(90, 52, 18, 0.12);
}

.ccu-colors__history {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ccu-colors__history:empty {
	display: none;
}

.ccu-colors__row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(4rem, 5.25rem);
	gap: 6px;
	align-items: center;
}

.ccu-colors__history:not(:empty) + .ccu-colors__row--current {
	margin-top: 8px;
}

.ccu-colors__slots {
	display: grid;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: clamp(4px, 1.4vw, 8px);
	min-width: 0;
}

.ccu-colors__slot {
	position: relative;
	display: grid;
	place-items: center;
	min-width: 0;
	aspect-ratio: 1;
	border-radius: 50%;
	background: radial-gradient(circle at 50% 42%, #5a4030 0%, #2a1b13 70%, #1a100c 100%);
	box-shadow:
		inset 0 7px 10px rgba(0, 0, 0, 0.42),
		inset 0 -2px 4px rgba(255, 220, 180, 0.12),
		0 1px 0 rgba(255, 255, 255, 0.28);
	transition: box-shadow 0.15s ease;
}

.ccu-colors__slot-index {
	font-size: clamp(10px, 2.5vw, 13px);
	font-weight: 800;
	color: rgba(255, 236, 214, 0.38);
	pointer-events: none;
}

.ccu-colors.is-dragging .ccu-colors__row--current .ccu-colors__slot {
	box-shadow:
		0 0 0 2px rgba(255, 224, 138, 0.85),
		inset 0 7px 10px rgba(0, 0, 0, 0.42);
}

.ccu-colors__slot.is-over {
	box-shadow:
		0 0 0 3px #ffe08a,
		0 0 0 6px rgba(255, 196, 70, 0.35),
		inset 0 7px 10px rgba(0, 0, 0, 0.42);
}

.ccu-colors__slot.is-origin {
	outline: 2px dashed rgba(255, 248, 230, 0.85);
	outline-offset: 2px;
}

.ccu-colors__row--win .ccu-colors__slot {
	box-shadow:
		0 0 0 3px #f6d78a,
		0 0 12px rgba(246, 196, 70, 0.55),
		inset 0 7px 10px rgba(0, 0, 0, 0.42);
}

.ccu-colors__score {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 2.8em;
	padding: 4px 3px;
	border-radius: 12px;
	background: rgba(255, 248, 236, 0.78);
	color: #5c4030;
	text-align: center;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.ccu-colors__score--blank {
	background: transparent;
	box-shadow: none;
}

.ccu-colors__score-turn {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.04em;
	color: #8a684f;
}

.ccu-colors__score-value {
	font-size: clamp(10px, 2.6vw, 13px);
	font-weight: 800;
	line-height: 1.25;
}

.ccu-colors__score[data-matches="0"] { background: rgba(255, 255, 255, 0.45); }
.ccu-colors__score[data-matches="1"] { background: rgba(214, 230, 255, 0.9); }
.ccu-colors__score[data-matches="2"] { background: rgba(214, 244, 228, 0.92); }
.ccu-colors__score[data-matches="3"] { background: rgba(255, 232, 186, 0.95); }
.ccu-colors__score[data-matches="5"] {
	background: linear-gradient(180deg, #ffe9a8, #f3c95a);
	color: #5a3d08;
}

.ccu-colors button.ccu-colors__ball,
.ccu-colors .ccu-colors__ball,
.ccu-colors__ghost {
	position: relative;
	display: grid;
	place-items: center;
	width: 92%;
	height: auto;
	aspect-ratio: 1;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background:
		radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.95) 0 7%, rgba(255, 255, 255, 0.15) 18%, transparent 36%),
		radial-gradient(circle at 50% 58%, var(--ccu-mid) 0%, var(--ccu-deep) 62%, var(--ccu-edge) 100%);
	box-shadow:
		inset 0 -8px 10px rgba(0, 0, 0, 0.28),
		inset 4px 4px 8px rgba(255, 255, 255, 0.28),
		0 6px 8px rgba(60, 32, 12, 0.22);
	cursor: grab;
	touch-action: none;
	-webkit-user-drag: none;
	color: var(--ccu-ink, #fff);
}

.ccu-colors button.ccu-colors__ball {
	width: 92%;
	max-width: none;
	min-width: 0;
	line-height: 1;
	appearance: none;
	-webkit-appearance: none;
	background-color: transparent;
}

.ccu-colors__ball-shine {
	position: absolute;
	left: 16%;
	top: 10%;
	width: 42%;
	height: 26%;
	border-radius: 50%;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
	transform: rotate(-18deg);
	pointer-events: none;
}

.ccu-colors__ball-name {
	position: relative;
	z-index: 1;
	font-size: clamp(11px, 2.9vw, 16px);
	font-weight: 800;
	line-height: 1;
	color: var(--ccu-ink, #fff);
	text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
	pointer-events: none;
}

.ccu-colors__ball--red {
	--ccu-mid: #ff4b4b;
	--ccu-deep: #d61f1f;
	--ccu-edge: #8d1010;
	--ccu-ink: #fff;
}

.ccu-colors__ball--blue {
	--ccu-mid: #4d86ff;
	--ccu-deep: #1f55d6;
	--ccu-edge: #12358f;
	--ccu-ink: #fff;
}

.ccu-colors__ball--yellow {
	--ccu-mid: #ffe14a;
	--ccu-deep: #f0b400;
	--ccu-edge: #c48a00;
	--ccu-ink: #6a4a00;
}

.ccu-colors__ball--yellow .ccu-colors__ball-name {
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

.ccu-colors__ball--green {
	--ccu-mid: #45d375;
	--ccu-deep: #1a9d48;
	--ccu-edge: #0e6b30;
	--ccu-ink: #fff;
}

.ccu-colors__ball--purple {
	--ccu-mid: #b06cf6;
	--ccu-deep: #7a2ed0;
	--ccu-edge: #4c148a;
	--ccu-ink: #fff;
}

.ccu-colors .ccu-colors__ball--mini {
	width: 14px;
	height: 14px;
	aspect-ratio: auto;
	flex: none;
	box-shadow:
		inset 0 -2px 3px rgba(0, 0, 0, 0.25),
		0 1px 2px rgba(0, 0, 0, 0.2);
	pointer-events: none;
	cursor: default;
}

.ccu-colors__ball.is-selected {
	outline: 3px solid #fff;
	outline-offset: 2px;
	box-shadow:
		0 0 0 6px rgba(47, 111, 237, 0.45),
		inset 0 -8px 10px rgba(0, 0, 0, 0.28),
		0 6px 8px rgba(60, 32, 12, 0.22);
}

.ccu-colors__ball.is-lifted {
	opacity: 0.35;
	filter: saturate(0.7);
}

.ccu-colors__ball.is-placed {
	animation: ccu-colors-pop 0.22s ease;
}

.ccu-colors__row--win .ccu-colors__ball {
	animation: ccu-colors-bounce 0.8s ease;
}

.ccu-colors__row--win .ccu-colors__slot:nth-child(2) .ccu-colors__ball { animation-delay: 0.05s; }
.ccu-colors__row--win .ccu-colors__slot:nth-child(3) .ccu-colors__ball { animation-delay: 0.1s; }
.ccu-colors__row--win .ccu-colors__slot:nth-child(4) .ccu-colors__ball { animation-delay: 0.15s; }
.ccu-colors__row--win .ccu-colors__slot:nth-child(5) .ccu-colors__ball { animation-delay: 0.2s; }

.ccu-colors__basket {
	position: relative;
	container-type: inline-size;
	margin: 12px 2px 0;
	padding: 0;
	outline: 2px solid transparent;
	outline-offset: 4px;
	transition: outline-color 0.15s ease, filter 0.15s ease;
}

.ccu-colors__basket.is-armed {
	outline-color: rgba(138, 79, 40, 0.45);
	outline-style: dashed;
}

.ccu-colors__basket.is-over {
	filter: brightness(1.05);
	outline-color: #e2b15a;
	outline-style: solid;
}

.ccu-colors__basket-rim {
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	bottom: 0;
	border-radius: 0;
	background: #e6d3bf;
	box-shadow:
		inset 0 2px 6px rgba(80, 46, 18, 0.22),
		inset 0 -1px 0 rgba(255, 250, 244, 0.65);
	z-index: 0;
	pointer-events: none;
}

.ccu-colors__basket-bed {
	position: relative;
	z-index: 1;
	display: flex;
	justify-content: center;
	align-items: center;
	gap: clamp(6px, 1.8vw, 12px);
	padding: 16px 14px;
}

.ccu-colors__pocket {
	flex: 1 1 0;
	max-width: 64px;
	min-width: 0;
	display: flex;
	justify-content: center;
	align-items: center;
	position: relative;
	z-index: 1;
}

.ccu-colors__basket .ccu-colors__ball,
.ccu-colors__basket button.ccu-colors__ball {
	width: 100%;
	max-width: 64px;
	height: auto;
}

.ccu-colors__pocket.is-empty::before {
	content: "";
	display: block;
	width: 100%;
	aspect-ratio: 1;
	border-radius: 50%;
	background: rgba(160, 100, 50, 0.1);
	box-shadow: inset 0 4px 7px rgba(90, 50, 20, 0.14);
}

.ccu-colors__pocket-mark {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	font-size: clamp(11px, 2.8vw, 14px);
	font-weight: 800;
	color: rgba(90, 50, 20, 0.42);
	pointer-events: none;
}

.ccu-colors__basket-front {
	display: none;
}

.ccu-colors__basket-empty {
	position: absolute;
	z-index: 3;
	left: 16px;
	right: 16px;
	top: 8px;
	margin: 0;
	text-align: center;
	font-size: 12px;
	font-weight: 700;
	line-height: 1.2;
	color: #7a5338;
	pointer-events: none;
}

.ccu-colors__basket:has(.ccu-colors__basket-empty:not([hidden])) .ccu-colors__basket-bed {
	padding-top: 32px;
}

.ccu-colors__result {
	margin-top: 12px;
	padding: 14px 12px 12px;
	border-radius: 18px;
	background: #fffaf3;
	border: 1px solid rgba(120, 78, 40, 0.12);
	text-align: center;
	animation: ccu-colors-arrive 0.35s ease;
}

.ccu-colors.is-won .ccu-colors__result {
	background: linear-gradient(180deg, #fff8e4, #fff1c9);
	border-color: rgba(210, 160, 40, 0.45);
}

.ccu-colors.is-lost .ccu-colors__result {
	background: #f7f3ef;
}

.ccu-colors__result-title {
	margin: 0;
	font-size: clamp(1.05rem, 4vw, 1.3rem);
	font-weight: 800;
	line-height: 1.35;
	color: #5c3828;
}

.ccu-colors.is-won .ccu-colors__result-title {
	color: #8a5a08;
}

.ccu-colors__result-detail {
	margin: 6px 0 0;
	font-size: 15px;
	font-weight: 700;
	color: #6b4a38;
}

.ccu-colors__answer {
	margin-top: 10px;
}

.ccu-colors__answer-label {
	margin: 0 0 6px;
	font-size: 12px;
	font-weight: 700;
	color: var(--ccu-muted);
}

.ccu-colors__answer-row {
	display: flex;
	justify-content: center;
	gap: 8px;
}

.ccu-colors__answer-row .ccu-colors__ball {
	width: clamp(36px, 12vw, 52px);
	cursor: default;
}

.ccu-colors__actions {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin-top: 12px;
}

.ccu-colors button.ccu-colors__btn {
	appearance: none;
	-webkit-appearance: none;
	min-height: 46px;
	margin: 0;
	padding: 10px 8px;
	border: 0;
	border-radius: 999px;
	font-size: clamp(12px, 3.3vw, 14px);
	white-space: nowrap;
	font-weight: 800;
	line-height: 1.2;
	letter-spacing: 0.02em;
	cursor: pointer;
	transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
}

.ccu-colors button.ccu-colors__btn:hover:not(:disabled) {
	filter: brightness(1.04);
}

.ccu-colors button.ccu-colors__btn:active:not(:disabled) {
	transform: translateY(1px);
}

.ccu-colors button.ccu-colors__btn:disabled {
	cursor: not-allowed;
}

.ccu-colors button.ccu-colors__btn--judge {
	grid-column: 1 / -1;
	min-height: 58px;
	padding: 14px 16px;
	font-size: clamp(17px, 4.6vw, 20px);
	color: #fff;
	background: linear-gradient(180deg, #43c274, #1f8d48);
	box-shadow: 0 6px 14px rgba(30, 120, 60, 0.22);
}

.ccu-colors button.ccu-colors__btn--judge:not(:disabled) {
	animation: ccu-colors-ready 0.45s ease;
}

.ccu-colors button.ccu-colors__btn--judge:disabled {
	background: #ddd6cc;
	color: #8d847c;
	box-shadow: none;
}

.ccu-colors button.ccu-colors__btn--undo,
.ccu-colors button.ccu-colors__btn--new {
	color: #5c4030;
	background: #fffaf4;
	box-shadow: inset 0 0 0 1.5px rgba(120, 78, 40, 0.2);
}

.ccu-colors button.ccu-colors__btn--undo[hidden] ~ button.ccu-colors__btn--new {
	grid-column: 1 / -1;
}

.ccu-colors button.ccu-colors__btn--ghost {
	flex: 1 1 100%;
}

.ccu-colors__ball:focus-visible,
.ccu-colors__slot:focus-visible,
.ccu-colors button.ccu-colors__btn:focus-visible,
.ccu-colors__basket:focus-visible {
	outline: 3px solid var(--ccu-focus);
	outline-offset: 3px;
}

.ccu-colors__live {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.ccu-colors__ghost {
	position: fixed;
	z-index: 99999;
	display: grid;
	place-items: center;
	margin: 0;
	pointer-events: none;
	cursor: grabbing;
	opacity: 1;
	filter: none;
	transform: none;
	box-shadow:
		inset 0 -8px 10px rgba(0, 0, 0, 0.28),
		inset 4px 4px 8px rgba(255, 255, 255, 0.35),
		0 18px 28px rgba(40, 20, 10, 0.38);
}

.ccu-colors__row.is-rising {
	animation: ccu-colors-rise 0.46s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ccu-colors__row--current.is-arriving {
	animation: ccu-colors-arrive 0.4s ease;
}

@keyframes ccu-colors-rise {
	from { transform: translateY(52px); opacity: 0.15; }
	to { transform: translateY(0); opacity: 1; }
}

@keyframes ccu-colors-arrive {
	from { transform: translateY(20px); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}

@keyframes ccu-colors-pop {
	from { transform: scale(0.82); }
	to { transform: scale(1); }
}

@keyframes ccu-colors-bounce {
	0%, 100% { transform: translateY(0); }
	35% { transform: translateY(-12px); }
	55% { transform: translateY(0); }
	72% { transform: translateY(-5px); }
	88% { transform: translateY(0); }
}

@keyframes ccu-colors-ready {
	from { transform: scale(0.97); }
	40% { transform: scale(1.03); }
	to { transform: scale(1); }
}

@media (max-width: 380px) {
	.ccu-colors {
		margin: 0.5rem auto;
		padding: 12px 8px 10px;
		border-radius: 20px;
	}

	.ccu-colors__board {
		padding: 10px 6px 12px;
	}

	.ccu-colors__row {
		grid-template-columns: minmax(0, 1fr) 4.15rem;
		gap: 4px;
	}

	.ccu-colors button.ccu-colors__btn {
		min-height: 44px;
		padding: 8px 4px;
		font-size: 12px;
	}

	.ccu-colors button.ccu-colors__btn--judge {
		min-height: 52px;
		padding: 12px 12px;
		font-size: 16px;
	}
}

@media (max-height: 740px) and (max-width: 800px) {
	.ccu-colors__howto p {
		font-size: 12px;
	}

	.ccu-colors h2.ccu-colors__title {
		font-size: 1.3rem;
	}

	.ccu-colors__basket {
		margin-top: 8px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ccu-colors *,
	.ccu-colors *::before,
	.ccu-colors *::after,
	.ccu-colors__ghost {
		animation: none !important;
		transition: none !important;
	}
}

@media (forced-colors: active) {
	.ccu-colors {
		border: 1px solid CanvasText;
	}

	.ccu-colors__ball,
	.ccu-colors__slot,
	.ccu-colors button.ccu-colors__btn {
		border: 1px solid CanvasText;
	}

	.ccu-colors__ball.is-selected {
		outline: 3px solid Highlight;
	}
}
