:root {
  color-scheme: light;
  --bg: #f7f3e8;
  --ink: #322620;
  --muted: #73665f;
  --panel: #fffdf6;
  --line: #d9cfc0;
  --accent: #e84d63;
  --accent-dark: #aa293e;
  --leaf: #2d8b68;
  --sky: #8cc8d8;
  --soil: #b6754d;
  --slot: #fff7dc;
  --shadow: 0 14px 34px rgba(72, 45, 30, 0.18);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.86), rgba(247, 243, 232, 0.95)),
    repeating-linear-gradient(90deg, #eff6d7 0 28px, #e5efc9 28px 56px);
}

button {
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 6px 0 var(--accent-dark);
  cursor: pointer;
  transition:
    transform 130ms ease,
    box-shadow 130ms ease,
    filter 130ms ease;
}

button:hover {
  filter: brightness(1.04);
}

button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.6);
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.game-panel {
  width: min(980px, 100%);
  min-height: min(760px, calc(100vh - 40px));
  padding: clamp(14px, 2.6vw, 26px);
  border: 2px solid rgba(111, 80, 54, 0.2);
  border-radius: 8px;
  background: rgba(255, 253, 246, 0.92);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--leaf);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.1rem);
  line-height: 0.95;
}

.scoreboard {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.scoreboard > div {
  min-width: 88px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8e8;
  text-align: center;
}

.scoreboard span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.scoreboard strong {
  display: block;
  margin-top: 2px;
  font-size: 1.55rem;
  line-height: 1;
}

.runner {
  padding: 6px 0 2px;
}

.track {
  position: relative;
  height: 42px;
  overflow: hidden;
  border: 2px solid rgba(45, 139, 104, 0.24);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(140, 200, 216, 0.18), rgba(255, 255, 255, 0.42)),
    repeating-linear-gradient(90deg, rgba(45, 139, 104, 0.2) 0 12px, transparent 12px 42px);
}

#runnerPig {
  position: absolute;
  top: 3px;
  left: var(--runner-left, 3%);
  width: 34px;
  height: 34px;
  transform: translateX(-50%);
  transition: left 360ms cubic-bezier(0.2, 0.9, 0.25, 1.15);
}

.board-wrap {
  position: relative;
  min-height: 426px;
  border: 2px solid rgba(132, 98, 68, 0.18);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 253, 246, 0.78), rgba(255, 253, 246, 0.78)),
    linear-gradient(135deg, rgba(45, 139, 104, 0.18) 25%, transparent 25%) 0 0 / 24px 24px,
    #f5e8c9;
}

.board {
  position: relative;
  width: 100%;
  height: clamp(426px, 58vh, 520px);
}

.tile {
  position: absolute;
  width: var(--tile-size);
  height: var(--tile-size);
  border: 2px solid #8c6444;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.56), transparent 42%),
    #fff5d6;
  box-shadow:
    0 9px 0 #c38b5e,
    0 16px 18px rgba(79, 50, 30, 0.2);
  display: grid;
  place-items: center;
  transform: translate3d(var(--x), var(--y), 0);
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    filter 160ms ease;
  user-select: none;
}

.tile img {
  width: 74%;
  height: 74%;
  object-fit: contain;
  pointer-events: none;
}

.tile:not(.blocked):hover {
  transform: translate3d(var(--x), calc(var(--y) - 5px), 0);
}

.tile.blocked {
  filter: saturate(0.68) brightness(0.82);
  cursor: not-allowed;
}

.tile.available {
  cursor: pointer;
}

.tile.hint {
  animation: hintPulse 820ms ease-in-out 3;
}

@keyframes hintPulse {
  50% {
    box-shadow:
      0 9px 0 #c38b5e,
      0 0 0 6px rgba(232, 77, 99, 0.32),
      0 16px 18px rgba(79, 50, 30, 0.2);
  }
}

.message {
  position: absolute;
  inset: auto 16px 16px;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid rgba(50, 38, 32, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 246, 0.9);
  color: var(--muted);
  font-weight: 800;
  pointer-events: none;
}

.message.win {
  color: #0b6b4c;
}

.message.lose {
  color: #a32437;
}

.tray-section {
  display: grid;
  gap: 12px;
}

.tray {
  min-height: 74px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
}

.slot {
  height: 74px;
  border: 2px dashed rgba(111, 80, 54, 0.35);
  border-radius: 8px;
  background: var(--slot);
  display: grid;
  place-items: center;
}

.slot img {
  width: 48px;
  height: 48px;
}

.slot.filled {
  border-style: solid;
  border-color: rgba(111, 80, 54, 0.5);
  background: #fff1c8;
}

.slot.clearing {
  animation: clearPop 230ms ease forwards;
}

@keyframes clearPop {
  to {
    transform: scale(0.84);
    opacity: 0;
  }
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.actions button {
  min-height: 44px;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
  }

  .game-panel {
    min-height: calc(100vh - 20px);
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .scoreboard {
    width: 100%;
  }

  .scoreboard > div {
    flex: 1;
  }

  .board-wrap {
    min-height: 392px;
  }

  .board {
    height: 392px;
  }

  .tray {
    min-height: 178px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .slot {
    height: 54px;
  }

  .slot img {
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 430px) {
  .actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
