:root {
  --wood: #b9772e;
  --wood-dark: #75461f;
  --wood-light: #e2a954;
  --leaf: #4f8f2f;
  --leaf-dark: #2f6725;
  --grass: #77ac39;
  --sand: #f2d589;
  --purple: #6c4397;
  --blue: #3a82aa;
  --ink: #3d3529;
  --paper: #fff6d7;
  --shadow: 0 12px 30px rgba(42, 46, 29, .28);
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
}

body {
  background: #315d2d;
  color: var(--ink);
  font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  min-height: 100dvh;
}

.screen {
  display: none;
  min-height: 100dvh;
}

.screen.active { display: block; }

.start-screen,
.result-screen {
  background:
    linear-gradient(rgba(20,53,23,.08), rgba(20,53,23,.18)),
    url("assets/parky-labyrint-achtergrond.jpg") center / cover no-repeat;
}

.start-overlay,
.result-overlay {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: max(20px, env(safe-area-inset-top)) 18px max(26px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(255,255,255,.05), rgba(37,70,34,.2));
}

.title-board,
.small-title-board,
.instruction-board,
.topper-board {
  border: 4px solid #d59743;
  background:
    linear-gradient(rgba(255,245,195,.96), rgba(235,194,111,.96));
  box-shadow:
    inset 0 0 0 3px rgba(255,255,255,.36),
    0 7px 0 var(--wood-dark),
    var(--shadow);
}

.title-board {
  width: min(760px, 94vw);
  padding: 16px 24px;
  border-radius: 30px;
  text-align: center;
  transform: rotate(-.4deg);
}

.whoi-label {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--purple);
  color: white;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .12em;
}

.title-board h1 {
  margin: 7px 0 0;
  color: var(--leaf);
  font-size: clamp(2.7rem, 8vw, 5.6rem);
  line-height: .95;
  text-shadow: 0 3px 0 white, 0 7px 0 rgba(69,71,37,.13);
}

.title-board h1 span { color: var(--purple); }

.title-board p {
  margin: 12px 0 0;
  font-size: clamp(1rem, 3vw, 1.4rem);
  font-weight: 850;
}

.start-card,
.result-card {
  width: min(650px, 92vw);
  margin-top: 30px;
  padding: clamp(20px, 4vw, 34px);
  border: 5px solid rgba(118,76,31,.92);
  border-radius: 28px;
  background: rgba(255,247,214,.96);
  box-shadow:
    inset 0 0 0 4px rgba(255,255,255,.42),
    var(--shadow);
  text-align: center;
}

.start-card h2 {
  margin: 0 0 18px;
  color: var(--wood-dark);
}

.mission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
}

.mission-card {
  position: relative;
  display: grid;
  min-height: 145px;
  place-content: center;
  padding: 18px;
  border: 4px solid #c99b50;
  border-radius: 22px;
  background: #fff8dc;
  box-shadow: 0 5px 0 #9b692c;
  transition: transform .15s ease;
}

.mission-card:has(input:checked) {
  border-color: var(--leaf);
  background: #eef7cc;
  transform: translateY(-4px);
}

.mission-card input {
  position: absolute;
  opacity: 0;
}

.mission-icon {
  margin-bottom: 7px;
  font-size: 2.8rem;
}

.mission-card strong,
.mission-card small { display: block; }

.mission-card small {
  margin-top: 5px;
  color: #6e6556;
  line-height: 1.3;
}

.big-button {
  width: 100%;
  min-height: 62px;
  margin-top: 22px;
  border: 4px solid #e4bd63;
  border-radius: 20px;
  background: linear-gradient(#8ac64d, #4d8c2f);
  color: white;
  box-shadow: 0 7px 0 #315f24;
  font-size: 1.2rem;
  font-weight: 900;
}

.big-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #315f24;
}

.game-screen {
  position: relative;
  overflow-x: hidden;
  padding: max(14px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom));
  background: #80b845;
}

.game-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(rgba(44,83,37,.14), rgba(44,83,37,.28)),
    url("assets/parky-labyrint-achtergrond.jpg") center / cover no-repeat;
  filter: saturate(.95);
}

.topbar,
.game-layout {
  position: relative;
  z-index: 1;
}

.topbar {
  max-width: 1480px;
  margin: 0 auto 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
}

.wood-button {
  min-height: 56px;
  border: 4px solid #d69b48;
  border-radius: 18px;
  background: linear-gradient(#7b52a5, #5d3589);
  color: white;
  box-shadow: 0 5px 0 #4c2b71;
  font-weight: 900;
}

.menu-button { padding: 8px 18px; }
.sound-button { width: 62px; font-size: 1.5rem; }

.small-title-board {
  justify-self: center;
  width: min(610px, 100%);
  padding: 8px 18px;
  border-radius: 22px;
  text-align: center;
}

.small-title-board h1 {
  margin: 0;
  color: var(--purple);
  font-size: clamp(1.6rem, 4vw, 2.9rem);
  line-height: 1;
}

.small-title-board p {
  margin: 5px 0 0;
  font-weight: 800;
}

.game-layout {
  max-width: 1480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 235px minmax(0, 1fr) 220px;
  align-items: start;
  gap: 14px;
}

.wood-panel {
  border: 5px solid var(--wood-dark);
  border-radius: 22px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.1), transparent 25%, rgba(80,37,10,.1)),
    #ba7932;
  box-shadow:
    inset 0 0 0 4px rgba(238,177,86,.62),
    var(--shadow);
}

.left-panel {
  padding: 14px;
}

.left-panel h2 {
  margin: 0 0 12px;
  padding: 9px;
  border-radius: 12px;
  background: #eec982;
  text-align: center;
  font-size: 1rem;
  text-transform: uppercase;
}

.second-heading { margin-top: 18px !important; }

.level-list,
.playmode-list {
  display: grid;
  gap: 10px;
}

.level-option,
.playmode-option {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 70px;
  padding: 10px;
  border: 4px solid rgba(95,58,25,.42);
  border-radius: 18px;
  color: white;
  text-align: left;
  box-shadow: 0 5px 0 rgba(91,48,17,.45);
  opacity: .82;
}

.level-option.active,
.playmode-option.active {
  outline: 4px solid #ffe28b;
  outline-offset: 1px;
  opacity: 1;
  transform: translateY(-2px);
}

.level-option.easy { background: linear-gradient(#78ad3c, #4f8229); }
.level-option.medium { background: linear-gradient(#63bfd0, #3c8fa6); }
.level-option.hard { background: linear-gradient(#8861ac, #643f89); }

.playmode-option:first-child { background: linear-gradient(#4e99c5, #33779e); }
.playmode-option:last-child { background: linear-gradient(#e4bf62, #b9872f); color: #4d3a1d; }

.level-symbol,
.playmode-option > span:first-child {
  font-size: 1.8rem;
}

.level-option strong,
.level-option small,
.playmode-option strong,
.playmode-option small {
  display: block;
}

.level-option small {
  margin-top: 4px;
  color: #ffe37e;
  letter-spacing: .1em;
}

.playmode-option small {
  margin-top: 3px;
  color: rgba(255,255,255,.9);
}

.maze-section {
  min-width: 0;
}

.maze-board {
  position: relative;
  padding: 12px;
  border: 7px solid #56752f;
  border-radius: 24px;
  background: #6e9c39;
  box-shadow:
    inset 0 0 0 5px rgba(189,224,107,.45),
    var(--shadow);
}

#mazeCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 5px solid #315d25;
  border-radius: 16px;
  background: var(--sand);
  touch-action: none;
}

.start-label,
.goal-label {
  position: absolute;
  z-index: 2;
  display: grid;
  width: 46px;
  height: 46px;
  border: 4px solid var(--wood-dark);
  border-radius: 8px;
  background: #b97831;
  color: white;
  box-shadow: 0 4px 0 #6e3f1d;
  place-items: center;
  font-size: 1.45rem;
  font-weight: 900;
}

.start-label { left: 18px; top: 18px; }
.goal-label { right: 18px; bottom: 18px; }

.countdown {
  position: absolute;
  inset: 12px;
  display: grid;
  border-radius: 16px;
  background: rgba(45,72,30,.72);
  color: white;
  place-items: center;
  font-size: clamp(5rem, 18vw, 10rem);
  font-weight: 900;
}

.instruction-board {
  width: fit-content;
  max-width: 92%;
  margin: 12px auto 10px;
  padding: 9px 18px;
  border-radius: 15px;
  text-align: center;
  font-weight: 900;
}

.arrow-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(68px, 110px));
  justify-content: center;
  gap: 10px;
}

.arrow-controls button {
  min-height: 82px;
  border: 5px solid #e4ad43;
  border-radius: 24px;
  background: linear-gradient(#ffdc74, #e4ad43);
  color: #8a591d;
  box-shadow:
    inset 0 0 0 4px rgba(255,255,255,.32),
    0 7px 0 #a76c20;
  font-size: 2.4rem;
  font-weight: 900;
}

.arrow-controls button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #a76c20;
}

.right-panel {
  display: grid;
  gap: 14px;
}

.helper-card,
.friend-card {
  border: 4px solid rgba(85,92,43,.5);
  border-radius: 22px;
  background: rgba(255,249,218,.94);
  box-shadow: var(--shadow);
}

.helper-card {
  padding: 14px;
  text-align: center;
}

.helper-icon { font-size: 4.4rem; }

.speech-bubble {
  position: relative;
  padding: 12px;
  border: 3px solid #b7a16a;
  border-radius: 16px;
  background: white;
}

.speech-bubble strong,
.speech-bubble span { display: block; }

.speech-bubble span {
  margin-top: 4px;
  font-size: .92rem;
}

.hint-button {
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  border: 4px solid #8d5aa9;
  border-radius: 16px;
  background: linear-gradient(#8d5aa9, #693a8e);
  color: white;
  box-shadow: 0 5px 0 #4d296c;
  font-weight: 900;
}

.stats-card {
  padding: 12px;
}

.stat {
  padding: 10px;
  border-radius: 14px;
  background: rgba(245,213,137,.9);
  text-align: center;
}

.stat + .stat { margin-top: 10px; }

.stat span,
.stat strong { display: block; }

.stat strong {
  margin-top: 4px;
  font-size: 1.8rem;
}

.friend-card { padding: 12px; }

.friend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.friend-row + .friend-row { margin-top: 8px; }

.result-card {
  margin-top: 0;
}

.result-icon { font-size: clamp(4rem, 14vw, 7rem); }

.result-small {
  margin: 5px 0;
  color: var(--leaf-dark);
  font-weight: 900;
  letter-spacing: .12em;
}

.result-card h2 {
  margin: 8px 0;
  color: var(--purple);
  font-size: clamp(2rem, 7vw, 3.7rem);
}

.result-card > p { font-size: 1.1rem; }

.topper-board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 20px 0;
  padding: 12px;
  border-radius: 18px;
  color: var(--purple);
  font-size: 1.3rem;
}

.topper-board span { font-size: 2rem; }

.result-stats {
  display: grid;
  grid-template-columns: repeat(2,1fr);
  gap: 12px;
}

.result-stats div {
  padding: 14px;
  border: 3px solid #c9a35c;
  border-radius: 16px;
  background: #fff4c7;
}

.result-stats span,
.result-stats strong { display: block; }

.result-stats strong {
  margin-top: 4px;
  font-size: 1.6rem;
}

.link-button {
  margin-top: 16px;
  border: 0;
  background: transparent;
  color: var(--purple);
  font-weight: 900;
  text-decoration: underline;
}

#mazeCanvas.blocked { animation: blocked .18s ease; }
@keyframes blocked { 50% { filter: brightness(.72); } }

button:focus-visible,
label:focus-within {
  outline: 5px solid white;
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .game-layout {
    grid-template-columns: 210px minmax(0,1fr);
  }

  .right-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3,1fr);
  }

  .helper-card {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
  }

  .helper-icon { font-size: 3rem; }
  .hint-button { grid-column: 1 / -1; margin-top: 0; }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 56px 1fr 56px;
    gap: 7px;
  }

  .menu-button {
    width: 56px;
    padding: 0;
    font-size: 0;
  }

  .menu-button::after {
    content: "⌂";
    font-size: 1.6rem;
  }

  .small-title-board p { display: none; }
  .small-title-board h1 { font-size: 1.35rem; }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .left-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .left-panel h2 {
    grid-column: 1 / -1;
    margin: 0 !important;
  }

  .level-list,
  .playmode-list {
    grid-template-columns: 1fr;
  }

  .right-panel {
    grid-column: auto;
    grid-template-columns: 1fr 1fr;
  }

  .friend-card { display: none; }

  .helper-card {
    display: block;
  }

  .helper-icon { display: none; }

  .arrow-controls {
    grid-template-columns: repeat(4, minmax(58px, 1fr));
    gap: 7px;
  }

  .arrow-controls button {
    min-height: 64px;
    border-radius: 18px;
    font-size: 1.8rem;
  }

  .mission-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .game-screen { padding-inline: 8px; }

  .left-panel {
    grid-template-columns: 1fr;
  }

  .level-list {
    grid-template-columns: repeat(3,1fr);
    gap: 5px;
  }

  .level-option {
    grid-template-columns: 1fr;
    min-height: 80px;
    padding: 6px;
    text-align: center;
  }

  .level-option small { font-size: .7rem; }
  .level-symbol { font-size: 1.3rem; }

  .playmode-list {
    grid-template-columns: repeat(2,1fr);
  }

  .playmode-option {
    grid-template-columns: 1fr;
    min-height: 78px;
    padding: 6px;
    text-align: center;
  }

  .right-panel { grid-template-columns: 1fr; }
  .stats-card {
    display: grid;
    grid-template-columns: repeat(2,1fr);
    gap: 8px;
  }

  .stat + .stat { margin-top: 0; }
}


/* V4: echte actieve standen, meer diepte en een betrouwbaar verborgen startscherm */
[hidden] {
  display: none !important;
}

.level-option,
.playmode-option {
  position: relative;
  grid-template-columns: 18px auto 1fr;
  overflow: hidden;
  isolation: isolate;
  transform: translateY(0);
  transition:
    transform .16s ease,
    filter .16s ease,
    box-shadow .16s ease,
    opacity .16s ease;
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,.28),
    inset 0 -4px 0 rgba(48,31,14,.22),
    0 7px 0 rgba(75,44,18,.72),
    0 11px 18px rgba(49,37,20,.23);
}

.level-option::after,
.playmode-option::after {
  content: "";
  position: absolute;
  inset: 3px 8px auto;
  height: 32%;
  z-index: -1;
  border-radius: 14px 14px 50% 50%;
  background: linear-gradient(rgba(255,255,255,.28), rgba(255,255,255,0));
  pointer-events: none;
}

.level-option:hover,
.playmode-option:hover {
  filter: brightness(1.07);
  transform: translateY(-2px);
}

.level-option:active,
.playmode-option:active {
  transform: translateY(5px);
  box-shadow:
    inset 0 3px 8px rgba(46,29,11,.24),
    0 2px 0 rgba(75,44,18,.78);
}

.level-option.active,
.playmode-option.active {
  outline: 3px solid #fff2a8;
  outline-offset: 2px;
  filter: saturate(1.13) brightness(1.06);
  transform: translateY(-3px);
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,.42),
    inset 0 -4px 0 rgba(48,31,14,.18),
    0 8px 0 rgba(75,44,18,.76),
    0 0 0 5px rgba(255,224,104,.24),
    0 0 22px rgba(255,223,94,.5);
}

.indicator-light {
  width: 14px;
  height: 14px;
  align-self: start;
  margin-top: 7px;
  border: 2px solid rgba(57,46,29,.74);
  border-radius: 50%;
  background: #635d4d;
  box-shadow:
    inset 0 2px 3px rgba(0,0,0,.46),
    0 1px 0 rgba(255,255,255,.25);
}

.active .indicator-light {
  border-color: #fff4aa;
  background: #fff26e;
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,.8),
    0 0 5px #fff,
    0 0 13px #ffe55b,
    0 0 24px rgba(255,224,67,.85);
  animation: lampGlow 1.2s ease-in-out infinite alternate;
}

@keyframes lampGlow {
  to {
    filter: brightness(1.18);
    transform: scale(1.08);
  }
}

.left-panel {
  background:
    linear-gradient(90deg, rgba(255,255,255,.12), transparent 24%, rgba(70,35,10,.14)),
    repeating-linear-gradient(0deg, rgba(83,43,13,.13) 0 2px, transparent 2px 19px),
    #ba7932;
}

.left-panel h2 {
  border: 3px solid #8a571f;
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,.38),
    0 4px 0 #75461f;
  text-shadow: 0 1px 0 rgba(255,255,255,.45);
}

.maze-board {
  box-shadow:
    inset 0 0 0 5px rgba(189,224,107,.45),
    inset 0 -12px 22px rgba(38,87,31,.22),
    0 10px 0 #315d25,
    0 20px 34px rgba(34,54,25,.32);
}

#mazeCanvas {
  box-shadow:
    inset 0 5px 15px rgba(122,82,26,.18),
    inset 0 -5px 12px rgba(255,255,255,.28);
}

.countdown {
  z-index: 20;
  animation: countdownPop .28s ease both;
}

@keyframes countdownPop {
  from { opacity: 0; transform: scale(.92); }
  to { opacity: 1; transform: scale(1); }
}

.arrow-controls button {
  position: relative;
  overflow: hidden;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
  text-shadow: 0 2px 0 rgba(255,255,255,.4);
  box-shadow:
    inset 0 5px 0 rgba(255,255,255,.4),
    inset 0 -7px 0 rgba(151,94,22,.2),
    0 8px 0 #9b641f,
    0 13px 18px rgba(70,44,17,.26);
}

.arrow-controls button::before {
  content: "";
  position: absolute;
  inset: 6px 10px auto;
  height: 30%;
  border-radius: 999px;
  background: rgba(255,255,255,.28);
}

.arrow-controls button:hover {
  filter: brightness(1.07);
  transform: translateY(-2px);
}

.arrow-controls button:active,
.arrow-controls button.pressed {
  transform: translateY(6px) scale(.98);
  box-shadow:
    inset 0 5px 9px rgba(117,72,16,.26),
    0 2px 0 #9b641f;
}

.hint-button,
.wood-button,
.big-button {
  position: relative;
  overflow: hidden;
  transition: transform .14s ease, filter .14s ease, box-shadow .14s ease;
}

.hint-button::before,
.wood-button::before,
.big-button::before {
  content: "";
  position: absolute;
  inset: 4px 10px auto;
  height: 32%;
  border-radius: 999px;
  background: rgba(255,255,255,.23);
  pointer-events: none;
}

.hint-button:hover,
.wood-button:hover,
.big-button:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.hint-button:active,
.wood-button:active,
.big-button:active {
  transform: translateY(4px);
}

.active-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-bottom: 10px;
  padding: 9px;
  border: 3px solid #74481e;
  border-radius: 14px;
  background: #f0d38b;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.42),
    0 4px 0 #75461f;
  text-align: center;
  font-size: .85rem;
}

.status-lamp {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid #536333;
  border-radius: 50%;
  background: #baff6c;
  box-shadow:
    inset 0 1px 2px white,
    0 0 7px #d9ff8d,
    0 0 15px rgba(157,255,79,.75);
  animation: lampGlow 1.2s ease-in-out infinite alternate;
}

.maze-friend {
  position: absolute;
  z-index: 4;
  filter: drop-shadow(0 4px 3px rgba(55,64,26,.3));
  pointer-events: none;
}

.friend-vivi {
  top: -7px;
  right: 16%;
  font-size: 2rem;
  animation: floatFriend 3.1s ease-in-out infinite;
}

.friend-bella {
  top: 25%;
  right: -7px;
  font-size: 2rem;
  animation: floatFriend 2.7s ease-in-out infinite .4s;
}

.friend-drop {
  left: -7px;
  bottom: 22%;
  font-size: 2rem;
  animation: floatFriend 3.4s ease-in-out infinite .8s;
}

@keyframes floatFriend {
  50% { transform: translateY(-8px) rotate(4deg); }
}

.helper-icon {
  filter: drop-shadow(0 6px 4px rgba(77,60,18,.28));
  animation: helperHover 2.2s ease-in-out infinite;
}

@keyframes helperHover {
  50% { transform: translateY(-7px) rotate(-3deg); }
}

.stat {
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,.38),
    inset 0 -4px 0 rgba(117,79,27,.12),
    0 4px 0 #75461f;
}

.sound-button[aria-pressed="true"] {
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,.3),
    0 5px 0 #4c2b71,
    0 0 18px rgba(210,178,255,.7);
}

@media (max-width: 760px) {
  .level-option,
  .playmode-option {
    grid-template-columns: 14px auto 1fr;
  }
}

@media (max-width: 520px) {
  .level-option,
  .playmode-option {
    grid-template-columns: 1fr;
  }

  .indicator-light {
    position: absolute;
    top: 6px;
    right: 8px;
    margin: 0;
  }

  .maze-friend {
    font-size: 1.5rem;
  }
}


/* V5 — telefoon en iPad: Parky direct met de vinger door het doolhof begeleiden */
.touch-instruction {
  display: none;
}

.touch-status {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: fit-content;
  max-width: 92%;
  margin: 0 auto 10px;
  padding: 8px 14px;
  border: 3px solid #477333;
  border-radius: 999px;
  background: rgba(242, 255, 210, .95);
  color: #315b26;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.7),
    0 4px 0 #315d25;
  font-weight: 900;
}

.touch-status-light {
  width: 13px;
  height: 13px;
  border: 2px solid #496332;
  border-radius: 50%;
  background: #baff6c;
  box-shadow:
    0 0 6px #dfff9d,
    0 0 13px rgba(157,255,79,.8);
}

.touch-status.dragging {
  background: #fff4bd;
  border-color: #a97727;
  color: #775018;
}

.touch-status.dragging .touch-status-light {
  background: #ffe05c;
  box-shadow:
    0 0 6px white,
    0 0 15px #ffe05c;
}

#mazeCanvas.touch-active {
  cursor: grabbing;
  filter: brightness(1.03);
}

.maze-board.touch-active {
  box-shadow:
    inset 0 0 0 5px rgba(215,241,126,.65),
    inset 0 -12px 22px rgba(38,87,31,.22),
    0 10px 0 #315d25,
    0 0 0 6px rgba(255,231,96,.35),
    0 20px 34px rgba(34,54,25,.32);
}

@media (pointer: coarse), (max-width: 900px) {
  .desktop-instruction {
    display: none;
  }

  .touch-instruction,
  .touch-status {
    display: inline-flex;
  }

  .maze-section {
    display: flex;
    flex-direction: column;
  }

  .maze-board {
    order: 1;
  }

  .instruction-board {
    order: 2;
    margin-top: 14px;
  }

  .touch-status {
    order: 3;
  }

  .arrow-controls {
    order: 4;
    position: sticky;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 30;
    width: min(100%, 520px);
    margin: 0 auto;
    padding: 9px;
    border: 4px solid rgba(91,58,25,.82);
    border-radius: 24px;
    background: rgba(255,244,196,.94);
    box-shadow:
      inset 0 3px 0 rgba(255,255,255,.55),
      0 7px 0 rgba(77,48,20,.72),
      0 12px 25px rgba(39,44,26,.28);
    backdrop-filter: blur(5px);
  }

  .arrow-controls button {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .game-screen {
    padding-bottom: calc(104px + env(safe-area-inset-bottom));
  }

  .maze-board {
    padding: 7px;
    border-width: 5px;
    border-radius: 18px;
  }

  #mazeCanvas {
    border-width: 4px;
    border-radius: 12px;
  }

  .start-label,
  .goal-label {
    width: 36px;
    height: 36px;
    border-width: 3px;
    font-size: 1.1rem;
  }

  .start-label {
    left: 11px;
    top: 11px;
  }

  .goal-label {
    right: 11px;
    bottom: 11px;
  }

  .instruction-board {
    font-size: .92rem;
  }

  .arrow-controls {
    grid-template-columns: repeat(4, 1fr);
  }

  .arrow-controls button {
    min-height: 58px;
    border-width: 4px;
    font-size: 1.65rem;
  }
}

/* V6 — video-intro */
.intro-screen {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  background: #1f3d24;
}
.intro-wrap {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.intro-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #1f3d24;
}
.intro-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(18,45,22,.08), transparent 55%, rgba(18,45,22,.48)),
    radial-gradient(circle at center, transparent 48%, rgba(10,25,13,.22));
}
.intro-actions {
  position: absolute;
  z-index: 3;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.intro-button {
  min-height: 48px;
  padding: 10px 16px;
  border: 3px solid #f1d786;
  border-radius: 999px;
  background: rgba(84,56,29,.84);
  color: white;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.22), 0 5px 0 #4e2e17, 0 12px 22px rgba(0,0,0,.24);
  font-weight: 900;
  backdrop-filter: blur(6px);
}
.intro-button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #4e2e17;
}
.intro-end-panel {
  position: relative;
  z-index: 4;
  width: min(620px, calc(100% - 28px));
  padding: clamp(24px, 5vw, 38px);
  border: 5px solid #d59a43;
  border-radius: 28px;
  background: rgba(255,247,214,.96);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.4), 0 10px 0 #75461f, 0 24px 44px rgba(0,0,0,.35);
  text-align: center;
  animation: introIn .45s ease both;
}
.intro-end-panel[hidden] { display: none !important; }
.intro-end-panel > span {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  background: #6c4397;
  color: white;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .1em;
}
.intro-end-panel h1 {
  margin: 10px 0 8px;
  color: #6c4397;
  font-size: clamp(2.5rem, 10vw, 5rem);
  line-height: .95;
}
.intro-end-panel p {
  margin: 0;
  color: #36572b;
  font-weight: 800;
}
.intro-screen.finished .intro-video { filter: brightness(.68); transition: filter .4s ease; }
.intro-screen.finished .intro-actions { opacity: 0; pointer-events: none; }
@keyframes introIn {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
