* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  background: #8faa6a;
  color: white;
  font-family: "Inter", sans-serif;
}

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* GAME */

#game-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

canvas {
  width: min(980px, calc(100vw - 340px));
  max-width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  display: block;
  background: #9ab774;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* SIDEBAR */

#sidebar {
  width: 320px;
  min-width: 320px;
  height: 100vh;
  padding: 26px 28px;
  background: rgba(24, 52, 18, 0.97);
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar h1 {
  margin: 0 0 18px 0;
  font-family: "Cinzel", serif;
  font-size: clamp(40px, 3.6vw, 54px);
  line-height: 0.9;
  font-weight: 900;
  letter-spacing: -1px;
}

.intro {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.94);
}

.instructions {
  margin-top: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.08);
}

.instructions h3 {
  margin: 0 0 6px 0;
  font-family: "Cinzel", serif;
  font-size: 18px;
  line-height: 1;
}

.instructions p {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.92);
}

#countdown {
  margin-top: 20px;
  margin-bottom: 22px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.09);
  font-size: 14px;
  font-weight: 700;
}

#sidebar h2 {
  margin: 0 0 12px 0;
  font-family: "Cinzel", serif;
  font-size: 32px;
  line-height: 1;
}

#trip-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px 0;
}

#trip-list li {
  margin: 7px 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  color: white;
  transition:
    opacity 0.2s ease,
    color 0.2s ease,
    background 0.2s ease,
    transform 0.2s ease;
}

#trip-list li:hover {
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.12);
}

#trip-list li.active {
  color: #f3ffd7;
  background: rgba(202, 255, 126, 0.24);
  box-shadow: inset 0 0 0 1px rgba(219, 255, 157, 0.35);
  transform: translateX(2px);
}

.trip-link-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.trip-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

/* TOAST */

#cat-toast {
  position: absolute;
  left: 50%;
  top: 28px;
  transform: translateX(-50%) translateY(-12px);
  z-index: 140;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(24, 52, 18, 0.92);
  color: white;
  font-size: 20px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

#cat-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* MOBILE MENU BUTTON */

#menu-button {
  display: none;
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 300;
  border: none;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.34);
  color: white;
  font-size: 16px;
  font-weight: 700;
  backdrop-filter: blur(4px);
  cursor: pointer;
}

/* DPAD */

#dpad {
  position: absolute;
  right: 20px;
  bottom: 96px;
  display: none;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 8px;
  z-index: 120;
}

#dpad button {
  border: none;
  background: rgba(0, 0, 0, 0.28);
  color: white;
  font-size: 22px;
  backdrop-filter: blur(4px);
  cursor: pointer;
}

#dpad button[data-dir="up"] {
  grid-column: 2;
  grid-row: 1;
}

#dpad button[data-dir="left"] {
  grid-column: 1;
  grid-row: 2;
}

#select-button {
  grid-column: 2;
  grid-row: 2;
  font-size: 14px;
}

#dpad button[data-dir="right"] {
  grid-column: 3;
  grid-row: 2;
}

#dpad button[data-dir="down"] {
  grid-column: 2;
  grid-row: 3;
}

/* MOBILE */

@media (max-width: 900px) {
  #app {
    display: block;
  }

  #game-container {
    width: 100vw;
    height: 100vh;
    align-items: center;
    justify-content: center;
  }

  canvas {
    width: 100vw;
    max-height: 76vh;
  }

  #sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    min-width: 100%;
    height: 100%;
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
    transition: right 0.25s ease;
    padding-top: 88px;
  }

  #sidebar.open {
    right: 0;
  }

  #sidebar h1 {
    font-size: 44px;
  }

  #sidebar h2 {
    font-size: 32px;
  }

  #menu-button {
    display: block;
  }

  #dpad {
    display: grid;
    bottom: calc(56px + env(safe-area-inset-bottom));
  }

  #cat-toast {
    top: 112px;
    max-width: calc(100vw - 36px);
    font-size: 18px;
    text-align: center;
    white-space: normal;
  }
}