* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
	--red: #ff1919;
	--red-soft: #ff5a5a;
	--bg: #0d0d0d;
	--panel: #191919;
	--cell-empty: #232323;
	--text: #ffffff;
	--muted: #9a9a9a;
}

html, body {
	height: 100%;
}

body {
	font-family: "Poppins", system-ui, Arial, sans-serif;
	background: #0a0a0a;
	color: var(--text);
	display: flex;
	flex-direction: column;
	height: 100dvh;
	overflow: hidden;
	user-select: none;
	-webkit-user-select: none;
	-webkit-tap-highlight-color: transparent;
}

/* Vieritettävä ristikkoalue – pyörä pysyy aina alhaalla */
.scrollarea {
	flex: 1 1 auto;
	overflow-y: auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

/* ---------- Elävä laavalamppu-tausta ---------- */
#bg {
	position: fixed;
	inset: 0;
	z-index: -1;
	overflow: hidden;
	background:
		radial-gradient(120% 90% at 50% -10%, #1c0a0a 0%, #0a0a0a 60%),
		#0a0a0a;
}
.blob {
	position: absolute;
	border-radius: 50%;
	filter: blur(64px);
	opacity: 0.5;
	mix-blend-mode: screen;
	will-change: transform;
}
.blob.b1 {
	width: 46vmax; height: 46vmax; left: -10vmax; top: -8vmax;
	background: radial-gradient(circle, #ff2020 0%, rgba(255, 32, 32, 0) 68%);
	animation: drift1 26s ease-in-out infinite;
}
.blob.b2 {
	width: 40vmax; height: 40vmax; right: -8vmax; top: 8vmax;
	background: radial-gradient(circle, #b51111 0%, rgba(181, 17, 17, 0) 68%);
	animation: drift2 33s ease-in-out infinite;
}
.blob.b3 {
	width: 54vmax; height: 54vmax; left: 8vmax; bottom: -18vmax;
	background: radial-gradient(circle, #ff4a2a 0%, rgba(255, 74, 42, 0) 70%);
	animation: drift3 38s ease-in-out infinite;
}
.blob.b4 {
	width: 34vmax; height: 34vmax; right: 4vmax; bottom: 2vmax;
	background: radial-gradient(circle, #7a0c0c 0%, rgba(122, 12, 12, 0) 70%);
	animation: drift4 30s ease-in-out infinite;
}
@keyframes drift1 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(8vmax, 11vmax) scale(1.25); } }
@keyframes drift2 { 0%, 100% { transform: translate(0, 0) scale(1.1); } 50% { transform: translate(-11vmax, 9vmax) scale(0.9); } }
@keyframes drift3 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(7vmax, -11vmax) scale(1.2); } }
@keyframes drift4 { 0%, 100% { transform: translate(0, 0) scale(0.95); } 50% { transform: translate(-9vmax, -7vmax) scale(1.15); } }
@media (prefers-reduced-motion: reduce) {
	.blob { animation: none !important; }
}

/* ---------- Ikonit ---------- */
.ic {
	width: 22px;
	height: 22px;
	display: inline-block;
	vertical-align: middle;
	flex-shrink: 0;
}

/* ---------- Topbar ---------- */
.topbar {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 14px;
	background: linear-gradient(180deg, rgba(8, 8, 8, 0.55), rgba(8, 8, 8, 0));
}
.back {
	text-decoration: none;
	color: #fff;
	background: var(--red);
	width: 34px; height: 34px;
	border-radius: 10px;
	display: flex; align-items: center; justify-content: center;
	line-height: 1;
	flex-shrink: 0;
}
.back .ic { width: 20px; height: 20px; }
.title { font-weight: 800; font-size: 1.15rem; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 7px; overflow: hidden; }
.title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title .logo { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; }
.stats { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.pill {
	background: var(--panel);
	border: 1.5px solid #333;
	border-radius: 20px;
	padding: 5px 12px;
	font-size: 0.85rem;
	font-weight: 600;
	white-space: nowrap;
}
#level { cursor: pointer; }
#level:hover { border-color: var(--red); }
.pill.coins { border-color: var(--red); color: #ffd24d; display: inline-flex; align-items: center; gap: 5px; }
.pill.coins .coin { width: 18px; height: 18px; }

/* ---------- Pistemittari ---------- */
.progress {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 16px 4px;
	flex-shrink: 0;
}
.progress-track {
	flex: 1;
	height: 12px;
	background: #232323;
	border: 1px solid #383838;
	border-radius: 8px;
	overflow: hidden;
}
.progress-track i {
	display: block;
	height: 100%;
	width: 0;
	border-radius: 8px;
	background: linear-gradient(90deg, #ff3030, #ff7a7a);
	box-shadow: 0 0 10px rgba(255, 25, 25, 0.5);
	transition: width 0.45s cubic-bezier(.2,.8,.2,1);
}
.progress-label {
	font-size: 0.8rem;
	font-weight: 700;
	color: var(--muted);
	white-space: nowrap;
	min-width: 56px;
	text-align: right;
}

/* ---------- Mykistysnappi ---------- */
.iconbtn {
	background: var(--panel);
	border: 1.5px solid #333;
	border-radius: 50%;
	width: 34px; height: 34px;
	display: flex; align-items: center; justify-content: center;
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s, color 0.15s;
}
.iconbtn .ic { width: 18px; height: 18px; }
.iconbtn:hover { background: #262626; }
.iconbtn.muted { color: #777; }

/* ---------- Sanaselitys (toast) ---------- */
.wordinfo {
	position: fixed;
	left: 50%; top: 98px;
	transform: translate(-50%, -14px);
	width: max-content;
	max-width: min(92vw, 460px);
	background: linear-gradient(160deg, #2a1414, #181818);
	border: 1.5px solid var(--red);
	border-radius: 12px;
	padding: 10px 16px;
	font-size: 0.9rem;
	line-height: 1.4;
	color: #eee;
	text-align: center;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55), 0 0 20px rgba(255, 25, 25, 0.25);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s, transform 0.3s;
	z-index: 40;
}
.wordinfo.show { opacity: 1; transform: translate(-50%, 0); }
.wordinfo b { color: #ff6b6b; letter-spacing: 1px; margin-right: 2px; }

/* ---------- Ristikko ---------- */
.crossword {
	display: grid;
	gap: 3px;
	justify-content: center;
	padding: 16px 8px 8px;
	margin: 0 auto;
}
.crossword .cell {
	width: var(--cell);
	height: var(--cell);
	background: var(--cell-empty);
	border-radius: 6px;
	display: flex; align-items: center; justify-content: center;
	font-weight: 700;
	font-size: calc(var(--cell) * 0.55);
	color: transparent;
	border: 1.5px solid #333;
	transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.crossword .cell.filled {
	background: linear-gradient(160deg, #ff3030, var(--red));
	color: #fff;
	border-color: #ff7070;
	box-shadow: 0 2px 8px rgba(255, 25, 25, 0.35);
	cursor: pointer;
}
.crossword .cell.pop { animation: pop 0.4s ease; }
.crossword .gap { width: var(--cell); height: var(--cell); }
@keyframes pop {
	0% { transform: scale(0.4); }
	60% { transform: scale(1.18); }
	100% { transform: scale(1); }
}

/* ---------- Bonus ---------- */
.bonus-box {
	max-width: 420px;
	margin: 4px auto;
	padding: 8px 14px;
	background: var(--panel);
	border: 1px solid #2e2e2e;
	border-radius: 12px;
	text-align: center;
}
.bonus-title { font-size: 0.82rem; color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.bonus-title .star { width: 15px; height: 15px; color: #ffd24d; }
.bonus-count { color: #ffd24d; }
.bonus-list { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-height: 84px; overflow-y: auto; }
.bonus-word {
	background: #2a1f0c; color: #ffd24d;
	border: 1px solid #5a4310;
	border-radius: 14px; padding: 2px 10px; font-size: 0.78rem; font-weight: 600;
	cursor: pointer;
}
.bonus-empty { color: #555; }

/* ---------- Viesti ---------- */
.message {
	text-align: center;
	min-height: 1.4em;
	margin: 4px 14px 2px;
	font-weight: 600;
	font-size: 0.95rem;
	color: var(--muted);
	text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}
.message.good { color: #4ade80; }
.message.bad { color: var(--red-soft); }
.message.info { color: #ffd24d; }
.message.shake { animation: shake 0.4s; }
@keyframes shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-7px); }
	75% { transform: translateX(7px); }
}

/* ---------- Alaosa ---------- */
.bottom {
	flex-shrink: 0;
	padding: 2px 10px 14px;
	display: flex;
	flex-direction: column;
	align-items: center;
	background: none;
}
.current {
	min-height: 40px;
	display: flex; align-items: center;
	gap: 4px;
	margin-bottom: 6px;
	font-size: 1.8rem;
	font-weight: 800;
	letter-spacing: 4px;
	color: #fff;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.15s, transform 0.15s;
	background: rgba(255, 25, 25, 0.12);
	border-radius: 12px;
	padding: 2px 18px;
	min-width: 70px;
	justify-content: center;
}
.current.show { opacity: 1; transform: translateY(0); }

.wheel-wrap {
	position: relative;
	width: min(80vw, 46vh, 340px);
	height: min(80vw, 46vh, 340px);
	margin: 0 auto;
}
.wheel {
	position: relative;
	width: 100%;
	height: 100%;
	background: radial-gradient(circle at 50% 50%, #222 0%, #141414 70%, #0d0d0d 100%);
	border-radius: 50%;
	border: 2px solid #2e2e2e;
	box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6);
	touch-action: none;
}
.lines {
	position: absolute;
	inset: 0;
	width: 100%; height: 100%;
	pointer-events: none;
	z-index: 1;
}
.letter {
	position: absolute;
	z-index: 2;
	display: flex; align-items: center; justify-content: center;
	background: linear-gradient(160deg, #2c2c2c, #1c1c1c);
	border: 2px solid #3a3a3a;
	border-radius: 50%;
	font-weight: 800;
	font-size: 1.5rem;
	color: #fff;
	cursor: pointer;
	transition: transform 0.1s, background 0.15s, border-color 0.15s;
}
.letter.active {
	background: linear-gradient(160deg, #ff3535, var(--red));
	border-color: #fff;
	transform: scale(1.12);
	box-shadow: 0 4px 14px rgba(255, 25, 25, 0.5);
}

.round-btn {
	position: absolute;
	bottom: 4px;
	z-index: 5;
	width: 52px; height: 52px;
	border-radius: 50%;
	border: 2px solid #333;
	background: var(--panel);
	color: #fff;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	transition: transform 0.1s, background 0.15s;
}
#btn-shuffle { left: 0; }
#btn-hint { right: 0; }
.round-btn .ic { width: 24px; height: 24px; }
.round-btn:hover { background: #262626; }
.round-btn:active { transform: scale(0.92); }
.round-btn.hint .ic { color: #ffd24d; }
.hint-cost {
	position: absolute;
	bottom: -3px; right: -3px;
	background: #ffd24d;
	color: #1a1a1a;
	font-size: 0.6rem;
	font-weight: 800;
	border-radius: 9px;
	padding: 1px 5px;
	border: 2px solid var(--bg);
}

/* ---------- Overlay ---------- */
.overlay {
	position: fixed; inset: 0;
	background: rgba(0, 0, 0, 0.8);
	display: flex; align-items: center; justify-content: center;
	opacity: 0; pointer-events: none;
	transition: opacity 0.3s;
	z-index: 50;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.overlay-card {
	background: var(--panel);
	border: 2px solid var(--red);
	border-radius: 20px;
	padding: 32px 28px;
	text-align: center;
	max-width: 86vw;
	box-shadow: 0 10px 40px rgba(255, 25, 25, 0.3);
	animation: pop 0.4s ease;
}
.overlay-text { font-size: 1.5rem; font-weight: 800; margin-bottom: 20px; line-height: 1.3; }
.overlay-text small { font-size: 0.95rem; color: var(--muted); font-weight: 500; }
.btn-next {
	background: var(--red);
	color: #fff;
	border: none;
	border-radius: 12px;
	padding: 14px 28px;
	font-size: 1.1rem;
	font-weight: 700;
	cursor: pointer;
	font-family: inherit;
	transition: transform 0.1s, background 0.15s;
}
.btn-next:hover { background: #ff3535; }
.btn-next:active { transform: scale(0.95); }

/* ---------- Vaikeustasovalikko ---------- */
.menu-card { padding: 26px 22px; }
.menu-title {
	font-size: 1.4rem;
	font-weight: 800;
	margin-bottom: 18px;
	text-align: center;
}
.diff-btn {
	display: grid;
	grid-template-columns: 1fr auto;
	grid-template-areas: "name prog" "desc prog";
	align-items: center;
	gap: 2px 12px;
	width: min(78vw, 320px);
	margin: 0 auto 12px;
	padding: 14px 18px;
	background: #232323;
	border: 2px solid #3a3a3a;
	border-radius: 14px;
	color: #fff;
	cursor: pointer;
	font-family: inherit;
	text-align: left;
	transition: transform 0.1s, background 0.15s, border-color 0.15s;
}
.diff-btn:last-child { margin-bottom: 0; }
.diff-btn:hover { background: #2c2c2c; border-color: var(--red); }
.diff-btn:active { transform: scale(0.97); }
.diff-name { grid-area: name; font-size: 1.15rem; font-weight: 700; }
.diff-desc { grid-area: desc; font-size: 0.8rem; color: var(--muted); }
.diff-prog {
	grid-area: prog;
	font-size: 0.9rem;
	font-weight: 700;
	color: #ffd24d;
	background: #1a1a1a;
	border-radius: 12px;
	padding: 4px 10px;
	white-space: nowrap;
}

/* Tabletti pystyssä – isompi pyörä, väljempi ristikko */
/* Kapea puhelin – piilota nimiteksti, jotta pisteet & napit mahtuvat */
@media (max-width: 440px) {
	.title span { display: none; }
	.topbar { gap: 8px; padding: 10px 12px; }
}

@media (min-width: 600px) and (orientation: portrait) {
	.wheel-wrap { width: min(62vw, 40vh, 380px); height: min(62vw, 40vh, 380px); }
	.title { font-size: 1.3rem; }
}

/* Leveä / vaakanäyttö – kaksipalstainen: ristikko vasemmalla, pyörä oikealla */
@media (min-width: 720px) and (orientation: landscape) {
	body {
		display: grid;
		grid-template-columns: minmax(0, 1fr) clamp(340px, 38vw, 460px);
		grid-template-rows: auto auto minmax(0, 1fr);
		column-gap: 4px;
	}
	.topbar { grid-column: 1 / -1; grid-row: 1; }
	.progress { grid-column: 1 / -1; grid-row: 2; }
	.scrollarea { grid-column: 1; grid-row: 3; min-height: 0; }
	.bottom {
		grid-column: 2; grid-row: 3;
		justify-content: center;
		background: none;
	}
	.wheel-wrap { width: min(40vw, 70vh, 430px); height: min(40vw, 70vh, 430px); }
}

/* Matala näyttö (esim. puhelin vaakatasossa) – tiivis */
@media (max-height: 520px) {
	.wheel-wrap { width: min(56vw, 64vh, 300px); height: min(56vw, 64vh, 300px); }
	.current { min-height: 30px; font-size: 1.4rem; margin-bottom: 2px; }
	.bonus-box { padding: 5px 12px; }
	.progress { padding: 5px 14px 2px; }
}
