:root {
  --background: #fff8e6;
  --foreground: #23161e;
  --maze: #191840;
  --wall: #34c1f5;
  --wall-light: #e6fbff;
  --panel: rgba(255, 255, 255, 0.86);
  --pink: #ef4d83;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
  min-height: 100%;
}

body {
  background: linear-gradient(145deg, #fff7de 0%, #ffd8e7 47%, #c8f2ff 100%);
  color: var(--foreground);
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  min-height: 100svh;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  font: inherit;
}

.game-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100svh;
  padding:
    max(8px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
}

.phone-stage {
  display: grid;
  gap: 9px;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: min(100svh - 16px, 852px);
  max-width: 393px;
  width: 100%;
}

.game-topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 62px;
}

.title-lockup p {
  color: #6f5360;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.title-lockup h1 {
  color: #2a1721;
  font-size: 30px;
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
  margin: 0;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-button,
.dir-button,
.start-button {
  align-items: center;
  background: var(--panel);
  border: 2px solid #ffffff;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(54, 33, 45, 0.12);
  display: inline-flex;
  font-weight: 950;
  justify-content: center;
  user-select: none;
}

.icon-button {
  color: #49303b;
  height: 43px;
  width: 47px;
}

.stats-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
}

.stats-row div {
  background: rgba(255, 255, 255, 0.78);
  border: 2px solid rgba(255, 255, 255, 0.96);
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(54, 33, 45, 0.08);
  min-width: 0;
  padding: 8px 7px;
  text-align: center;
}

.stats-row span {
  color: #79576a;
  display: block;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 5px;
}

.stats-row strong {
  color: #2b1c24;
  display: block;
  font-size: clamp(15px, 4.2vw, 18px);
  font-weight: 950;
  line-height: 1;
}

.maze-board {
  align-self: center;
  aspect-ratio: 13 / 17;
  background: var(--maze);
  border: 4px solid #fff8ff;
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(29, 25, 69, 0.3);
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  grid-template-rows: repeat(17, minmax(0, 1fr));
  justify-self: center;
  max-height: 100%;
  max-width: 100%;
  overflow: hidden;
  padding: 4px;
  position: relative;
  width: min(100%, calc((100svh - 228px) * 13 / 17));
}

.maze-cell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  position: relative;
}

.maze-cell.path {
  background: #211d55;
}

.maze-cell.wall {
  background: linear-gradient(135deg, var(--wall) 0%, #128bc6 100%);
  border: 1px solid var(--wall-light);
  border-radius: 4px;
  box-shadow: inset 0 -3px 0 rgba(14, 72, 115, 0.25);
}

.heart-asset {
  animation: heartPulse 1.5s ease-in-out infinite;
  display: block;
  height: 48%;
  max-height: 18px;
  max-width: 18px;
  width: 48%;
}

.actor {
  align-items: center;
  display: flex;
  filter: drop-shadow(0 4px 5px rgba(6, 5, 18, 0.28));
  inset: -27%;
  justify-content: center;
  pointer-events: none;
  position: absolute;
  z-index: 4;
}

.actor img {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.actor b {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.98);
  border-radius: 6px;
  bottom: -2px;
  box-shadow: 0 3px 7px rgba(6, 5, 18, 0.16);
  color: #271b22;
  font-size: 8px;
  font-weight: 950;
  left: 50%;
  line-height: 1;
  padding: 3px 4px;
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.status-panel {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #ffffff;
  border-radius: 8px;
  box-shadow: 0 18px 38px rgba(9, 9, 31, 0.22);
  display: grid;
  gap: 12px;
  left: 50%;
  padding: 16px;
  place-items: center;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(72%, 230px);
  z-index: 8;
}

.status-panel strong {
  color: #241720;
  font-size: 22px;
  font-weight: 950;
  line-height: 1.15;
  text-align: center;
}

.start-button {
  background: linear-gradient(135deg, var(--pink), #d62f67);
  color: #ffffff;
  min-height: 44px;
  padding: 0 24px;
}

.control-deck {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, 72px);
  grid-template-rows: repeat(3, 42px);
  justify-content: center;
  padding-bottom: max(0px, env(safe-area-inset-bottom));
}

.dir-button {
  color: #41313a;
  font-size: 17px;
  height: 42px;
  width: 72px;
}

.dir-button:active,
.icon-button:active,
.start-button:active {
  transform: translateY(1px) scale(0.98);
}

.dir-button.up {
  grid-column: 2;
  grid-row: 1;
}

.dir-button.left {
  grid-column: 1;
  grid-row: 2;
}

.dir-button.right {
  grid-column: 3;
  grid-row: 2;
}

.dir-button.down {
  grid-column: 2;
  grid-row: 3;
}

@keyframes heartPulse {
  0%,
  100% {
    transform: scale(0.92);
  }

  50% {
    transform: scale(1.08);
  }
}

@media (max-height: 740px) {
  .phone-stage {
    gap: 7px;
  }

  .game-topbar {
    min-height: 54px;
  }

  .title-lockup h1 {
    font-size: 25px;
  }

  .icon-button {
    height: 38px;
    width: 42px;
  }

  .stats-row div {
    padding: 6px;
  }

  .control-deck {
    grid-template-columns: repeat(3, 66px);
    grid-template-rows: repeat(3, 38px);
  }

  .dir-button {
    height: 38px;
    width: 66px;
  }

  .maze-board {
    width: min(100%, calc((100svh - 205px) * 13 / 17));
  }
}

@media (prefers-reduced-motion: reduce) {
  .heart-asset {
    animation: none;
  }
}
