/* Base minimal styles */
html, body { height: 100%; }
body { margin: 0; color: #111; font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; }

#canvas { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; z-index: 1; }
/* Top-left circular toolbar buttons */
#helpBtn { position: fixed; top: 12px; left: 12px; z-index: 4; width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.6); background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center; font-weight: 600; }
#helpBtn:hover { background: rgba(255,255,255,0.12); }
/* Paragraphs button */
#paraBtn { position: fixed; top: 12px; left: 48px; z-index: 4; width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.6); background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center; font-weight: 600; }
#paraBtn:hover { background: rgba(255,255,255,0.12); }
/* Music toggle button */
#musicBtn { position: fixed; top: 12px; left: 84px; z-index: 4; width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.6); background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center; font-weight: 600; }
#musicBtn:hover { background: rgba(255,255,255,0.12); }
/* Extra toolbar buttons */
#saveBtn { position: fixed; top: 12px; left: 120px; z-index: 4; width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.6); background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center; font-weight: 600; }
#saveBtn:hover { background: rgba(255,255,255,0.12); }
#clearBtn { position: fixed; top: 12px; left: 156px; z-index: 4; width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.6); background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center; font-weight: 600; }
#clearBtn:hover { background: rgba(255,255,255,0.12); }

/* Help modal overlay */
#helpModal { position: fixed; inset: 0; z-index: 5; pointer-events: none; opacity: 0; transition: opacity 180ms ease; }
#helpModal.open { pointer-events: auto; opacity: 1; }
.help-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.35); }
.help-content { position: absolute; top: 48px; left: 50%; transform: translateX(-50%); width: min(720px, 92vw); max-height: 70vh; overflow: auto; background: rgba(255,255,255,0.92); color: #111; border: 1px solid rgba(0,0,0,0.15); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); backdrop-filter: blur(6px); padding: 16px 18px; }
#paraModal { position: fixed; inset: 0; z-index: 5; pointer-events: none; opacity: 0; transition: opacity 180ms ease; }
#paraModal.open { pointer-events: auto; opacity: 1; }
#paraList { display: grid; gap: 10px; }
#paraList .para-item { border: 1px solid rgba(0,0,0,0.15); border-radius: 8px; padding: 10px; cursor: pointer; background: rgba(0,0,0,0.04); }
#paraList .para-item:hover { background: rgba(0,0,0,0.08); }

/* Right-side paragraph view */
#paragraphView { position: fixed; top: 0; right: 0; width: min(35vw, 480px); height: 100vh; background: var(--pv-bg); color: var(--pv-text); border-left: 1px solid rgba(0,0,0,0.2); backdrop-filter: blur(6px); z-index: 4; transform: translateX(100%); transition: transform 200ms ease; display: flex; flex-direction: column; }
#paragraphView.open { transform: translateX(0%); }
#paragraphView .pv-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid rgba(0,0,0,0.2); }
#pvText { padding: 12px; line-height: 1.6; font-size: 15px; overflow-y: auto; color: var(--pv-text); }
.pv-done { background: var(--pv-done-bg); color: var(--pv-done-text); border-radius: 4px; }
.pv-next { color: var(--pv-caret); background: var(--pv-next-bg); border-bottom: 2px solid var(--pv-caret); }
.pv-remaining { color: var(--pv-remaining-text); }
.help-close { position: absolute; top: 8px; right: 10px; width: 28px; height: 28px; border: 1px solid rgba(0,0,0,0.2); background: rgba(0,0,0,0.06); color: #111; cursor: pointer; border-radius: 6px; }
.help-close:hover { background: rgba(0,0,0,0.1); }
.help-content h2, .help-content h3 { margin: 8px 0; }
.help-content p { margin: 8px 0; }
.help-content ul { margin: 8px 0 0 18px; }

/* Mascot positioning */
#mascot { position: fixed; right: 12px; bottom: 56px; z-index: 3; pointer-events: none; }
#mascotImg { position: absolute; right: 0; bottom: 0; width: 96px; height: 96px; object-fit: cover; border-radius: 10px; box-shadow: 0 6px 16px rgba(0,0,0,0.25); }
#mascotSvg #m-body rect { fill: rgba(0,0,0,0.12); stroke-width: 2; stroke: #222; }
#mascotSvg #m-eyes circle { fill: #222; }
#mascotSvg .acc { display: none; fill: #222; stroke: none; }

#stats { position: fixed; bottom: 0; left: 0; right: 0; height: 28px; display: flex; gap: 12px; align-items: center; justify-content: center; padding: 0 10px; backdrop-filter: blur(6px); z-index: 5; border-top: 1px solid rgba(255,255,255,0.35); background: rgba(0,0,0,0.12); box-shadow: 0 -1px 0 rgba(0,0,0,0.3); font-size: 13px; }
#stats span { min-width: 110px; text-align: center; line-height: 28px; }

/* Shape selection panel (pill style) */
#shapePanel { position: fixed; top: 12px; right: 12px; z-index: 3; background: rgba(0,0,0,0.08); border: 1px solid rgba(255,255,255,0.22); color: #fff; backdrop-filter: blur(6px); border-radius: 12px; padding: 6px 10px; display: flex; align-items: center; gap: 8px; box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset; }
#shapePanel label { opacity: .95; font-weight: 600; font-size: 14px; }
#shapePanel select { padding: 3px 8px; border: 1px solid rgba(255,255,255,0.3); border-radius: 8px; background: rgba(0,0,0,0.2); color: #fff; font-size: 14px; }

/* Theme selection panel (pill style) */
#themePanel { position: fixed; top: 56px; right: 12px; z-index: 3; background: rgba(0,0,0,0.08); border: 1px solid rgba(255,255,255,0.22); color: #fff; backdrop-filter: blur(6px); border-radius: 12px; padding: 6px 10px; display: flex; align-items: center; gap: 8px; box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset; }
#themePanel label { opacity: .95; font-weight: 600; font-size: 14px; }
#themePanel select { padding: 3px 8px; border: 1px solid rgba(255,255,255,0.3); border-radius: 8px; background: rgba(0,0,0,0.2); color: #fff; font-size: 14px; }
.refresh-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; opacity: 0.95; margin-left: 6px; }
.refresh-toggle input { accent-color: #cfcfcf; }

/* Image controls panel (pill style) */
#imagePanel { position: fixed; top: 100px; right: 12px; z-index: 3; background: rgba(0,0,0,0.08); border: 1px solid rgba(255,255,255,0.22); color: #fff; backdrop-filter: blur(6px); border-radius: 12px; padding: 6px 10px; display: flex; align-items: center; gap: 8px; box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset; }
#imagePanel input[type="file"] { max-width: 170px; color: #fff; font-size: 14px; }

/* Freehand sketch panel (pill style) */
#sketchPanel { position: fixed; top: 144px; right: 12px; z-index: 3; background: rgba(0,0,0,0.08); border: 1px solid rgba(255,255,255,0.22); color: #fff; backdrop-filter: blur(6px); border-radius: 12px; padding: 8px 10px; display: flex; align-items: center; gap: 10px; box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset; width: auto; white-space: nowrap; }
#sketchPanel strong { font-size: 13px; letter-spacing: .2px; opacity: .95; padding: 4px 8px; border-radius: 8px; background: rgba(255,255,255,0.05); }
.active#sketchPanel strong, #sketchPanel.active strong { background: rgba(255,255,255,0.12); }
.sketch-row { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
#brushSize { width: 120px; accent-color: #bfbfbf; }
#brushColor { width: 56px; height: 24px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.3); background: rgba(0,0,0,0.2); }

/* Range styling (WebKit/Chromium) */
input[type="range"]::-webkit-slider-runnable-track { height: 8px; background: rgba(255,255,255,0.3); border-radius: 8px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #dcdcdc; margin-top: -5px; border: 1px solid rgba(0,0,0,0.25); }
/* Firefox */
input[type="range"] { height: 8px; }
input[type="range"]::-moz-range-track { height: 8px; background: rgba(255,255,255,0.3); border-radius: 8px; }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #dcdcdc; border: 1px solid rgba(0,0,0,0.25); }

/* Mobile UI (overlay controls) */
/* Hidden by default; shown via media query */
#mobileControlsBtn { position: fixed; top: 12px; right: 12px; z-index: 6; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.6); background: rgba(0,0,0,0.08); color: #fff; cursor: pointer; display: none; place-items: center; font-size: 20px; }
#mobileControlsBtn:hover { background: rgba(255,255,255,0.12); }
#mobileControlsOverlay { position: fixed; inset: 0; z-index: 7; pointer-events: none; opacity: 0; transition: opacity 180ms ease; }
#mobileControlsOverlay.open { pointer-events: auto; opacity: 1; }
.mc-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.35); }
.mc-content { position: absolute; top: 56px; right: 12px; width: min(88vw, 420px); max-height: 72vh; overflow: auto; background: rgba(255,255,255,0.92); color: #111; border: 1px solid rgba(0,0,0,0.15); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); backdrop-filter: blur(6px); padding: 10px 12px; }
.mc-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 6px; border-bottom: 1px solid rgba(0,0,0,0.12); margin-bottom: 8px; }
.mc-close { width: 32px; height: 32px; border: 1px solid rgba(0,0,0,0.2); background: rgba(0,0,0,0.06); color: #111; cursor: pointer; border-radius: 6px; }
.mc-close:hover { background: rgba(0,0,0,0.1); }

@media (max-width: 768px) {
	/* Finger-friendly sizes for toolbar buttons */
	#helpBtn, #paraBtn, #musicBtn, #saveBtn, #clearBtn { width: 40px; height: 40px; font-size: 16px; }

	/* Disable touch gestures on canvas to prevent scroll/pinch */
	#canvas { touch-action: none; }

	/* Collapse top-right controls into gear; hide fixed pills */
	#shapePanel, #themePanel, #sketchPanel { display: none; }

	/* Show floating gear button */
	#mobileControlsBtn { display: grid; }

	/* Inside mobile overlay, render controls vertically and larger */
	#mobileControlsOverlay.open #mobileControlsContainer { display: flex; flex-direction: column; gap: 10px; }
	#mobileControlsOverlay.open #shapePanel,
	#mobileControlsOverlay.open #themePanel,
	#mobileControlsOverlay.open #sketchPanel {
		display: flex;
		position: static;
		background: rgba(0,0,0,0.06);
		color: #111;
		border-color: rgba(0,0,0,0.15);
		box-shadow: none;
		backdrop-filter: none;
		width: auto;
	}
	#mobileControlsOverlay.open #shapePanel label,
	#mobileControlsOverlay.open #themePanel label,
	#mobileControlsOverlay.open #sketchPanel strong {
		font-size: 16px;
	}
	#mobileControlsOverlay.open #shapePanel select,
	#mobileControlsOverlay.open #themePanel select { font-size: 16px; padding: 8px 10px; }

	/* Larger sliders and color input */
	#mobileControlsOverlay.open #brushSize { width: 220px; }
	#mobileControlsOverlay.open #brushColor { width: 64px; height: 32px; }
	input[type="range"]::-webkit-slider-runnable-track { height: 12px; }
	input[type="range"]::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -6px; }
	input[type="range"] { height: 12px; }
	input[type="range"]::-moz-range-track { height: 12px; }
	input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; }
}
