html, body {
  margin: 0;
  overflow: hidden;
}

.stage {
  box-sizing: border-box;
  min-height: 100vh;
  display: grid;
  place-items: center;
  margin: 0;
  background: #ffd23f;
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
  padding: clamp(8px, 4vw, 24px);
}

.fme {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 440px;
}

.fme__bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.fme__title {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  margin-right: auto;
  font-weight: 800;
  font-size: clamp(11px, 2.8vw, 13px);
  line-height: 1.2;
  color: #17141a;
}

.fme__ico {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: #17141a;
}

.fme__ico--sm {
  width: 12px;
  height: 12px;
}

.fme__pill {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(23, 20, 26, 0.14);
  font-weight: 700;
  font-size: clamp(9px, 2.4vw, 11px);
  line-height: 1.2;
  color: #17141a;
  white-space: nowrap;
}

.fme__label {
  font-weight: 600;
  color: rgba(23, 20, 26, 0.78);
}

.fme__num {
  font-weight: 800;
}

.fme__btn {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 4px;
  padding: 0;
  background: rgba(23, 20, 26, 0.14);
  cursor: pointer;
  color: #17141a;
}

.fme__btn:hover {
  background: rgba(23, 20, 26, 0.24);
}

.fme__btn:focus-visible {
  outline: 2px solid #17141a;
  outline-offset: 0;
}

.fme__mazeWrap {
  position: relative;
}

.fme__maze {
  display: grid;
  gap: 4px;
  justify-content: center;
  grid-template-columns: repeat(7, clamp(22px, 6.4vw, 32px));
  grid-template-areas: "c0r0 c1r0 c2r0 c3r0 c4r0 c5r0 c6r0" "c0r1 c1r1 c2r1 c3r1 c4r1 c5r1 c6r1" "c0r2 c1r2 c2r2 c3r2 c4r2 c5r2 c6r2" "c0r3 c1r3 c2r3 c3r3 c4r3 c5r3 c6r3" "c0r4 c1r4 c2r4 c3r4 c4r4 c5r4 c6r4";
  border-radius: 16px;
  padding: 4px;
  background: rgba(23, 20, 26, 0.12);
  justify-self: center;
}

.fme__cell, .fme__wall {
  aspect-ratio: 1/1;
  min-width: 0;
  border-radius: 4px;
}

.fme__wall {
  background: #17141a;
}

.fme__cell {
  display: grid;
  place-items: center;
  width: 100%;
  border: 0;
  padding: 0;
  background: #fff7e6;
  cursor: pointer;
  color: #0a4fe8;
}

.fme__cell.is-start {
  background: rgba(255, 247, 230, 0.6);
}

.fme__cell.is-goal {
  background: #0a4fe8;
}

.fme__cell:focus-visible {
  outline: 2px solid #17141a;
  outline-offset: -2px;
}

.fme__char {
  width: 68%;
  height: 68%;
  opacity: 0;
  transform: scale(0.6);
  color: #0a4fe8;
}

.fme__cell:focus .fme__char {
  opacity: 1;
  transform: scale(1);
  transition: opacity 220ms cubic-bezier(0.2, 1.4, 0.4, 1), transform 220ms cubic-bezier(0.2, 1.4, 0.4, 1);
}

.fme__cell.is-goal:focus .fme__char {
  color: #fff7e6;
}

.fme__cell::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px rgba(10, 79, 232, 0.5);
  opacity: 0;
}

.fme__cell {
  position: relative;
}

.fme__cell:focus::after {
  opacity: 1;
}

.fme [hidden] {
  display: none !important;
}

.fme__done {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(23, 20, 26, 0.55);
}

.fme__donePanel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-radius: 16px;
  padding: 16px;
  background: #ffffff;
  box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}

.fme__doneTitle {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-weight: 800;
  font-size: clamp(13px, 3.4vw, 16px);
  line-height: 1.2;
  color: #17141a;
}

.fme__doneLine {
  margin: 0;
  font-weight: 600;
  font-size: clamp(10px, 2.6vw, 12px);
  line-height: 1.4;
  color: rgba(23, 20, 26, 0.78);
}

.fme__again {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  border-radius: 12px;
  padding: 4px 12px;
  background: #0a4fe8;
  color: #fff7e6;
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(10px, 2.6vw, 12px);
  line-height: 1.4;
  cursor: pointer;
}

.fme__again:hover {
  background: #2f6df6;
}

.fme__again:focus-visible {
  outline: 2px solid #17141a;
  outline-offset: 2px;
}

.fme__hint {
  margin: 0;
  font-weight: 500;
  font-size: clamp(9px, 2.4vw, 11px);
  line-height: 1.4;
  color: rgba(23, 20, 26, 0.78);
}

.fme.is-demo .fme__cell:focus .fme__char {
  animation-name: fmeStep;
  animation-duration: 300ms;
  animation-timing-function: cubic-bezier(0.2, 1.4, 0.4, 1);
  animation-iteration-count: infinite;
}

@keyframes fmeStep {
  0%, 100% {
    transform: scale(1) translateY(0);
  }
  40% {
    transform: scale(1.08) translateY(-2px);
  }
}
.fme.is-demo .fme__cell.is-path {
  animation-name: fmePath;
  animation-duration: 2s;
  animation-timing-function: ease-out;
  animation-iteration-count: infinite;
  animation-fill-mode: backwards;
  animation-delay: calc(var(--i) * 120ms);
}

@keyframes fmePath {
  0% {
    background-color: #fff7e6;
  }
  10% {
    background-color: rgba(10, 79, 232, 0.34);
  }
  55% {
    background-color: rgba(10, 79, 232, 0.34);
  }
  75% {
    background-color: #fff7e6;
  }
  100% {
    background-color: #fff7e6;
  }
}
.fme.is-demo .fme__cell.is-goal {
  animation-name: fmeGoal;
  animation-duration: 2s;
  animation-timing-function: ease-out;
  animation-iteration-count: infinite;
}

@keyframes fmeGoal {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.82;
    transform: scale(1.06);
  }
}
@media (max-width: 340px) {
  .fme {
    gap: 4px;
  }
  .fme__maze {
    grid-template-columns: repeat(7, 16px);
  }
  .fme__donePanel {
    padding: 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .fme.is-demo .fme__cell:focus .fme__char,
  .fme.is-demo .fme__cell.is-path,
  .fme.is-demo .fme__cell.is-goal {
    animation: none !important;
  }
  .fme__cell:focus .fme__char {
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
