* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at top left, rgba(255, 229, 152, 0.22), transparent 25%),
    radial-gradient(circle at bottom right, rgba(81, 140, 92, 0.22), transparent 24%),
    linear-gradient(180deg, #fdf7ea 0%, #f6e7c6 100%);
  color: #20323a;
  font-family: "Trebuchet MS", "Avenir Next", Avenir, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

body {
  padding: 18px;
}

body.quest-embed-mode {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 236, 170, 0.24), transparent 26%),
    radial-gradient(circle at bottom right, rgba(86, 150, 98, 0.18), transparent 24%),
    linear-gradient(180deg, #fbf5e5 0%, #f3e0b0 100%);
}

button {
  font: inherit;
}

.quest-shell {
  max-width: 1440px;
  margin: 0 auto;
}

body.quest-embed-mode .quest-shell {
  max-width: none;
}

.quest-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

body.quest-embed-mode .quest-header {
  display: none;
}

.quest-logo {
  width: clamp(170px, 18vw, 270px);
  height: auto;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.18));
}

.quest-title-block h1 {
  margin: 0.1rem 0 0.4rem;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 0.95;
  color: #103420;
}

.quest-kicker,
.small-label {
  margin: 0;
  color: #d64e5d;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.quest-subtitle {
  max-width: 36rem;
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.45;
  color: rgba(32, 50, 58, 0.78);
}

.quest-layout {
  display: grid;
  grid-template-columns: minmax(272px, 320px) minmax(0, 1fr);
  gap: 0.85rem;
}

body.quest-embed-mode .quest-layout {
  grid-template-columns: minmax(252px, 300px) minmax(0, 1fr);
  gap: 0.75rem;
}

.quest-sidebar,
.quest-stage {
  display: grid;
  gap: 1rem;
}

.quest-card {
  background: rgba(255, 253, 247, 0.95);
  border: 1px solid rgba(32, 50, 58, 0.08);
  border-radius: 28px;
  padding: 0.9rem 1rem;
  box-shadow: 0 18px 40px rgba(61, 50, 27, 0.12);
}

body.quest-embed-mode .quest-card {
  border-radius: 24px;
  padding: 0.95rem 1rem;
}

.quest-card h2 {
  margin: 0 0 0.65rem;
  font-size: 1.15rem;
  color: #13311e;
}

.quest-card--hero {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 0.7rem;
  align-items: center;
  background:
    linear-gradient(155deg, rgba(86, 155, 88, 0.12), rgba(255, 255, 255, 0.92)),
    rgba(255, 253, 247, 0.96);
}

.quest-zoomba {
  width: 100%;
  max-height: 110px;
  height: auto;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 12px 20px rgba(17, 34, 20, 0.14));
}

.quest-card--hero h2 {
  font-size: 1.3rem;
}

.quest-card--hero p:last-child,
.stat-copy,
.controls-text {
  margin: 0;
  line-height: 1.55;
  color: rgba(32, 50, 58, 0.82);
}

.stat-row + .stat-row {
  margin-top: 0.85rem;
}

.water-meter {
  position: relative;
  margin-top: 0.38rem;
  width: 100%;
  height: 20px;
  border-radius: 999px;
  background: rgba(138, 214, 239, 0.22);
  overflow: hidden;
  border: 2px solid rgba(73, 140, 173, 0.22);
}

.water-meter span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, #54c9f2, #3aa2d4 80%);
  border-radius: inherit;
  transition: width 180ms ease;
}

.sidebar-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.small-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(214, 78, 93, 0.1);
  color: #9e3642;
  font-size: 0.8rem;
  font-weight: 800;
}

.sticker-tray {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.sticker-badge {
  display: grid;
  gap: 0.3rem;
  place-items: center;
  padding: 0.55rem 0.3rem;
  border-radius: 18px;
  border: 2px dashed rgba(32, 50, 58, 0.12);
  background: rgba(255, 247, 221, 0.7);
  min-height: 78px;
}

.sticker-badge--earned {
  border-style: solid;
  border-color: rgba(245, 165, 59, 0.28);
  background:
    radial-gradient(circle at top, rgba(255, 241, 194, 0.86), rgba(255, 232, 158, 0.72)),
    rgba(255, 247, 221, 0.92);
}

.sticker-badge__icon {
  font-size: 1.7rem;
}

.sticker-badge__label {
  text-align: center;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.2;
  color: #22412d;
}

.quest-stage {
  align-content: start;
}

.quest-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.level-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.level-tab,
.toolbar-btn,
.move-btn,
.big-btn,
.ghost-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.level-tab {
  padding: 0.62rem 0.95rem;
  border-radius: 999px;
  background: rgba(255, 251, 241, 0.95);
  border: 1px solid rgba(32, 50, 58, 0.08);
  font-size: 0.85rem;
  font-weight: 800;
  color: #2a4035;
}

.level-tab[aria-current="true"] {
  background: linear-gradient(180deg, #ffdf7b, #f5b63c);
  color: #3f2909;
}

.level-tab:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.toolbar-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.toolbar-btn,
.ghost-btn {
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: rgba(28, 60, 42, 0.12);
  color: #1e4730;
  font-weight: 800;
}

.toolbar-btn:hover,
.level-tab:hover,
.move-btn:hover,
.big-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.canvas-shell {
  position: relative;
  border-radius: 34px;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  border: 12px solid rgba(44, 78, 45, 0.9);
  box-shadow: 0 28px 60px rgba(41, 34, 18, 0.24);
  background:
    linear-gradient(180deg, rgba(20, 62, 38, 0.2), transparent 24%),
    linear-gradient(180deg, #f5e8ba 0%, #ecd898 100%);
}

body.quest-embed-mode .canvas-shell {
  border-radius: 28px;
  border-width: 10px;
}

#game-canvas {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  aspect-ratio: 3 / 2;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(22, 41, 25, 0.42);
  backdrop-filter: blur(8px);
}

.overlay.is-visible {
  display: grid;
}

.overlay-card {
  width: min(100%, 520px);
  border-radius: 30px;
  padding: 1.4rem;
  background: linear-gradient(180deg, rgba(255, 248, 221, 0.98), rgba(255, 241, 208, 0.96));
  box-shadow: 0 24px 52px rgba(29, 23, 11, 0.28);
  text-align: center;
}

.overlay-card h2 {
  margin: 0.3rem 0 0.65rem;
  font-size: 2rem;
  line-height: 0.98;
  color: #16321e;
}

.overlay-card p {
  margin: 0;
  line-height: 1.55;
  color: rgba(32, 50, 58, 0.8);
}

.overlay-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.big-btn {
  padding: 0.9rem 1.4rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffdc6d, #f5b63c);
  color: #4d340e;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(165, 114, 28, 0.25);
}

.controls-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.8rem;
  align-items: center;
  padding: 0.55rem 0.2rem 0;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(2, 58px);
  gap: 0.45rem;
}

.move-btn {
  width: 58px;
  height: 58px;
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #f3e7bc);
  color: #24442f;
  font-size: 1.1rem;
  font-weight: 900;
  box-shadow: 0 10px 18px rgba(60, 48, 24, 0.12);
}

.move-btn--up {
  grid-column: 2;
  grid-row: 1;
}

.move-btn--left {
  grid-column: 1;
  grid-row: 2;
}

.move-btn--right {
  grid-column: 3;
  grid-row: 2;
}

.move-btn--down {
  grid-column: 2;
  grid-row: 2;
}

.controls-title {
  margin: 0 0 0.2rem;
  font-size: 0.92rem;
  font-weight: 900;
  color: #173621;
}

@media (max-width: 1080px) {
  .quest-layout {
    grid-template-columns: 1fr;
  }

  .quest-sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .quest-card--hero {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  body {
    padding: 12px;
  }

  body.quest-embed-mode {
    padding: 0;
  }

  .quest-header {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .quest-sidebar {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .quest-card--hero {
    grid-template-columns: 88px minmax(0, 1fr);
  }
}
