:root {
  --bg: #f6efe5;
  --panel: #fff8ee;
  --text: #2b2118;
  --wall: #7a4f2a;
  --floor: #f2d7b5;
  --door: #6ea7ff;
  --door-open: #9fd18b;
  --safe: #8fd694;
  --grid-border: rgba(0,0,0,0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100svh;
}

.wrap {
  width: min(100%, 900px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 8px 16px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.gameShell {
  background: var(--panel);
  border-radius: 16px;
  padding: 10px 14px 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.gamesHeader {
  text-align: center;
  margin-bottom: 18px;
}

.gamesTitle {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
}

.small {
  opacity: 0.8;
}


.hud {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-weight: bold;
}

.board {
  display: grid;
  width: min(100%, min(640px, calc(100svh - 250px)));
  max-width: 640px;
  margin: 0 auto;
  position: relative;
  gap: 0;
  background: var(--floor);
  overflow: hidden;
}

.actorLayer {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition-property: left, top;
  transition-timing-function: linear;
  transition-duration: 680ms;
  z-index: 5;
}


.footer {
  text-align: center;
  margin-top: 16px;
}

.tileImage {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  transform: scale(1.01);
}

.doorImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  pointer-events: none;
  transform: scale(0.92);
}

.actorImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  width: calc(100% + 1px);
  height: calc(100% + 1px);
  margin-right: -1px;
  margin-bottom: -1px;
  border: none;
  overflow: hidden;
  background: var(--floor);
}

.wall {
  background: var(--wall);
}

.floor {
  background: var(--floor);
}

.safezone {
  background: var(--safe);
}

.door {
  cursor: pointer;
  background: var(--floor);
}

.endPanel {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: rgba(43, 33, 24, 0.72);
  text-align: center;
}

.endPanelContent {
  width: min(100%, 420px);
  background: #fff3e6;
  border: 2px solid rgba(0,0,0,0.08);
  border-radius: 18px;
  padding: 20px 18px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.22);
}

.hidden {
  display: none !important;
}

.hudCats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.boardMeta {
  width: 100%;
  max-width: 640px;
  margin: 14px auto 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  column-gap: 12px;
  align-items: start;
}

.hudCenter {
  display: flex;
  justify-content: center;
  align-items: start;
  padding-top: 0;
}

.infoMiddleButton {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1;
}

.hudPanel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.hudPanelLeft {
  align-items: flex-start;
  text-align: left;
}

.hudPanelRight {
  align-items: flex-end;
  text-align: right;
}

.hudLabel {
  font-weight: bold;
  font-size: 0.95rem;
  width: 100%;
}

.catRow {
  display: flex;
  gap: 6px;
  min-height: 52px;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.catRowLeft {
  justify-content: flex-start;
}

.catRowRight {
  justify-content: flex-end;
}

.catToken {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
}


.catRowLarge {
  flex-wrap: nowrap;
  justify-content: flex-end;
  overflow: hidden;
}

.catRowLarge .catToken {
  flex: 0 0 auto;
}

@media (max-width: 600px) {
  .catRowLarge .catToken {
    width: 30px;
    height: 30px;
  }
}

.spawnBlock {
  align-items: flex-end;
}

.spawnPreview {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spawnPreview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 600px) {
  .wrap {
    padding: 12px 8px 24px;
  }

  .gameShell {
    padding: 10px;
  }

  .gamesHeader {
    margin-bottom: 10px;
  }

  .gamesTitle {
    font-size: clamp(1.5rem, 7vw, 2.2rem);
  }

  .catToken {
    width: 38px;
    height: 38px;
  }

  .boardMeta {
    margin-top: 10px;
    align-items: flex-end;
  }
}


.bottomInfoRow {
  display: none;
}

.infoBottomButton {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  padding: 0;
}

.inlineIcon {
  width: 1.4em;
  height: 1.4em;
  object-fit: contain;
  vertical-align: middle;
  margin: 0 2px;
}

.resultDots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 10px;
}

.resultDot {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #bdbdbd;
}

.resultDot.saved {
  background: #d8c64a;
}

.resultDot.failed {
  background: #9a9a9a;
}

.finalFraction {
  font-weight: bold;
  margin: 0;
}

.titleRow {
  display: flex;
  align-items: center;
  gap: 10px;
}

.iconButton {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #2b2118;
  color: #fff8ee;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
}

.infoPanel {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(43, 33, 24, 0.55);
}

.infoPanelContent {
  width: min(100%, 480px);
  background: rgba(255, 248, 238, 0.96);
  border-radius: 18px;
  padding: 20px 18px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.22);
  text-align: left;
}

.infoCloseButton {
  margin-top: 12px;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: #2b2118;
  color: #fff8ee;
  cursor: pointer;
}

.finalMoodImage {
  width: 96px;
  height: 96px;
  object-fit: contain;
  display: block;
  margin: 6px auto 12px;
}

@media (min-width: 700px) {
  .finalMoodImage {
    width: 112px;
    height: 112px;
  }
}


#shareBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  padding: 14px 22px;
  margin-top: 14px;
  border: none;
  border-radius: 14px;
  background: #2b2118;
  color: #fff8ee;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}

#shareBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.22);
}

#shareBtn:active {
  transform: translateY(0);
}

#shareBtn::before {
  content: "↗";
  margin-right: 10px;
  font-size: 1.1em;
}

.mazeMeta {
  margin: 2px 0 0;
  font-size: 0.85rem;
  font-weight: bold;
  opacity: 0.7;
}


.portraitLock {
  display: none !important;
}

@media (orientation: landscape) and (max-width: 950px) and (max-height: 600px) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  .portraitLock {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
    color: var(--text);
    text-align: center;
  }

  .portraitLockCard {
    max-width: 360px;
    padding: 22px;
    border-radius: 18px;
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  }

  .portraitLockCard strong {
    display: block;
    font-size: 1.4rem;
    margin-bottom: 8px;
  }

  .wrap {
    display: none;
  }
}
