:root {
  --ink: #f8f4ff;
  --muted: #d8cbed;
  --panel: rgba(35, 18, 66, 0.92);
  --panel-2: rgba(63, 35, 99, 0.92);
  --purple: #6d3ac6;
  --magenta: #aa2b82;
  --teal: #158f90;
  --cream: #f0dfbd;
  --shadow: 0 22px 60px rgba(8, 3, 20, 0.36);
  --radius: 26px;
  --focus: #ffdc6b;
}

* { box-sizing: border-box; }
html {
  height: auto;
  min-height: 0;
  overflow: visible;
  scroll-behavior: smooth;
}
body {
  position: relative;
  margin: 0;
  padding: 0;
  height: auto;
  min-height: 0;
  overflow: visible;
  font-family: Montserrat, Arial, sans-serif;
  color: var(--ink);
  background-color: #f4f0f7;
  background-image: url("https://dcciportal.co.uk/wp-content/uploads/2026/02/Picture1.png");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: scroll;
}

body::before {
  content: none;
}


/* Ensure HTML hidden state always wins over component display rules. */
[hidden] { display: none !important; }

button, select, textarea { font: inherit; }
button, select { min-height: 44px; }
button:focus-visible, select:focus-visible, textarea:focus-visible, canvas:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 1000;
  padding: 12px 16px;
  background: #fff;
  color: #111;
  border-radius: 10px;
}
.skip-link:focus { top: 12px; }

.app-shell {
  position: relative;
  z-index: 0;
  width: min(1800px, calc(100% - 20px));
  margin: 0 auto;
  padding: 20px 0 80px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr minmax(260px, 420px);
  gap: 28px;
  align-items: center;
  padding: clamp(24px, 4vw, 52px);
  border: 2px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(79, 43, 125, .96), rgba(36, 19, 68, .96));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero::before,
.control-panel::before,
.puzzle-stage::before,
.completion-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, #8E44AD 0%, #E91E63 30%, #3F51B5 62%, #27AE60 100%);
}


.interactive-tools-logo {
  display: block;
  width: clamp(72px, 7vw, 108px);
  height: auto;
  margin: 0 0 10px;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.28));
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(2.3rem, 5vw, 5rem);
  line-height: .98;
  letter-spacing: 0;
  text-shadow: 0 4px 0 rgba(0,0,0,.18);
}
.eyebrow {
  margin: 0 0 12px;
  color: #f0b6e0;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: .82rem;
}
.intro {
  margin: 0;
  max-width: 820px;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  line-height: 1.65;
}
.hero-badge {
  padding: 12px;
  border-radius: 24px;
  background: linear-gradient(145deg, #7d50bf, #2c174e);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.14), 0 18px 35px rgba(0,0,0,.3);
  transform: rotate(1.3deg);
}
.hero-badge img { display: block; width: 100%; border-radius: 16px; }

.control-panel {
  position: relative;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: end;
  margin-top: 18px;
  padding: 18px;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.1);
  overflow: hidden;
}
.control-group { display: grid; gap: 7px; min-width: 260px; }
.control-group label { font-weight: 800; color: #eadff7; }
select, textarea {
  color: var(--ink);
  background: #26143f;
  border: 2px solid rgba(255,255,255,.18);
  border-radius: 12px;
  padding: 12px 14px;
}
.control-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
button {
  border: 0;
  border-radius: 13px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}
button:hover { transform: translateY(-2px); filter: brightness(1.08); }
button:active { transform: translateY(0); }
.primary-btn {
  color: white;
  background: linear-gradient(135deg, var(--purple), var(--magenta));
  box-shadow: 0 8px 20px rgba(109,58,198,.28);
}
.secondary-btn, .icon-btn {
  color: white;
  background: rgba(255,255,255,.10);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.icon-btn { width: 48px; padding: 10px; font-size: 1.3rem; }

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, auto)) 1fr;
  gap: 14px;
  align-items: center;
  margin: 14px 0;
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(20, 10, 40, .82);
  border: 1px solid rgba(255,255,255,.1);
}
.status-strip > div:not(.progress-wrap) { display: grid; gap: 2px; }
.status-label { color: #cbb9df; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.status-strip strong { font-size: 1.25rem; }
.progress-track { height: 14px; background: #160b2d; border-radius: 999px; overflow: hidden; box-shadow: inset 0 2px 6px rgba(0,0,0,.4); }
.progress-bar { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #81d1c6, var(--magenta)); transition: width .3s ease; }

.puzzle-stage {
  position: relative;
  padding: clamp(12px, 2vw, 20px);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(63,35,99,.96), rgba(26,14,49,.98));
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.12);
  overflow: hidden;
}
.puzzle-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 8.5;
  min-height: 680px;
  border-radius: 20px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px),
    #170c2b;
  background-size: 36px 36px;
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.06), inset 0 0 50px rgba(0,0,0,.42);
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
canvas.is-dragging { cursor: grabbing; }
.preview-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 4%;
  background: rgba(10,5,20,.78);
  backdrop-filter: blur(6px);
}
.preview-overlay img { max-width: 92%; max-height: 92%; border-radius: 16px; box-shadow: 0 18px 45px rgba(0,0,0,.55); }
.loading-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(22,11,45,.94);
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
}
.help-text { margin: 12px 4px 0; color: #cdbfe0; font-size: .92rem; }

.completion-panel {
  position: relative;
  margin-top: 18px;
  padding: clamp(26px, 5vw, 54px);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(74,42,114,.98), rgba(32,18,58,.98));
  box-shadow: var(--shadow);
  border: 2px solid rgba(255,255,255,.12);
  overflow: hidden;
}
.completion-panel h2 { margin: 0 0 10px; font-size: clamp(2rem, 4vw, 3.4rem); }
.celebration-mark { font-size: 3rem; animation: bob 1.4s ease-in-out infinite; }
.completion-summary { color: #eadff7; font-size: 1.1rem; }
.reflection-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 24px 0;
}
.reflection-grid article {
  padding: 20px;
  border-radius: 18px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
}
.reflection-grid h3 { margin: 0 0 8px; color: #f4c1e5; }
.reflection-grid p { margin: 0; color: #ded3eb; line-height: 1.55; }
.completion-panel label { display: block; margin-bottom: 8px; font-weight: 800; }
textarea { width: 100%; resize: vertical; line-height: 1.55; }
.completion-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.copy-status { min-height: 1.4em; color: #a8e4d8; font-weight: 700; }

.accessibility-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #7344c9, #b32e87);
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
  font-size: 1.25rem;
}
.accessibility-panel {
  position: fixed;
  right: 18px;
  bottom: 82px;
  z-index: 29;
  width: min(320px, calc(100vw - 36px));
  padding: 20px;
  border-radius: 18px;
  background: #1f1139;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.15);
}
.accessibility-panel h2 { margin-top: 0; }
.accessibility-panel button { width: 100%; margin-top: 8px; color: white; background: rgba(255,255,255,.1); }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translate(-50%, 160%);
  padding: 12px 18px;
  border-radius: 999px;
  background: #0f261f;
  color: white;
  box-shadow: var(--shadow);
  transition: transform .25s ease;
}
.toast.show { transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.high-contrast {
  --ink: #fff;
  --muted: #fff;
  --panel: #000;
  --panel-2: #111;
  background: #000;
}
.high-contrast::before { display: none; }
.high-contrast .hero,
.high-contrast .puzzle-stage,
.high-contrast .completion-panel { background: #000; border-color: #fff; }
.large-text { font-size: 118%; }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }

@keyframes bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .hero-badge { max-width: 520px; }
  .control-panel { align-items: stretch; flex-direction: column; }
  .control-actions { justify-content: flex-start; }
  .status-strip { grid-template-columns: repeat(3, 1fr); }
  .progress-wrap { grid-column: 1 / -1; }
  .reflection-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .app-shell { width: min(100% - 12px, 1800px); padding-top: 6px; }
  .hero { border-radius: 18px; padding: 22px 18px; }
  .interactive-tools-logo { width: 78px; margin-bottom: 8px; }
  .control-actions > button:not(.icon-btn) { flex: 1 1 45%; }
  .control-group { min-width: 0; }
  .status-strip { gap: 8px; padding: 12px; }
  .status-strip strong { font-size: 1rem; }
  .help-text { font-size: .82rem; }
}

@media (max-width: 1100px) {
  .puzzle-frame { min-height: 690px; aspect-ratio: auto; }
}

@media (max-width: 760px) {
  .puzzle-frame { min-height: 860px; aspect-ratio: auto; }
}

/* Keep the canvas and tray visible inside WordPress/iframe wrappers. */
.puzzle-frame, #puzzleCanvas { max-width: 100%; }


.milo-finder-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 4, 18, .86);
  backdrop-filter: blur(8px);
}
.milo-finder-card {
  width: min(1320px, 96vw);
  max-height: 96vh;
  overflow: auto;
  padding: clamp(20px, 3vw, 34px);
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(63,35,99,.99), rgba(24,13,44,.99));
  border: 2px solid rgba(255,255,255,.16);
  box-shadow: 0 30px 90px rgba(0,0,0,.58);
}
.milo-finder-card h2 { margin: 0 0 8px; font-size: clamp(2rem, 4vw, 3.6rem); }
.milo-finder-card > p { color: #e6daef; }
.milo-finder-viewport {
  width: 100%;
  max-height: 68vh;
  overflow: auto;
  border-radius: 18px;
  background: #100820;
  border: 2px solid rgba(255,255,255,.15);
  overscroll-behavior: contain;
}
.milo-finder-image-wrap {
  position: relative;
  width: 100%;
  transform-origin: top left;
  touch-action: none;
  user-select: none;
}
.milo-finder-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  -webkit-user-drag: none;
}
.milo-selection-circle,
.milo-reveal-circle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.milo-selection-circle {
  border: 5px solid #fff;
  background: rgba(122, 69, 202, .22);
  box-shadow: 0 0 0 4px rgba(170,43,130,.85), 0 8px 22px rgba(0,0,0,.42);
}
.milo-reveal-circle {
  border: 7px solid #ffdc6b;
  box-shadow: 0 0 0 6px rgba(255,255,255,.9), 0 0 32px 14px rgba(255,220,107,.72);
  animation: miloPulse 1s ease-in-out infinite;
}
.milo-finder-feedback { min-height: 1.5em; margin: 12px 0 0; font-weight: 800; color: #ffe487 !important; }
.milo-finder-feedback.success { color: #a8e4d8 !important; }
.milo-finder-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.milo-finder-actions button:disabled { opacity: .48; cursor: not-allowed; transform: none; }
@keyframes miloPulse { 0%,100% { scale: .94; } 50% { scale: 1.08; } }
@media (max-width: 760px) {
  .milo-finder-modal { padding: 6px; }
  .milo-finder-card { width: 100%; max-height: 99vh; border-radius: 18px; padding: 16px; }
  .milo-finder-viewport { max-height: 62vh; }
  .milo-finder-actions button { flex: 1 1 42%; }
}

/* v4 portal-safe layout and compact brand treatment */
.brand-row {
  display: flex;
  align-items: center;
  min-height: 58px;
  margin: 0 0 18px;
}
.interactive-tools-logo {
  width: 132px !important;
  max-width: 132px !important;
  height: 58px !important;
  max-height: 58px !important;
  object-fit: contain !important;
  object-position: left center;
  margin: 0 !important;
  border-radius: 10px;
}
.hero {
  grid-template-columns: minmax(0, 1fr) minmax(210px, 330px);
  padding: clamp(22px, 3vw, 38px);
}
.hero h1 { font-size: clamp(2rem, 4.4vw, 4.3rem); }
.puzzle-frame {
  min-height: 760px !important;
  height: min(78vh, 920px) !important;
  aspect-ratio: auto !important;
}
@media (max-width: 1180px) {
  .app-shell { width: min(1500px, calc(100% - 16px)); }
  .puzzle-frame { min-height: 720px !important; height: 78vh !important; }
}
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .hero-badge { display: none; }
  .interactive-tools-logo { width: 110px !important; max-width: 110px !important; height: 48px !important; }
  .puzzle-frame { min-height: 900px !important; height: 1050px !important; }
}
