[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0, 0, 0, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 18px 18px;
}

.memory-game {
  --rail-width: 252px;
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle, rgba(0, 0, 0, 0.08) 1px, transparent 1px),
    var(--screen);
  background-size: 9px 9px;
}

.memory-game::before {
  content: "";
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1;
  width: var(--rail-width);
  background: var(--ink);
  pointer-events: none;
}

.hidden-controls {
  display: none !important;
}

.memory-game .maze {
  position: absolute;
  inset: 0 0 0 var(--rail-width);
  z-index: 0;
  display: grid;
  grid-template-columns: repeat(var(--maze-cols, 31), var(--cell));
  grid-template-rows: repeat(var(--maze-rows, 23), var(--cell));
  align-content: center;
  justify-content: center;
  width: calc(100% - var(--rail-width));
  height: 100%;
  margin: 0;
  padding: var(--maze-pad, 8px);
  border: 0;
  gap: var(--gap, 2px);
  overflow: hidden;
  background: var(--ink);
  box-shadow: none;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.memory-game .maze.dragging {
  cursor: grabbing;
}

.memory-game .cell {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--cell);
  height: var(--cell);
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  color: var(--ink);
  font: inherit;
  line-height: 1;
  text-align: center;
  background: var(--paper);
  cursor: pointer;
  overflow: visible;
}

.memory-game .cell.wall {
  cursor: default;
  background:
    repeating-linear-gradient(45deg, #111 0 4px, #2a2a2a 4px 6px);
}

.memory-game .cell.path {
  background: #f7f7f2;
}

.memory-game .cell.visited.path {
  background: #edede7;
}

.memory-game .cell.syllable {
  background: #fff;
}

.memory-game .cell.current {
  z-index: 5;
  outline: 3px solid var(--ink);
  outline-offset: -1px;
}

.syllable-token {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding-top: 1px;
  color: var(--ink);
  font-family: "Silom", "Courier New", monospace;
  font-size: min(19px, calc(var(--cell) * 0.52));
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.home-icon {
  width: 68%;
  height: 68%;
  border: 3px solid var(--ink);
  background:
    linear-gradient(45deg, transparent 0 42%, var(--ink) 43% 57%, transparent 58%) 50% 10% / 80% 45% no-repeat,
    linear-gradient(var(--ink) 0 0) 24% 50% / 52% 36% no-repeat;
}

.hedgehog-icon {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(2px 2px 0 #fff) drop-shadow(-2px -2px 0 #fff);
}

.mini-pet {
  width: calc(var(--cell) * 2.15);
  height: calc(var(--cell) * 1.58);
  pointer-events: none;
}

.hedgehog-spines,
.hedgehog-body,
.hedgehog-face,
.hedgehog-eye,
.hedgehog-brow,
.hedgehog-mouth,
.hedgehog-cheek,
.hedgehog-nose,
.hedgehog-leg-back,
.hedgehog-leg-front {
  position: absolute;
  display: block;
}

.hedgehog-spines {
  left: 0;
  top: 11%;
  width: 64%;
  height: 68%;
  background:
    linear-gradient(135deg, transparent 0 48%, var(--ink) 49% 100%) 0 0 / 18% 42% repeat-x,
    var(--ink);
  clip-path: polygon(0 60%, 7% 19%, 15% 55%, 23% 12%, 31% 57%, 40% 8%, 51% 58%, 63% 17%, 74% 63%, 100% 52%, 100% 92%, 0 92%);
}

.hedgehog-body {
  left: 24%;
  top: 34%;
  width: 57%;
  height: 45%;
  background: var(--ink);
  border-radius: 2px;
}

.hedgehog-face {
  right: 3%;
  top: 38%;
  width: 33%;
  height: 34%;
  border: 3px solid var(--ink);
  background: var(--paper);
}

.hedgehog-eye {
  right: 19%;
  top: 48%;
  width: 7%;
  height: 7%;
  background: var(--ink);
  box-shadow: 0 0 0 2px var(--paper);
}

.hedgehog-brow {
  right: 16%;
  top: 41%;
  width: 16%;
  height: 3px;
  background: var(--ink);
  opacity: 0;
}

.hedgehog-mouth {
  right: 13%;
  top: 62%;
  width: 13%;
  height: 7%;
  border-bottom: 3px solid var(--ink);
  border-radius: 0 0 10px 10px;
}

.hedgehog-cheek {
  right: 28%;
  top: 58%;
  width: 7%;
  height: 7%;
  background: var(--ink);
  opacity: 0;
}

.hedgehog-nose {
  right: 0;
  top: 50%;
  width: 9%;
  height: 13%;
  background: var(--ink);
}

.hedgehog-leg-back,
.hedgehog-leg-front {
  bottom: 4%;
  width: 12%;
  height: 13%;
  background: var(--ink);
}

.hedgehog-leg-back {
  left: 30%;
}

.hedgehog-leg-front {
  left: 57%;
}

.hedgehog-sad .hedgehog-brow {
  opacity: 1;
  transform: rotate(18deg);
}

.hedgehog-sad .hedgehog-mouth {
  top: 64%;
  border-top: 3px solid var(--ink);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
}

.hedgehog-happy .hedgehog-mouth,
.hedgehog-eat .hedgehog-mouth,
.hedgehog-care .hedgehog-mouth {
  width: 15%;
  height: 8%;
  border-bottom-width: 3px;
}

.hedgehog-care .hedgehog-cheek {
  opacity: 1;
}

.hedgehog-sleep {
  transform: rotate(-2deg);
}

.hedgehog-sleep .hedgehog-eye {
  right: 17%;
  top: 50%;
  width: 12%;
  height: 3px;
  box-shadow: none;
}

.hedgehog-sleep .hedgehog-brow {
  opacity: 0;
}

.hedgehog-sleep .hedgehog-mouth {
  right: 13%;
  top: 63%;
  width: 11%;
  height: 4%;
  border-bottom-width: 3px;
  border-radius: 0 0 10px 10px;
}

.hedgehog-sleep .hedgehog-cheek {
  opacity: 1;
  width: 5%;
  height: 5%;
}

.react-bad .mini-pet {
  transform: rotate(-5deg);
}

.react-eat .mini-pet,
.react-care .mini-pet,
.react-home .mini-pet {
  transform: translateY(-3px);
}

.spritz-flash {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(244, 244, 240, 0.16);
}

.spritz-word {
  display: grid;
  place-items: center;
  min-width: 190px;
  min-height: 112px;
  padding: 14px 26px;
  border: 6px solid var(--ink);
  background: var(--white);
  box-shadow: 8px 8px 0 var(--ink);
  font-family: "Silom", "Courier New", monospace;
  font-size: 58px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.progress-badge,
.admin-toggle {
  position: fixed;
  top: 12px;
  z-index: 32;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 3px solid var(--ink);
  background: var(--white);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: "Silom", "Courier New", monospace;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.progress-badge {
  left: 12px;
  padding: 6px 9px;
  pointer-events: none;
}

.progress-slots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.progress-slot {
  display: inline-block;
  width: 9px;
  height: 15px;
  border: 2px dotted var(--ink);
  background: var(--paper);
}

.admin-toggle {
  left: 132px;
  padding: 6px 9px;
  cursor: pointer;
}

.admin-toggle[aria-expanded="true"],
.admin-close:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.side-pocket {
  position: fixed;
  top: 62px;
  left: 12px;
  z-index: 31;
  display: grid;
  gap: 8px;
  justify-items: start;
  pointer-events: none;
}

.pocket-pet {
  display: grid;
  place-items: center;
  width: 112px;
  height: 86px;
  border: 4px solid var(--ink);
  background: var(--white);
  box-shadow: 4px 4px 0 var(--ink);
}

.pocket-pet .hedgehog-icon {
  width: 96px;
  height: 70px;
  filter: none;
}

.pocket-icons {
  display: grid;
  grid-template-columns: repeat(2, 52px);
  gap: 6px;
  align-items: flex-start;
  min-height: 52px;
}

.pocket-word-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 3px solid var(--ink);
  background: var(--white);
  box-shadow: 3px 3px 0 var(--ink);
  animation: pocket-icon-in var(--celebration-duration, 620ms) steps(4, end) both;
}

.pocket-icon,
.pocket-icon svg {
  display: block;
  width: 34px;
  height: 34px;
}

.pocket-icon path {
  fill: var(--ink);
}

@keyframes pocket-icon-in {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  45% {
    transform: scale(1.12);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.admin-panel {
  position: fixed;
  top: 58px;
  left: 12px;
  z-index: 70;
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100dvh - 88px);
  overflow: auto;
  border: 4px solid var(--ink);
  background: var(--paper);
  box-shadow: 7px 7px 0 var(--ink);
}

.admin-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 3px solid var(--ink);
  background: var(--white);
}

.admin-head h2 {
  margin: 0 0 4px;
  font-family: "Silom", "Courier New", monospace;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.admin-head p {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.25;
}

.admin-close {
  align-self: start;
  border: 3px solid var(--ink);
  background: var(--white);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 5px 8px;
  font-family: "Silom", "Courier New", monospace;
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
}

.admin-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-bottom: 3px solid var(--ink);
  background: var(--paper);
}

.admin-settings label {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1.2fr) 54px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 10px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  font-size: 13px;
}

.admin-settings label:nth-child(2n) {
  border-right: 0;
}

.admin-settings span {
  color: var(--dim);
}

.admin-settings input[type="range"] {
  width: 100%;
  accent-color: var(--ink);
}

.admin-settings output {
  font-family: "Silom", "Courier New", monospace;
  font-size: 12px;
  text-align: right;
}

.admin-word-list {
  display: grid;
  gap: 0;
}

.admin-word-row {
  display: grid;
  grid-template-columns: 42px minmax(80px, 1fr) minmax(80px, 1fr) minmax(120px, 1.35fr);
  align-items: center;
  min-height: 50px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
  font-size: 15px;
}

.admin-word-row[data-active="true"] {
  background: var(--white);
}

.admin-word-row > span {
  min-width: 0;
  padding: 7px 9px;
}

.admin-icon,
.admin-icon svg {
  display: block;
  width: 28px;
  height: 28px;
}

.admin-icon {
  margin-left: 7px;
}

.admin-icon path {
  fill: var(--ink);
}

.admin-word {
  font-family: "Silom", "Courier New", monospace;
  font-weight: 900;
  text-transform: uppercase;
}

.admin-syllables,
.admin-icon-name {
  color: var(--dim);
}

.celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 24;
  display: grid;
  place-items: center;
  gap: 10px;
  pointer-events: none;
}

.celebration-pet {
  position: relative;
  display: block;
  animation: celebration-pop var(--celebration-duration, 620ms) steps(4, end) both;
}

.celebration-pet .hedgehog-icon {
  width: 190px;
  height: 138px;
  filter: drop-shadow(5px 5px 0 var(--white)) drop-shadow(-5px -5px 0 var(--white));
}

.celebration-overlay[data-kind="home"] .celebration-pet {
  animation: celebration-pop var(--celebration-duration, 620ms) steps(4, end) both;
}

.celebration-overlay[data-kind="home"] .celebration-pet::after {
  content: "Zzz";
  position: absolute;
  right: -24px;
  top: -26px;
  padding: 2px 6px;
  border: 3px solid var(--ink);
  background: var(--white);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: "Silom", "Courier New", monospace;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.celebration-overlay[data-kind="home"] .celebration-pet .hedgehog-icon {
  width: 270px;
  height: 190px;
}

.celebration-token {
  display: grid;
  place-items: center;
  min-width: 76px;
  min-height: 48px;
  border: 4px solid var(--ink);
  background: var(--white);
  box-shadow: 5px 5px 0 var(--ink);
  font-family: "Silom", "Courier New", monospace;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  animation: celebration-token-pop var(--celebration-duration, 620ms) steps(4, end) both;
}

@keyframes celebration-pop {
  0% {
    transform: scale(0.28) translateY(18px);
    opacity: 0;
  }
  35% {
    transform: scale(1.12) translateY(-4px);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes celebration-token-pop {
  0% {
    transform: translateY(12px);
    opacity: 0;
  }
  45% {
    transform: translateY(-2px);
    opacity: 1;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.floating-controls {
  position: fixed;
  left: 12px;
  right: auto;
  bottom: 12px;
  z-index: 30;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.control-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 3px solid var(--ink);
  background: var(--white);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: "Silom", "Courier New", monospace;
  font-size: 14px;
  text-transform: uppercase;
}

.control-button {
  padding: 6px 10px;
  cursor: pointer;
}

.restart-button {
  margin-left: 12px;
  opacity: 0.82;
}

.control-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.mobile-arrows {
  display: none;
}

.direction-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 3px solid var(--ink);
  padding: 0;
  background: var(--white);
  box-shadow: 3px 3px 0 var(--ink);
  color: var(--ink);
  font-family: "Silom", "Courier New", monospace;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.direction-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.eat-control-button {
  min-width: 54px;
}

.restart-control-button {
  margin-left: auto;
  opacity: 0.82;
}

.reward-overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(244, 244, 240, 0.12);
}

.reward-icon {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border: 6px solid var(--ink);
  background: var(--white);
  box-shadow: 8px 8px 0 var(--ink);
}

.reward-word-icon,
.reward-word-icon svg {
  display: block;
  width: 104px;
  height: 104px;
}

.reward-word-icon path {
  fill: var(--ink);
}

@media (max-width: 760px), (max-height: 520px) {
  .memory-game {
    --rail-width: 96px;
    --control-strip-height: 46px;
  }

  .memory-game .maze {
    inset: 0 0 var(--control-strip-height) var(--rail-width);
    height: calc(100% - var(--control-strip-height));
  }

  .floating-controls {
    display: none;
  }

  .mobile-arrows {
    position: fixed;
    left: 5px;
    right: 5px;
    bottom: 5px;
    z-index: 31;
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 36px;
    touch-action: manipulation;
  }

  .direction-button {
    width: 30px;
    height: 30px;
    border-width: 2px;
    box-shadow: 2px 2px 0 var(--ink);
    font-size: 15px;
  }

  .mobile-arrows .control-button {
    min-height: 30px;
    padding: 4px 7px;
  }

  .mobile-arrows .restart-control-button {
    margin-left: auto;
  }

  .progress-badge,
  .admin-toggle {
    top: 6px;
    min-height: 30px;
    border-width: 2px;
    box-shadow: 2px 2px 0 var(--ink);
    font-size: 11px;
  }

  .progress-badge {
    left: 6px;
    padding: 4px 5px;
  }

  .admin-toggle {
    top: 44px;
    left: 6px;
    padding: 4px 6px;
  }

  .progress-slot {
    width: 7px;
    height: 12px;
    border-width: 2px;
  }

  .progress-slots {
    gap: 2px;
  }

  .side-pocket {
    top: 84px;
    left: 6px;
    gap: 5px;
  }

  .pocket-pet {
    width: 78px;
    height: 60px;
    border-width: 3px;
    box-shadow: 3px 3px 0 var(--ink);
  }

  .pocket-pet .hedgehog-icon {
    width: 66px;
    height: 48px;
  }

  .pocket-icons {
    grid-template-columns: 38px;
    gap: 4px;
  }

  .pocket-word-icon {
    width: 38px;
    height: 38px;
    border-width: 2px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .pocket-icon,
  .pocket-icon svg {
    width: 25px;
    height: 25px;
  }

  .admin-panel {
    top: 44px;
    left: 6px;
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 60px);
    border-width: 3px;
    box-shadow: 4px 4px 0 var(--ink);
  }

  .admin-head {
    padding: 9px;
  }

  .admin-word-row {
    grid-template-columns: 36px minmax(68px, 1fr) minmax(70px, 1fr);
  }

  .admin-settings {
    grid-template-columns: 1fr;
  }

  .admin-settings label {
    grid-template-columns: minmax(100px, 1fr) minmax(98px, 1.2fr) 46px;
    border-right: 0;
    font-size: 12px;
  }

  .admin-icon-name {
    display: none;
  }

  .celebration-pet .hedgehog-icon {
    width: 138px;
    height: 100px;
  }

  .celebration-token {
    min-width: 62px;
    min-height: 42px;
    font-size: 24px;
  }

  .control-button {
    min-height: 34px;
    font-size: 12px;
    border-width: 2px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .spritz-word {
    min-width: 140px;
    min-height: 88px;
    font-size: 44px;
    border-width: 5px;
  }

  .reward-icon {
    width: 120px;
    height: 120px;
  }

  .reward-word-icon,
  .reward-word-icon svg {
    width: 86px;
    height: 86px;
  }
}
