:root {
	--bg: #0f1115;
	--panel: #161a22;
	--text: #e6e8ef;
	--muted: #9aa3b2;
	--accent: #7cc7ff;
	--accent-2: #a78bfa;
	--danger: #ff6b6b;
	--ok: #22c55e;
	--ok-2: #34d399;
	--info: #60a5fa;
	--info-2: #3b82f6;
	--warn: #f59e0b;
	--warn-2: #f97316;
	--ok-dark: #166534;
	--ok-mid: #15803d;
	--danger-dark: #991b1b;
	--danger-mid: #dc2626;
	--danger-soft-1: #7f1d1d;
	--danger-soft-2: #b91c1c;
	--gold-1: #c8a25f;
	--gold-2: #f2e7c9;
	--gold-dark-1: #a97c2f;
	--gold-dark-2: #8f6a23;
	--card: #1b2130;
	--shadow: 0 6px 18px rgba(0,0,0,0.3);
	--radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
	background: linear-gradient(180deg, #0b0d12 0%, #121722 100%);
	color: var(--text);
}

.gw-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	padding: 18px clamp(16px, 4vw, 40px);
	background: var(--panel);
	position: sticky; top: 0; z-index: 10;
	box-shadow: var(--shadow);
}
.gw-header h1 { margin: 0; font-size: clamp(18px, 2.5vw, 28px); letter-spacing: 0.3px; }
.gw-stats { display: flex; gap: 18px; font-size: 14px; color: var(--muted); }
.gw-stats .stat strong { color: var(--text); font-weight: 600; }

.gw-header .support-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 36px;
	padding: 0 12px;
	border-radius: 8px;
	background: linear-gradient(90deg, var(--accent), var(--accent-2));
	color: #0a0c10;
	font-size: 14px;
	white-space: nowrap;
	font-weight: 700;
	text-decoration: none;
	border: none;
	box-shadow: 0 6px 14px rgba(124,199,255,0.15);
}
.gw-header .support-btn:hover { box-shadow: 0 8px 18px rgba(124,199,255,0.22); transform: translateY(-1px); }
.gw-header .support-btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(124,199,255,0.25); }
@media (max-width: 420px) {
	.gw-header .support-btn { font-size: 12px; padding: 0 10px; height: 34px; }
}

.gw-controls {
	display: flex;
	gap: 12px;
	padding: 14px clamp(16px, 4vw, 40px);
	background: transparent;
	align-items: end;
	flex-wrap: wrap;
}
.gw-controls .control { display: grid; gap: 6px; min-width: 0; }
.gw-controls .control:not(.buttons) {
	flex: 0 0 200px;
}
.gw-controls .control.buttons {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	flex: 1 1 61%;
	min-width: 61%;
	align-self: end;
	flex-wrap: wrap;
}
.gw-controls .control.buttons .flex-spacer { flex: 1; }
.gw-controls label { font-size: 12px; color: var(--muted); }
.gw-controls .control select {
	width: 100%;
	min-width: 0;
	max-width: 100%;
}
select, button {
	height: 40px; border-radius: 10px; border: 1px solid #2a3242; background: var(--card);
	color: var(--text); padding: 0 12px; outline: none;
}
select:focus, button:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,199,255,0.2); }
.buttons {
	display: flex;
	gap: 12px;
	align-items: center;
	flex-wrap: nowrap;
	width: 100%;
}
.buttons { align-self: end; }
.buttons .flex-spacer { flex: 1; }
.btn-group { display: flex; gap: 10px; flex-wrap: nowrap; align-items: center; }
.mode-indicator {
	display: none;
	flex: 1 1 auto;
	text-align: center;
	font-weight: 500;
	font-size: 15px;
	letter-spacing: 0.2px;
	color: #0a0c10;
	padding: 0 12px;
	border-radius: 10px;
	border: none;
}
.host-view:not(.sp-mode) .mode-indicator {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 40px;
	background: linear-gradient(90deg, var(--accent), var(--accent-2));
	box-shadow: 0 6px 14px rgba(124,199,255,0.25);
}
.sp-mode .mode-indicator {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 40px;
	background: linear-gradient(90deg, var(--info), var(--info-2));
	box-shadow: 0 6px 14px rgba(96,165,250,0.25);
}
button.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); border: none; color: #0a0c10; font-weight: 700; }
button.ghost { background: transparent; border: 1px solid #2a3242; }
button.ghost.danger { border-color: var(--danger); color: var(--danger); }
button.primary.danger { background: var(--danger); color: #fff; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

button.btn-darken-non {
	background: linear-gradient(90deg, var(--ok-dark), var(--ok-mid));
	border: 1px solid var(--ok-mid);
	color: #e6e8ef; font-weight: 700;
}
button.btn-darken-match {
	background: linear-gradient(90deg, var(--danger-soft-1), var(--danger-soft-2));
	border: 1px solid var(--danger-soft-2);
	color: #e6e8ef; font-weight: 700;
}
button.btn-lighten-match {
	background: linear-gradient(90deg, var(--gold-dark-1), var(--gold-dark-2));
	border: 1px solid var(--gold-1);
	color: #ffffff; font-weight: 700;
}
button.btn-ask.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); border: none; color: #0a0c10; font-weight: 700; }

.inline-toggle { display: inline-flex; align-items: center; gap: 8px; }
.inline-toggle .toggle-label { font-size: 13px; color: var(--muted); }
.hide-toggle { display: none; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #2a3242; transition: .2s; border-radius: 26px; }
.slider:before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
input:checked + .slider { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
input:checked + .slider:before { transform: translateX(20px); }

.gw-helper {
	padding: 0 clamp(16px, 4vw, 40px) 14px;
	color: var(--muted);
	font-size: 14px;
}

main { padding: 8px clamp(16px, 4vw, 40px) 40px; }
.gw-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 14px;
}

.host-panel { 
	max-width: 560px; 
	margin: 12px auto 24px; 
	padding: 14px; 
	background: var(--panel); 
	border: 1px solid #2a3242; 
	border-radius: 14px; 
	box-shadow: var(--shadow); 
	display: grid; 
	gap: 10px; 
	place-items: center; 
}
.host-panel.hidden { display: none; }
.host-panel #hostImg { width: 160px; height: 160px; object-fit: cover; border-radius: 12px; border: 1px solid #2a3242; background: #0b0f18; }

.card {
	position: relative;
	background: var(--card);
	border: 1px solid #2a3242;
	border-radius: var(--radius);
	overflow: hidden;
	box-shadow: var(--shadow);
	transition: transform .15s ease, box-shadow .2s ease, filter .2s ease, opacity .2s ease;
	cursor: pointer;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,0.35); }
.card__img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: #0b0f18; }
.card__name { padding: 8px 10px; font-size: 13px; text-align: center; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 1px solid #2a3242; }
.card.eliminated { filter: grayscale(100%) brightness(0.6); opacity: 0.28; cursor: default; }
.card.correct { outline: 2px solid var(--gold-1); box-shadow: 0 0 0 3px rgba(200,162,95,0.28); }
.card.wrong { outline: 2px solid var(--star4-2); box-shadow: 0 0 0 3px rgba(139,92,246,0.28); }

.card__eye {
	position: absolute;
	right: 8px;
	top: 8px;
	width: 26px; height: 26px;
	padding: 0; line-height: 0;
	border-radius: 8px;
	background: rgba(0,0,0,0.35);
	border: 1px solid #2a3242;
	display: inline-flex; align-items: center; justify-content: center;
	color: #e6e8ef; cursor: pointer;
	transition: background .2s ease, transform .15s ease;
	appearance: none; -webkit-appearance: none; outline: none;
}
.card__eye:hover { background: rgba(0,0,0,0.55); transform: translateY(-1px); }
.card__eye svg { width: 18px; height: 18px; display: block; filter: drop-shadow(0 0 1px rgba(0,0,0,0.35)); }

.gw-modal.hidden { display: none; }
.gw-modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 1000; }
.gw-modal__backdrop { position: absolute; inset: 0; background: rgba(3,6,14,0.75); backdrop-filter: blur(2px); z-index: 0; }
.gw-modal__dialog {
	position: relative; z-index: 2; width: min(560px, calc(100% - 32px));
	background: var(--panel); border: 1px solid #2a3242; border-radius: 14px; box-shadow: var(--shadow);
	padding: 18px;
}
.gw-modal__dialog h2 { margin: 4px 0 10px; }
.gw-modal__body { display: flex; gap: 14px; align-items: center; }
.gw-modal__body.message { flex-direction: column; text-align: center; }
.gw-modal__body.message #messageText { white-space: pre-line; font-size: 17px; }
.gw-modal__body.message #messageImg { display: none; width: 160px; height: 160px; object-fit: cover; border-radius: 12px; border: 1px solid #2a3242; background: #0b0f18; margin-top: 8px; }
.gw-modal__body.details { flex-direction: column; align-items: center; }

.howto-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.howto-tabs button { height: 36px; font-weight: 700; }
.howto-tabs button.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124,199,255,0.2) inset; }
.howto-section { display: none; width: 100%; }
.howto-section.active { display: block; }

.gw-modal.result-win .gw-modal__dialog { border-color: var(--gold-1); box-shadow: 0 0 0 1px rgba(200,162,95,0.25), var(--shadow); }
.gw-modal.result-win #messageTitle { color: var(--gold-1); }
.gw-modal.result-lose .gw-modal__dialog { border-color: var(--star4-2); box-shadow: 0 0 0 1px rgba(139,92,246,0.25), var(--shadow); }
.gw-modal.result-lose #messageTitle { color: var(--star4-2); }

.fx-container { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10000; }
.confetti-piece {
	position: absolute;
	top: 0;
	width: 8px; height: 14px;
	opacity: 0.95;
	border-radius: 2px;
	animation: confetti-fall-a linear forwards;
	will-change: transform;
}
@keyframes confetti-fall-a {
	0% { transform: translate3d(0, -120vh, 0) rotate(0deg); }
	100% { transform: translate3d(8vw, 120vh, 0) rotate(720deg); }
}
@keyframes confetti-fall-b {
	0% { transform: translate3d(0, -120vh, 0) rotate(0deg); }
	100% { transform: translate3d(-6vw, 120vh, 0) rotate(540deg); }
}
@keyframes confetti-fall-c {
	0% { transform: translate3d(0, -120vh, 0) rotate(0deg); }
	100% { transform: translate3d(2vw, 120vh, 0) rotate(900deg); }
}
.confetti-gold-1 { background: #f2e7c9; }
.confetti-gold-2 { background: #e6cf9a; }
.confetti-gold-3 { background: #c8a25f; }
.confetti-blue { background: #7cc7ff; }
.confetti-purple { background: #a78bfa; }
.sad-drop {
	position: absolute;
	top: 0;
	width: 6px; height: 12px; opacity: 0.8;
	border-radius: 50% 50% 50% 50%/60% 60% 40% 40%;
	background: #8b5cf6;
	animation: sad-fall 3.6s linear infinite;
	filter: blur(0.2px);
}
@keyframes sad-fall {
	0% { transform: translateY(-120vh) scale(0.9); opacity: 0.0; }
	20% { opacity: 0.7; }
	100% { transform: translateY(120vh) scale(1); opacity: 0.0; }
}
.fx-container.fadeout { animation: fx-fadeout 1.5s ease forwards; }
@keyframes fx-fadeout { from { opacity: 1; } to { opacity: 0; } }

.gw-modal__dialog { position: relative; }
.modal-rain { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }

.card__guess {
	position: absolute;
	left: 8px;
	top: 8px;
	width: 24px; height: 24px;
	padding: 0; line-height: 0;
	border-radius: 7px;
	background: rgba(0,0,0,0.35);
	border: 1px solid #2a3242;
	display: none; align-items: center; justify-content: center;
	color: #e6e8ef; cursor: pointer;
	transition: background .2s ease, transform .15s ease;
	appearance: none; -webkit-appearance: none; outline: none;
}
.card__guess:hover { background: rgba(0,0,0,0.55); transform: translateY(-1px); }
.card__guess svg { width: 14px; height: 14px; display: block; }

body.sp-mode .card__guess { display: inline-flex; }

body.host-view.host-selected #grid { display: none; }
.gw-modal__body img { width: 128px; height: 128px; object-fit: cover; border-radius: 12px; border: 1px solid #2a3242; background: #0b0f18; }
.details-list { width: 100%; display: grid; gap: 8px; margin-top: 8px; }
.details-list .row { display: grid; grid-template-columns: auto auto 1fr; gap: 6px; align-items: center; background: #111724; border: 1px solid #2a3242; border-radius: 10px; padding: 8px 10px; }
.details-list .icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; }
.details-list .icon img { width: 18px; height: 18px; object-fit: contain; display: block; }
.details-list .label { color: var(--muted); font-size: 12px; }
.details-list .value { color: var(--text); font-weight: 600; }
.gw-modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

.gw-footer { padding: 20px clamp(16px, 4vw, 40px); color: var(--muted); font-size: 13px; text-align: center; }

.hide-filtered .card.eliminated { display: none; }

:root {
	--star5-1: #f2e7c9;
	--star5-2: #c8a25f;
	--star4-1: #c4b5fd;
	--star4-2: #8b5cf6;
}
.card.star-5 { border-color: var(--star5-2); box-shadow: 0 0 0 1px rgba(200,162,95,0.5), var(--shadow); }
.card.star-4 { border-color: var(--star4-2); box-shadow: 0 0 0 1px rgba(139,92,246,0.45), var(--shadow); }
.card.star-5 .card__name { background: linear-gradient(90deg, rgba(242,231,201,0.08), rgba(200,162,95,0.12)); }
.card.star-4 .card__name { background: linear-gradient(90deg, rgba(196,181,253,0.08), rgba(139,92,246,0.12)); }

.gw-modal.star-5 .details-list .icon { background: none; }
.gw-modal.star-4 .details-list .icon { background: none; }

.card .card__eye,
.card .card__guess {
	background: linear-gradient(90deg, var(--accent), var(--accent-2));
	border: none;
	color: #0a0c10;
	box-shadow: 0 6px 14px rgba(124,199,255,0.25);
}
.card .card__eye:hover,
.card .card__guess:hover { box-shadow: 0 8px 18px rgba(124,199,255,0.35); }

@media (max-width: 720px) {
	.gw-header__actions #hamburgerBtn { display: inline-flex !important; width: 40px; height: 40px; padding: 0; align-items: center; justify-content: center; text-align: center; line-height: 1; }
	.gw-header__actions #statsBtn,
	.gw-header__actions #howToBtn { display: none !important; }
	.mobile-menu { position: sticky; top: 56px; z-index: 9; background: var(--panel); border-top: 1px solid #2a3242; border-bottom: 1px solid #2a3242; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px clamp(16px,4vw,40px); }
	.mobile-menu.hidden { display: none; }

	.mobile-menu .control { display: grid; gap: 6px; grid-column: 1 / -1; }

	.gw-controls { flex-wrap: wrap; }
	.gw-modal__body { flex-direction: column; text-align: center; }
	.gw-controls .control { flex: 1 1 100%; }
	.gw-controls .control.control--prop,
	.gw-controls .control.control--val { flex: 1 1 100%; }
	.gw-controls .control.buttons { flex: 1 1 100%; }
	.buttons { gap: 8px; flex-wrap: wrap; }
	.btn-group { width: 100%; justify-content: space-between; flex-wrap: wrap; }
	.gw-controls .control select { width: 100%; max-width: none; }

	.control--mobile-only { display: grid; }
	body.host-view .control--mobile-only { display: grid !important; }

	.gw-controls .control.buttons .btn-group:nth-child(2) button { flex: 1 1 0; }
	#resetBtn { min-width: 0; }


	.gw-controls .control.buttons .btn-group:nth-child(1) { order: 1; width: 100%; }
	body:not(.sp-mode) .gw-controls .control.buttons .btn-group:nth-child(1) { flex-wrap: nowrap; }
	body:not(.sp-mode) .gw-controls .control.buttons .btn-group:nth-child(1) button { flex: 1 1 0; min-width: 0; }
	.gw-controls .control.buttons .btn-group:nth-child(2) { order: 2; width: 100%; }
	.gw-controls .control.buttons .btn-group:nth-child(3) {
		order: 3;
		width: auto;
		flex: 0 0 auto;
		flex-wrap: nowrap;
		justify-content: flex-start;
	}
	.gw-controls .control.buttons .inline-toggle { order: 3; margin-left: auto; width: auto; justify-content: flex-end; }
	body:not(.sp-mode) #giveUpBtn { display: none !important; }


	body.host-view .gw-controls .control.buttons .btn-group:nth-child(3) {
		order: 4;
		width: 100%;
		flex-wrap: nowrap;
		justify-content: space-between;
	}
	body.host-view #modeToggleBtn { display: none !important; }
	body.host-view #hostResetBtn,
	body.host-view #modeIndicator { display: inline-flex !important; }


	body.host-view #hostResetBtn { display: inline-flex; align-items: center; justify-content: center; }

	body.host-view.host-selected main { background: var(--panel); margin: 0; padding: 8px 0 24px; }
	.host-panel { width: 100%; max-width: none; border-radius: 0; margin: 0 0 16px 0; border-left: none; border-right: none; }

	.gw-grid.size-small { grid-template-columns: repeat(4, 1fr); gap: 3px; }
	.gw-grid.size-medium { grid-template-columns: repeat(3, 1fr); }
	.gw-grid.size-big { grid-template-columns: repeat(2, 1fr); }

	#howToModal .gw-modal__dialog { max-height: calc(100dvh - 32px); overflow: auto; -webkit-overflow-scrolling: touch; }

	.gw-grid.size-small .card__eye { width: 24px; height: 24px; }
	.gw-grid.size-small .card__eye svg { width: 16px; height: 16px; }
	.gw-grid.size-small .card__guess { width: 22px; height: 22px; }
	.gw-grid.size-small .card__guess svg { width: 12px; height: 12px; }

	.gw-grid.size-big .card__eye { width: 30px; height: 30px; }
	.gw-grid.size-big .card__eye svg { width: 20px; height: 20px; }
	.gw-grid.size-big .card__guess { width: 28px; height: 28px; }
	.gw-grid.size-big .card__guess svg { width: 16px; height: 16px; }
}

@media (max-width: 1024px) {
	.gw-controls { flex-wrap: wrap; }
	.gw-controls .control { min-width: 0; }
	.gw-controls .control:not(.buttons) { order: 1; flex: 1 1 0; }
	.gw-controls .control.control--prop,
	.gw-controls .control.control--val { flex: 1 1 0; }
	.gw-controls .control.buttons { order: 2; flex: 0 0 100%; width: 100%; }
	.buttons { gap: 10px; flex-wrap: nowrap; width: 100%; }
	.btn-group { width: auto; justify-content: flex-start; flex-wrap: nowrap; }
	.gw-controls .flex-spacer { display: none; }
	.inline-toggle { margin-left: auto; width: auto; justify-content: flex-end; }
	.gw-controls .control select { width: 100%; max-width: none; }
}

@media (min-width: 721px) {
	.control--mobile-only { display: none !important; }
	#mobileMenu { display: none !important; }
	#hamburgerBtn { display: none !important; }
}


.details-list .icon {
	width: 24px;
	height: 24px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: #0f131d !important;
	border: 1px solid #2a3242;
	border-radius: 6px;
	padding: 2px;
}
.details-list .icon img,
.details-list .icon svg {
	width: 20px; height: 20px;
	display: block;
}
.details-list .icon img { object-fit: contain; filter: drop-shadow(0 0 1px rgba(0,0,0,0.6)); }
.details-list .icon svg { color: var(--text); }

.stats-summary { width: 100%; display: grid; gap: 8px; }
.stats-summary p { margin: 0; color: var(--muted); }
.stats-graph svg { width: 100%; height: 180px; display: block; }
.stats-legend { color: var(--muted); font-size: 12px; text-align: center; margin-top: 2px; }
