:root {
  --bg-1: #f9f6ee;
  --bg-2: #e6f3f4;
  --ink: #202335;
  --muted: #5d6078;
  --panel: rgba(255, 255, 255, 0.88);
  --accent: #ff7f50;
  --accent-2: #2a9d8f;
  --danger: #cf3f3f;
  --shadow: 0 12px 34px rgba(30, 45, 80, 0.14);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Atkinson Hyperlegible", sans-serif;
  background:
    radial-gradient(80vw 60vh at 5% 3%, rgba(255, 188, 111, 0.48), transparent 58%),
    radial-gradient(90vw 80vh at 97% 6%, rgba(56, 176, 163, 0.31), transparent 64%),
    linear-gradient(165deg, var(--bg-1), var(--bg-2));
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
}

p {
  margin: 0;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

.auth-body {
  display: grid;
  place-items: center;
  padding: 1.2rem;
}

.auth-shell {
  width: min(420px, 100%);
  border-radius: 22px;
  box-shadow: var(--shadow);
  background: var(--panel);
  backdrop-filter: blur(4px);
  padding: 1.2rem;
  display: grid;
  gap: 1rem;
}

.error-banner {
  color: #fff;
  background: var(--danger);
  border-radius: 12px;
  padding: 0.55rem 0.8rem;
}

.auth-footnote {
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(7px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  display: grid;
  gap: 0.8rem;
  padding: 0.9rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand h1 {
  font-size: 1.15rem;
}

.brand p {
  color: var(--muted);
  font-size: 0.86rem;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #ffd166);
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.main-nav a {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.9rem;
  padding: 0.42rem 0.76rem;
  transition: all 160ms ease;
}

.main-nav a.active,
.main-nav a:hover {
  border-color: transparent;
  background: linear-gradient(120deg, #ffd166, #ff8a5b);
}

.main-nav a.locked {
  opacity: 0.44;
  color: #4b4e63;
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 0, 0, 0.12);
  filter: grayscale(1);
  pointer-events: none;
}

.page-shell {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.panel {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--panel);
  backdrop-filter: blur(4px);
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.grid-2 {
  display: grid;
  gap: 1rem;
}

.canvas-column {
  display: grid;
  gap: 0.6rem;
}

.stack-form {
  display: grid;
  gap: 0.8rem;
}

.stack-form.compact {
  gap: 0.6rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
  color: var(--muted);
}

input,
select,
button {
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  padding: 0.58rem 0.7rem;
  font: inherit;
}

button {
  cursor: pointer;
  color: #fff;
  font-weight: 700;
  border: none;
  background: linear-gradient(120deg, var(--accent), #ff9d5f);
}

button.warn {
  background: linear-gradient(120deg, #de5e5e, #c74343);
}

.ghost-btn {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

button:disabled,
.ghost-btn.locked {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  min-width: 42px;
  min-height: 42px;
  padding: 0.4rem 0.55rem;
  font-size: 1.1rem;
  line-height: 1;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0.4rem 0;
}

.stat-card {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0.7rem;
  display: grid;
  gap: 0.15rem;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.stat-card strong {
  font-family: "Fredoka", sans-serif;
  font-size: 1.4rem;
}

.canvas-shell {
  width: 100%;
  max-width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(170deg, #d9f5ff, #fef4da);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.canvas-shell.tall {
  aspect-ratio: 9 / 14;
  margin-inline: auto;
}

.canvas-shell.sprite-stage {
  aspect-ratio: 16 / 10;
  width: min(100%, 360px);
  margin-inline: 0;
  background:
    radial-gradient(65% 80% at 50% 18%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, #eff8ff 0%, #f5f3e7 64%, #e7f0d8 100%);
}

#child-stage {
  position: relative;
}

#child-canvas {
  width: 100%;
  height: 100%;
}

#child-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border: none;
  border-radius: 0;
  touch-action: none;
}

body.canvas-only .topbar,
body.canvas-only .panel > :not(.grid-2) {
  display: none;
}

body.canvas-only .page-shell {
  max-width: 100vw;
  padding: 0;
}

body.canvas-only .panel {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
}

body.canvas-only .grid-2 {
  grid-template-columns: 1fr;
}

body.canvas-only .grid-2 > :first-child {
  display: none;
}

body.canvas-only #child-stage {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  border: none;
  aspect-ratio: auto;
  touch-action: none;
}

body.canvas-only #child-canvas {
  width: 100%;
  height: 100%;
}

.quest-toggle-btn {
  position: absolute;
  right: 0.9rem;
  bottom: 0.9rem;
  width: 64px;
  height: 64px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.92);
  padding: 0.2rem;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 42;
}

.quest-toggle-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

body.canvas-only .quest-toggle-btn {
  display: inline-flex;
}

.child-quest-board {
  position: absolute;
  top: 8%;
  right: 2.5%;
  width: min(86vw, 440px);
  max-height: 84%;
  overflow: auto;
  border-radius: 24px 16px 22px 18px;
  padding: 1rem 0.95rem 0.9rem;
  border: 6px solid #60371b;
  background:
    linear-gradient(180deg, rgba(75, 42, 21, 0.34), rgba(32, 18, 8, 0.5)),
    url("/static/assets/quests/icons/board-texture.png");
  background-size: cover, cover;
  background-position: center, center;
  box-shadow:
    0 22px 38px rgba(13, 8, 4, 0.5),
    inset 0 0 0 2px rgba(255, 227, 187, 0.24),
    inset 0 -12px 22px rgba(0, 0, 0, 0.3);
  transform: translateX(118%) rotate(2deg);
  opacity: 0;
  pointer-events: none;
  transition: transform 360ms cubic-bezier(0.21, 1.02, 0.35, 1), opacity 250ms ease;
  z-index: 44;
}

.child-quest-board::before,
.child-quest-board::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.child-quest-board::before {
  inset: 8px;
  border-radius: 16px 10px 14px 12px;
  border: 1px solid rgba(255, 226, 178, 0.18);
  box-shadow: inset 0 1px 12px rgba(255, 230, 200, 0.14);
}

.child-quest-board::after {
  inset: 0;
  background:
    radial-gradient(circle at 15px 15px, rgba(44, 24, 10, 0.9) 0 5px, rgba(44, 24, 10, 0) 6px),
    radial-gradient(circle at calc(100% - 15px) 15px, rgba(44, 24, 10, 0.9) 0 5px, rgba(44, 24, 10, 0) 6px),
    radial-gradient(circle at 15px calc(100% - 15px), rgba(44, 24, 10, 0.9) 0 5px, rgba(44, 24, 10, 0) 6px),
    radial-gradient(circle at calc(100% - 15px) calc(100% - 15px), rgba(44, 24, 10, 0.9) 0 5px, rgba(44, 24, 10, 0) 6px);
}

.child-quest-board.open {
  transform: translateX(0) rotate(0deg);
  opacity: 1;
  pointer-events: auto;
}

.child-quest-board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  position: sticky;
  top: 0;
  z-index: 1;
  padding-bottom: 0.35rem;
  background: linear-gradient(180deg, rgba(54, 31, 14, 0.7), rgba(54, 31, 14, 0));
  backdrop-filter: blur(1px);
}

.child-quest-board-header h3 {
  font-family: "Fredoka", sans-serif;
  color: #fff1d6;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.child-quest-board .ghost-btn {
  background: rgba(52, 31, 13, 0.84);
  border-color: rgba(255, 230, 193, 0.45);
  color: #fff1d6;
}

.child-quest-list {
  display: grid;
  gap: 0.62rem;
}

.child-quest-item {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 0.65rem;
  align-items: start;
  border-radius: 12px;
  border: 1px solid rgba(255, 236, 204, 0.3);
  background: rgba(34, 18, 7, 0.42);
  color: #fff4db;
  padding: 0.58rem 0.62rem;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 160ms ease, background 160ms ease;
}

.child-quest-item:hover,
.child-quest-item:focus-visible {
  outline: none;
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(12, 6, 2, 0.35);
  background: rgba(61, 34, 14, 0.55);
}

.child-quest-icon-wrap {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 218, 164, 0.45);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25);
}

.child-quest-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.child-quest-icon--fallback {
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 224, 171, 0.7), rgba(255, 224, 171, 0)),
    linear-gradient(165deg, rgba(255, 232, 197, 0.2), rgba(90, 50, 22, 0.5));
}

.child-quest-copy {
  min-width: 0;
}

.child-quest-item h4 {
  margin: 0 0 0.18rem 0;
  font-family: "Fredoka", sans-serif;
  font-size: 0.97rem;
  line-height: 1.2;
  color: #fff7e6;
}

.child-quest-item p {
  margin: 0 0 0.42rem 0;
  font-size: 0.84rem;
  line-height: 1.25;
  color: rgba(255, 239, 214, 0.95);
}

.child-quest-item .button-row {
  display: flex;
  justify-content: flex-start;
}

.child-quest-item .quest-pill {
  background: rgba(255, 214, 129, 0.2);
  color: #fff0cb;
  border: 1px solid rgba(255, 228, 179, 0.32);
}

body.canvas-only .child-quest-board {
  width: min(88vw, 500px);
  max-height: 86%;
}

body.canvas-only .child-quest-board .quest-pill {
  font-size: 0.8rem;
}

body.canvas-only .child-quest-board .muted {
  color: #ffe8cb;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.event-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem;
}

.quest-board {
  display: grid;
  gap: 0.55rem;
}

.quest-board.locked {
  opacity: 0.58;
  filter: grayscale(0.35);
}

.quest-card {
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.92);
  padding: 0.6rem 0.7rem;
  display: grid;
  gap: 0.4rem;
}

.quest-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.quest-card h4 {
  margin: 0;
  font-family: "Fredoka", sans-serif;
  font-size: 1rem;
}

.quest-pill {
  border-radius: 999px;
  background: rgba(42, 157, 143, 0.14);
  color: #1b6f65;
  font-size: 0.75rem;
  padding: 0.16rem 0.52rem;
}

.quest-card p {
  color: var(--muted);
  font-size: 0.87rem;
}

.quest-card .button-row button {
  font-size: 0.86rem;
  padding: 0.42rem 0.62rem;
}

.quest-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.event-list li {
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.9);
  padding: 0.5rem 0.65rem;
  font-size: 0.88rem;
}

@media (min-width: 880px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    align-items: center;
    padding: 0.9rem 1.3rem;
  }

  .page-shell {
    padding: 1.2rem;
  }

  .grid-2 {
    grid-template-columns: 320px 1fr;
  }

  .canvas-column {
    justify-items: center;
    align-content: start;
  }

  .canvas-shell.tall {
    width: min(100%, 680px, calc((100vh - 220px) * 0.642857));
  }
}
