/**
 * Hebrew Color Match Game – RTL styles
 *
 * @package HebrewColorMatchGame
 */

:root {
	--hcm-primary: #7c4dff;
	--hcm-primary-dark: #5e35b1;
	--hcm-secondary: #26a69a;
	--hcm-accent: #ffd54f;
	--hcm-danger: #e53935;
	--hcm-success: #43a047;
	--hcm-bg: #f5f3ff;
	--hcm-card-bg: #ffffff;
	--hcm-text: #1a1a2e;
	--hcm-text-muted: #5c5c7a;
	--hcm-border: #d8d4ef;
	--hcm-radius: 16px;
	--hcm-shadow: 0 8px 32px rgba(26, 26, 46, 0.12);
	--hcm-font: "Segoe UI", Tahoma, Arial, sans-serif;
	--hcm-btn-min-height: 48px;
	--hcm-focus-ring: 0 0 0 3px rgba(124, 77, 255, 0.45);
}

.hcm-game-wrapper {
	direction: rtl;
	text-align: right;
	font-family: var(--hcm-font);
	color: var(--hcm-text);
	max-width: 640px;
	margin: 1.5rem auto;
	padding: 0 1rem;
	box-sizing: border-box;
}

.hcm-game-card {
	background: var(--hcm-card-bg);
	border: 1px solid var(--hcm-border);
	border-radius: var(--hcm-radius);
	box-shadow: var(--hcm-shadow);
	padding: 1.25rem 1.5rem 1.5rem;
	box-sizing: border-box;
}

.hcm-noscript {
	padding: 1rem;
	background: #fff3cd;
	border: 1px solid #ffc107;
	border-radius: 8px;
	text-align: center;
}

.hcm-header {
	margin-bottom: 1rem;
	text-align: center;
}

.hcm-title {
	margin: 0;
	font-size: clamp(1.35rem, 4vw, 1.85rem);
	color: var(--hcm-primary-dark);
	font-weight: 700;
}

.hcm-subtitle {
	margin: 0 0 1rem;
	font-size: 1.15rem;
	text-align: center;
	color: var(--hcm-text);
}

.hcm-intro {
	text-align: center;
	font-size: 1.1rem;
	color: var(--hcm-text-muted);
	margin: 0 0 1.25rem;
}

.hcm-hud {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1rem;
	justify-content: center;
	padding: 0.75rem 1rem;
	background: var(--hcm-bg);
	border-radius: 12px;
	margin-bottom: 1rem;
	font-size: 0.9rem;
	font-weight: 600;
}

.hcm-hud-item {
	white-space: nowrap;
}

.hcm-hidden {
	display: none !important;
}

.hcm-screen {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1rem;
}

.hcm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--hcm-btn-min-height);
	padding: 0.6rem 1.25rem;
	font-size: 1rem;
	font-weight: 600;
	font-family: inherit;
	border: 2px solid transparent;
	border-radius: 12px;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
	background: var(--hcm-bg);
	color: var(--hcm-text);
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

.hcm-btn:hover {
	background: #ebe8f8;
}

.hcm-btn:focus-visible {
	outline: none;
	box-shadow: var(--hcm-focus-ring);
}

.hcm-btn:active {
	transform: scale(0.97);
}

.hcm-btn-primary {
	background: var(--hcm-primary);
	color: #fff;
	border-color: var(--hcm-primary-dark);
}

.hcm-btn-primary:hover {
	background: var(--hcm-primary-dark);
}

.hcm-btn-secondary {
	background: var(--hcm-secondary);
	color: #fff;
	border-color: #00897b;
}

.hcm-btn-ghost {
	background: transparent;
	border-color: var(--hcm-border);
	color: var(--hcm-text-muted);
}

.hcm-btn-icon {
	min-height: 42px;
	padding: 0.45rem 0.9rem;
	font-size: 0.9rem;
}

.hcm-btn:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.hcm-difficulty-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 0.75rem;
	width: 100%;
	max-width: 420px;
}

.hcm-btn-difficulty {
	flex-direction: column;
	padding: 1rem 0.5rem;
	font-size: 1.1rem;
}

.hcm-diff-easy {
	border-color: #81c784;
}

.hcm-diff-medium {
	border-color: #ffb74d;
}

.hcm-diff-hard {
	border-color: #e57373;
}

.hcm-btn-difficulty.hcm-selected {
	background: var(--hcm-primary);
	color: #fff;
	border-color: var(--hcm-primary-dark);
}

.hcm-level-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
	gap: 0.6rem;
	width: 100%;
	max-width: 520px;
}

.hcm-level-cell {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	justify-content: center;
	min-height: 64px;
	min-width: 68px;
	padding: 0.35rem 0.3rem 0.3rem;
	border: 2px solid var(--hcm-border);
	border-radius: 12px;
	background: var(--hcm-bg);
	cursor: pointer;
	font-family: inherit;
	transition: border-color 0.15s ease, background 0.15s ease;
	box-sizing: border-box;
}

.hcm-level-cell:hover:not(:disabled) {
	border-color: var(--hcm-primary);
	background: #ebe8f8;
}

.hcm-level-cell:focus-visible {
	outline: none;
	box-shadow: var(--hcm-focus-ring);
}

.hcm-level-cell.hcm-locked {
	opacity: 0.45;
	cursor: not-allowed;
	background: #eceff3;
}

.hcm-level-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.15rem;
	width: 100%;
}

.hcm-level-num {
	display: block;
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.1;
}

.hcm-level-stars {
	display: flex;
	flex-direction: row;
	justify-content: center;
	align-items: center;
	gap: 1px;
	width: 100%;
	line-height: 1;
	direction: ltr;
}

.hcm-level-star {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 8px;
	width: 8px;
	height: 8px;
	color: var(--hcm-accent);
}

.hcm-level-star svg {
	display: block;
	width: 8px;
	height: 8px;
}

.hcm-play-area {
	width: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1rem;
	margin-bottom: 0.75rem;
}

.hcm-progress-bar {
	width: 100%;
	height: 8px;
	background: var(--hcm-border);
	border-radius: 4px;
	overflow: hidden;
}

.hcm-progress-fill {
	height: 100%;
	background: linear-gradient(90deg, var(--hcm-primary), var(--hcm-secondary));
	border-radius: 4px;
	transition: width 0.3s ease;
}

.hcm-instruction,
.hcm-pick-label {
	margin: 0;
	text-align: center;
	font-size: 1.05rem;
	font-weight: 600;
	color: var(--hcm-text);
}

.hcm-question {
	margin: 0;
	text-align: center;
	font-size: clamp(1.25rem, 4.5vw, 1.65rem);
	font-weight: 700;
	color: var(--hcm-primary-dark);
	line-height: 1.35;
}

.hcm-object-wrap {
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 0.5rem 0;
}

.hcm-object-image {
	font-size: clamp(4.5rem, 18vw, 7rem);
	line-height: 1;
	padding: 0.75rem;
	background: var(--hcm-bg);
	border-radius: 24px;
	border: 3px solid var(--hcm-border);
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
	user-select: none;
}

.hcm-pick-label {
	font-size: 0.95rem;
	font-weight: 500;
	color: var(--hcm-text-muted);
}

.hcm-target-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
}

.hcm-target-label {
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--hcm-text-muted);
}

.hcm-target-swatch {
	width: 100px;
	height: 100px;
	border-radius: 50%;
	border: 4px solid var(--hcm-border);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.hcm-options-grid {
	display: grid;
	gap: 0.85rem;
	width: 100%;
	max-width: 420px;
}

.hcm-options-3 {
	grid-template-columns: repeat(3, 1fr);
}

.hcm-options-4 {
	grid-template-columns: repeat(2, 1fr);
}

.hcm-options-6 {
	grid-template-columns: repeat(3, 1fr);
}

.hcm-options-8 {
	grid-template-columns: repeat(4, 1fr);
}

.hcm-color-option {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-end;
	aspect-ratio: 0.85;
	min-height: 88px;
	padding: 0.5rem 0.35rem 0.4rem;
	border: 3px solid rgba(255, 255, 255, 0.7);
	border-radius: 16px;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
	transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	box-sizing: border-box;
}

.hcm-color-option.hcm-color-light {
	border-color: var(--hcm-border);
}

.hcm-color-label {
	display: block;
	margin-top: auto;
	padding: 0.2rem 0.35rem;
	font-size: 0.85rem;
	font-weight: 700;
	color: #fff;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
	background: rgba(0, 0, 0, 0.25);
	border-radius: 8px;
	line-height: 1.2;
}

.hcm-color-light .hcm-color-label {
	color: var(--hcm-text);
	text-shadow: none;
	background: rgba(255, 255, 255, 0.85);
}

.hcm-color-option:hover:not(:disabled) {
	transform: scale(1.05);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.hcm-color-option:focus-visible {
	outline: none;
	box-shadow: var(--hcm-focus-ring), 0 3px 12px rgba(0, 0, 0, 0.12);
}

.hcm-color-option:active:not(:disabled) {
	transform: scale(0.95);
}

.hcm-color-option.hcm-correct {
	border-color: var(--hcm-success);
	box-shadow: 0 0 0 4px rgba(67, 160, 71, 0.4);
}

.hcm-color-option.hcm-wrong {
	border-color: var(--hcm-danger);
	box-shadow: 0 0 0 4px rgba(229, 57, 53, 0.4);
	animation: hcm-shake 0.4s ease;
}

.hcm-color-option.hcm-option-hidden {
	opacity: 0.15;
	transform: scale(0.85);
	pointer-events: none;
}

@keyframes hcm-shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-6px); }
	75% { transform: translateX(6px); }
}

.hcm-feedback {
	padding: 0.6rem 1.2rem;
	border-radius: 10px;
	font-weight: 700;
	font-size: 1.05rem;
	text-align: center;
}

.hcm-feedback-correct {
	background: #e8f5e9;
	color: var(--hcm-success);
}

.hcm-feedback-wrong {
	background: #ffebee;
	color: var(--hcm-danger);
}

.hcm-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	justify-content: center;
	margin-bottom: 0.75rem;
}

.hcm-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(26, 26, 46, 0.55);
	padding: 1rem;
	box-sizing: border-box;
}

.hcm-modal-content {
	background: var(--hcm-card-bg);
	border-radius: var(--hcm-radius);
	padding: 1.5rem 1.75rem;
	max-width: 400px;
	width: 100%;
	text-align: center;
	box-shadow: var(--hcm-shadow);
	direction: rtl;
}

.hcm-modal-title {
	margin: 0 0 0.75rem;
	font-size: 1.5rem;
	color: var(--hcm-primary-dark);
}

.hcm-lose-title {
	color: var(--hcm-danger);
}

.hcm-stars-display {
	font-size: 1.5rem;
	color: var(--hcm-accent);
	letter-spacing: 2px;
}

.hcm-modal-actions {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	margin-top: 1.25rem;
}

.hcm-modal-actions .hcm-btn {
	width: 100%;
}

@media (min-width: 600px) {
	.hcm-modal-actions {
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
	}

	.hcm-modal-actions .hcm-btn {
		width: auto;
		flex: 1 1 auto;
		min-width: 120px;
	}
}

@media (max-width: 480px) {
	.hcm-game-card {
		padding: 1rem;
	}

	.hcm-difficulty-grid {
		grid-template-columns: 1fr;
	}

	.hcm-level-grid {
		grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
	}

	.hcm-level-cell {
		min-width: 62px;
		min-height: 60px;
	}

	.hcm-object-image {
		font-size: 4rem;
	}

	.hcm-color-option {
		min-height: 76px;
	}

	.hcm-options-3 {
		gap: 0.6rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hcm-btn,
	.hcm-level-cell,
	.hcm-color-option,
	.hcm-progress-fill,
	.hcm-target-swatch {
		transition: none;
	}

	.hcm-btn:active,
	.hcm-color-option:active {
		transform: none;
	}

	.hcm-color-option.hcm-wrong {
		animation: none;
	}
}
