/* =============================================================================
   Peechmart Doodle Submit — Nintendo DS aesthetic
   ============================================================================= */

:root {
	--ds-body:        #55B8EA;
	--ds-body-dark:   #3A9ACC;
	--ds-body-darker: #2A7AAA;
	--ds-bezel:       #222230;
	--ds-lcd:         #1C2B1C;
	--ds-lcd-text:    #80C880;
	--ds-lcd-dim:     #2A4A2A;
	--ds-btn-a:       #CC2020;
	--ds-btn-b:       #D08800;
	--ds-btn-x:       #2050C0;
	--ds-btn-y:       #1A9030;
	--ds-dpad:        #1A1A1A;
	--ds-speaker:     36px;  /* slim speaker columns for top half */
	--ds-side:        84px;  /* wider columns for dpad/abxy in bottom half */
	--ds-gap:         16px;
}

/* ── OUTER WRAPPER ─────────────────────────────────────────────────────── */
.peechmart-doodle-submit {
	max-width: 720px;
	margin: 2rem auto;
	font-family: 'Tahoma', 'Segoe UI', Arial, sans-serif;
	font-size: 11px;
	user-select: none;
}

/* ── DS BODY ───────────────────────────────────────────────────────────── */
.pd-ds {
	background: var(--ds-body);
	border-radius: 14px 14px 22px 22px;
	padding: 12px 12px 16px;
	box-shadow:
		inset  2px  2px 0 rgba(255,255,255,0.4),
		inset -2px -2px 0 rgba(0,0,0,0.12),
		0 8px 28px rgba(0,0,0,0.4);
}

/* ── SHARED HALF LAYOUT ────────────────────────────────────────────────── */
/* Top uses slim speaker columns; bottom uses wider columns for controls.
   min-width: 0 on grid items prevents Fabric's inline 600px from
   stretching the grid cell before ResizeObserver fires. */

.pd-ds__top-body {
	display: grid;
	grid-template-columns: var(--ds-side) 1fr var(--ds-side);
	gap: var(--ds-gap);
	align-items: center;
}

.pd-ds__bottom-body {
	display: grid;
	grid-template-columns: var(--ds-side) 1fr var(--ds-side);
	gap: var(--ds-gap);
	align-items: center;
}

/* ── TOP HALF ──────────────────────────────────────────────────────────── */
.pd-ds__top {
	margin-bottom: 0;
}

/* Speakers — slim 36px columns, centered dot grid */
.pd-ds__speaker {
	width: 22px;
	height: 52px;
	margin: 0 auto;
	background-image: radial-gradient(
		circle,
		rgba(0,0,0,0.5) 2px,
		transparent 2px
	);
	background-size: 7px 7px;
	background-position: center center;
	background-repeat: repeat;
	border-radius: 3px;
}

/* Screen wrap — same element for top and bottom.
   min-width: 0 is critical: prevents a grid item from expanding
   to fit Fabric's 600px inline canvas width.
   Aspect ratio 1.5:1 for responsive design. */
.pd-ds__screen-wrap {
	min-width: 0;
	background: var(--ds-bezel);
	border-radius: 6px;
	padding: 5px;
	box-shadow:
		inset 2px 2px 4px rgba(0,0,0,0.65),
		inset -1px -1px 2px rgba(255,255,255,0.04);
	width: 100%;
	aspect-ratio: 1.5;
}

.pd-ds__screen {
	position: relative;
	background: #000;
	border-radius: 3px;
	overflow: hidden;
	line-height: 0;
	min-width: 0;
}

.pd-ds__screen-wrap--bottom .pd-ds__screen {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	background: #fff;
	overflow-x: hidden;
	overflow-y: auto;
	padding: 20px;
	height: 100%;
}

.pd-ds__screen-wrap--bottom .pd-tool-screen-wrapper {
	width: 100%;
	max-width: 100%;
}

/* Override Fabric's inline width on its wrapper div */
.pd-ds__screen .canvas-container {
	width: 100% !important;
}

/* Canvas - let Fabric.js control dimensions via attributes */
.pd-ds__screen canvas {
	display: block;
	touch-action: none;
	cursor: crosshair;
	max-width: 100%;
	height: auto;
}

/* Mobile prompt — shown on mobile in normal mode */
.pd-mobile-prompt {
	display: none;
	position: absolute;
	inset: 0;
	background: #fff;
	z-index: 100;
	justify-content: center;
	align-items: center;
	cursor: pointer;
	user-select: none;
}

.pd-mobile-prompt__text {
	font-size: 18px;
	font-weight: bold;
	color: #55B8EA;
}

/* Draw-lock overlay — always hidden */
.pd-draw-lock {
	display: none !important;
}

/* ── HINGE ─────────────────────────────────────────────────────────────── */
.pd-ds__hinge {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 8px;
	height: 14px;
	background: var(--ds-body-darker);
	margin: 6px 0;
	border-radius: 2px;
	box-shadow: inset 0 2px 3px rgba(0,0,0,0.4);
	position: relative;
}

.pd-ds__hinge-piece {
	width: 64px;
	height: 10px;
	background: var(--ds-body-dark);
	border-radius: 3px;
	box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
}

.pd-ds__hinge-gap { width: 24px; }

/* Power indicator LED — two vertical bars */
.pd-ds__led {
	position: absolute;
	right: 12px;
	width: 14px;
	height: 8px;
	display: flex;
	gap: 2px;
}

.pd-ds__led::before,
.pd-ds__led::after {
	content: '';
	flex: 1;
	background: #7FEF7F;
	border-radius: 1px;
	box-shadow: 0 0 3px #7FEF7F;
	animation: pd-led-glow 1.5s ease-in-out infinite;
}

@keyframes pd-led-glow {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.5; }
}

/* ── BOTTOM HALF ───────────────────────────────────────────────────────── */
.pd-ds__bottom { }

/* D-pad area — fills the left 84px column */
.pd-ds__dpad-area {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	justify-content: center;
}

/* D-pad cross: connected + shape */
.pd-ds__dpad {
	display: grid;
	grid-template-columns: repeat(3, 24px);
	grid-template-rows:    repeat(3, 24px);
	gap: 0;
}

.pd-ds__dp {
	background: #333;
	border: none;
	cursor: default;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 8px;
	color: transparent;
	padding: 0;
	box-shadow:
		inset  1px  1px 0 rgba(255,255,255,0.1),
		inset -1px -1px 0 rgba(0,0,0,0.4);
}

.pd-ds__dp:hover  { background: #333; }
.pd-ds__dp:active { background: #333; }

/* Connected + shape - no gaps, minimal border-radius */
.pd-ds__dp--up     { grid-column: 2; grid-row: 1; border-radius: 6px 6px 0 0; }
.pd-ds__dp--left   { grid-column: 1; grid-row: 2; border-radius: 6px 0 0 6px; }
.pd-ds__dp--center { grid-column: 2; grid-row: 2; background: #333; border-radius: 2px; pointer-events: none; }
.pd-ds__dp--right  { grid-column: 3; grid-row: 2; border-radius: 0 6px 6px 0; }
.pd-ds__dp--down   { grid-column: 2; grid-row: 3; border-radius: 0 0 6px 6px; }

.pd-ds__dp--up::after    { content: ''; }
.pd-ds__dp--left::after  { content: ''; }
.pd-ds__dp--right::after { content: ''; }
.pd-ds__dp--down::after  { content: ''; }

/* START / SELECT pills below d-pad */
.pd-ds__startselect {
	display: flex;
	flex-direction: column;
	gap: 5px;
	align-items: center;
}

.pd-ds__pill-btn {
	padding: 4px 12px;
	background: var(--ds-body-darker);
	border: 1px solid rgba(0,0,0,0.3);
	border-radius: 10px;
	font-size: 8px;
	font-weight: bold;
	letter-spacing: 0.06em;
	color: rgba(255,255,255,0.75);
	cursor: default;
	box-shadow:
		inset  1px  1px 0 rgba(255,255,255,0.22),
		inset -1px -1px 0 rgba(0,0,0,0.2);
	white-space: nowrap;
}

.pd-ds__pill-btn:hover  { background: var(--ds-body-darker); color: rgba(255,255,255,0.75); }
.pd-ds__pill-btn:active {
	box-shadow:
		inset  1px  1px 0 rgba(255,255,255,0.22),
		inset -1px -1px 0 rgba(0,0,0,0.2);
}

/* ── BOTTOM SCREEN (LCD tool panel) ────────────────────────────────────── */
.pd-ds__screen-wrap--bottom .pd-ds__screen {
	line-height: normal;
	background: #fff;
}

.pd-tool-screen-wrapper {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	width: 100%;
	height: 100%;
	gap: 8px;
	padding: 10px;
}

.pd-tool-screen {
	background: transparent;
	border-radius: 3px;
	padding: 0;
	color: #333;
	font-size: 11px;
	font-family: 'Tahoma', 'Segoe UI', Arial, sans-serif;
	display: flex;
	flex-direction: column;
	gap: 12px;
	justify-content: center;
	align-items: stretch;
	width: 100%;
	flex: 1;
	overflow-x: hidden;
	overflow-y: auto;
}

/* Tool selector buttons */
.pd-tool-screen__tools {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 6px;
}

.pd-tool-btn {
	padding: 8px 6px;
	background: #e8e8e8;
	color: #333;
	border: 1px solid #ccc;
	border-radius: 4px;
	cursor: pointer;
	font-size: 10px;
	text-transform: uppercase;
	font-weight: 500;
	font-family: 'Tahoma', 'Segoe UI', Arial, sans-serif;
	transition: all 150ms ease;
	letter-spacing: 0.3px;
}

.pd-tool-btn:hover {
	background: #ddd;
	border-color: #999;
}

.pd-tool-btn:active {
	background: #ccc;
}

.pd-tool-btn.is-active {
	background: #55B8EA;
	color: #fff;
	border-color: #3A9ACC;
}

.pd-tool-screen__status {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 10px;
	color: #34495E;
	border-bottom: 2px solid #E8EBED;
	padding-bottom: 8px;
	margin-bottom: 4px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.pd-tool-screen__status img {
	image-rendering: pixelated;
	opacity: 0.8;
	flex-shrink: 0;
}

.pd-tool-screen__row {
	display: flex;
	align-items: center;
	gap: 5px;
	flex-wrap: wrap;
}

/* Color pickers */
.pd-color-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	cursor: pointer;
}

.pd-color-wrap span {
	font-size: 9px;
	color: #666;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	font-weight: 500;
}

.pd-color-wrap input[type="color"] {
	width: 40px;
	height: 32px;
	padding: 2px;
	border: 1px solid #ddd;
	border-radius: 4px;
	cursor: pointer;
	background: none;
}

/* Sliders */
.pd-slider-group {
	display: flex;
	flex-direction: column;
	gap: 4px;
	flex: 1;
	min-width: 100px;
}

.pd-slider-group label {
	font-size: 9px;
	color: #666;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	font-weight: 500;
}

.pd-tool-screen input[type="range"] {
	width: 100%;
	cursor: pointer;
	accent-color: #55B8EA;
	height: 6px;
	-webkit-appearance: none;
	appearance: none;
	background: linear-gradient(to right, #ccc 0%, #ccc 100%);
	background-size: 100% 4px;
	background-position: center;
	background-repeat: no-repeat;
	padding: 1px 0;
}

.pd-tool-screen input[type="range"]::-webkit-slider-track {
	background: #999;
	height: 4px;
	border-radius: 2px;
}

.pd-tool-screen input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #55B8EA;
	cursor: pointer;
	border: 2px solid #fff;
	box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pd-tool-screen input[type="range"]::-moz-range-track {
	background: #999;
	height: 4px;
	border-radius: 2px;
	border: none;
}

.pd-tool-screen input[type="range"]::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #55B8EA;
	cursor: pointer;
	border: 2px solid #fff;
	box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Action buttons */
.pd-tool-screen__row--actions {
	gap: 6px;
	justify-content: space-between;
}

.pd-tool-screen__row--actions button {
	flex: 1;
	padding: 6px 8px;
	font-size: 10px;
	font-family: 'Tahoma', 'Segoe UI', Arial, sans-serif;
	background: #e8e8e8;
	color: #333;
	border: 1px solid #ccc;
	border-radius: 4px;
	cursor: pointer;
	text-transform: uppercase;
	font-weight: 500;
}

.pd-tool-screen__row--actions button:hover  { background: #ddd; border-color: #999; }
.pd-tool-screen__row--actions button:active { background: #ccc; }

/* Name + submit form row */
.pd-tool-screen__row--form {
	border-top: 1px solid #ddd;
	padding-top: 8px;
	gap: 8px;
	display: flex;
	flex-direction: column;
	align-items: stretch;
}

.pd-tool-screen__row--form input[type="text"] {
	padding: 10px 12px;
	background: #fff;
	color: #333;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 12px;
	font-family: 'Tahoma', 'Segoe UI', Arial, sans-serif;
}

.pd-tool-screen__row--form input[type="text"]::placeholder { color: #aaa; }
.pd-tool-screen__row--form input[type="text"]:focus {
	outline: none;
	border-color: #55B8EA;
	box-shadow: 0 0 0 2px rgba(85, 184, 234, 0.1);
}

.pd-tool-screen__row--form button#pd-submit {
	padding: 10px 16px;
	font-size: 13px;
	font-family: 'Tahoma', 'Segoe UI', Arial, sans-serif;
	background: #55B8EA;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	text-transform: uppercase;
	font-weight: bold;
	transition: background 150ms;
}

.pd-tool-screen__row--form button#pd-submit:hover  { background: #3A9ACC; }
.pd-tool-screen__row--form button#pd-submit:active { background: #2A7AAA; }

/* Status message */
.peechmart-doodle-submit__message {
	padding: 8px 10px;
	font-size: 11px;
	font-family: 'Tahoma', 'Segoe UI', Arial, sans-serif;
	border-radius: 4px;
	border: 1px solid;
	display: none;
	margin-top: auto;
}

.peechmart-doodle-submit__message:not(:empty) { display: block; }

.peechmart-doodle-submit__message--success {
	background: #e8f5e9;
	color: #2e7d32;
	border-color: #81c784;
}

.peechmart-doodle-submit__message--error {
	background: #ffebee;
	color: #c62828;
	border-color: #ef5350;
}

/* ── ABXY FACE BUTTONS ─────────────────────────────────────────────────── */
.pd-ds__abxy-area {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	justify-content: center;
}

/* 3×3 grid, diamond: X=top, Y=left, A=right, B=bottom */
.pd-ds__abxy {
	display: grid;
	grid-template-columns: repeat(3, 26px);
	grid-template-rows:    repeat(3, 26px);
	gap: 2px;
}

.pd-ds__face-btn {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	border: none;
	cursor: default;
	font-size: 10px;
	font-weight: bold;
	font-family: 'Tahoma', sans-serif;
	color: rgba(255,255,255,0.9);
	text-shadow: 0 1px 2px rgba(0,0,0,0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow:
		0 3px 0 rgba(0,0,0,0.3),
		inset 1px 1px 0 rgba(255,255,255,0.25);
	transition: none;
}

.pd-ds__face-btn:hover  { filter: none; }
.pd-ds__face-btn:active {
	transform: none;
	box-shadow:
		0 3px 0 rgba(0,0,0,0.3),
		inset 1px 1px 0 rgba(255,255,255,0.25);
}

/* Diamond placement */
.pd-ds__face-btn--x { grid-column: 2; grid-row: 1; background: var(--ds-btn-x); }
.pd-ds__face-btn--y { grid-column: 1; grid-row: 2; background: var(--ds-btn-y); }
.pd-ds__face-btn--a { grid-column: 3; grid-row: 2; background: var(--ds-btn-a); }
.pd-ds__face-btn--b { grid-column: 2; grid-row: 3; background: var(--ds-btn-b); }

/* Active tool styling removed — buttons are visual only */

/* ── FULLSCREEN CONTROLS ───────────────────────────────────────────────── */
.pd-fs-controls {
	display: none;
	position: fixed;
	right: 0;
	top: 0;
	width: 360px;
	height: 100vh;
	background: #fff;
	border-left: 1px solid #ddd;
	overflow-y: auto;
	z-index: 10000;
	padding: 0;
	font-family: 'Tahoma', 'Segoe UI', Arial, sans-serif;
}

.peechmart-doodle-submit.is-fullscreen .pd-fs-controls {
	display: block;
}

.pd-fs-controls__inner {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 20px;
	height: 100%;
}

.pd-fs-controls h2 {
	margin: 0;
	padding: 0;
	font-size: 16px;
	color: #333;
	font-weight: bold;
}

.pd-fs-section {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.pd-fs-section label {
	font-size: 11px;
	color: #666;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	font-weight: 500;
}

.pd-fs-section input[type="range"] {
	width: 100%;
	cursor: pointer;
	accent-color: #55B8EA;
	height: 6px;
	-webkit-appearance: none;
	appearance: none;
	background: linear-gradient(to right, #ccc 0%, #ccc 100%);
	background-size: 100% 4px;
	background-position: center;
	background-repeat: no-repeat;
	padding: 1px 0;
}

.pd-fs-section input[type="range"]::-webkit-slider-track {
	background: #999;
	height: 4px;
	border-radius: 2px;
}

.pd-fs-section input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #55B8EA;
	cursor: pointer;
	border: 2px solid #fff;
	box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pd-fs-section input[type="range"]::-moz-range-track {
	background: #999;
	height: 4px;
	border-radius: 2px;
	border: none;
}

.pd-fs-section input[type="range"]::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #55B8EA;
	cursor: pointer;
	border: 2px solid #fff;
	box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pd-fs-section input[type="color"] {
	width: 60px;
	height: 40px;
	border: 1px solid #ddd;
	border-radius: 4px;
	cursor: pointer;
}

/* Tool buttons -->
.pd-fs-tool-buttons {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 6px;
}

.pd-fs-tool-btn {
	padding: 8px;
	font-size: 10px;
	background: #f0f0f0;
	color: #333;
	border: 2px solid #ddd;
	border-radius: 4px;
	cursor: pointer;
	font-weight: 500;
	transition: all 150ms;
}

.pd-fs-tool-btn:hover {
	background: #e0e0e0;
	border-color: #999;
}

.pd-fs-tool-btn.is-active {
	background: #55B8EA;
	color: #fff;
	border-color: #3A9ACC;
}

/* Action buttons */
.pd-fs-button-group {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	gap: 6px;
}

.pd-fs-button-group button {
	padding: 8px;
	font-size: 10px;
	background: #e8e8e8;
	color: #333;
	border: 1px solid #ccc;
	border-radius: 4px;
	cursor: pointer;
	text-transform: uppercase;
	font-weight: 500;
	transition: all 150ms;
}

.pd-fs-button-group button:hover {
	background: #ddd;
	border-color: #999;
}

.pd-fs-button-group button:active {
	background: #ccc;
}

/* Exit fullscreen button */
#pd-fs-exit {
	padding: 8px;
	font-size: 11px;
	background: #f0f0f0;
	color: #333;
	border: 1px solid #ddd;
	border-radius: 4px;
	cursor: pointer;
	font-weight: 500;
	width: 100%;
	transition: all 150ms;
}

#pd-fs-exit:hover {
	background: #e0e0e0;
	border-color: #999;
}

/* Divider -->
.pd-fs-divider {
	border: none;
	border-top: 1px solid #ddd;
	margin: 4px 0;
}

/* Name input and submit -->
.pd-fs-section input[type="text"] {
	padding: 10px;
	background: #fff;
	color: #333;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 12px;
	font-family: 'Tahoma', 'Segoe UI', Arial, sans-serif;
	width: 100%;
}

.pd-fs-section input[type="text"]::placeholder {
	color: #aaa;
}

.pd-fs-section input[type="text"]:focus {
	outline: none;
	border-color: #55B8EA;
	box-shadow: 0 0 0 2px rgba(85, 184, 234, 0.1);
}

#pd-fs-submit {
	padding: 10px;
	font-size: 13px;
	background: #55B8EA;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	text-transform: uppercase;
	font-weight: bold;
	width: 100%;
	transition: background 150ms;
}

#pd-fs-submit:hover {
	background: #3A9ACC;
}

#pd-fs-submit:active {
	background: #2A7AAA;
}

/* ── FULLSCREEN ────────────────────────────────────────────────────────── */
.peechmart-doodle-submit.is-fullscreen {
	position: fixed;
	inset: 0;
	max-width: none;
	margin: 0;
	z-index: 9999;
	background: #f0f0f0;
	border-radius: 0;
	padding: 0;
	display: flex;
	flex-direction: row;
	font-family: 'Tahoma', 'Segoe UI', Arial, sans-serif;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds {
	border-radius: 0;
	background: transparent;
	padding: 0;
	display: flex;
	flex-direction: row;
	flex: 1;
	height: 100%;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds__top {
	flex: 1;
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	overflow: hidden;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds__top-body {
	height: 100%;
	width: 100%;
	grid-template-columns: 1fr;
	gap: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds__speaker {
	display: none;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds__hinge {
	display: none;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds__bottom {
	width: 360px;
	background: #fff;
	padding: 0;
	border-left: 1px solid #ddd;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	justify-content: stretch;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds__bottom-body {
	grid-template-columns: 1fr;
	gap: 0;
	display: flex;
	flex-direction: column;
	padding: 16px;
	overflow-y: auto;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds__dpad-area {
	display: none;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds__abxy-area {
	display: none;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds__screen-wrap--bottom {
	width: 100%;
	height: auto;
	background: transparent;
	padding: 0;
	box-shadow: none;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds__screen-wrap--bottom .pd-ds__screen {
	background: transparent;
	overflow: visible;
	border-radius: 0;
	line-height: normal;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds__screen-wrap--top {
	width: auto;
	height: auto;
	display: flex;
	flex-direction: column;
	border-radius: 0;
}

.peechmart-doodle-submit.is-fullscreen .pd-ds__screen-wrap--top .pd-ds__screen {
	background: #fff;
	border-radius: 0;
	overflow: visible;
	border: 0;
	display: flex;
	justify-content: center;
	align-items: center;
}

/* Canvas border in fullscreen */
.peechmart-doodle-submit.is-fullscreen canvas {
	border: 3px solid #333;
}

/* Canvas in fullscreen - Fabric.js controls via attributes */
.peechmart-doodle-submit.is-fullscreen .pd-ds__screen-wrap--top .pd-ds__screen canvas {
	max-width: 100%;
	max-height: 100%;
}

/* ── FULLSCREEN RESPONSIVE ─────────────────────────────────────── */
/* Tablet: 768px to 1024px - stack vertically */
@media ( max-width: 1024px ) {
	.peechmart-doodle-submit.is-fullscreen {
		flex-direction: column;
	}

	.peechmart-doodle-submit.is-fullscreen .pd-ds {
		flex-direction: column;
		flex: 1;
	}

	.peechmart-doodle-submit.is-fullscreen .pd-ds__top {
		flex: 1;
		min-height: 0;
		padding: 0;
	}

	.peechmart-doodle-submit.is-fullscreen .pd-ds__bottom {
		width: 100%;
		height: auto;
		flex: 0 0 auto;
		border-left: none;
		border-top: 1px solid #ddd;
		max-height: 40vh;
	}

	.peechmart-doodle-submit.is-fullscreen .pd-fs-controls {
		display: none !important;
	}
}

/* Mobile: below 768px - full-height stacked */
@media ( max-width: 768px ) {
	.peechmart-doodle-submit.is-fullscreen .pd-ds__top {
		padding: 0;
		flex: 1;
		min-height: 0;
	}

	.peechmart-doodle-submit.is-fullscreen .pd-ds__bottom {
		flex: 0 0 auto;
		max-height: 35vh;
		width: 100%;
	}

	.peechmart-doodle-submit.is-fullscreen .pd-ds__bottom-body {
		padding: 12px;
	}

	.pd-fs-controls {
		display: none !important;
	}
}

/* ── MOBILE TOOLBAR: Default hidden, styles ────────────────────────────────── */
.pd-mb-toolbar {
	display: none;
	flex-direction: column;
	gap: 6px;
	padding: 8px 12px;
	background: var(--ds-body-darker, #2A7AAA);
}

.pd-mb-tools {
	display: flex;
	gap: 8px;
	justify-content: center;
}

.pd-mb-tool-btn {
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 6px;
	background: rgba(0, 0, 0, 0.2);
	color: white;
	font-size: 18px;
	cursor: pointer;
	transition: background 200ms;
}

.pd-mb-tool-btn:hover {
	background: rgba(0, 0, 0, 0.3);
}

.pd-mb-tool-btn.is-active {
	background: rgba(255, 255, 255, 0.25);
	box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.4);
}

.pd-mb-controls {
	display: flex;
	gap: 8px;
	align-items: center;
}

#pd-mb-size {
	flex: 1;
	height: 32px;
}

#pd-mb-color {
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 4px;
	cursor: pointer;
}

.pd-mb-actions {
	display: flex;
	gap: 8px;
	justify-content: center;
}

#pd-mb-undo,
#pd-mb-redo,
#pd-mb-clear,
#pd-mb-fullscreen {
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 6px;
	background: rgba(0, 0, 0, 0.2);
	color: white;
	cursor: pointer;
	transition: background 200ms;
	font-size: 16px;
}

#pd-mb-undo:hover,
#pd-mb-redo:hover,
#pd-mb-clear:hover,
#pd-mb-fullscreen:hover {
	background: rgba(0, 0, 0, 0.3);
}

#pd-mb-undo:disabled,
#pd-mb-redo:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* Mobile submit row */
.pd-mb-submit-row {
	display: none;
	flex-direction: column;
	gap: 8px;
	padding: 8px 12px;
	background: var(--ds-body-darker, #2A7AAA);
}

#pd-mb-name {
	width: 100%;
	padding: 8px 12px;
	border: none;
	border-radius: 4px;
	min-height: 44px;
	font-size: 14px;
	box-sizing: border-box;
}

#pd-mb-submit {
	width: 100%;
	min-height: 44px;
	padding: 0 16px;
	border: none;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.2);
	color: white;
	cursor: pointer;
	transition: background 200ms;
	font-weight: bold;
	font-size: 16px;
	box-sizing: border-box;
}

#pd-mb-submit:hover {
	background: rgba(0, 0, 0, 0.3);
}

#pd-mb-message {
	font-size: 13px;
	padding: 6px 8px;
	text-align: center;
	min-height: 20px;
	border-radius: 4px;
	display: none;
}

#pd-mb-message:not(:empty) {
	display: block;
}

#pd-mb-message.peechmart-doodle-submit__message--success {
	background: #4caf50;
	color: white;
}

#pd-mb-message.peechmart-doodle-submit__message--error {
	background: #f44336;
	color: white;
}

/* ── TOUCH TARGET IMPROVEMENTS (all mobile) ────────────────────────────────── */
@media ( max-width: 767px ) {
	.pd-tool-screen .pd-tool-btn,
	.pd-tool-screen button {
		min-height: 44px;
		min-width: 44px;
	}

	#pd-size,
	#pd-opacity {
		height: 32px;
	}

	input[type="range"]::-webkit-slider-thumb {
		width: 28px;
		height: 28px;
	}

	input[type="range"]::-moz-range-thumb {
		width: 28px;
		height: 28px;
	}

	#pd-color,
	#pd-bg-color {
		width: 44px;
		height: 44px;
	}

	/* Show mobile prompt, hide toolbar on mobile */
	.peechmart-doodle-submit:not(.is-fullscreen) .pd-mobile-prompt {
		display: flex;
	}

	.peechmart-doodle-submit:not(.is-fullscreen) .pd-tool-screen-wrapper {
		display: none;
	}
}

/* ── MOBILE: Simplified layout for small screens (< 480px) ───────────────────── */
@media ( max-width: 480px ) {
	/* Remove DS body padding to prevent overflow */
	.pd-ds {
		padding: 8px 4px 12px;
	}

	/* Show mobile toolbar and submit row (but not in fullscreen) */
	.peechmart-doodle-submit:not(.is-fullscreen) .pd-mb-toolbar {
		display: flex;
		padding: 4px 8px;
	}

	.peechmart-doodle-submit:not(.is-fullscreen) .pd-mb-submit-row {
		display: flex;
		padding: 4px 8px;
	}

	/* Hide mobile toolbar and submit row in fullscreen */
	.peechmart-doodle-submit.is-fullscreen .pd-mb-toolbar,
	.peechmart-doodle-submit.is-fullscreen .pd-mb-submit-row {
		display: none !important;
	}

	/* Account for screen-wrap padding in width calculation */
	.pd-ds__screen-wrap {
		width: calc(100% - 10px);
	}

	/* Reduce screen padding to prevent overflow */
	.pd-ds__screen-wrap--bottom .pd-ds__screen {
		padding: 8px;
	}

	/* Hide decorative DS chrome */
	.pd-ds__speaker,
	.pd-ds__hinge,
	.pd-ds__dpad-area,
	.pd-ds__abxy-area,
	.pd-ds__startselect {
		display: none !important;
	}

	/* Collapse grid to single column */
	.pd-ds__top-body,
	.pd-ds__bottom-body {
		grid-template-columns: 1fr;
	}

	/* Hide bottom half entirely (tools moved to mobile toolbar) */
	.pd-ds__bottom {
		display: none;
	}

	/* Hide regular mobile prompt (toolbar replaces it) */
	.peechmart-doodle-submit:not(.is-fullscreen) .pd-mobile-prompt {
		display: none !important;
	}
}
