:root {
  font-family: Arial, Helvetica, sans-serif;
  color: #203c35;
  background: #f5f3ec;
  font-synthesis: none;
  --green: #214c40;
  --lime: #dbef99;
  --line: #24705b;
  --muted: #667069;
  --edge: #dcded3;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
}
button:disabled {
  cursor: default;
  opacity: 0.42;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible,
#board:focus-visible {
  outline: 3px solid #2469b3;
  outline-offset: 3px;
}
a {
  color: inherit;
}
/* The stage gets the remaining visible height. No gameplay overflow is hidden:
   if accessibility enlargement needs more room, content can reflow and scroll. */
.shell {
  width: 100%;
  max-width: 460px;
  height: 100vh;
  height: var(--app-height, 100dvh);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: calc(8px + var(--safe-top)) calc(12px + var(--safe-right))
    calc(8px + var(--safe-bottom)) calc(12px + var(--safe-left));
}
.shell > :not(.play-area) {
  flex-shrink: 0;
}
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
}
.wordmark {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 44px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand {
  font-size: 0.625rem;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 3px;
}
h1 {
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -1.5px;
  margin: 0;
  font-weight: 800;
}
.title-dot {
  color: #79a65b;
}
.edition {
  text-align: right;
  display: grid;
  gap: 4px;
  margin-left: auto;
}
.edition strong {
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}
.edition span {
  font-size: 0.6875rem;
  color: var(--muted);
}
.header-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon {
  border: 1px solid #cdd4c5;
  border-radius: 50%;
  width: 44px;
  min-width: 44px;
  height: 44px;
  background: transparent;
  padding: 0;
  font-size: 1.25rem;
}
.stats {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--edge);
  padding: 5px 3px;
}
.stats > div {
  display: grid;
  gap: 2px;
}
.stat-label {
  font-size: 0.6875rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
}
.stats strong {
  font-size: 1.25rem;
  line-height: 1.2;
}
.stats small {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
}
.star-symbol {
  color: #997019;
}
/* 296 = six 44px targets, five 4px gaps and 12px frame. The board never
   shrinks below usable targets to manufacture a passing viewport check. */
.play-area {
  flex: 1 0 296px;
  min-height: 296px;
  min-width: 296px;
  display: grid;
  place-items: center;
  container-type: size;
}
.board-wrap {
  position: relative;
  width: min(100%, calc(100dvh - 220px - var(--safe-top) - var(--safe-bottom)));
  min-width: 296px;
  max-width: 100%;
  aspect-ratio: 1;
  padding: 5px;
  background: #dce2d5;
  border: 1px solid #cdd5c6;
  border-radius: 14px;
  box-shadow: 0 3px 0 #e7e9df;
}
@supports (width: 1cqh) {
  .board-wrap {
    width: min(100cqw, 100cqh);
  }
}
#board {
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  grid-template-rows: repeat(6, minmax(44px, 1fr));
  height: 100%;
  gap: 4px;
  touch-action: pinch-zoom;
  user-select: none;
  position: relative;
  z-index: 1;
}
.cell {
  border-radius: 8px;
  background: #fffef7;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1.75rem;
  color: #85610b;
  touch-action: pinch-zoom;
}
.cell.blocked {
  background: repeating-linear-gradient(
    135deg,
    #c3ccbf 0,
    #c3ccbf 3px,
    #cbd3c6 3px,
    #cbd3c6 7px
  );
  box-shadow: inset 0 0 0 1px #b8c4b5;
}
.cell.start {
  background: var(--green);
  color: #fff;
}
.cell.finish {
  background: #f0dfb2;
  color: #5b4a1b;
  box-shadow: inset 0 0 0 2px #ad945c;
}
.cell.on-path:not(.start):not(.finish) {
  background: #d9e9c3;
}
.cell .label {
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.25px;
  line-height: 1.1;
  z-index: 3;
  padding: 3px 1px;
  max-width: 100%;
  overflow-wrap: anywhere;
  border-radius: 3px;
}
.cell.start .label {
  background: var(--green);
}
.cell.finish .label {
  background: #f0dfb2;
}
.cell .star {
  z-index: 3;
  text-shadow: 0 0 4px #fffef7;
}
.cell.current::after {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line);
  position: absolute;
  z-index: 4;
  box-shadow: 0 0 0 4px #d9e9c3;
}
#line {
  position: absolute;
  left: 5px;
  top: 5px;
  width: calc(100% - 10px);
  height: calc(100% - 10px);
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}
#path-line {
  fill: none;
  stroke: var(--line);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.status {
  min-height: 2.4em;
  margin: 0;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 0.8125rem;
  line-height: 1.2;
  color: #536157;
}
.actions,
#locked-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.primary {
  color: #f8faec;
  background: var(--green);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.primary span {
  color: var(--lime);
}
.actions button,
#locked-tools button {
  min-height: 48px;
  font-size: 0.875rem;
  padding: 10px 12px;
}
.actions .primary,
#locked-tools .primary {
  flex: 1;
}
.secondary {
  color: var(--green);
  background: #e6e8de;
  padding: 12px 15px;
}
.wide {
  width: 100%;
  margin-top: 8px;
}
/* Only the modal background is locked; normal gameplay is never clipped. */
html:has(dialog[open]) {
  overflow: hidden;
}
dialog {
  position: fixed;
  inset: var(--safe-top) 0 var(--safe-bottom);
  margin: auto;
  width: min(440px, calc(100% - 24px - var(--safe-left) - var(--safe-right)));
  max-height: calc(
    var(--app-height, 100dvh) - var(--safe-top) - var(--safe-bottom) - 16px
  );
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #d2d9cb;
  border-radius: 20px;
  padding: 16px;
  background: #faf9f3;
  color: #203c35;
  box-shadow: 0 20px 80px #143a3325;
}
dialog::backdrop {
  background: #132d2966;
  backdrop-filter: blur(3px);
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.eyebrow {
  font-size: 0.6875rem;
  letter-spacing: 1.5px;
  font-weight: 700;
  margin: 0;
  color: var(--muted);
}
h2 {
  font-size: 1.5rem;
  letter-spacing: -0.7px;
  line-height: 1.1;
  margin: 8px 0;
}
dialog p {
  font-size: 0.875rem;
  line-height: 1.4;
  margin: 8px 0;
  color: #526058;
}
dialog .primary {
  width: 100%;
  margin-top: 10px;
  min-height: 44px;
}
.examples {
  display: flex;
  gap: 16px;
  margin: 12px 0;
}
.examples figure {
  margin: 0;
  flex: 1;
}
.examples svg {
  width: 100%;
  max-height: 80px;
  background: #f1f2e8;
  border-radius: 7px;
}
.examples text {
  font-size: 14px;
  font-weight: bold;
  text-anchor: middle;
  fill: #203c35;
}
.example-grid {
  stroke: #ccd4c5;
  stroke-width: 1;
  fill: none;
}
.example-route {
  stroke: #8ab56d;
  stroke-width: 8;
  stroke-linejoin: round;
  stroke-linecap: round;
  fill: none;
}
figcaption {
  font-size: 0.75rem;
  color: #677365;
  line-height: 1.4;
  margin-top: 4px;
}
figcaption b {
  color: #203c35;
}
summary {
  cursor: pointer;
  min-height: 44px;
  padding: 12px 0;
  font-size: 0.875rem;
  font-weight: 700;
}
.legend {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}
.legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}
.legend i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.legend-start {
  background: var(--green);
}
.legend-finish {
  background: #c5a553;
}
footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 12px 0;
  flex-wrap: wrap;
}
.storage-note {
  font-size: 0.8125rem;
  color: #9a421e;
}
#result {
  text-align: center;
}
#result .dialog-head {
  text-align: left;
}
.medal-icon {
  font-size: 2rem;
  line-height: 1;
  margin: 8px 0;
}
.result-score {
  padding: 10px;
  background: #e6eddb;
  border-radius: 12px;
  font-size: 1.25rem;
  font-weight: 700;
}
#result-summary,
#best-summary,
.device-note {
  font-size: 0.8125rem;
}
#share-status:empty {
  display: none;
}
#share-manual {
  width: 100%;
  height: 100px;
  font: inherit;
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.celebrate {
  animation: celebrate 0.5s ease;
}
@keyframes celebrate {
  50% {
    box-shadow: 0 0 0 6px #b6ce88;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
  }
}
@media (max-height: 600px) {
  .shell {
    gap: 4px;
    padding-top: calc(4px + var(--safe-top));
    padding-bottom: calc(4px + var(--safe-bottom));
  }
  .topbar {
    min-height: 44px;
  }
  h1 {
    font-size: 1.75rem;
  }
  .brand {
    font-size: 0.625rem;
    margin-bottom: 1px;
  }
  .stats {
    padding: 3px 2px;
  }
  .stats > div {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
  }
  .stats strong {
    font-size: 1.125rem;
  }
  .stat-label {
    letter-spacing: 0;
  }
  .actions button,
  #locked-tools button {
    min-height: 44px;
    padding: 8px 10px;
  }
  .status {
    font-size: 0.8125rem;
    line-height: 1.1;
    min-height: 2.2em;
  }
}
