/* Agate Hunter — coastal beachcombing game */

.ah-wrap {
	--ah-ink: #0f2740;
	--ah-muted: #5a6f82;
	--ah-paper: #f4f0e6;
	--ah-sand: #e8d9b8;
	--ah-sea: #1a6b8a;
	--ah-sea-deep: #0d3d52;
	--ah-foam: #c8e6f0;
	--ah-accent: #c45c26;
	--ah-gold: #d4a017;
	--ah-float: #2a9d8f;
	--ah-rare: #7b2cbf;
	--ah-beacon: #b45309;
	--ah-card: #fffdf8;
	--ah-border: #d4c9b0;
	--ah-danger: #b45309;
	--ah-radius: 14px;
	--ah-shadow: 0 10px 28px rgba(15, 39, 64, 0.12);

	margin: 0 0 1.25rem;
	max-width: 100%;
	width: 100%;
	box-sizing: border-box;
	color: var(--ah-ink);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 0.95rem;
	line-height: 1.45;
	background: linear-gradient(180deg, #eaf4f8 0%, var(--ah-paper) 42%, var(--ah-sand) 100%);
	border: 1px solid var(--ah-border);
	border-radius: var(--ah-radius);
	box-shadow: var(--ah-shadow);
	overflow: hidden;
	-webkit-tap-highlight-color: transparent;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	touch-action: manipulation;
}

.ah-wrap *,
.ah-wrap *::before,
.ah-wrap *::after {
	box-sizing: border-box;
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
}

.ah-wrap input,
.ah-wrap textarea {
	-webkit-user-select: text;
	user-select: text;
}

.ah-wrap.ah-lost .ah-panel-title {
	color: var(--ah-danger);
}

.ah-masthead {
	padding: 0.45rem 0.6rem 0.1rem;
	text-align: center;
}

.ah-kicker {
	font-size: 0.6rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--ah-muted);
	margin-bottom: 0.08rem;
	font-weight: 600;
}

.ah-title {
	margin: 0;
	font-size: clamp(1.1rem, 3.5vw, 1.4rem);
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--ah-sea-deep);
	font-family: Georgia, "Times New Roman", Times, serif;
	line-height: 1.1;
	overflow: visible;
}

.ah-tagline {
	display: none; /* save vertical space — shown on menu overlay instead */
}

.ah-toolbar {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.3rem;
	padding: 0.05rem 0.5rem 0.2rem;
}

.ah-link-beacon {
	font-size: 0.82rem;
	font-weight: 700;
	color: var(--ah-sea) !important;
	text-decoration: none !important;
}

.ah-link-beacon:hover {
	text-decoration: underline !important;
}

.ah-tool-btn {
	appearance: none;
	border: 1px solid var(--ah-border);
	background: var(--ah-card);
	color: var(--ah-ink);
	font: inherit;
	font-size: 0.72rem;
	font-weight: 700;
	padding: 0.28rem 0.55rem;
	border-radius: 999px;
	cursor: pointer;
	text-decoration: none !important;
}

.ah-tool-link {
	display: inline-block;
}

.ah-hud {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 0.25rem;
	padding: 0.2rem 0.45rem 0.3rem;
}

.ah-stat {
	background: var(--ah-card);
	border: 1px solid var(--ah-border);
	border-radius: 8px;
	padding: 0.25rem 0.15rem;
	text-align: center;
	min-width: 0;
}

.ah-stat-label {
	display: block;
	font-size: 0.52rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--ah-muted);
	font-weight: 700;
	margin-bottom: 0.04rem;
}

.ah-stat-val {
	display: block;
	font-size: 0.86rem;
	font-weight: 800;
	color: var(--ah-ink);
	font-variant-numeric: tabular-nums;
	line-height: 1.15;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ah-stat-lives .ah-stat-val {
	color: #c45c26;
	letter-spacing: 0.06em;
	font-size: 0.95rem;
}

.ah-stage {
	position: relative;
	margin: 0 0.4rem 0.35rem;
	border-radius: 12px;
	overflow: hidden;
	border: 2px solid rgba(15, 39, 64, 0.18);
	background: #c9b48a;
	/* Prefer tall playfield on phones */
	height: min(80vh, 660px);
	min-height: 440px;
	max-height: 84vh;
}

.ah-canvas {
	display: block;
	width: 100%;
	height: 100%;
	cursor: crosshair;
	touch-action: none;
	vertical-align: middle;
}

/* Whale / bins action chip */
.ah-whale-btn {
	position: absolute;
	right: 10px;
	bottom: 10px;
	z-index: 4;
	appearance: none;
	border: none;
	background: linear-gradient(180deg, #3aa0b8 0%, #1a6b8a 100%);
	color: #fff;
	font: inherit;
	font-weight: 800;
	font-size: 0.78rem;
	letter-spacing: 0.03em;
	padding: 0.65rem 0.85rem;
	border-radius: 999px;
	cursor: pointer;
	box-shadow: 0 3px 0 #0d4a60, 0 8px 18px rgba(13, 61, 82, 0.3);
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px) scale(0.92);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
	pointer-events: none;
	-webkit-tap-highlight-color: transparent;
}

.ah-whale-btn.is-ready {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
	pointer-events: auto;
	animation: ah-whale-pulse 1.8s ease-in-out infinite;
}

.ah-whale-btn:disabled {
	cursor: default;
}

.ah-whale-btn:active {
	transform: translateY(2px) scale(0.98);
	box-shadow: 0 1px 0 #0d4a60;
}

@keyframes ah-whale-pulse {
	0%, 100% { box-shadow: 0 3px 0 #0d4a60, 0 8px 18px rgba(13, 61, 82, 0.3); }
	50% { box-shadow: 0 3px 0 #0d4a60, 0 8px 22px rgba(42, 157, 143, 0.55); }
}

.ah-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	background: linear-gradient(
		180deg,
		rgba(13, 61, 82, 0.55) 0%,
		rgba(15, 39, 64, 0.72) 100%
	);
	backdrop-filter: blur(2px);
	transition: opacity 0.25s ease, visibility 0.25s ease;
	z-index: 5;
}

.ah-overlay.is-hidden {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.ah-panel {
	width: min(100%, 340px);
	background: var(--ah-card);
	border: 1px solid var(--ah-border);
	border-radius: 16px;
	padding: 1.2rem 1.1rem 1.05rem;
	text-align: center;
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.ah-panel-eyebrow {
	font-size: 0.7rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--ah-sea);
	font-weight: 700;
	margin-bottom: 0.35rem;
}

.ah-panel-title {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 1.4rem;
	font-weight: 800;
	color: var(--ah-sea-deep);
	margin-bottom: 0.5rem;
	line-height: 1.2;
}

.ah-panel-body {
	margin: 0 0 0.85rem;
	color: var(--ah-muted);
	font-size: 0.88rem;
	line-height: 1.45;
}

.ah-panel-body strong {
	color: var(--ah-ink);
}

.ah-lost-note {
	display: inline-block;
	margin-top: 0.35rem;
	font-size: 0.78rem;
	color: var(--ah-danger);
}

.ah-howto {
	text-align: left;
	margin: 0 0 1rem;
	padding: 0.55rem 0.7rem;
	background: rgba(26, 107, 138, 0.08);
	border-radius: 10px;
	font-size: 0.78rem;
	color: var(--ah-ink);
	line-height: 1.45;
}

.ah-howto li {
	margin: 0.15rem 0;
}

.ah-btn {
	appearance: none;
	border: none;
	background: linear-gradient(180deg, #2a8fad 0%, var(--ah-sea) 100%);
	color: #fff;
	font: inherit;
	font-weight: 700;
	font-size: 1rem;
	padding: 0.75rem 1.25rem;
	border-radius: 999px;
	cursor: pointer;
	width: 100%;
	box-shadow: 0 4px 0 #0d4a60, 0 8px 18px rgba(13, 61, 82, 0.25);
	transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
	-webkit-tap-highlight-color: transparent;
}

.ah-btn:hover {
	filter: brightness(1.05);
}

.ah-btn:active {
	transform: translateY(2px);
	box-shadow: 0 2px 0 #0d4a60, 0 4px 10px rgba(13, 61, 82, 0.2);
}

.ah-btn:focus-visible {
	outline: 3px solid #7dd3fc;
	outline-offset: 2px;
}

.ah-hint {
	margin: 0.7rem 0 0;
	font-size: 0.75rem;
	color: var(--ah-muted);
}

.ah-legend {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.3rem 0.65rem;
	list-style: none;
	margin: 0;
	padding: 0 0.65rem 0.55rem;
	font-size: 0.72rem;
	color: var(--ah-muted);
}

.ah-legend li {
	display: inline-flex;
	align-items: center;
	gap: 0.28rem;
	white-space: nowrap;
}

.ah-legend em {
	font-style: normal;
	font-weight: 700;
	color: var(--ah-ink);
}

.ah-dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	display: inline-block;
	flex-shrink: 0;
	box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

.ah-dot-shell { background: #f0ebe0; border: 1px solid #c4b8a0; }
.ah-dot-agate { background: linear-gradient(135deg, #c45c26, #e8a87c); }
.ah-dot-float { background: radial-gradient(circle at 30% 30%, #7ee8d8, var(--ah-float)); }
.ah-dot-rare { background: radial-gradient(circle at 30% 30%, #d4a5ff, var(--ah-rare)); }
.ah-dot-beacon { background: linear-gradient(135deg, #f4c430, var(--ah-beacon)); }
.ah-dot-bins { background: linear-gradient(135deg, #5dade2, #1a6b8a); }
.ah-dot-hazard { background: #c45c26; }
.ah-dot-karen { background: #e85d04; box-shadow: 0 0 0 1px #7a1f1f; }
.ah-dot-fog { background: linear-gradient(135deg, #9aafb8, #1a2a40); }

.ah-footer {
	margin: 0;
	padding: 0 1rem 0.85rem;
	text-align: center;
	font-size: 0.7rem;
	color: var(--ah-muted);
	opacity: 0.85;
}

.ah-footer a {
	color: var(--ah-sea) !important;
	font-weight: 700;
}

/* Mode pick grid */
.ah-mode-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.4rem;
	margin: 0 0 0.85rem;
}

@media (min-width: 360px) {
	.ah-mode-grid {
		grid-template-columns: 1fr 1fr 1fr;
	}
}

.ah-mode-btn {
	appearance: none;
	border: 1px solid var(--ah-border);
	background: linear-gradient(180deg, #fff 0%, #f4f0e6 100%);
	border-radius: 12px;
	padding: 0.75rem 0.35rem 0.65rem;
	font: inherit;
	font-weight: 700;
	font-size: 0.78rem;
	color: var(--ah-sea-deep);
	cursor: pointer;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.35rem;
	box-shadow: 0 2px 0 var(--ah-border);
	-webkit-tap-highlight-color: transparent;
	line-height: 1.2;
}

.ah-mode-ico {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: linear-gradient(145deg, #e8a87c, #c45c26);
	box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
	position: relative;
}

.ah-mode-ico::after {
	content: "";
	position: absolute;
	inset: 8px;
	border-radius: 50%;
	background: rgba(255,255,255,0.35);
}

.ah-mode-ico-wave {
	background: linear-gradient(145deg, #7dd3fc, #1a6b8a);
}

.ah-mode-ico-whale {
	background: linear-gradient(145deg, #a5b4fc, #334155);
}

.ah-mode-btn:hover {
	border-color: #94a3b8;
}

.ah-mode-btn:active {
	transform: translateY(1px);
	box-shadow: none;
}

.ah-btn-sm {
	padding: 0.55rem 0.9rem;
	font-size: 0.9rem;
	width: auto;
}

.ah-btn-secondary {
	margin-top: 0.5rem;
	background: transparent;
	color: var(--ah-sea-deep);
	border: 1px solid var(--ah-border);
	box-shadow: none;
}

.ah-btn-secondary:hover {
	filter: none;
	background: rgba(26, 107, 138, 0.08);
}

.ah-btn-secondary:active {
	box-shadow: none;
}

/* Arcade name entry */
.ah-arcade {
	margin: 0.5rem 0 0.75rem;
	padding: 0.65rem;
	background: rgba(15, 39, 64, 0.06);
	border-radius: 12px;
	text-align: left;
}

.ah-arcade-label {
	display: block;
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--ah-muted);
	margin-bottom: 0.35rem;
}

.ah-arcade-row {
	display: flex;
	gap: 0.4rem;
	align-items: center;
}

.ah-arcade-input {
	flex: 1;
	min-width: 0;
	font-family: "Courier New", Courier, monospace;
	font-size: 1.15rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	padding: 0.5rem 0.65rem;
	border: 2px solid var(--ah-sea);
	border-radius: 8px;
	background: #fff;
	color: var(--ah-ink);
}

.ah-arcade-msg {
	margin: 0.4rem 0 0;
	font-size: 0.78rem;
	color: var(--ah-sea);
	font-weight: 600;
	min-height: 1.1em;
}

/* Settings sheet */
.ah-settings {
	position: absolute;
	inset: 0;
	z-index: 8;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	background: rgba(15, 39, 64, 0.55);
}

.ah-settings[hidden] {
	display: none !important;
}

.ah-settings-card {
	width: min(100%, 300px);
	background: var(--ah-card);
	border-radius: 16px;
	border: 1px solid var(--ah-border);
	padding: 1.1rem;
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
}

.ah-settings-title {
	font-family: Georgia, serif;
	font-weight: 800;
	font-size: 1.2rem;
	margin-bottom: 0.75rem;
	color: var(--ah-sea-deep);
}

.ah-set-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	font-size: 0.88rem;
	font-weight: 600;
	margin-bottom: 0.65rem;
	color: var(--ah-ink);
}

.ah-set-row input[type="range"] {
	flex: 1;
	max-width: 120px;
}

.ah-toast {
	position: absolute;
	left: 50%;
	top: 12%;
	transform: translate(-50%, 0);
	background: rgba(255, 253, 248, 0.96);
	border: 1px solid var(--ah-border);
	border-radius: 999px;
	padding: 0.4rem 0.85rem;
	font-weight: 800;
	font-size: 0.82rem;
	color: var(--ah-sea-deep);
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	z-index: 6;
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
	white-space: nowrap;
	max-width: 90%;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.ah-toast.is-show {
	opacity: 1;
	visibility: visible;
	transform: translate(-50%, -4px);
}

@media (max-width: 520px) {
	.ah-kicker {
		display: none;
	}

	.ah-masthead {
		padding: 0.35rem 0.45rem 0.05rem;
	}

	.ah-title {
		font-size: 1.12rem;
	}

	.ah-link-beacon {
		font-size: 0.72rem;
	}

	.ah-hud {
		gap: 0.2rem;
		padding: 0.15rem 0.35rem 0.25rem;
	}

	.ah-stat {
		padding: 0.2rem 0.1rem;
		border-radius: 7px;
	}

	.ah-stat-val {
		font-size: 0.8rem;
	}

	.ah-stat-label {
		font-size: 0.48rem;
	}

	.ah-stage {
		margin: 0 0.3rem 0.3rem;
		min-height: 460px;
		height: min(78vh, 640px);
		max-height: 82vh;
	}

	.ah-footer {
		padding: 0 0.6rem 0.5rem;
		font-size: 0.62rem;
	}

	.ah-whale-btn {
		font-size: 0.7rem;
		padding: 0.5rem 0.65rem;
		bottom: 8px;
		right: 8px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ah-whale-btn.is-ready {
		animation: none;
	}

	.ah-toast {
		transition: none;
	}

	.ah-btn {
		transition: none;
	}
}
