/* Write and Rung — Game Styles */

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	font-size: 16px;
	margin: 0;
	padding: 0;
	background: #f5f3ff;
	color: #1e1b4b;
}

a { color: rgb(92, 5, 137); }
a:hover { color: rgb(165, 59, 227); }

.bigger {
	text-align: center;
	padding: 16px 10px 8px;
	font-size: 16px;
	line-height: 1.5;
}

/* ---- Timer ---- */
#timer {
	display: none;
	text-align: center;
	font-family: 'Courier New', monospace;
	font-size: 18px;
	font-weight: bold;
	color: #4c1d95;
	padding: 4px 0;
	margin: 4px auto;
}

/* ---- Game Container ---- */
#game {
	max-width: 520px;
	margin: 0 auto;
	padding: 0 16px 40px;
}

/* ---- Shared Active Clue ---- */
#active-clue {
	text-align: center;
	font-size: 15px;
	line-height: 1.5;
	color: #374151;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	padding: 12px 14px;
	margin-bottom: 12px;
	min-height: 22px;
	transition: opacity 0.15s;
}

/* ---- Phase Headers ---- */
.phase-header {
	text-align: center;
	font-size: 13px;
	color: #6b7280;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	margin: 16px 0 10px;
}

/* ---- Ladder Rows (sortable clue rows) ---- */
#ladder-rows {
	min-height: 60px;
}

.clue-row {
	display: flex;
	align-items: center;
	gap: 10px;
	background: #fff;
	border: 2px solid #e5e7eb;
	border-radius: 10px;
	padding: 10px 14px;
	margin-bottom: 6px;
	user-select: none;
	touch-action: none;
	transition: border-color 0.2s, background 0.2s, box-shadow 0.15s;
}

.clue-row.active-row {
	border-color: #7c3aed;
	background: #faf5ff;
}

.clue-row.solved-row {
	background: #f0fdf4;
	border-color: #86efac;
}

.clue-row.solved-row.active-row {
	border-color: #7c3aed;
	background: #f0fdf4;
}

.clue-row.ui-sortable-helper {
	cursor: grabbing;
	box-shadow: 0 4px 16px rgba(76, 29, 149, 0.2);
	border-color: #7c3aed;
	z-index: 10;
}

.drag-handle {
	color: #a78bfa;
	font-size: 18px;
	flex-shrink: 0;
	cursor: grab;
	padding: 4px 0;
}

.drag-handle:active {
	cursor: grabbing;
}

.ladder-placeholder {
	background: #f5f3ff;
	border: 2px dashed #c4b5fd;
	border-radius: 10px;
	height: 58px;
	margin-bottom: 6px;
}

/* ---- Letter Boxes ---- */
.letter-boxes {
	display: flex;
	justify-content: center;
	gap: 6px;
	padding: 2px 0;
	flex: 1;
}

.letter-box {
	width: 42px;
	height: 42px;
	border: 2px solid #d1d5db;
	border-radius: 6px;
	text-align: center;
	font-family: 'Courier New', monospace;
	font-size: 22px;
	font-weight: 700;
	text-transform: uppercase;
	color: #1e1b4b;
	outline: none;
	padding: 0;
	box-sizing: border-box;
	caret-color: #7c3aed;
	transition: border-color 0.15s, background-color 0.2s;
}

.letter-box:focus {
	border-color: #7c3aed;
	box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.letter-box-correct {
	background-color: #bbf7d0;
	border-color: #22c55e;
	color: #166534;
	cursor: default;
}

.letter-box-correct:focus {
	border-color: #22c55e;
	box-shadow: none;
}

.letter-boxes.wrong .letter-box {
	border-color: #ef4444;
}

.letter-boxes.wrong {
	animation: shake 0.4s ease;
}

/* ---- Endpoint Areas (above/below ladder) ---- */
#endpoint-top-area,
#endpoint-bottom-area {
	display: flex;
	flex-direction: column;
	align-items: center;
}

#endpoint-top-area {
	margin-bottom: 6px;
}

#endpoint-bottom-area {
	margin-top: 6px;
}

.endpoint-connector {
	width: 2px;
	height: 10px;
	background: #c4b5fd;
}

.endpoint-input-row .letter-box {
	border-color: #7c3aed;
	background: #faf5ff;
	color: #4c1d95;
}

.endpoint-input-row .letter-box:focus {
	border-color: #4c1d95;
	box-shadow: 0 0 0 2px rgba(76, 29, 149, 0.15);
}

.endpoint-input-row .letter-box-correct {
	border-color: #22c55e;
	background: #bbf7d0;
	color: #166534;
}

/* ---- Win Modal ---- */
.modal {
	display: none;
	position: fixed;
	top: 0; left: 0;
	width: 100%; height: 100%;
	background: rgba(0,0,0,0.5);
	z-index: 100;
}

.modal-content {
	background: #fff;
	max-width: 420px;
	width: 85%;
	margin: 15vh auto 0;
	border-radius: 14px;
	padding: 28px 24px;
	text-align: center;
	position: relative;
	box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-content .close {
	position: absolute;
	top: 10px;
	right: 16px;
	font-size: 28px;
	color: #9ca3af;
	cursor: pointer;
	line-height: 1;
}

.modal-content .close:hover {
	color: #374151;
}

#the_results {
	font-size: 18px;
	line-height: 1.6;
	margin-bottom: 16px;
}

#the_results .win-time {
	font-size: 24px;
	font-weight: 800;
	color: #4c1d95;
}

#copy_score a {
	display: inline-block;
	padding: 10px 24px;
	background: #4c1d95;
	color: #fff;
	border-radius: 8px;
	text-decoration: none;
	font-weight: 700;
	font-size: 14px;
	transition: background 0.15s;
}

#copy_score a:hover {
	background: #6d28d9;
	color: #fff;
}

#copy_score em {
	display: block;
	margin-top: 8px;
	font-size: 13px;
	color: #166534;
}

#next-game {
	margin-top: 16px;
	padding: 12px;
	background: #f5f3ff;
	border-radius: 8px;
	font-size: 14px;
	color: #374151;
}

#leaderboard-link {
	display: block;
	margin-top: 12px;
	font-size: 14px;
}

/* ---- How To Play Modal ---- */
#howToPlayModal .modal-content {
	text-align: left;
	max-width: 500px;
	font-size: 15px;
	line-height: 1.6;
}

#howToPlayModal .modal-content p {
	margin: 0 0 12px;
}

.ladder-example {
	font-family: 'Courier New', monospace;
	font-weight: 700;
	letter-spacing: 0.1em;
	line-height: 1.8;
	text-align: center;
	color: #4c1d95;
	margin: 12px 0;
}

/* ---- Animations ---- */
@keyframes shake {
	0%, 100% { transform: translateX(0); }
	20% { transform: translateX(-6px); }
	40% { transform: translateX(6px); }
	60% { transform: translateX(-4px); }
	80% { transform: translateX(4px); }
}

@keyframes fadeSlideIn {
	from {
		opacity: 0;
		transform: translateY(-8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
	#active-clue { font-size: 14px; padding: 10px 12px; }
	.endpoint-word { font-size: 17px; }
	.letter-box {
		width: 36px;
		height: 36px;
		font-size: 18px;
	}
	.letter-boxes {
		gap: 4px;
	}
	.clue-row {
		padding: 8px 10px;
		gap: 8px;
	}
	.modal-content { margin-top: 8vh; padding: 20px 16px; }
}

@media (max-width: 360px) {
	.letter-box {
		width: 32px;
		height: 32px;
		font-size: 16px;
	}
	.letter-boxes {
		gap: 3px;
	}
	.clue-row {
		padding: 6px 8px;
		gap: 6px;
	}
}
