@font-face {
  font-family: "Secular One";
  src: url("assets/fonts/SecularOne-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --sky: #4ab8e9;
  --sky-deep: #146b8d;
  --sky-soft: #dff6ff;
  --sand: #f4c977;
  --sand-light: #ffe5a1;
  --sand-dark: #d39543;
  --cream: #fff8ea;
  --cream-deep: #f8ebd4;
  --brown: #5b3a2b;
  --brown-deep: #38251d;
  --brown-soft: #8a6047;
  --orange: #f6a21a;
  --orange-light: #ffc84f;
  --green: #1f7a35;
  --green-light: #bfe982;
  --red: #b44332;
  --purple: #8255d8;
  --line: #c58b47;
  --white: #fffdf7;
  --shadow: rgba(56, 37, 29, 0.2);
  --shadow-strong: rgba(56, 37, 29, 0.32);
  --radius-card: 18px;
  --radius-panel: 24px;
  --radius-control: 12px;
  --font-body: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  --font-display: "Secular One", "Arial Rounded MT Bold", "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--sky);
  /* No rubber-band bounce or pull-to-refresh on the game screen. */
  overscroll-behavior: none;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  /* iOS 100vh ignores the browser bar, making the page scrollable and bouncy. */
  min-height: 100dvh;
  margin: 0;
  /* Keeps pinch zoom but stops double-tap zoom on fast button taps. */
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  color: var(--brown-deep);
  background: var(--sky);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button,
h1,
h2,
h3 {
  font-family: var(--font-display);
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--brown-deep);
  outline-offset: 3px;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 50;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  color: var(--cream);
  background: var(--brown-deep);
  border-radius: 8px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.screen {
  min-height: 100dvh;
}

.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px solid transparent;
  border-radius: var(--radius-control);
  padding: 10px 18px;
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.1;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button:active {
  transform: translateY(1px);
}

.button-primary {
  color: var(--brown-deep);
  background: var(--orange);
  border-color: var(--brown-deep);
  box-shadow: 0 4px 0 var(--brown-deep);
}

.button-primary:hover {
  background: var(--orange-light);
  box-shadow: 0 6px 0 var(--brown-deep);
}

.button-primary:active {
  box-shadow: 0 2px 0 var(--brown-deep);
}

.button-outline {
  color: var(--brown-deep);
  background: rgba(255, 248, 234, 0.82);
  border-color: var(--brown-deep);
}

.button-outline:hover {
  color: var(--cream);
  background: var(--brown-deep);
}

.button-quiet {
  color: var(--brown-deep);
  background: transparent;
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.button-quiet:hover {
  color: var(--brown-deep);
  background: var(--cream);
}

.button-large {
  min-height: 54px;
  padding-inline: 24px;
  font-size: 1.05rem;
}

.button-wide {
  width: 100%;
  margin-top: 10px;
}

.kicker {
  margin: 0 0 9px;
  color: var(--brown-deep);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.wordmark {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  width: max-content;
  color: var(--orange);
  font-family: var(--font-display);
  font-size: 1.32rem;
  font-weight: 1000;
  letter-spacing: -0.08em;
  line-height: 0.78;
  text-decoration: none;
  text-shadow: 1px 2px 0 var(--brown-deep), -1px -1px 0 var(--brown-deep), 2px 0 0 var(--brown-deep), 0 3px 0 var(--brown-deep);
}

.wordmark-action {
  padding-left: 0;
}

.wordmark-town {
  color: var(--orange-light);
  padding-left: 7px;
}

.wordmark-flag {
  position: absolute;
  top: -9px;
  left: 23px;
  width: 2px;
  height: 11px;
  background: var(--brown-deep);
  transform: rotate(-8deg);
}

.wordmark-flag::after {
  content: "";
  position: absolute;
  top: 0;
  left: 1px;
  width: 10px;
  height: 7px;
  background: var(--red);
  clip-path: polygon(0 0, 100% 22%, 0 100%);
}

/* The welcome sky is the first focal point. Clouds add the requested sense of place. */
.welcome-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  overflow: hidden;
  background-color: var(--sky);
  background-image: linear-gradient(90deg, rgba(255, 248, 234, 0.28) 0%, rgba(255, 248, 234, 0.08) 46%, rgba(255, 248, 234, 0) 72%), url("assets/dashboard-cloud-sky.webp");
  background-position: center, center;
  background-repeat: no-repeat;
  background-size: cover, cover;
}

.sky-decor,
.sky-decor::before,
.sky-decor::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sky-decor {
  z-index: -1;
  overflow: hidden;
}

.sky-decor::before {
  content: "";
  top: auto;
  height: 32%;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.14));
}

.sun-disc {
  position: absolute;
  top: 9%;
  right: 10%;
  width: clamp(84px, 11vw, 146px);
  aspect-ratio: 1;
  border: 7px solid rgba(255, 255, 255, 0.48);
  border-radius: 50%;
  background: #ffda62;
  box-shadow: 0 0 0 12px rgba(255, 255, 255, 0.14);
}

.cloud,
.scene-cloud {
  position: absolute;
  width: 150px;
  height: 44px;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.74);
  filter: drop-shadow(0 8px 0 rgba(83, 158, 184, 0.1));
}

.cloud::before,
.cloud::after,
.scene-cloud::before,
.scene-cloud::after {
  content: "";
  position: absolute;
  bottom: 0;
  border-radius: 50%;
  background: inherit;
}

.cloud::before,
.scene-cloud::before {
  left: 20px;
  width: 62px;
  height: 62px;
}

.cloud::after,
.scene-cloud::after {
  right: 20px;
  width: 80px;
  height: 80px;
}

.cloud-one {
  top: 14%;
  left: -190px;
  animation: cloud-drift-one 38s linear infinite;
}

.cloud-two {
  top: 31%;
  left: -220px;
  width: 112px;
  height: 34px;
  opacity: 0.56;
  animation: cloud-drift-two 48s linear 5s infinite;
}

.cloud-three {
  top: 59%;
  left: -200px;
  width: 210px;
  opacity: 0.38;
  animation: cloud-drift-three 55s linear 11s infinite;
}

.bird {
  position: absolute;
  width: 22px;
  height: 9px;
  border-top: 3px solid rgba(56, 37, 29, 0.52);
  border-radius: 50% 50% 0 0;
  transform: rotate(-8deg);
}

.bird::after {
  content: "";
  position: absolute;
  left: 12px;
  top: -3px;
  width: 18px;
  height: 8px;
  border-top: 3px solid rgba(56, 37, 29, 0.52);
  border-radius: 50% 50% 0 0;
  transform: rotate(13deg);
}

.bird-one {
  top: 23%;
  left: 17%;
}

.bird-two {
  top: 28%;
  left: 21%;
  transform: scale(0.7) rotate(-8deg);
}

.welcome-topbar,
.welcome-content,
.welcome-footer {
  position: relative;
  z-index: 1;
  width: min(1380px, calc(100% - 48px));
  margin-inline: auto;
}

.welcome-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 30px;
}

.welcome-content {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(420px, 1.15fr);
  align-items: center;
  gap: clamp(30px, 7vw, 120px);
  flex: 1;
  padding-block: clamp(58px, 8vw, 110px);
}

.welcome-copy {
  max-width: 610px;
  padding: 24px;
  background: rgba(255, 248, 234, 0.82);
  border: 2px solid rgba(56, 37, 29, 0.58);
  border-radius: 22px;
  box-shadow: 0 7px 0 rgba(56, 37, 29, 0.18);
}

.welcome-copy h1 {
  max-width: 630px;
  margin: 0;
  color: var(--brown-deep);
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 6.4vw, 6.3rem);
  letter-spacing: -0.065em;
  line-height: 0.96;
}

.welcome-lede {
  max-width: 560px;
  margin: 24px 0 0;
  color: var(--brown);
  font-size: clamp(1rem, 1.4vw, 1.28rem);
  font-weight: 650;
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
}

.inline-status {
  min-height: 26px;
  margin: 20px 0 0;
  color: var(--brown);
  font-size: 0.88rem;
  font-weight: 700;
}

.welcome-scene {
  position: relative;
  min-height: min(54vw, 610px);
  overflow: hidden;
  border: 3px solid var(--brown-deep);
  border-radius: 44% 56% 17px 17px / 18% 16% 17px 17px;
  background: linear-gradient(180deg, #75d0ef 0%, #b5e8e4 43%, #8fce74 43%, #64ac56 100%);
  box-shadow: 0 11px 0 rgba(56, 37, 29, 0.24);
  transform: rotate(1.5deg);
}

.scene-cloud {
  z-index: 1;
  width: 160px;
  height: 40px;
  opacity: 0.78;
}

.scene-cloud-back {
  top: 14%;
  left: 8%;
  transform: scale(0.8);
}

.scene-cloud-front {
  top: 25%;
  right: -3%;
  transform: scale(1.1);
}

.scene-hill {
  position: absolute;
  bottom: -23%;
  border-radius: 50% 50% 0 0;
}

.scene-hill-back {
  left: -15%;
  width: 70%;
  height: 64%;
  background: #76bb5f;
  transform: rotate(-6deg);
}

.scene-hill-front {
  right: -21%;
  width: 82%;
  height: 66%;
  background: #4d9850;
  transform: rotate(7deg);
}

.scene-town {
  position: absolute;
  z-index: 2;
  right: 11%;
  bottom: 11%;
  left: 11%;
  height: 52%;
  border: 3px solid rgba(91, 58, 43, 0.7);
  border-radius: 48% 45% 22px 22px;
  background: #eac676;
  box-shadow: inset 0 -18px 0 rgba(179, 124, 52, 0.2);
}

.scene-road {
  position: absolute;
  right: 14%;
  bottom: -9%;
  left: 23%;
  height: 78%;
  border: 18px solid #fff0bb;
  border-bottom: 0;
  border-radius: 47% 55% 0 0;
  transform: rotate(-15deg);
}

.scene-node {
  position: absolute;
  display: grid;
  width: clamp(42px, 7vw, 74px);
  aspect-ratio: 1;
  place-items: center;
  color: var(--cream);
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2vw, 1.85rem);
  font-weight: 900;
  border: 4px solid var(--cream);
  border-radius: 50%;
  background: var(--sky);
  box-shadow: 0 7px 0 var(--brown-deep);
}

.scene-node-one {
  left: 17%;
  bottom: 21%;
}

.scene-node-two {
  top: 25%;
  left: 45%;
  background: var(--orange);
}

.scene-node-three {
  right: 13%;
  bottom: 31%;
  background: var(--purple);
}

.scene-tower {
  position: absolute;
  z-index: 2;
  bottom: 8%;
  width: 54px;
  height: 105px;
  border: 3px solid var(--brown-deep);
  border-radius: 7px 7px 2px 2px;
  background: #e9954f;
  box-shadow: inset 0 -12px 0 rgba(91, 58, 43, 0.14);
}

.scene-tower::before {
  content: "";
  position: absolute;
  top: -19px;
  right: -8px;
  left: -8px;
  height: 25px;
  border: 3px solid var(--brown-deep);
  border-radius: 50% 50% 4px 4px;
  background: #f3c45c;
}

.scene-tower::after {
  content: "";
  position: absolute;
  right: 9px;
  bottom: 14px;
  left: 9px;
  height: 26px;
  border: 3px solid var(--brown-deep);
  border-radius: 50% 50% 0 0;
  background: #73c3dc;
}

.scene-tower-one {
  left: 16%;
}

.scene-tower-two {
  right: 17%;
  height: 77px;
  background: #d66d52;
}

.scene-tree {
  position: absolute;
  z-index: 3;
  bottom: 6%;
  width: 25px;
  height: 78px;
  border-radius: 50% 50% 25% 25%;
  background: #4a9b47;
  box-shadow: 10px 8px 0 -3px #6fb851, -10px 20px 0 -4px #6fb851;
}

.scene-tree::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 7px;
  width: 11px;
  height: 19px;
  background: var(--brown);
}

.scene-tree-one {
  left: 7%;
}

.scene-tree-two {
  right: 7%;
  transform: scale(0.76);
}

.scene-caption {
  position: absolute;
  z-index: 4;
  right: 18px;
  bottom: 18px;
  left: 18px;
  padding: 10px 14px;
  color: var(--cream);
  background: rgba(56, 37, 29, 0.84);
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 800;
  text-align: center;
}

.welcome-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 28px;
  color: var(--brown);
  font-size: 0.76rem;
  font-weight: 750;
}

.footer-separator {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brown);
}

@keyframes cloud-drift-one {
  from { transform: translateX(0); }
  to { transform: translateX(calc(100vw + 420px)); }
}

@keyframes cloud-drift-two {
  from { transform: translateX(0); }
  to { transform: translateX(calc(100vw + 470px)); }
}

@keyframes cloud-drift-three {
  from { transform: translateX(0); }
  to { transform: translateX(calc(100vw + 520px)); }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes dashboard-cloud-drift {
  from { background-position: 47% center; transform: scale(1.02); }
  to { background-position: 53% center; transform: scale(1.07); }
}

/* The signed-in view reserves the largest surface for the quest decision. */
.dashboard-screen {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  color: var(--brown-deep);
  background: var(--sky);
}

.dashboard-screen::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: -3%;
  pointer-events: none;
  background: url("assets/dashboard-cloud-sky.webp") 48% center / cover no-repeat;
  animation: dashboard-cloud-drift 28s ease-in-out infinite alternate;
  will-change: background-position, transform;
}

.dashboard-layout,
.mobile-nav {
  position: relative;
  z-index: 1;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  min-height: 100dvh;
}

.side-nav {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 28px 11px 18px;
  background: var(--cream);
  border-right: 3px solid var(--brown-deep);
  box-shadow: 7px 0 0 rgba(56, 37, 29, 0.13);
}

.wordmark-side {
  align-self: center;
  margin-bottom: 34px;
  font-size: 1rem;
}

.desktop-nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 7px 4px;
  color: var(--brown-deep);
  background: transparent;
  border: 2px solid transparent;
  border-radius: 9px;
  font-size: 0.71rem;
  font-weight: 850;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease, border-color 150ms ease;
}

.nav-item:hover {
  background: var(--cream-deep);
  border-color: var(--line);
  transform: translateY(-1px);
}

.nav-item.is-active {
  background: var(--orange-light);
  border-color: var(--brown-deep);
  box-shadow: 0 3px 0 var(--brown-deep);
}

.nav-icon {
  width: 25px;
  height: 25px;
  flex: none;
}

.nav-item[data-view="community"] {
  min-height: 62px;
  padding: 5px 3px;
}

.nav-item[data-view="community"] .nav-icon {
  width: 34px;
  height: 32px;
}

.nav-logout {
  margin-top: auto;
}

.dashboard-main {
  min-width: 0;
  padding: 25px clamp(18px, 3.3vw, 54px) 42px;
}

.dashboard-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1530px;
  margin: 0 auto 21px;
}

.page-heading h1 {
  margin: 0;
  color: var(--brown-deep);
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.6vw, 3.45rem);
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.api-status {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  color: var(--brown-deep);
  background: rgba(255, 248, 234, 0.78);
  border: 2px solid rgba(56, 37, 29, 0.56);
  border-radius: 10px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: none;
  border: 2px solid var(--brown-deep);
  border-radius: 50%;
  background: var(--orange);
}

.api-status[data-status="online"] .status-dot {
  background: var(--green);
}

.api-status[data-status="error"] .status-dot {
  background: var(--red);
}

.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  color: var(--brown-deep);
  background: var(--cream);
  border: 2px solid var(--brown-deep);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 150ms ease, background-color 150ms ease;
}

.icon-button:hover {
  background: var(--orange-light);
  transform: rotate(8deg);
}

.icon-button svg {
  width: 22px;
  height: 22px;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 10px 4px 5px;
  color: var(--brown-deep);
  background: var(--cream);
  border: 2px solid var(--brown-deep);
  border-radius: 30px;
  font-size: 0.82rem;
  font-weight: 850;
}

.player-chip #player-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  color: var(--cream);
  background: var(--sky-deep);
  border: 2px solid var(--brown-deep);
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 900;
}

.avatar-small {
  width: 30px;
  height: 30px;
}

.view-root {
  width: 100%;
  max-width: 1530px;
  margin: 0 auto;
}

.home-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 304px;
  align-items: start;
  gap: 18px;
}

.map-panel,
.profile-card,
.source-card,
.badge-panel,
.activity-panel,
.content-view,
.settings-view {
  background: var(--cream);
  border: 3px solid var(--brown-deep);
}

.map-panel {
  min-width: 0;
  padding: 13px;
  border-radius: var(--radius-panel);
  box-shadow: 0 7px 0 rgba(56, 37, 29, 0.24);
}

.map-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 10px 13px;
}

.map-panel-header h2,
.content-view h2,
.settings-view h2,
.login-dialog h2 {
  margin: 0;
  color: var(--brown-deep);
  font-family: var(--font-display);
  letter-spacing: -0.04em;
  line-height: 1.02;
}

.map-panel-header h2 {
  max-width: 680px;
  font-size: clamp(1.5rem, 2.7vw, 2.5rem);
}

.map-panel-header p {
  max-width: 210px;
  margin: 2px 0 0;
  color: var(--brown-soft);
  font-size: 0.8rem;
  font-weight: 750;
  text-align: right;
}

.map-board {
  position: relative;
  min-height: min(67dvh, 680px);
  overflow: hidden;
  border: 3px solid var(--brown);
  border-radius: 16px;
  background: var(--sand);
  isolation: isolate;
}

.map-board::before,
.map-board::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  background: rgba(255, 229, 161, 0.7);
}

.map-board::before {
  top: -15%;
  left: -9%;
  width: 53%;
  height: 57%;
  transform: rotate(16deg);
}

.map-board::after {
  right: -14%;
  bottom: -16%;
  width: 63%;
  height: 55%;
  transform: rotate(-18deg);
}

.map-sun {
  position: absolute;
  top: 7%;
  right: 12%;
  width: 105px;
  height: 54px;
  border-radius: 100px 100px 0 0;
  background: rgba(255, 234, 166, 0.72);
}

.map-route {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.map-route path {
  fill: none;
  stroke: rgba(255, 245, 192, 0.98);
  stroke-linecap: round;
  stroke-width: 20;
}

.map-route .route-shadow {
  stroke: rgba(190, 133, 54, 0.58);
  stroke-width: 26;
}

.map-cactus {
  position: absolute;
  z-index: 2;
  width: 19px;
  height: 74px;
  border-radius: 18px 18px 8px 8px;
  background: #77b54d;
  box-shadow: 0 8px 0 rgba(174, 123, 47, 0.21);
}

.map-cactus::before,
.map-cactus::after {
  content: "";
  position: absolute;
  width: 21px;
  height: 31px;
  border: 9px solid #77b54d;
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
}

.map-cactus::before {
  top: 23px;
  left: -19px;
  transform: rotate(-90deg);
}

.map-cactus::after {
  top: 35px;
  right: -18px;
  transform: rotate(90deg);
}

.cactus-one {
  top: 10%;
  left: 7%;
  transform: scale(0.68);
}

.cactus-two {
  right: 8%;
  bottom: 12%;
  transform: scale(0.82) rotate(8deg);
}

.cactus-three {
  right: 5%;
  top: 24%;
  transform: scale(0.52);
}

.map-node {
  position: absolute;
  z-index: 3;
  top: var(--node-y);
  left: var(--node-x);
  width: 104px;
  transform: translate(-50%, -50%);
}

.node-note {
  position: absolute;
  bottom: 88px;
  left: 50%;
  width: 184px;
  min-height: 82px;
  padding: 12px 14px;
  color: var(--brown-deep);
  background: var(--cream);
  border: 3px solid var(--brown);
  border-radius: 14px;
  box-shadow: 0 5px 0 rgba(91, 58, 43, 0.26);
  transform: translateX(-50%);
}

.node-note::after {
  content: "";
  position: absolute;
  bottom: -13px;
  left: 50%;
  width: 20px;
  height: 20px;
  background: var(--cream);
  border-right: 3px solid var(--brown);
  border-bottom: 3px solid var(--brown);
  transform: translateX(-50%) rotate(45deg);
}

.node-note strong,
.node-note span {
  display: block;
}

.node-note strong {
  font-size: 0.92rem;
  line-height: 1.15;
}

.node-note span {
  margin-top: 5px;
  color: var(--green);
  font-size: 0.77rem;
  font-weight: 900;
}

.node-note .node-subtitle {
  color: var(--brown-soft);
  font-weight: 750;
}

.map-node:nth-of-type(2) .node-note,
.map-node:nth-of-type(4) .node-note {
  bottom: auto;
  top: 88px;
}

.map-node:nth-of-type(1) .node-note {
  transform: translateX(-38%);
}

.map-node:nth-of-type(4) .node-note {
  transform: translateX(-62%);
}

.map-node:nth-of-type(2) .node-note::after,
.map-node:nth-of-type(4) .node-note::after {
  top: -13px;
  bottom: auto;
  border-top: 3px solid var(--brown);
  border-left: 3px solid var(--brown);
  border-right: 0;
  border-bottom: 0;
}

.node-orb {
  position: relative;
  width: 118px;
  height: 112px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease;
}

.node-art {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

.node-orb:hover {
  filter: brightness(1.08) saturate(1.1);
  transform: translateY(-4px) scale(1.05);
}

.node-orb:active {
  transform: translateY(2px) scale(0.98);
}

.node-orb::after {
  display: none;
}

.node-lock-badge {
  position: absolute;
  right: 6px;
  bottom: 4px;
  width: 30px;
  height: 30px;
  padding: 5px;
  color: var(--cream);
  background: var(--brown-deep);
  border: 2px solid var(--cream);
  border-radius: 50%;
  box-shadow: 0 2px 0 rgba(56, 37, 29, 0.35);
  pointer-events: none;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  padding: 11px 7px 1px;
  color: var(--brown-soft);
  font-size: 0.75rem;
  font-weight: 800;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-mark {
  width: 11px;
  height: 11px;
  border: 2px solid var(--brown-deep);
  border-radius: 50%;
  background: var(--sky);
}

.legend-mark.mark-orange {
  background: var(--orange);
}

.legend-mark.mark-purple {
  background: var(--purple);
}

.side-rail {
  display: grid;
  align-content: start;
  gap: 12px;
}

.profile-card {
  position: relative;
  padding: 18px;
  overflow: hidden;
  border-radius: 24px 24px 10px 10px;
  box-shadow: 0 7px 0 rgba(56, 37, 29, 0.21);
}

.profile-card::before {
  content: "";
  position: absolute;
  top: -55px;
  right: -42px;
  width: 145px;
  height: 145px;
  border-radius: 50%;
  background: var(--sky-soft);
}

.profile-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-large {
  width: 64px;
  height: 64px;
  font-size: 1.35rem;
  color: var(--brown-deep);
  background: var(--orange);
}

.profile-name {
  min-width: 0;
}

.profile-name strong {
  display: block;
  overflow: visible;
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-size: 1.1rem;
  text-overflow: clip;
  white-space: normal;
}

.profile-name span {
  display: block;
  margin-top: 3px;
  color: var(--brown-soft);
  font-size: 0.78rem;
  font-weight: 750;
}

.profile-divider {
  height: 2px;
  margin: 17px 0 14px;
  background: var(--cream-deep);
}

.profile-source-label {
  margin: 0;
  color: var(--brown-soft);
  font-size: 0.73rem;
  font-weight: 850;
  text-transform: uppercase;
}

.profile-source-value {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.source-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 11px;
  border-radius: 10px;
  background: var(--brown-deep);
  color: var(--cream);
}

.source-item {
  min-width: 0;
  padding: 9px 8px;
  border: 1px solid rgba(255, 248, 234, 0.24);
  border-radius: 7px;
}

.source-item strong,
.source-item span {
  display: block;
}

.source-item strong {
  font-family: var(--font-display);
  font-size: 1.23rem;
}

.source-item span {
  margin-top: 2px;
  color: #ffe8ba;
  font-size: 0.68rem;
  font-weight: 750;
}

.badge-panel,
.activity-panel {
  padding: 14px;
  border-radius: 10px;
}

.compact-empty {
  margin: 0;
  color: var(--brown-soft);
  font-size: 0.78rem;
  font-weight: 750;
}

.rail-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.rail-heading h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.03rem;
}

.rail-link {
  padding: 2px;
  color: var(--sky-deep);
  background: transparent;
  border: 0;
  font-size: 0.72rem;
  font-weight: 900;
  text-decoration: underline;
  cursor: pointer;
}

.rail-link:hover {
  color: var(--brown-deep);
}

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

.badge-item {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  color: var(--brown-deep);
  text-align: center;
}

.badge-medal {
  width: 37px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--cream);
  background: var(--sky-deep);
  border: 2px solid var(--brown-deep);
  border-radius: 50% 50% 44% 44%;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 950;
  clip-path: polygon(50% 0, 66% 9%, 84% 7%, 90% 26%, 100% 42%, 88% 59%, 88% 80%, 67% 85%, 50% 100%, 33% 85%, 12% 80%, 12% 59%, 0 42%, 10% 26%, 16% 7%, 34% 9%);
}

.badge-item:nth-child(2) .badge-medal {
  background: var(--green);
}

.badge-item:nth-child(3) .badge-medal {
  background: var(--orange);
  color: var(--brown-deep);
}

.badge-item:nth-child(4) .badge-medal {
  background: var(--purple);
}

.badge-item span {
  width: 100%;
  overflow: hidden;
  color: var(--brown-soft);
  font-size: 0.62rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.activity-item {
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--cream-deep);
}

.activity-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.activity-mark {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  color: var(--cream);
  background: var(--green);
  border: 2px solid var(--brown-deep);
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 900;
}

.activity-item strong,
.activity-item span {
  display: block;
}

.activity-item strong {
  color: var(--brown);
  font-size: 0.76rem;
  line-height: 1.2;
}

.activity-item span {
  margin-top: 2px;
  color: var(--brown-soft);
  font-size: 0.68rem;
  font-weight: 750;
}

.activity-item time {
  color: #c17a3f;
  font-size: 0.63rem;
  font-weight: 850;
  white-space: nowrap;
}

.activity-mark-1 { background: #f38d17; }
.activity-mark-2 { background: #39a9e8; }

.rail-action {
  width: 100%;
}

.mobile-nav {
  display: none;
}

/* Resource views make the API response inspectable instead of hiding it in a visual mockup. */
.content-view,
.settings-view {
  padding: clamp(18px, 3vw, 32px);
  border-radius: var(--radius-panel);
  box-shadow: 0 7px 0 rgba(56, 37, 29, 0.21);
}

.content-view-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.content-view h2,
.settings-view h2 {
  font-size: clamp(1.8rem, 3.2vw, 3rem);
}

.content-view-header p {
  max-width: 420px;
  margin: 0;
  color: var(--brown-soft);
  font-weight: 700;
}

.resource-section {
  margin-top: 25px;
}

.resource-section:first-of-type {
  margin-top: 0;
}

.resource-section h3 {
  margin: 0 0 10px;
  color: var(--brown-soft);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.resource-list {
  display: grid;
  gap: 9px;
}

.resource-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-width: 0;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
}

.resource-index {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  color: var(--cream);
  background: var(--sky-deep);
  border: 2px solid var(--brown-deep);
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 900;
}

.resource-card:nth-child(2n) .resource-index {
  background: var(--orange);
  color: var(--brown-deep);
}

.resource-card:nth-child(3n) .resource-index {
  background: var(--purple);
}

.resource-card h4,
.resource-card p {
  min-width: 0;
  margin: 0;
}

.resource-card h4 {
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.resource-card p {
  margin-top: 3px;
  color: var(--brown-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.resource-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--sky-deep);
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
}

.resource-link:hover {
  color: var(--brown-deep);
  text-decoration: underline;
}

.resource-link svg {
  width: 18px;
  height: 18px;
}

.empty-state,
.error-state,
.loading-state {
  padding: 24px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: #fffdf8;
}

.empty-state h3,
.error-state h3,
.loading-state h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.18rem;
}

.empty-state h2 {
  margin: 0;
  color: var(--brown-deep);
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.empty-state p,
.error-state p,
.loading-state p {
  max-width: 540px;
  margin: 8px 0 0;
  color: var(--brown-soft);
  font-weight: 700;
}

.page-not-ready-view {
  min-height: min(68dvh, 720px);
  display: grid;
  place-items: center;
  background: rgba(255, 250, 240, 0.96);
}

.page-not-ready-card {
  width: min(100%, 600px);
  display: grid;
  justify-items: center;
  padding: clamp(24px, 5vw, 52px);
  text-align: center;
}

.page-not-ready-card .kicker {
  margin: 17px 0 8px;
  color: var(--brown-soft);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-not-ready-icon {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  color: var(--brown-deep);
  background: var(--orange-light);
  border: 3px solid var(--brown-deep);
  border-radius: 50%;
  box-shadow: 0 4px 0 rgba(56, 37, 29, 0.25);
}

.page-not-ready-icon svg {
  width: 40px;
  height: 40px;
}

.page-not-ready-card > p:not(.kicker) {
  margin: 12px 0 0;
}

.page-not-ready-card .button {
  margin-top: 24px;
}

.error-state {
  border-style: solid;
  border-color: var(--red);
}

.error-state .button {
  margin-top: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(280px, 1.15fr);
  gap: 18px;
  margin-top: 24px;
}

.settings-card {
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
}

.settings-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.settings-card p {
  margin: 8px 0 0;
  color: var(--brown-soft);
  font-size: 0.86rem;
  font-weight: 700;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
}

.switch {
  position: relative;
  width: 58px;
  height: 34px;
  flex: none;
  padding: 3px;
  border: 2px solid var(--brown-deep);
  border-radius: 20px;
  background: var(--cream-deep);
  cursor: pointer;
}

.switch::after {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brown-deep);
  transition: transform 160ms ease, background-color 160ms ease;
}

.switch[aria-checked="true"] {
  background: var(--green-light);
}

.switch[aria-checked="true"]::after {
  background: var(--green);
  transform: translateX(22px);
}

.settings-code {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 13px;
  padding: 10px;
  color: var(--cream);
  background: var(--brown-deep);
  border-radius: 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
}

/* The dialog is the only elevated surface above the welcome world. */
.modal-shell {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(31, 52, 60, 0.55);
}

.login-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 470px);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  padding: 34px clamp(22px, 5vw, 42px) 26px;
  color: var(--brown-deep);
  background: var(--cream);
  border: 3px solid var(--brown-deep);
  border-radius: 22px;
  box-shadow: 0 10px 0 var(--brown-deep);
  animation: dialog-in 180ms ease-out both;
}

.dialog-close {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--brown-deep);
  background: transparent;
  border: 2px solid transparent;
  border-radius: 50%;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.dialog-close:hover {
  background: var(--cream-deep);
  border-color: var(--brown-deep);
}

.login-crest {
  position: relative;
  width: 70px;
  height: 70px;
  margin-bottom: 22px;
  border: 3px solid var(--brown-deep);
  border-radius: 50%;
  background: var(--orange-light);
  box-shadow: 0 5px 0 var(--brown-deep);
}

.crest-roof {
  position: absolute;
  top: 17px;
  left: 17px;
  width: 36px;
  height: 20px;
  border: 3px solid var(--brown-deep);
  border-bottom: 0;
  background: var(--sky);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.crest-body {
  position: absolute;
  right: 21px;
  bottom: 13px;
  left: 21px;
  height: 24px;
  border: 3px solid var(--brown-deep);
  background: var(--sky);
}

.crest-door {
  position: absolute;
  bottom: 13px;
  left: 29px;
  width: 11px;
  height: 17px;
  border: 2px solid var(--brown-deep);
  background: var(--cream);
}

.login-dialog h2 {
  font-size: clamp(2rem, 6vw, 3.1rem);
}

.dialog-description {
  margin: 12px 0 24px;
  color: var(--brown-soft);
  font-size: 0.88rem;
  font-weight: 700;
}

.field-label {
  display: block;
  margin: 14px 0 6px;
  color: var(--brown);
  font-size: 0.8rem;
  font-weight: 900;
}

.field-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  color: var(--brown-deep);
  background: var(--white);
  border: 2px solid var(--brown-soft);
  border-radius: 9px;
}

.field-input::placeholder {
  color: #775f50;
}

.field-input:focus {
  border-color: var(--sky-deep);
  box-shadow: 0 0 0 3px rgba(74, 184, 233, 0.25);
}

.form-message {
  margin: 10px 0 0;
  font-size: 0.8rem;
  font-weight: 850;
}

.form-message-error {
  color: var(--red);
}

.login-note {
  margin: 18px 0 0;
  color: var(--brown-soft);
  font-size: 0.73rem;
  font-weight: 700;
}

.lesson-dialog-shell {
  position: fixed;
  z-index: 35;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.lesson-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 52, 60, 0.56);
}

.lesson-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 650px);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  padding: 30px clamp(20px, 4vw, 34px) 24px;
  color: var(--brown-deep);
  background: var(--cream);
  border: 3px solid var(--brown-deep);
  border-radius: 20px;
  box-shadow: 0 9px 0 rgba(56, 37, 29, 0.3);
  animation: dialog-in 180ms ease-out both;
}

.lesson-dialog h2 {
  max-width: 540px;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  letter-spacing: -0.045em;
  line-height: 1.02;
}

.lesson-dialog-close {
  position: absolute;
  top: 10px;
  right: 11px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--brown-deep);
  background: var(--cream-deep);
  border: 2px solid var(--brown-deep);
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.lesson-preview-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  color: var(--brown-soft);
  background: rgba(255, 229, 161, 0.42);
  border-left: 4px solid var(--orange);
  font-size: 0.76rem;
  font-weight: 750;
  line-height: 1.4;
}

.lesson-dialog-actions,
.quiz-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.lesson-empty-state {
  display: grid;
  gap: 5px;
  margin-top: 18px;
  padding: 16px;
  color: var(--brown-soft);
  background: var(--cream-deep);
  border: 2px dashed var(--line);
  border-radius: 10px;
}

.lesson-empty-state strong {
  color: var(--brown-deep);
  font-size: 0.92rem;
}

.lesson-empty-state span {
  font-size: 0.78rem;
  font-weight: 750;
}

.quiz-preview {
  margin-top: 18px;
  padding: 15px;
  background: #fffdf7;
  border: 2px solid var(--line);
  border-radius: 12px;
}

.quiz-preview-label {
  color: var(--orange);
  font-size: 0.7rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.quiz-preview-note {
  margin-top: 8px;
  font-size: 0.74rem;
}

.quiz-record-content {
  margin: 12px 0 0;
  color: var(--brown-soft);
  font-size: 0.8rem;
  font-weight: 800;
}

.quiz-preview h3 {
  margin: 18px 0 10px;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.quiz-options {
  display: grid;
  gap: 8px;
}

.quiz-option {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 11px;
  color: var(--brown-deep);
  background: var(--cream);
  border: 2px solid rgba(56, 37, 29, 0.32);
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.quiz-option:hover:not(:disabled),
.quiz-option.is-selected {
  background: var(--orange-light);
  border-color: var(--brown-deep);
}

.quiz-option > span {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  color: var(--cream);
  background: var(--brown-soft);
  border-radius: 50%;
  font-size: 0.7rem;
}

.quiz-option.is-correct {
  background: var(--green-light);
  border-color: var(--green);
}

.quiz-option.is-incorrect {
  background: #ffd8cd;
  border-color: var(--red);
}

.quiz-option:disabled {
  cursor: default;
  opacity: 1;
}

.quiz-feedback {
  display: grid;
  gap: 3px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 750;
}

.quiz-feedback.is-correct {
  color: #195c2c;
  background: var(--green-light);
}

.quiz-feedback.is-incorrect {
  color: #8a2b20;
  background: #ffd8cd;
}

.quiz-feedback strong {
  font-size: 0.85rem;
}

.sync-overlay {
  position: fixed;
  z-index: 45;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 39, 52, 0.3);
  backdrop-filter: blur(3px);
}

.sync-dialog {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(350px, calc(100% - 32px));
  padding: 24px 25px 22px;
  color: var(--brown-deep);
  background: var(--cream);
  border: 3px solid var(--brown-deep);
  border-radius: 16px;
  box-shadow: 0 7px 0 rgba(56, 37, 29, 0.28);
  text-align: center;
}

.sync-dialog strong {
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.sync-dialog p {
  margin: 0;
  color: var(--brown-soft);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.35;
}

.sync-spinner {
  width: 38px;
  height: 38px;
  border: 5px solid var(--cream-deep);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: sync-spin 800ms linear infinite;
}

@keyframes sync-spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  z-index: 30;
  bottom: 22px;
  left: 50%;
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 16px;
  color: var(--cream);
  background: var(--brown-deep);
  border: 2px solid var(--cream);
  border-radius: 9px;
  box-shadow: 0 5px 0 rgba(56, 37, 29, 0.3);
  font-size: 0.84rem;
  font-weight: 800;
  text-align: center;
  transform: translateX(-50%);
  animation: toast-in 180ms ease-out both;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

@media (max-width: 1180px) {
  .home-view {
    grid-template-columns: minmax(0, 1fr) 274px;
  }

  .side-nav {
    padding-inline: 8px;
  }

  .welcome-content {
    gap: 44px;
  }
}

@media (max-width: 980px) {
  .dashboard-layout {
    grid-template-columns: 93px minmax(0, 1fr);
  }

  .side-nav {
    padding-inline: 6px 8px;
  }

  .desktop-nav {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
  }

  .nav-item {
    min-width: 0;
  }

  .nav-item .nav-asset {
    max-width: 100%;
  }

  .wordmark-side {
    font-size: 0.84rem;
  }

  .home-view {
    grid-template-columns: 1fr;
  }

  .side-rail {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .profile-card {
    grid-row: span 2;
  }

  .rail-action {
    grid-column: 1 / -1;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .welcome-topbar,
  .welcome-content,
  .welcome-footer {
    width: min(100% - 30px, 620px);
  }

  .welcome-content {
    grid-template-columns: 1fr;
    gap: 44px;
    padding-block: 58px 42px;
  }

  .welcome-copy h1 {
    max-width: 580px;
    font-size: clamp(2.9rem, 12vw, 5rem);
  }

  .welcome-copy {
    padding: 19px;
  }

  .welcome-scene {
    min-height: 360px;
    transform: rotate(0.8deg);
  }

  .welcome-footer {
    flex-wrap: wrap;
    padding-bottom: 21px;
  }

  .side-nav {
    display: none;
  }

  .dashboard-screen {
    display: flex;
    flex-direction: column;
  }

  .dashboard-layout {
    order: 1;
    display: block;
    min-height: 0;
  }

  .dashboard-main {
    padding: 19px 15px 28px;
  }

  .dashboard-topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 13px;
    margin-bottom: 16px;
  }

  .topbar-actions {
    justify-content: flex-start;
    width: 100%;
    flex-wrap: wrap;
  }

  .player-chip {
    margin-left: auto;
  }

  .map-panel {
    padding: 9px;
  }

  .map-panel-header {
    flex-direction: column;
    gap: 7px;
    padding: 7px 7px 11px;
  }

  .map-panel-header p {
    max-width: none;
    text-align: left;
  }

  .map-board {
    min-height: 585px;
  }

  .map-node {
    width: 84px;
  }

  .node-note {
    width: min(166px, calc(100vw - 72px));
    min-height: 70px;
    padding: 9px 10px;
  }

  .node-note strong {
    font-size: 0.79rem;
  }

  .node-note span {
    font-size: 0.68rem;
  }

  .node-orb {
    width: 70px;
    height: 70px;
    font-size: 1.15rem;
  }

  .node-note,
  .map-node:nth-of-type(2) .node-note,
  .map-node:nth-of-type(4) .node-note {
    bottom: 78px;
    top: auto;
  }

  .node-note::after,
  .map-node:nth-of-type(2) .node-note::after,
  .map-node:nth-of-type(4) .node-note::after {
    top: auto;
    bottom: -11px;
    border-top: 0;
    border-left: 0;
    border-right: 3px solid var(--brown);
    border-bottom: 3px solid var(--brown);
  }

  .side-rail {
    grid-template-columns: 1fr;
  }

  .profile-card {
    grid-row: auto;
  }

  .rail-action {
    grid-column: auto;
  }

  .content-view-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .resource-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .resource-link {
    grid-column: 2;
  }

  .mobile-nav {
    position: static;
    order: 0;
    margin: 10px 10px 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
    padding: 6px;
    background: var(--cream);
    border: 3px solid var(--brown-deep);
    border-radius: 14px;
    box-shadow: 0 5px 0 rgba(56, 37, 29, 0.27);
  }

  .mobile-nav-item {
    min-width: 0;
    min-height: 58px;
    display: grid;
    place-items: center;
    gap: 2px;
    padding: 5px 2px;
    color: var(--brown-deep);
    background: transparent;
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 0.54rem;
    font-weight: 900;
    line-height: 1.05;
    white-space: nowrap;
    cursor: pointer;
  }

  .mobile-nav-item span {
    max-width: 100%;
    text-align: center;
  }

  .mobile-nav-item:hover,
  .mobile-nav-item.is-active {
    background: var(--orange-light);
    border-color: var(--brown-deep);
  }

  .mobile-nav-item svg {
    width: 22px;
    height: 22px;
  }

  .lesson-dialog-shell {
    padding: 12px;
  }

  .lesson-dialog {
    max-height: calc(100dvh - 24px);
    padding: 28px 16px 18px;
    border-radius: 16px;
  }

  .lesson-dialog-actions {
    align-items: stretch;
    justify-content: stretch;
  }

  .lesson-dialog-actions .button {
    flex: 1 1 100%;
    justify-content: center;
    width: 100%;
    margin-right: 0;
  }
}

@media (max-width: 500px) {
  .welcome-topbar {
    padding-top: 19px;
  }

  .welcome-topbar .button {
    min-height: 44px;
    padding-inline: 13px;
  }

  .welcome-content {
    gap: 28px;
    padding-block: 50px 28px;
  }

  .welcome-copy h1 {
    font-size: clamp(2.65rem, 13vw, 4.3rem);
  }

  .welcome-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .welcome-actions .button {
    width: 100%;
  }

  .welcome-scene {
    min-height: 286px;
  }

  .scene-caption {
    right: 12px;
    bottom: 12px;
    left: 12px;
    padding: 8px 10px;
    font-size: 0.76rem;
  }

  .dashboard-main {
    padding-inline: 11px;
  }

  .page-heading h1 {
    font-size: 2.35rem;
  }

  .api-status {
    max-width: calc(100% - 54px);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .player-chip {
    order: 3;
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .map-board {
    min-height: 520px;
  }

  .map-node {
    width: 70px;
  }

  .node-orb {
    width: 62px;
    height: 62px;
    border-width: 4px;
    font-size: 1rem;
  }

  .node-note,
  .map-node:nth-of-type(2) .node-note,
  .map-node:nth-of-type(4) .node-note {
    bottom: 69px;
    width: min(166px, calc(100vw - 72px));
  }

  .map-node:nth-of-type(1) .node-note {
    transform: translateX(-20%);
  }

  .map-node:nth-of-type(4) .node-note {
    transform: translateX(-80%);
  }

  .node-note strong {
    font-size: 0.72rem;
  }

  .node-note span {
    margin-top: 3px;
    font-size: 0.62rem;
  }

  .map-route path {
    stroke-width: 14;
  }

  .map-route .route-shadow {
    stroke-width: 20;
  }

  .map-cactus {
    transform: scale(0.72);
  }

  .cactus-two {
    transform: scale(0.58);
  }

  .cactus-three {
    transform: scale(0.4);
  }

  .content-view,
  .settings-view {
    padding: 17px 13px;
  }

  .resource-card {
    gap: 9px;
    padding: 11px 9px;
  }

  .resource-index {
    width: 34px;
    height: 34px;
    font-size: 0.84rem;
  }

  .resource-card h4 {
    font-size: 0.86rem;
  }

  .resource-card p {
    font-size: 0.7rem;
  }

  .login-dialog {
    padding: 28px 19px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* Wide quest map: the board intentionally stays larger than its viewport so it can be explored to the right. */
.dashboard-screen[data-active-view="home"] .dashboard-topbar {
  display: none;
}

.dashboard-screen[data-active-view="home"] .dashboard-main {
  padding: 18px clamp(12px, 1.7vw, 28px) 28px;
}

.dashboard-screen[data-active-view="home"] .view-root {
  max-width: none;
}

.dashboard-screen:not(.is-quiz-screen) .side-nav {
  background-color: #bd7a46;
  background-image: repeating-linear-gradient(0deg, #b46f3f 0 19px, #c8824d 19px 24px);
}

.dashboard-screen:not(.is-quiz-screen) .wordmark-side {
  display: none;
}

.dashboard-screen:not(.is-quiz-screen) .desktop-nav {
  padding: 8px 5px;
  background: var(--cream);
  border: 3px solid var(--brown-deep);
  border-radius: 5px;
  box-shadow: 0 4px 0 rgba(56, 37, 29, 0.24);
}

.dashboard-screen:not(.is-quiz-screen) .nav-logout {
  background: var(--cream);
  border-color: var(--brown-deep);
  box-shadow: 0 4px 0 rgba(56, 37, 29, 0.24);
}

.home-map-view {
  grid-template-columns: minmax(0, 1fr) 336px;
  gap: 18px;
  min-height: calc(100dvh - 46px);
}

.map-panel-landscape {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: min(840px, calc(100dvh - 46px));
  height: min(840px, calc(100dvh - 46px));
  padding: 9px;
  overflow: hidden;
  border-radius: 4px;
  background: #bd7a46;
  box-shadow: 0 6px 0 rgba(56, 37, 29, 0.3);
}

.map-panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 10px 10px;
  color: var(--cream);
}

.map-panel-toolbar .kicker {
  margin-bottom: 3px;
  color: #ffe5a1;
}

.map-panel-toolbar h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1;
}

.map-scroll-controls {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #ffe5a1;
  font-size: 0.72rem;
  font-weight: 850;
  white-space: nowrap;
}

.map-demo-pill {
  padding: 4px 7px;
  color: var(--brown-deep);
  background: var(--orange-light);
  border: 2px solid var(--brown-deep);
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.map-scroll-button {
  width: 31px;
  height: 29px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--brown-deep);
  background: var(--cream);
  border: 2px solid var(--brown-deep);
  border-radius: 7px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  cursor: pointer;
}

.map-scroll-button:hover {
  background: var(--orange-light);
}

.map-scroll {
  min-width: 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  border: 3px solid var(--brown-deep);
  border-radius: 8px;
  background: var(--sand);
  scroll-behavior: smooth;
  scrollbar-color: var(--brown-deep) #f4c977;
  scrollbar-width: auto;
}

/* Supplied Figma artwork is applied as a nine-slice frame, so it stays crisp
   when the map is wide, narrow, tall, or horizontally scrollable. */
.map-frame {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 26px solid transparent;
  border-image-source: url("assets/map-frame.png");
  border-image-slice: 52 fill;
  border-image-width: 26px;
  border-image-repeat: stretch;
  border-radius: 5px;
  background: #f6ca79;
}

.map-layout-vertical .map-frame {
  border-image-source: url("assets/ui-vertical-2/map-frame.png");
  border-image-slice: 32 fill;
}

.map-frame .map-scroll {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
}

.map-scroll:focus-visible {
  outline: 3px solid var(--cream);
  outline-offset: -7px;
}

.map-scroll::-webkit-scrollbar {
  height: 15px;
}

.map-scroll::-webkit-scrollbar-track {
  background: #f4c977;
  border-top: 2px solid var(--brown-deep);
}

.map-scroll::-webkit-scrollbar-thumb {
  background: var(--brown-deep);
  border: 3px solid #f4c977;
  border-radius: 20px;
}

.map-board-landscape {
  width: 1580px;
  min-height: 690px;
  height: calc(min(820px, 100dvh - 112px));
  border: 0;
  border-radius: 0;
  background: #f6ca79 url("assets/map/map-background.webp") center / 100% 100% no-repeat;
}

.map-board-landscape::before {
  top: 14%;
  left: -8%;
  width: 39%;
  height: 55%;
  background: rgba(255, 236, 176, 0.78);
}

.map-board-landscape::after {
  right: 1%;
  bottom: -30%;
  width: 36%;
  height: 75%;
  background: rgba(255, 239, 188, 0.78);
}

.map-wordmark {
  position: absolute;
  z-index: 5;
  top: 30px;
  right: 38px;
  display: flex;
  flex-direction: column;
  color: #f3a51a;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 1000;
  letter-spacing: -0.1em;
  line-height: 0.75;
  text-decoration: none;
  text-shadow: 2px 3px 0 #b34325, -1px -1px 0 var(--brown-deep), 2px 0 0 var(--brown-deep), 0 2px 0 var(--brown-deep);
  transform: rotate(-5deg);
}

.map-wordmark span:last-child {
  padding-left: 11px;
  color: #ffc84f;
}

.map-board-landscape .map-route path {
  stroke: transparent;
}

.map-board-landscape .map-route .route-shadow {
  stroke: transparent;
}

.map-board-landscape .map-route {
  inset: 0;
  width: 100%;
  height: 100%;
  background: url("assets/map/street.png") center / 100% 100% no-repeat;
}

.nav-item:has(.nav-asset) {
  min-height: 62px;
  padding: 5px 3px;
}

.nav-item .nav-asset {
  display: block;
  max-width: 65px;
  max-height: 48px;
  object-fit: contain;
}

.nav-item:has(.nav-asset) .nav-icon,
.nav-item:has(.nav-asset) > span {
  display: none;
}

.map-board-landscape .map-cactus {
  z-index: 2;
}

.map-board-landscape .cactus-one {
  top: 15%;
  left: 17%;
  transform: scale(0.9);
}

.map-board-landscape .cactus-two {
  right: 24%;
  bottom: 13%;
  transform: scale(1.05) rotate(8deg);
}

.map-board-landscape .cactus-three {
  top: 20%;
  right: 7%;
  transform: scale(0.7);
}

.cactus-four {
  bottom: 11%;
  left: 26%;
  transform: scale(0.7) rotate(-4deg);
}

.map-board-landscape .map-node {
  width: 132px;
}

.map-board-landscape .node-note,
.map-board-landscape .map-node:nth-of-type(2) .node-note,
.map-board-landscape .map-node:nth-of-type(4) .node-note {
  top: auto;
  bottom: 112px;
  width: 240px;
  min-height: 116px;
  padding: 14px 17px;
  border-width: 3px;
  border-radius: 14px;
  transform: translateX(-50%);
}

.map-board-landscape .node-note::after,
.map-board-landscape .map-node:nth-of-type(2) .node-note::after,
.map-board-landscape .map-node:nth-of-type(4) .node-note::after {
  top: auto;
  bottom: -13px;
  border-top: 0;
  border-left: 0;
  border-right: 3px solid var(--brown);
  border-bottom: 3px solid var(--brown);
}

.map-board-landscape .node-note small,
.map-board-landscape .node-note strong,
.map-board-landscape .node-note span {
  display: block;
}

.map-board-landscape .node-note small {
  color: var(--brown-soft);
  font-size: 0.86rem;
  font-weight: 950;
  text-transform: uppercase;
}

.map-board-landscape .node-note strong {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: 1.05;
}

.map-board-landscape .node-note .node-subtitle {
  margin-top: 7px;
  color: #26953c;
  font-size: 0.86rem;
  font-weight: 950;
}

.map-board-landscape .map-node-locked .node-subtitle {
  color: #77716d;
}

.map-board-landscape .node-orb {
  width: 130px;
  height: 124px;
}

.map-board-landscape .node-orb[data-state="locked"] { filter: saturate(0.85); }

.button.button-primary.rail-action {
  min-height: 75px;
  color: var(--cream);
  background: url("assets/map/button-template.png") center / 100% 100% no-repeat;
  border: 0;
  box-shadow: none;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 2vw, 2rem);
  font-weight: 1000;
  letter-spacing: 0.04em;
  text-shadow: 2px 3px 0 #8c3a1e, -1px -1px 0 var(--brown-deep), 1px -1px 0 var(--brown-deep), -1px 1px 0 var(--brown-deep), 1px 1px 0 var(--brown-deep);
}

.button.button-primary.rail-action:hover {
  background-color: transparent;
  filter: brightness(1.06) saturate(1.05);
  transform: translateY(-2px);
}

.profile-card-game {
  padding: 14px;
  border-radius: 19px 19px 7px 7px;
  box-shadow: 0 5px 0 rgba(56, 37, 29, 0.28);
}

.profile-card-game::before {
  display: none;
}

.profile-card-game .avatar-large {
  width: 76px;
  height: 76px;
  border-width: 4px;
  background: linear-gradient(135deg, #f6c564, #a85c2c);
  box-shadow: 0 3px 0 var(--brown-deep);
}

.profile-card-game .profile-name strong {
  font-size: 1.38rem;
}

.profile-card-game .profile-name span {
  font-size: 0.82rem;
}

.profile-card-game .profile-name span {
  color: var(--brown);
  font-weight: 850;
}

.profile-xp-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.profile-level {
  min-width: 42px;
  padding: 4px 7px;
  color: #fff7e8;
  background: #e33c27;
  border: 2px solid #8e2d22;
  border-radius: 6px;
  box-shadow: 0 2px 0 #8e2d22;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 1000;
  text-align: center;
}

.profile-xp-row .points-meter {
  height: 17px;
  margin-top: 0;
}

.profile-xp-row > strong {
  min-width: 32px;
  color: var(--brown-deep);
  font-family: var(--font-display);
  font-size: 0.95rem;
  text-align: right;
}

.streak-card {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 13px;
  padding: 7px 8px;
  background: #a96c3f;
  border: 2px solid var(--brown-deep);
  border-radius: 7px;
  box-shadow: 0 3px 0 rgba(56, 37, 29, 0.25);
}

.streak-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  flex: 1;
  gap: 3px;
}

.streak-day {
  display: grid;
  justify-items: center;
  gap: 2px;
  color: #ffe9bd;
  font-size: 0.57rem;
  font-weight: 900;
}

.streak-day b {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #75482e;
  border-radius: 50%;
  font-size: 0.74rem;
  line-height: 1;
}

.streak-day.streak-done b {
  background: #4fd548;
  box-shadow: inset 0 0 0 2px #d8ffd2;
}

.streak-day.streak-missed b {
  background: #f47a18;
  box-shadow: inset 0 0 0 2px #ffe2b0;
}

.streak-total {
  display: grid;
  justify-items: center;
  min-width: 33px;
  color: #fff3d8;
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1;
}

.streak-total small {
  margin-top: 3px;
  font-family: var(--font-body);
  font-size: 0.59rem;
  font-weight: 900;
}

.points-row,
.streak-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 13px;
  color: var(--brown-soft);
  font-size: 0.75rem;
  font-weight: 850;
}

.points-row strong,
.streak-row strong {
  color: var(--brown-deep);
  font-family: var(--font-display);
  font-size: 0.94rem;
}

.streak-row {
  padding: 9px 10px;
  border: 2px solid var(--brown);
  border-radius: 6px;
  background: #b87948;
  color: var(--cream);
}

.streak-row strong {
  color: #ffe5a1;
  font-size: 0.72rem;
}

.points-meter,
.daily-progress {
  height: 18px;
  margin-top: 6px;
  overflow: hidden;
  background: #a6a5a0;
  border: 3px solid var(--brown);
  border-radius: 999px;
}

.points-meter span,
.daily-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(180deg, #ffde38, #f18a16);
}

.daily-card {
  padding: 13px;
  background: var(--cream);
  border: 3px solid var(--brown-deep);
  border-radius: 10px;
  box-shadow: 0 5px 0 rgba(56, 37, 29, 0.25);
}

.daily-card .rail-heading {
  margin-bottom: 9px;
}

.daily-card .rail-heading h2 {
  font-family: var(--font-display);
  font-size: 1rem;
}

.daily-count {
  color: var(--brown-soft);
  font-size: 0.84rem;
  font-weight: 900;
}

.daily-task {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
}

.daily-gift {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--cream);
  background: var(--orange);
  border: 2px solid var(--brown-deep);
  border-radius: 10px;
  font-size: 1.35rem;
}

.daily-task strong,
.daily-task span {
  display: block;
}

.daily-task strong { font-size: 0.8rem; line-height: 1.15; }
.daily-task span { margin-top: 3px; color: var(--brown-soft); font-size: 0.66rem; font-weight: 750; }

.daily-progress { height: 15px; }
.daily-progress span { background: linear-gradient(180deg, #72de39, #28a52a); }

.badge-panel,
.activity-panel {
  border-radius: 10px;
  box-shadow: 0 5px 0 rgba(56, 37, 29, 0.22);
}

.badge-panel .badge-list {
  align-items: end;
  gap: 3px;
}

.badge-panel .badge-item {
  min-height: 76px;
}

.badge-art {
  width: 100%;
  max-width: 100%;
  height: 73px;
  object-fit: contain;
  display: block;
  overflow: hidden;
}

.activity-empty {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 9px 0 2px;
}

.activity-empty .activity-mark {
  width: 34px;
  height: 34px;
}

.activity-empty strong,
.activity-empty span { display: block; }
.activity-empty strong { font-size: 0.75rem; line-height: 1.15; }
.activity-empty span { margin-top: 3px; color: var(--brown-soft); font-size: 0.67rem; font-weight: 750; }

.home-map-view .rail-action {
  min-height: 58px;
  color: var(--cream);
  font-size: 1.3rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

@media (min-width: 981px) and (max-height: 800px) {
  .home-map-view {
    gap: 12px;
  }

  .home-map-view .side-rail {
    gap: 8px;
  }

  .profile-card-game,
  .daily-card,
  .badge-panel,
  .activity-panel {
    padding: 10px;
  }

  .profile-card-game .avatar-large {
    width: 62px;
    height: 62px;
  }

  .profile-card-game .profile-name strong {
    font-size: 1.16rem;
  }

  .profile-card-game .profile-name span {
    font-size: 0.72rem;
  }

  .profile-xp-row,
  .streak-card {
    margin-top: 8px;
  }

  .streak-card {
    padding-block: 5px;
  }

  .streak-day b {
    width: 18px;
    height: 18px;
  }

  .badge-panel .badge-item,
  .badge-art {
    min-height: 61px;
    height: 59px;
  }

  .activity-list {
    gap: 4px;
  }

  .activity-item {
    padding-bottom: 4px;
  }

  .activity-mark {
    width: 24px;
    height: 24px;
  }

  .button.button-primary.rail-action {
    min-height: 50px;
  }
}

@media (max-width: 980px) {
  .home-map-view {
    grid-template-columns: 1fr;
  }

  .map-panel-landscape {
    min-height: 690px;
  }
}

@media (max-width: 760px) {
  .dashboard-screen[data-active-view="home"] .dashboard-main {
    padding: 10px;
  }

  .map-panel-landscape {
    min-height: 620px;
    padding: 7px;
  }

  .map-panel-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .map-scroll-controls {
    width: 100%;
    justify-content: flex-end;
  }

  .map-board-landscape {
    width: 1460px;
    min-height: 570px;
    height: 570px;
  }
}

.map-panel-landscape {
  position: relative;
}

.map-player-trigger,
.map-player-popover {
  display: none;
}

.avatar-image {
  color: transparent !important;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.avatar-image.avatar-default {
  background-color: transparent;
  background-size: contain;
  border-color: transparent;
}

@media (max-width: 980px) {
  .home-map-view .side-rail {
    display: none;
  }

  .map-player-trigger {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
  }

  .avatar-map-trigger {
    width: 40px;
    height: 40px;
    color: var(--brown-deep);
    background: var(--orange-light);
    border: 3px solid var(--brown-deep);
    box-shadow: 0 3px 0 rgba(56, 37, 29, 0.45);
  }

  .map-player-trigger:hover .avatar-map-trigger,
  .map-player-trigger[aria-expanded="true"] .avatar-map-trigger {
    transform: translateY(-2px) scale(1.04);
    filter: brightness(1.05);
  }

  .map-player-popover:not([hidden]) {
    position: absolute;
    z-index: 12;
    top: 64px;
    right: 12px;
    width: min(310px, calc(100% - 24px));
    display: block;
    padding: 16px;
    color: var(--brown-deep);
    background: var(--cream);
    border: 3px solid var(--brown-deep);
    border-radius: 15px;
    box-shadow: 0 7px 0 rgba(56, 37, 29, 0.32);
    animation: dialog-in 160ms ease-out both;
  }

  .map-player-close {
    position: absolute;
    top: 6px;
    right: 7px;
    width: 31px;
    height: 31px;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--brown-deep);
    background: transparent;
    border: 0;
    border-radius: 50%;
    font-size: 1.45rem;
    line-height: 1;
    cursor: pointer;
  }

  .map-player-close:hover {
    background: var(--cream-deep);
  }

  .map-player-popover-head {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .avatar-map-popover {
    width: 56px;
    height: 56px;
    color: var(--brown-deep);
    background: var(--orange-light);
    border: 3px solid var(--brown-deep);
  }

  .map-player-popover-head strong,
  .map-player-popover-head span {
    display: block;
  }

  .map-player-popover-head strong {
    max-width: 190px;
    overflow: hidden;
    font-family: var(--font-display);
    font-size: 1.12rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .map-player-popover-head span {
    margin-top: 3px;
    color: var(--brown-soft);
    font-size: 0.74rem;
    font-weight: 750;
  }

  .map-player-popover-points {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 15px;
    padding: 9px 10px;
    background: var(--cream-deep);
    border-radius: 8px;
    color: var(--brown-soft);
    font-size: 0.75rem;
    font-weight: 850;
  }

  .map-player-popover-points strong {
    color: var(--brown-deep);
    font-family: var(--font-display);
  }

  .map-player-view-button {
    width: 100%;
    min-height: 40px;
    margin-top: 12px;
    color: var(--brown-deep);
    background: var(--orange);
    border: 2px solid var(--brown-deep);
    border-radius: 8px;
    box-shadow: 0 3px 0 var(--brown-deep);
    font-family: var(--font-display);
    font-weight: 900;
    cursor: pointer;
  }

  .map-player-view-button:hover {
    background: var(--orange-light);
  }
}

@media (max-width: 600px) {
  .map-scroll-controls > span:first-child {
    display: none;
  }
}

/* Vertical route mode reuses the same map nodes, but makes the map a tall, clipped journey. */
.map-scroll-vertical {
  overflow-x: hidden;
  overflow-y: auto;
}

.map-board-vertical {
  width: 100%;
  min-height: 1420px;
  height: 1420px;
  border: 0;
  border-radius: 0;
  background-color: #f6ca79;
  background-image: url("assets/ui-vertical/map-background.webp");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.map-board-vertical::before,
.map-board-vertical::after,
.map-board-vertical .map-sun,
.map-board-vertical .map-cactus {
  display: none;
}

.map-vertical-road {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 50%;
  width: clamp(350px, 43%, 510px);
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  transform: translateX(-50%);
  user-select: none;
}

.map-board-vertical .map-place-vertical {
  position: absolute;
  z-index: 2;
  display: block;
  height: auto;
  pointer-events: none;
  user-select: none;
}

.map-board-vertical .map-place-vertical-city {
  top: 3%;
  left: 1%;
  width: 29%;
}

.map-board-vertical .map-place-vertical-frontier {
  top: 17%;
  right: 1%;
  width: 27%;
}

.map-board-vertical .map-place-vertical-island {
  top: 43%;
  right: 0.5%;
  width: 37%;
}

.map-board-vertical .map-place-vertical-town {
  top: 69%;
  left: 1%;
  width: 32%;
}

.map-board-vertical .map-wordmark {
  top: 12px;
  right: 14px;
  left: auto;
  width: 104px;
  height: 92px;
  z-index: 5;
}

.map-board-vertical .map-route path {
  stroke-width: 13;
}

.map-board-vertical .map-route .route-shadow {
  stroke-width: 19;
}

.map-board-vertical .map-node {
  width: 116px;
}

.map-board-vertical .node-note,
.map-board-vertical .map-node:nth-of-type(2) .node-note,
.map-board-vertical .map-node:nth-of-type(4) .node-note {
  top: auto;
  bottom: 102px;
  width: 218px;
  min-height: 100px;
  transform: translateX(-50%);
}

.map-board-vertical .node-note::after,
.map-board-vertical .map-node:nth-of-type(2) .node-note::after,
.map-board-vertical .map-node:nth-of-type(4) .node-note::after {
  top: auto;
  bottom: -13px;
  border-top: 0;
  border-left: 0;
  border-right: 3px solid var(--brown);
  border-bottom: 3px solid var(--brown);
}

.map-board-vertical .node-note small {
  display: block;
  color: var(--brown-soft);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

.map-board-vertical .node-note strong {
  display: block;
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.08;
}

.map-board-vertical .node-note .node-subtitle {
  margin-top: 6px;
  font-size: 0.75rem;
}

.map-board-vertical .node-orb {
  width: 91px;
  height: 91px;
}

.map-board-vertical .node-orb svg {
  width: 42px;
  height: 42px;
}

.map-board-vertical .node-orb::after {
  right: -4px;
  bottom: -14px;
  width: 35px;
  height: 23px;
  background: #5ee62a;
}

.map-board-vertical .node-orb[data-state] {
  background: transparent;
  border: 0;
  box-shadow: none;
}
.map-board-vertical .node-orb[data-state="locked"]::after { display: none; }

.map-player-trigger {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.avatar-map-trigger {
  width: 40px;
  height: 40px;
  color: var(--brown-deep);
  background: var(--orange-light);
  border: 3px solid var(--brown-deep);
  box-shadow: 0 3px 0 rgba(56, 37, 29, 0.45);
}

.map-player-popover:not([hidden]) {
  position: absolute;
  z-index: 12;
  top: 64px;
  right: 12px;
  width: min(350px, calc(100% - 24px));
  max-height: calc(100% - 76px);
  display: block;
  overflow: auto;
  padding: 16px;
  color: var(--brown-deep);
  background: var(--cream);
  border: 3px solid var(--brown-deep);
  border-radius: 15px;
  box-shadow: 0 7px 0 rgba(56, 37, 29, 0.32);
  animation: dialog-in 160ms ease-out both;
}

.map-player-close {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--brown-deep);
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

.map-player-close:hover {
  background: var(--cream-deep);
}

.map-player-popover-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.map-player-popover-head > div {
  min-width: 0;
  flex: 1;
}

.avatar-map-popover {
  width: 56px;
  height: 56px;
  color: var(--brown-deep);
  background: var(--orange-light);
  border: 3px solid var(--brown-deep);
}

.map-player-popover-head strong,
.map-player-popover-head span {
  display: block;
}

.map-player-popover-head strong {
  max-width: 100%;
  overflow: visible;
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-size: 1.12rem;
  text-overflow: clip;
  white-space: normal;
}

.map-player-popover-head span {
  margin-top: 3px;
  color: var(--brown-soft);
  font-size: 0.74rem;
  font-weight: 750;
}

.map-player-popover-points {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 15px;
  padding: 9px 10px;
  background: var(--cream-deep);
  border-radius: 8px;
  color: var(--brown-soft);
  font-size: 0.75rem;
  font-weight: 850;
}

.map-player-popover-points strong {
  color: var(--brown-deep);
  font-family: var(--font-display);
}

.player-avatar-form,
.map-player-form,
.map-preference-section {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 2px solid var(--cream-deep);
}

.player-avatar-form label,
.map-player-form label,
.map-preference-section > span {
  display: block;
  margin-bottom: 6px;
  color: var(--brown-soft);
  font-size: 0.71rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.player-avatar-form > input[type="file"] {
  display: block;
  width: 100%;
  min-width: 0;
  color: var(--brown-deep);
  font-size: 0.68rem;
}

.player-avatar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.player-avatar-form button {
  min-height: 37px;
  margin-top: 7px;
  padding: 6px 9px;
  color: var(--brown-deep);
  background: var(--cream-deep);
  border: 2px solid var(--brown-deep);
  border-radius: 7px;
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 900;
  cursor: pointer;
}

.player-avatar-form button:hover:not(:disabled) {
  background: var(--orange-light);
}

.player-avatar-form .player-avatar-reset {
  color: var(--brown-soft);
  background: transparent;
  border-color: var(--brown-soft);
  font-family: inherit;
  font-size: 0.68rem;
}

.player-avatar-form .player-avatar-reset:hover:not(:disabled) {
  color: var(--brown-deep);
  background: var(--cream-deep);
}

.player-avatar-note {
  display: block;
  margin: 6px 0 0;
  color: var(--brown-soft);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.3;
}

.map-player-form > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.map-player-form input {
  min-width: 0;
  height: 37px;
  padding: 7px 9px;
  color: var(--brown-deep);
  background: var(--white);
  border: 2px solid var(--brown-soft);
  border-radius: 7px;
  font-weight: 750;
}

.map-player-form button,
.map-layout-switch button {
  min-height: 37px;
  padding: 6px 9px;
  color: var(--brown-deep);
  background: var(--cream-deep);
  border: 2px solid var(--brown-deep);
  border-radius: 7px;
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 900;
  cursor: pointer;
}

.map-player-form button:hover,
.map-layout-switch button:hover,
.map-layout-switch button.is-active {
  background: var(--orange-light);
}

.map-player-logout {
  width: 100%;
  min-height: 43px;
  margin-top: 10px;
  padding: 8px 12px;
  color: #7f3429;
  background: #f8e5d5;
  border: 2px solid var(--brown-deep);
  border-radius: 9px;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
}

.map-player-logout:hover {
  color: var(--brown-deep);
  background: var(--orange-light);
}

.map-layout-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.map-layout-switch button {
  min-height: 44px;
  font-family: var(--font-body);
  font-size: 0.7rem;
}

@media (max-width: 760px) {
  .map-board-vertical {
    min-height: 1240px;
    height: 1240px;
  }

  .map-board-vertical .map-wordmark {
    width: 78px;
    height: 70px;
  }

  .map-board-vertical .node-note {
    width: 192px;
  }
}

/* The first visit is a clean illustrated title screen; the login art stays interactive. */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.welcome-screen {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 100svh;
  min-height: 100dvh;
  overflow: hidden;
  place-items: center;
  padding: 0;
  background-color: #4ab8e9;
  background-image: url("assets/landing-town.webp");
  background-position: center;
  background-size: cover;
  animation: welcome-scene-drift 34s ease-in-out infinite alternate;
}

.welcome-screen .sky-decor,
.welcome-screen .welcome-topbar,
.welcome-screen .welcome-content,
.welcome-screen .welcome-footer {
  display: none;
}

.landing-start {
  position: absolute;
  z-index: 1;
  top: 72%;
  left: 50%;
  display: grid;
  width: min(31vw, 504px);
  min-width: 250px;
  aspect-ratio: 504 / 123;
  place-items: center;
  padding: 0;
  color: #fff8ea;
  background: transparent;
  border: 0;
  border-radius: 24px;
  cursor: pointer;
  filter: drop-shadow(0 8px 5px rgba(55, 34, 19, 0.48));
  transform: translate(-50%, -50%);
  transition: filter 160ms ease, transform 160ms ease;
}

.landing-start img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  transition: filter 160ms ease;
}

.landing-start span {
  position: relative;
  z-index: 1;
  padding: 0 8%;
  color: #fffdf7;
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.05vw, 2rem);
  font-weight: 950;
  line-height: 1;
  text-align: center;
  text-shadow: 0 2px 0 #733313, 2px 0 0 #733313, -2px 0 0 #733313, 0 4px 1px #733313;
  white-space: nowrap;
}

.landing-start:hover {
  filter: drop-shadow(0 11px 6px rgba(55, 34, 19, 0.5));
  transform: translate(-50%, -53%) scale(1.035);
}

.landing-start:hover img {
  filter: brightness(1.12) saturate(1.08);
}

.landing-start:active {
  filter: drop-shadow(0 3px 2px rgba(55, 34, 19, 0.42));
  transform: translate(-50%, -48%) scale(0.985);
}

.modal-shell {
  z-index: 30;
  padding: 12px;
}

.modal-backdrop {
  background: rgba(20, 30, 39, 0.72);
  backdrop-filter: blur(3px);
}

.login-dialog {
  --login-dialog-width: min(calc(100vw - 24px), 680px);
  position: relative;
  isolation: isolate;
  width: var(--login-dialog-width);
  /* Square frame where it fits; taller (never shorter than the content needs) on narrow screens. */
  height: min(calc(100dvh - 24px), max(var(--login-dialog-width), 640px));
  max-height: calc(100dvh - 24px);
  overflow: hidden;
  padding: 0;
  color: var(--brown-deep);
  background: url("assets/login-panel-frame.webp") center / 100% 100% no-repeat;
  border: 0;
  border-radius: 0;
  box-shadow: 0 15px 38px rgba(14, 23, 30, 0.48);
  animation: dialog-in 180ms ease-out both;
}

.login-panel-content {
  position: absolute;
  inset: 12.5% 12% 11.5%;
  display: flex;
  flex-direction: column;
  /* Spacers (::before/::after) centre the content but let it scroll from the top instead of clipping both ends. */
  justify-content: flex-start;
  gap: clamp(7px, 1.7vh, 14px);
  overflow-y: auto;
  padding: 0 1%;
  scrollbar-width: thin;
}

/* Equal flexible spacers centre whichever children are visible and collapse to 0 when content overflows. */
.login-panel-content::before,
.login-panel-content::after {
  content: "";
  flex: 1 0 0;
}

.login-dialog .login-title {
  font-size: clamp(1.45rem, 3.2vw, 2.1rem);
}

.login-title {
  margin: 0;
  color: var(--brown);
  font-size: clamp(1.2rem, 3vw, 1.75rem);
  font-weight: 400;
  line-height: 1.14;
  text-align: center;
}

.login-description {
  margin: 0;
  color: #725640;
  font-size: clamp(0.78rem, 1.8vw, 0.95rem);
  line-height: 1.35;
  text-align: center;
}

.login-art-close {
  position: absolute;
  z-index: 3;
  top: 7.2%;
  right: 7.4%;
  width: 10%;
  aspect-ratio: 1;
  padding: 0;
  background: url("assets/login-close.png") center / contain no-repeat;
  border: 0;
  cursor: pointer;
  transition: filter 140ms ease, transform 140ms ease;
}

.login-art-close:hover {
  filter: brightness(1.1);
  transform: scale(1.08) rotate(5deg);
}

.login-panel-form {
  display: flex;
  flex-direction: column;
  gap: clamp(7px, 1.5vh, 12px);
}

.login-panel-form[hidden] {
  display: none;
}

.modal-shell.is-register .login-panel-content {
  inset: 9.5% 12% 8.5%;
  gap: clamp(4px, 0.8vh, 7px);
}

.modal-shell.is-register .login-dialog h2 {
  font-size: clamp(1.2rem, 3vw, 1.75rem);
}

.modal-shell.is-register .login-field-group {
  gap: 3px;
}

.modal-shell.is-register .login-field-input {
  min-height: 40px;
  padding-block: 6px;
}

.modal-shell.is-register .login-panel-form {
  gap: clamp(4px, 0.8vh, 7px);
}

.login-field-group {
  display: grid;
  gap: 5px;
}

.login-field-label {
  color: #604533;
  font-family: var(--font-display);
  font-size: clamp(0.8rem, 1.9vw, 0.94rem);
  font-weight: 400;
}

.login-field-input {
  width: 100%;
  min-height: 44px;
  padding: 8px 13px;
  color: #47382e;
  background: #fffefa;
  border: 1px solid #8e7663;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: clamp(0.78rem, 2vw, 0.94rem);
  outline-offset: 2px;
}

.login-field-input::placeholder {
  color: #8798aa;
  opacity: 1;
}

.login-password-field {
  position: relative;
}

.login-password-field .login-field-input {
  padding-right: 48px;
}

.password-visibility {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  width: 36px;
  aspect-ratio: 1;
  place-items: center;
  padding: 4px;
  color: #51463f;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transform: translateY(-50%);
}

.password-visibility:hover {
  background: #eee7db;
}

.password-visibility svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.login-form-error {
  margin: 0;
  padding: 7px 9px;
  color: #a33c28;
  background: rgba(255, 247, 225, 0.94);
  border-radius: 7px;
  font-size: clamp(0.72rem, 1.7vw, 0.84rem);
  line-height: 1.25;
  text-align: center;
}

.login-form-error[data-state="pending"] {
  color: #604533;
  background: rgba(255, 249, 233, 0.94);
}

.login-form-error[data-state="success"] {
  color: #247344;
  background: rgba(237, 255, 226, 0.96);
}

.email-verification-resend {
  justify-self: center;
  padding: 5px 10px;
  color: #387c24;
  background: rgba(255, 249, 233, 0.96);
  border: 1px solid currentColor;
  border-radius: 7px;
  font: inherit;
  font-size: clamp(0.72rem, 1.7vw, 0.84rem);
  font-weight: 700;
  cursor: pointer;
}

.email-verification-resend:hover:not(:disabled) {
  color: #245b18;
  background: #fffdf7;
}

.email-verification-resend:focus-visible {
  outline: 2px solid #f5a51b;
  outline-offset: 2px;
}

.email-verification-resend:disabled {
  opacity: 0.65;
  cursor: wait;
}

.login-panel-submit {
  position: relative;
  display: grid;
  align-self: center;
  width: min(46%, 205px);
  min-width: 150px;
  aspect-ratio: 188 / 50;
  place-items: center;
  padding: 0;
  color: #fffdf7;
  background: transparent;
  border: 0;
  cursor: pointer;
  filter: drop-shadow(0 3px 2px rgba(71, 47, 27, 0.38));
  transition: filter 140ms ease, transform 140ms ease;
}

.login-panel-submit img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.login-panel-submit span {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: clamp(0.82rem, 2vw, 1.05rem);
  font-weight: 400;
  text-shadow: 0 1px 0 #773710, 1px 0 0 #773710, -1px 0 0 #773710;
}

.login-panel-submit:hover:not(:disabled) {
  filter: brightness(1.08) drop-shadow(0 5px 3px rgba(71, 47, 27, 0.38));
  transform: translateY(-2px);
}

.login-panel-submit:disabled {
  cursor: wait;
  filter: grayscale(0.24) opacity(0.75);
}

.login-note {
  margin: 0;
  color: #725640;
  font-size: clamp(0.7rem, 1.6vw, 0.8rem);
  line-height: 1.35;
  text-align: center;
}

.modal-shell.is-registration-success .login-note {
  display: none;
}

.auth-mode-switch {
  margin: 0;
  color: #725640;
  font-size: clamp(0.7rem, 1.6vw, 0.82rem);
  line-height: 1.3;
  text-align: center;
}

.auth-mode-switch button {
  padding: 1px 3px;
  color: #387c24;
  background: transparent;
  border: 0;
  border-radius: 4px;
  font: inherit;
  font-family: var(--font-display);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.auth-mode-switch button:hover {
  color: #245b18;
}

.auth-mode-switch button:focus-visible {
  outline: 2px solid #f5a51b;
  outline-offset: 2px;
}

@keyframes welcome-scene-drift {
  from { background-position: 49% center; }
  to { background-position: 51% center; }
}

@media (max-width: 760px) {
  .landing-start {
    top: 72%;
    width: min(72vw, 420px);
    min-width: 0;
  }

  .landing-start span {
    font-size: clamp(0.94rem, 4.6vw, 1.45rem);
  }
}

@media (max-width: 420px) {
  .modal-shell {
    padding: 8px;
  }

  .login-dialog {
    width: min(calc(100vw - 16px), 420px);
    height: min(520px, calc(100dvh - 16px));
    max-height: calc(100dvh - 16px);
    aspect-ratio: auto;
  }

  .login-panel-content {
    inset: 12% 10% 8%;
    justify-content: flex-start;
    gap: clamp(6px, 1.25vh, 10px);
    padding: 14px 2% 12px;
  }

  .login-panel-content > *,
  .login-panel-form,
  .login-field-group {
    flex: 0 0 auto;
  }

  .modal-shell.is-register .login-dialog {
    height: min(620px, calc(100dvh - 16px));
  }

  .modal-shell.is-register .login-panel-content {
    inset: 10% 9% 6%;
    gap: 6px;
    padding: 8px 2% 14px;
  }

  .modal-shell.is-register .login-description,
  .modal-shell.is-register .login-field-label,
  .modal-shell.is-register .login-form-error {
    font-size: 0.7rem;
  }

  .modal-shell.is-register .login-field-group {
    gap: 3px;
  }

  .modal-shell.is-register .login-field-input {
    min-height: 36px;
    padding-block: 5px;
    font-size: 0.75rem;
  }

  .modal-shell.is-register .login-panel-form {
    gap: 5px;
  }

  .modal-shell.is-register .login-note {
    display: none;
  }

  .modal-shell.is-register .auth-mode-switch {
    display: flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(255, 250, 235, 0.84);
    border: 1px solid rgba(91, 57, 37, 0.3);
    border-radius: 8px;
    font-size: 0.78rem;
  }

  .modal-shell.is-register .auth-mode-switch button {
    min-height: 34px;
    padding: 5px 8px;
    background: #fff0bf;
    border: 1px solid rgba(91, 57, 37, 0.42);
    border-radius: 6px;
    font-size: 0.8rem;
  }

  .modal-shell:not(.is-register) .login-note {
    display: none;
  }

  .modal-shell:not(.is-register) .auth-mode-switch {
    display: flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(255, 250, 235, 0.84);
    border: 1px solid rgba(91, 57, 37, 0.3);
    border-radius: 8px;
    font-size: 0.78rem;
  }

  .modal-shell:not(.is-register) .auth-mode-switch button {
    min-height: 34px;
    padding: 5px 8px;
    background: #fff0bf;
    border: 1px solid rgba(91, 57, 37, 0.42);
    border-radius: 6px;
    font-size: 0.8rem;
  }

  .login-dialog .login-title {
    padding-inline: 14px;
    font-size: clamp(1.25rem, 6.2vw, 1.55rem);
  }

  .login-description {
    font-size: 0.75rem;
  }

  .login-field-input {
    min-height: 40px;
    padding-block: 6px;
    font-size: 0.78rem;
  }

  .login-field-label {
    font-size: 0.78rem;
  }

  .login-panel-form {
    gap: 7px;
  }

  .login-panel-submit {
    min-width: 142px;
  }

  .login-note {
    font-size: 0.68rem;
  }
}

@media (max-width: 340px) {
  .login-panel-content {
    inset: 12% 10% 8%;
    gap: 6px;
    padding: 14px 2% 12px;
  }

  .login-description {
    display: none;
  }

  .login-dialog .login-title {
    font-size: 1.15rem;
  }

  .login-field-group {
    gap: 3px;
  }

  .login-field-input {
    min-height: 38px;
  }

  .login-panel-form {
    gap: 6px;
  }

  .login-panel-submit {
    min-width: 132px;
  }

  .login-note {
    font-size: 0.62rem;
  }

  .modal-shell.is-register .login-dialog {
    height: min(620px, calc(100dvh - 16px));
  }

  .modal-shell.is-register .login-panel-content {
    inset: 9% 8% 6%;
    gap: 4px;
    padding: 6px 2% 12px;
  }

  .modal-shell.is-register .login-description {
    display: none;
  }

  .modal-shell.is-register .login-field-input {
    min-height: 34px;
  }

  .modal-shell.is-register .login-panel-form {
    gap: 4px;
  }
}

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

  .landing-start,
  .landing-start img,
  .login-art-close,
  .login-panel-submit {
    transition: none;
  }
}

:root[data-motion="reduced"] .welcome-screen {
  animation: none;
}

.map-wordmark {
  display: block;
  width: 130px;
  height: 116px;
  color: transparent;
  text-shadow: none;
  letter-spacing: normal;
  line-height: normal;
  transform: none;
}

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

.map-place {
  display: none;
}

.map-world-next {
  display: none;
}

.profile-card-game {
  display: grid;
  gap: 10px;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.profile-card-game::before {
  display: none;
}

.profile-avatar-badge {
  position: relative;
  width: 84px;
  height: 92px;
  flex: none;
}

.profile-avatar-trigger {
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease;
}

.profile-avatar-trigger:hover,
.profile-avatar-trigger[aria-expanded="true"] {
  filter: brightness(1.05);
  transform: translateY(-2px);
}

.profile-avatar-trigger:focus-visible {
  outline-offset: 2px;
}

.profile-avatar-frame,
.profile-avatar-user,
.profile-avatar-default,
.profile-level-ribbon {
  position: absolute;
  display: block;
}

.profile-avatar-frame {
  z-index: 2;
  top: 0;
  left: 50%;
  width: 90%;
  aspect-ratio: 1;
  overflow: visible;
  border-radius: 50%;
  transform: translateX(-50%);
}

.profile-avatar-frame--custom {
  overflow: hidden;
  background: linear-gradient(140deg, #fff4ad 0%, #ffc42b 34%, #9e561b 51%, #ffe47c 68%, #cc7a1d 100%);
  border: 4px solid #754116;
  box-shadow: 0 3px 0 rgba(56, 37, 29, 0.35);
}

.profile-avatar-frame--custom::after {
  position: absolute;
  z-index: 2;
  inset: 3px;
  content: "";
  border: 2px solid #ffea8f;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(122, 65, 17, 0.45);
  pointer-events: none;
}

.profile-avatar-default {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.profile-avatar-user {
  z-index: 1;
  inset: 7%;
  width: 86%;
  height: 86%;
  border-radius: 50%;
  background: var(--cream);
  object-fit: cover;
}

.profile-level-ribbon {
  z-index: 4;
  top: 69%;
  left: 50%;
  width: 94%;
  height: auto;
  object-fit: contain;
  transform: translateX(-50%);
  pointer-events: none;
}

.profile-level-label {
  position: absolute;
  z-index: 5;
  top: 83%;
  left: 50%;
  width: 52%;
  color: #fffaf2;
  font-family: var(--font-display);
  font-size: clamp(0.52rem, 0.75vw, 0.72rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 2px #742015;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.profile-info {
  min-width: 0;
  flex: 1;
}

.profile-xp-row {
  display: block;
  margin-top: 8px;
}

.profile-xp-row .points-meter {
  position: relative;
  height: 26px;
  margin: 0;
  background: #aaa8a1;
  border: 3px solid var(--brown);
}

.profile-xp-row .points-meter strong {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fffdf7;
  font-family: var(--font-display);
  font-size: 0.84rem;
  line-height: 1;
  text-shadow: 0 1px 2px #5b3a2b, 1px 0 1px #5b3a2b, -1px 0 1px #5b3a2b;
}

.daily-progress-row {
  display: grid;
  grid-template-columns: 38px minmax(70px, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.daily-progress {
  position: relative;
}

.daily-gift {
  display: block;
  width: 38px;
  height: 44px;
  object-fit: contain;
}

.daily-quest-note {
  margin: 0;
}

.streak-card {
  position: relative;
  height: 52px;
  margin-top: 0;
  padding: 5px 12px;
  background: url("assets/dashboard/streak-bar-1.png") center / 100% 100% no-repeat;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.streak-days {
  width: 82%;
  height: 100%;
  flex: none;
  gap: 0;
}

.streak-day {
  align-content: center;
  gap: 3px;
}

.streak-day b {
  position: relative;
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.streak-day b img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.streak-day b .streak-day-hole { z-index: 0; }
.streak-day b .streak-day-status { z-index: 1; }

.streak-day small {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  color: #fff5e4;
  font-size: clamp(0.45rem, 0.58vw, 0.6rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.streak-total {
  position: absolute;
  top: 50%;
  right: 2%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 17%;
  min-width: 0;
  font-size: 0.76rem;
  text-align: center;
  transform: translateY(-50%);
}

.streak-total > img {
  width: 17px;
  height: 21px;
  flex: none;
  object-fit: contain;
}

.streak-total > span {
  display: grid;
  justify-items: center;
  color: #fff7e8;
  font-family: var(--font-display);
  font-size: 0.72rem;
  line-height: 1;
}

.streak-total small {
  display: block;
  margin-top: 2px;
  font-family: var(--font-body);
  font-size: 0.43rem;
  font-weight: 900;
  line-height: 1;
}

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

@media (min-width: 1181px) {
  .dashboard-screen:not(.is-quiz-screen) .dashboard-layout {
    grid-template-columns: 138px minmax(0, 1fr);
  }

  .dashboard-screen:not(.is-quiz-screen) .side-nav {
    position: relative;
    width: 94px;
    height: calc(100dvh - 80px);
    min-height: 0;
    margin: 41px 0 0 29px;
    padding: 6px 5px;
    background-color: #bd7a46;
    background-image: repeating-linear-gradient(0deg, #b46f3f 0 19px, #c8824d 19px 24px);
    border: 3px solid var(--brown-deep);
    border-radius: 4px;
    box-shadow: 0 4px 0 rgba(56, 37, 29, 0.24);
  }

  .dashboard-screen:not(.is-quiz-screen) .side-nav::before {
    position: absolute;
    z-index: 0;
    inset: 6px;
    content: "";
    background: var(--cream);
    border: 2px solid var(--brown-deep);
    border-radius: 5px;
  }

  .dashboard-screen:not(.is-quiz-screen) .side-nav > * {
    position: relative;
    z-index: 1;
  }

  .dashboard-screen:not(.is-quiz-screen) .desktop-nav {
    flex: 1;
    align-content: start;
    gap: 4px;
    padding: 8px 3px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .dashboard-screen:not(.is-quiz-screen) .nav-item:has(.nav-asset),
  .dashboard-screen:not(.is-quiz-screen) .nav-item[data-view="community"] {
    min-height: 58px;
    padding: 3px 2px;
  }

  .dashboard-screen:not(.is-quiz-screen) .nav-item.is-active {
    background: #dedbd5;
    border-color: transparent;
    box-shadow: none;
  }

  .dashboard-screen:not(.is-quiz-screen) .nav-logout {
    margin-top: auto;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
  }

  .dashboard-screen[data-active-view="home"] .dashboard-main {
    min-width: 0;
    padding: 41px 20px 25px 0;
  }

  .dashboard-screen[data-active-view="home"] .view-root {
    width: 100%;
    max-width: none;
  }

  .dashboard-screen[data-active-view="home"] .map-panel-toolbar {
    display: none;
  }

  .home-view.home-map-view {
    grid-template-columns: minmax(0, 1fr) minmax(336px, min(24vw, 425px));
    align-items: start;
    gap: 18px;
    min-height: calc(100dvh - 73px);
  }

  .home-map-view .map-panel-landscape {
    grid-template-rows: minmax(0, 1fr);
    height: min(856px, calc(100dvh - 74px));
    min-height: 0;
    padding: 0;
    overflow: hidden;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .home-map-view .map-frame {
    width: 100%;
    height: 100%;
    border-width: 12px;
    border-image-width: 12px;
    border-radius: 0;
  }

  .home-map-view .map-frame .map-scroll {
    width: 100%;
    height: 100%;
  }

  .home-map-view .map-board-landscape {
    width: 2294px;
    height: 100%;
    min-height: 0;
    background-image: url("assets/ui-horizontal/map-background-horizontal.webp");
    background-position: left center;
    background-size: 1147px 100%;
    background-repeat: no-repeat;
  }

  .home-map-view .map-board-landscape::before,
  .home-map-view .map-board-landscape::after,
  .home-map-view .map-board-landscape .map-cactus {
    display: none;
  }

  .home-map-view .map-board-landscape .map-route {
    background-image: url("assets/ui-horizontal/street-horizontal.png");
    background-position: left center;
    background-size: 2294px 100%;
    background-repeat: no-repeat;
  }

  .home-map-view .map-board-landscape .map-world-next {
    position: absolute;
    z-index: 0;
    top: 0;
    left: 1147px;
    display: block;
    width: 1147px;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
  }

  .home-map-view .map-wordmark {
    top: 12px;
    right: auto;
    left: 990px;
    width: 130px;
    height: 116px;
  }

  .home-map-view .map-node {
    width: 142px;
  }

  .home-map-view .map-place {
    position: absolute;
    z-index: 2;
    display: block;
    height: auto;
    pointer-events: none;
    user-select: none;
  }

  .home-map-view .map-place-city {
    top: 80px;
    left: 52px;
    width: 337px;
  }

  .home-map-view .map-place-frontier {
    top: 215px;
    left: 825px;
    width: 370px;
  }

  .home-map-view .map-place-island {
    top: 632px;
    left: 728px;
    width: 459px;
  }

  .home-map-view .map-place-next-city {
    top: 80px;
    left: 1199px;
    width: 337px;
  }

  .home-map-view .map-place-next-frontier {
    top: 215px;
    left: 1972px;
    width: 370px;
  }

  .home-map-view .map-place-next-island {
    top: 632px;
    left: 1875px;
    width: 419px;
  }

  .home-map-view .map-board-landscape .map-node {
    left: var(--node-x-wide);
  }

  .home-map-view .node-orb {
    width: 142px;
    height: 142px;
  }

  .home-map-view .node-note,
  .home-map-view .map-node:nth-of-type(2) .node-note,
  .home-map-view .map-node:nth-of-type(4) .node-note {
    top: auto;
    bottom: 170px;
    width: 286px;
    min-height: 158px;
    padding: 14px 18px;
    border-radius: 15px;
    transform: translateX(-50%);
  }

  .home-map-view .map-node-locked .node-note {
    bottom: 179px;
  }

  .home-map-view .node-note small {
    font-size: 0.9rem;
  }

  .home-map-view .node-note strong {
    font-size: 1.23rem;
    line-height: 1.07;
  }

  .home-map-view .node-note .node-subtitle {
    margin-top: 7px;
    font-size: 0.92rem;
  }

  .home-map-view .map-node:nth-of-type(1) .node-note,
  .home-map-view .map-node:nth-of-type(3) .node-note {
    top: 50%;
    right: calc(100% + 36px);
    bottom: auto;
    left: auto;
    transform: translateY(-50%);
  }

  .home-map-view .map-node:nth-of-type(1) .node-note {
    right: calc(100% + 45px);
  }

  .home-map-view .map-node:nth-of-type(3) .node-note {
    right: calc(100% + 29px);
    transform: translateY(calc(-50% - 31px));
  }

  .home-map-view .map-node:nth-of-type(2) .node-note {
    top: 50%;
    right: auto;
    bottom: auto;
    left: calc(100% + 36px);
    transform: translateY(-50%);
  }

  .home-map-view .map-node:nth-of-type(1) .node-note::after,
  .home-map-view .map-node:nth-of-type(3) .node-note::after {
    top: 50%;
    right: -13px;
    bottom: auto;
    left: auto;
    border-top: 3px solid var(--brown);
    border-right: 3px solid var(--brown);
    border-bottom: 0;
    border-left: 0;
    transform: translateY(-50%) rotate(45deg);
  }

  .home-map-view .map-node:nth-of-type(2) .node-note::after {
    top: 50%;
    right: auto;
    bottom: auto;
    left: -13px;
    border-top: 0;
    border-right: 0;
    border-bottom: 3px solid var(--brown);
    border-left: 3px solid var(--brown);
    transform: translateY(-50%) rotate(45deg);
  }

  .home-map-view .side-rail {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 100px auto 224px 75px;
    align-content: start;
    gap: 12px;
    width: auto;
    height: min(864px, calc(100dvh - 66px));
    padding: 8px 19px 20px;
    overflow: visible;
    background: var(--cream);
    border: 3px solid var(--brown);
    border-radius: 17px;
    box-shadow: 0 5px 0 rgba(56, 37, 29, 0.3);
    transform: translateY(-4px);
  }

  /* Two-row achievements (5–8 badges): fixed track so the badge card
     always contains both rows; the rail scrolls if needed. */
  .home-map-view .side-rail.rail-many-badges {
    grid-template-rows: auto 100px 200px 224px 75px;
  }

  .home-map-view .profile-card-game {
    gap: 14px;
    margin-bottom: 22px;
  }

  .home-map-view .profile-header {
    align-items: flex-start;
    gap: 12px;
  }

  .home-map-view .profile-avatar-badge {
    width: 120px;
    height: 132px;
  }

  .home-map-view .profile-level-label {
    font-size: 1rem;
  }

  .home-map-view .profile-info {
    padding-top: 10px;
  }

  .home-map-view .profile-name strong {
    font-size: 1.8rem;
    line-height: 1.05;
  }

  .home-map-view .profile-name span {
    margin-top: 3px;
    font-size: 1rem;
    white-space: nowrap;
  }

  .home-map-view .profile-xp-row {
    margin-top: 11px;
  }

  .home-map-view .profile-xp-row .points-meter {
    height: 34px;
    background: #aaa8a1 url("assets/dashboard/progress-bar-bg.png") center / 100% 100% no-repeat;
    border: 0;
  }

  .home-map-view .profile-xp-row .points-meter span {
    top: 3px;
    left: 3px;
    height: calc(100% - 6px);
    background: url("assets/dashboard/progress-bar-fill.png") left center / 100% 100% no-repeat;
  }

  .home-map-view .profile-xp-row .points-meter strong {
    font-size: 1rem;
  }

  .home-map-view .streak-card {
    height: 58px;
    padding-inline: 12px;
  }

  .home-map-view .streak-day b {
    width: 22px;
    height: 22px;
  }

  .home-map-view .streak-total {
    top: 50%;
    right: 2%;
    width: 17%;
    color: #fff7e8;
    font-size: 0.82rem;
    transform: translateY(-50%);
  }

  .home-map-view .daily-card {
    height: 100px;
    padding: 9px 16px;
    background: url("assets/dashboard/daily-quest-container.png") center / 100% 100% no-repeat;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .home-map-view .daily-card .rail-heading {
    margin-bottom: 2px;
    padding-left: 6px;
  }

  .home-map-view .daily-card .rail-heading h2 {
    font-size: 1.12rem;
  }

  .home-map-view .daily-progress-row {
    grid-template-columns: 38px minmax(70px, 1fr) auto;
    gap: 5px;
    height: 49px;
  }

  .home-map-view .daily-gift {
    position: relative;
    z-index: 2;
    width: 38px;
    height: 44px;
  }

  .home-map-view .daily-progress {
    height: 25px;
    margin: 0;
    background: url("assets/dashboard/quest-bar-bg.png") center / 100% 100% no-repeat;
    border: 0;
    border-radius: 0;
  }

  .home-map-view .daily-progress span {
    position: absolute;
    top: 3px;
    left: 3px;
    height: calc(100% - 6px);
    background: url("assets/dashboard/quest-bar-fill.png") left center / 100% 100% no-repeat;
    border-radius: 20px;
  }

  .home-map-view .daily-count {
    color: var(--brown);
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .home-map-view .badge-panel {
    height: auto;
    min-height: 125px;
    padding: 8px 15px 5px;
    background: url("assets/dashboard/achievements-container.png") center / 100% 100% no-repeat;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .home-map-view .badge-panel .rail-heading {
    margin: 0 2px 0;
  }

  .home-map-view .badge-panel .rail-heading h2,
  .home-map-view .activity-panel .rail-heading h2 {
    font-size: 1.12rem;
  }

  .home-map-view .badge-panel .badge-list {
    height: auto;
    min-height: 88px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: hidden;
  }

  .home-map-view .badge-panel .badge-item {
    min-height: 76px;
    font-size: 0.72rem;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }

  .home-map-view .badge-panel .badge-art {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 70px;
    min-height: 0;
    object-fit: contain;
  }

  .home-map-view .activity-panel {
    height: 224px;
    padding: 9px 17px 10px;
    background: url("assets/dashboard/activity-feed-container.png") center / 100% 100% no-repeat;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .home-map-view .activity-panel .rail-heading {
    margin: 0 2px 2px;
  }

  .home-map-view .activity-list {
    gap: 0;
  }

  .home-map-view .activity-item {
    grid-template-columns: 46px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 57px;
    padding: 4px 0;
    border-bottom-color: rgba(91, 58, 43, 0.28);
  }

  .home-map-view .activity-mark {
    width: 46px;
    height: 46px;
    background: transparent;
    border: 0;
    border-radius: 0;
  }

  .home-map-view .activity-item strong {
    font-size: 1rem;
    line-height: 1.1;
  }

  .home-map-view .activity-item div span {
    margin-top: 2px;
    color: #a66c42;
    font-size: 0.84rem;
    font-weight: 750;
  }

  .home-map-view .activity-item time {
    font-size: 0.66rem;
  }

  .home-map-view .rail-action {
    align-self: start;
    justify-self: center;
    width: min(309px, 88%);
    height: 75px;
    min-height: 75px;
    margin-top: 28px;
  }
}

@media (min-width: 1181px) and (max-height: 800px) {
  .dashboard-screen:not(.is-quiz-screen) .side-nav {
    height: calc(100dvh - 40px);
    margin-top: 20px;
  }

  .dashboard-screen[data-active-view="home"] .dashboard-main {
    padding-top: 20px;
    padding-bottom: 20px;
  }

  .home-map-view .map-panel-landscape {
    height: calc(100dvh - 52px);
  }

  .home-map-view .side-rail {
    grid-template-rows: auto 84px auto 180px 54px;
    gap: 8px;
    height: calc(100dvh - 40px);
    padding: 8px 14px 12px;
    overflow-y: auto;
    transform: translateY(-4px);
  }

  .home-map-view .side-rail.rail-many-badges {
    grid-template-rows: auto 84px 150px 180px 54px;
  }

  .home-map-view .profile-card-game {
    gap: 8px;
    margin-bottom: 0;
  }

  .home-map-view .profile-avatar-badge {
    width: 82px;
    height: 90px;
  }

  .home-map-view .profile-info {
    padding-top: 2px;
  }

  .home-map-view .profile-name strong {
    font-size: 1.05rem;
  }

  .home-map-view .profile-name span {
    font-size: 0.66rem;
  }

  .home-map-view .profile-xp-row {
    margin-top: 6px;
  }

  .home-map-view .profile-xp-row .points-meter {
    height: 25px;
  }

  .home-map-view .profile-level-label {
    font-size: 0.65rem;
  }

  .home-map-view .streak-card {
    height: 48px;
  }

  .home-map-view .streak-day b {
    width: 18px;
    height: 18px;
  }

  .home-map-view .daily-card {
    height: 84px;
    padding-block: 5px;
  }

  .home-map-view .daily-progress-row {
    height: 42px;
  }

  .home-map-view .badge-panel {
    height: auto;
    min-height: 104px;
    padding-block: 5px;
  }

  .home-map-view .badge-panel .badge-list {
    height: auto;
    min-height: 74px;
  }

  .home-map-view .badge-panel .badge-item,
  .home-map-view .badge-panel .badge-art {
    height: 56px;
    min-height: 0;
    max-width: 100%;
  }

  .home-map-view .activity-panel {
    height: 180px;
    padding-block: 5px;
  }

  .home-map-view .activity-item {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    min-height: 45px;
    gap: 7px;
  }

  .home-map-view .activity-mark {
    width: 34px;
    height: 34px;
  }

  .home-map-view .activity-item strong {
    font-size: 0.72rem;
  }

  .home-map-view .activity-item div span {
    font-size: 0.64rem;
  }

  .home-map-view .activity-item time {
    font-size: 0.56rem;
  }

  .home-map-view .rail-action {
    height: 54px;
    min-height: 54px;
    margin-top: 0;
  }

  .home-map-view.map-layout-vertical .map-board-vertical .map-wordmark {
    top: 12px;
    right: 14px;
    left: auto;
    width: 104px;
    height: 92px;
  }

  .home-map-view.map-layout-vertical .map-board-vertical .map-node {
    width: 116px;
  }

  .home-map-view.map-layout-vertical .map-board-vertical .node-orb {
    width: 91px;
    height: 91px;
  }

  .home-map-view.map-layout-vertical .map-board-vertical .node-note {
    top: auto;
    right: auto;
    bottom: 102px;
    left: 50%;
    width: 218px;
    min-height: 100px;
    padding: 10px 12px;
    border-radius: 12px;
    transform: translateX(-50%);
  }

  .home-map-view.map-layout-vertical .map-board-vertical .node-note::after {
    top: auto;
    right: auto;
    bottom: -13px;
    left: 50%;
    border-top: 0;
    border-right: 3px solid var(--brown);
    border-bottom: 3px solid var(--brown);
    border-left: 0;
    transform: translateX(-50%) rotate(45deg);
  }

  .home-map-view.map-layout-vertical .map-board-vertical .node-note small {
    font-size: 0.76rem;
  }

  .home-map-view.map-layout-vertical .map-board-vertical .node-note strong {
    font-size: 1rem;
    line-height: 1.08;
  }

  .home-map-view.map-layout-vertical .map-board-vertical .node-note .node-subtitle {
    margin-top: 6px;
    font-size: 0.75rem;
  }
}

/* Keep the supplied map artwork in proportion on laptop and phone viewports. */
@media (min-width: 1181px) and (max-height: 800px) {
  .home-map-view .map-board-landscape {
    height: 832px;
    min-height: 832px;
    zoom: 0.77;
  }
}

@media (max-width: 1180px) {
  .home-map-view .map-board-landscape {
    width: 2294px;
    height: 832px;
    min-height: 832px;
    border: 0;
    border-radius: 0;
    background: #f6ca79 url("assets/ui-horizontal/map-background-horizontal.webp") left top / 1147px 832px no-repeat;
    zoom: 0.68;
  }

  .home-map-view .map-board-landscape::before,
  .home-map-view .map-board-landscape::after,
  .home-map-view .map-board-landscape .map-cactus {
    display: none;
  }

  .home-map-view .map-board-landscape .map-route {
    background: url("assets/ui-horizontal/street-horizontal.png") left top / 2294px 832px no-repeat;
  }

  .home-map-view .map-board-landscape .map-world-next {
    position: absolute;
    z-index: 0;
    top: 0;
    left: 1147px;
    display: block;
    width: 1147px;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
  }

  .home-map-view .map-board-landscape .map-wordmark {
    top: 12px;
    right: auto;
    left: 990px;
    width: 130px;
    height: 116px;
  }

  .home-map-view .map-board-landscape .map-place {
    position: absolute;
    z-index: 2;
    display: block;
    height: auto;
    pointer-events: none;
  }

  .home-map-view .map-place-city { top: 80px; left: 52px; width: 337px; }
  .home-map-view .map-place-frontier { top: 215px; left: 825px; width: 370px; }
  .home-map-view .map-place-island { top: 632px; left: 728px; width: 459px; }
  .home-map-view .map-place-next-city { top: 80px; left: 1199px; width: 337px; }
  .home-map-view .map-place-next-frontier { top: 215px; left: 1972px; width: 370px; }
  .home-map-view .map-place-next-island { top: 632px; left: 1875px; width: 419px; }

  .home-map-view .map-board-landscape .map-node {
    left: var(--node-x-wide);
    width: 142px;
  }

  .home-map-view .map-board-landscape .node-orb {
    width: 142px;
    height: 142px;
  }

  .home-map-view .map-board-landscape .node-note {
    top: auto;
    bottom: 170px;
    width: 286px;
    min-height: 158px;
    padding: 14px 18px;
    transform: translateX(-50%);
  }

  .home-map-view .map-node:nth-of-type(1) .node-note,
  .home-map-view .map-node:nth-of-type(3) .node-note {
    top: 50%;
    right: calc(100% + 45px);
    bottom: auto;
    left: auto;
    transform: translateY(-50%);
  }

  .home-map-view .map-node:nth-of-type(3) .node-note {
    right: calc(100% + 29px);
    transform: translateY(calc(-50% - 31px));
  }

  .home-map-view .map-node:nth-of-type(2) .node-note {
    top: 50%;
    right: auto;
    bottom: auto;
    left: calc(100% + 36px);
    transform: translateY(-50%);
  }
}

/* The quiz occupies the map frame and uses the supplied answer/button artwork. */
.resource-play-button {
  padding: 0;
  background: transparent;
  border: 0;
  font-family: inherit;
  cursor: pointer;
}

.quiz-game-view {
  min-width: 0;
}

.quiz-game-panel {
  min-width: 0;
  height: min(856px, calc(100dvh - 74px));
}

.quiz-game-frame {
  width: 100%;
  height: 100%;
  border-width: 12px;
  border-image-width: 12px;
}

.quiz-game-board {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.8vh, 21px);
  width: 100%;
  height: 100%;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: clamp(20px, 3vw, 42px);
  background: #f6ca79 url("assets/ui-horizontal/map-background-horizontal.webp") center / 100% 100% no-repeat;
  border: 2px solid #312016;
  scrollbar-color: #815234 #f6ca79;
}

.quiz-game-timer {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: 7px;
  min-height: 48px;
  padding: 5px 24px;
  color: #795039;
  background: #fff8e7;
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 1.4rem;
  line-height: 1;
}

.quiz-game-timer img {
  width: 31px;
  height: 31px;
  object-fit: contain;
}

.quiz-game-question {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-height: 144px;
  padding: 24px 26px 27px;
  color: #795039;
  background: url("assets/quiz/question-panel.png") center / 100% 100% no-repeat;
}

.quiz-game-question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quiz-game-question-head > span {
  font-size: 0.77rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.quiz-game-question h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1rem, 1.8vw, 1.45rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

#quiz-intro-heading:focus {
  outline: 3px solid var(--brown-deep);
  outline-offset: 3px;
}

/* Quiz intro: lesson reading shown like a question, scrollable, then Start. */
.quiz-game-board.town-quiz-intro-board {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  align-items: stretch;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.town-quiz-intro-copy {
  max-height: none;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
  color: var(--brown-deep);
  background: var(--cream);
  border: 2px solid var(--brown-deep);
  border-radius: 12px;
  scrollbar-color: var(--brown-deep) var(--cream);
}

.town-quiz-intro-copy p {
  margin: 0 0 10px;
  font-size: clamp(0.85rem, 1.2vw, 1rem);
  line-height: 1.55;
}

.town-quiz-intro-copy p:last-child {
  margin-bottom: 0;
}

.town-quiz-intro-meta {
  margin: 0;
  color: var(--brown-soft);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.town-quiz-intro-footer {
  align-items: center;
}

.town-quiz-intro-footer .button-primary {
  min-width: 190px;
  font-size: 1.05rem;
}

/* Short screens: keep the intro question, reading copy, meta, and Start
   visible without scrolling the board. */
@media (max-height: 620px) {
  .quiz-game-board.town-quiz-intro-board .quiz-game-question {
    min-height: 0;
    padding: 12px 16px;
  }

  .town-quiz-intro-copy {
    max-height: 22dvh;
  }

  .town-quiz-intro-meta {
    font-size: 0.72rem;
  }
}

.quiz-game-description {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #795039;
  font-size: clamp(0.72rem, 1vw, 0.92rem);
  font-weight: 750;
  line-height: 1.2;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.quiz-game-hint-button {
  width: 38px;
  height: 38px;
  flex: none;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.quiz-game-hint-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.quiz-game-context {
  display: flex;
  align-items: center;
  min-height: 75px;
  margin: 0;
  padding: 14px 21px;
  color: #795039;
  background: rgba(255, 249, 233, 0.85);
  border-radius: 9px;
  font-size: clamp(0.88rem, 1.3vw, 1.08rem);
  font-weight: 800;
  line-height: 1.35;
}

.quiz-game-context.is-hint {
  background: url("assets/quiz/hint-panel.png") center / 100% 100% no-repeat;
}

.quiz-game-context.is-correct { color: #28652a; }
.quiz-game-context.is-incorrect { color: #993221; }

.quiz-game-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 28px) clamp(12px, 2.7vw, 46px);
  min-width: 0;
  margin-top: 2px;
}

.quiz-game-option {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  width: 100%;
  min-width: 0;
  min-height: 110px;
  padding: 11px 20px;
  color: white;
  background: url("assets/quiz/option.png") center / 100% 100% no-repeat;
  border: 0;
  font-family: var(--font-display);
  font-size: clamp(0.96rem, 1.45vw, 1.35rem);
  line-height: 1.22;
  text-align: left;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease;
}

.quiz-game-option:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-2px);
}

.quiz-game-option.is-selected {
  background-image: url("assets/quiz/selected.png");
}

.quiz-game-option.is-correct {
  background-image: url("assets/quiz/answer-correct.png");
}

.quiz-game-option.is-incorrect {
  background-image: url("assets/quiz/answer-incorrect.png");
}

.quiz-game-option:disabled {
  cursor: default;
  opacity: 1;
}

.quiz-game-option-letter {
  display: grid;
  place-items: center;
  width: 60px;
  height: 55px;
  color: #795039;
  font-size: clamp(1.6rem, 2.7vw, 2.6rem);
  line-height: 1;
}

.quiz-game-option-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.quiz-game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-top: auto;
  padding-top: 20px;
}

.quiz-game-footer > span {
  color: #533b2c;
  font-family: var(--font-display);
  font-size: clamp(1rem, 1.8vw, 1.55rem);
  text-align: center;
}

.quiz-game-graphic-button {
  display: block;
  width: clamp(140px, 24%, 268px);
  flex: none;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease;
}

.quiz-game-graphic-button img {
  display: block;
  width: 100%;
  height: auto;
}

.quiz-game-graphic-button:hover:not(:disabled) {
  filter: brightness(1.07);
  transform: translateY(-3px);
}

.quiz-game-graphic-button:disabled {
  cursor: default;
  filter: grayscale(1);
  opacity: 0.55;
}

.quiz-game-rail {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  min-height: min(864px, calc(100dvh - 66px));
  padding: 18px 20px;
  color: #795039;
  background: var(--cream);
  border: 3px solid var(--brown);
  border-radius: 17px;
  box-shadow: 0 5px 0 rgba(56, 37, 29, 0.3);
}

.quiz-game-player {
  display: flex;
  align-items: center;
  gap: 16px;
}

.quiz-game-avatar {
  flex: none;
  width: 110px;
  height: 110px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.quiz-game-player strong,
.quiz-game-player span:not(.avatar) {
  display: block;
}

.quiz-game-player strong {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.quiz-game-player div > span {
  margin-top: 4px;
  font-size: 0.9rem;
  font-weight: 750;
}

.quiz-game-achievements {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 7px;
  min-height: 228px;
  padding: 12px 16px 18px;
  background: #fff;
  border: 2px solid #ded8d1;
  border-radius: 10px;
  box-shadow: 0 4px 0 #b8b1a9;
}

.quiz-game-achievements h3 {
  justify-self: start;
  width: 100%;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.quiz-game-achievements img {
  width: 96px;
  height: 116px;
  object-fit: contain;
  filter: grayscale(1);
}

.quiz-game-achievements > strong {
  color: #8a8a8a;
  font-family: var(--font-display);
  font-size: 1rem;
}

.quiz-game-achievements small {
  color: #8a8a8a;
  font-size: 0.7rem;
}

@media (max-width: 1180px) {
  .quiz-game-view {
    grid-template-columns: 1fr;
  }

  .quiz-game-panel {
    min-height: 690px;
    height: auto;
  }

  .quiz-game-board {
    height: auto;
    min-height: 670px;
  }

  .quiz-game-rail {
    min-height: 0;
  }
}

@media (max-width: 650px) {
  .quiz-game-frame {
    border-width: 9px;
    border-image-width: 9px;
  }

  .quiz-game-board {
    padding: 18px 15px;
  }

  .quiz-game-question {
    min-height: 155px;
    padding: 21px 18px;
  }

  .quiz-game-question h2 {
    font-size: 1.08rem;
  }

  .quiz-game-options {
    grid-template-columns: 1fr;
  }

  .quiz-game-option {
    min-height: 88px;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 14px;
    padding-inline: 16px;
  }

  .quiz-game-option-letter {
    width: 52px;
    height: 48px;
  }

  .quiz-game-footer {
    flex-wrap: wrap;
  }

  .quiz-game-footer > span {
    order: -1;
    width: 100%;
  }

  .quiz-game-graphic-button {
    width: min(46%, 168px);
  }

  .quiz-game-rail {
    padding: 16px;
  }

  .quiz-game-avatar {
    width: 76px;
    height: 76px;
  }

}

/* A quiz is a single-screen activity: keep its frame and controls inside the viewport. */
.dashboard-screen.is-quiz-screen {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.dashboard-screen.is-quiz-screen .dashboard-layout {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.dashboard-screen.is-quiz-screen .dashboard-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.dashboard-screen.is-quiz-screen .view-root {
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-width: none;
  margin: 0 auto;
}

.dashboard-screen.is-quiz-screen .quiz-game-view {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
}

.dashboard-screen.is-quiz-screen .quiz-game-panel,
.dashboard-screen.is-quiz-screen .quiz-game-frame,
.dashboard-screen.is-quiz-screen .quiz-game-board,
.dashboard-screen.is-quiz-screen .quiz-game-rail {
  height: 100%;
  min-height: 0;
}

.dashboard-screen.is-quiz-screen .quiz-game-panel,
.dashboard-screen.is-quiz-screen .quiz-game-frame,
.dashboard-screen.is-quiz-screen .quiz-game-rail {
  overflow: hidden;
}

.dashboard-screen.is-quiz-screen .quiz-game-board {
  display: grid;
  grid-template-rows: auto minmax(88px, auto) minmax(48px, auto) minmax(0, 1fr) auto;
  gap: clamp(6px, 1.2vh, 12px);
  padding: clamp(10px, 2vh, 22px) clamp(12px, 2vw, 30px);
  overflow: hidden;
  scrollbar-width: none;
}

.dashboard-screen.is-quiz-screen .quiz-game-timer {
  min-height: 38px;
  padding-block: 3px;
  font-size: clamp(1rem, 1.8vw, 1.35rem);
}

.dashboard-screen.is-quiz-screen .quiz-game-timer img {
  width: 27px;
  height: 27px;
}

.dashboard-screen.is-quiz-screen .quiz-game-timer {
  position: relative;
  top: clamp(20px, 2.8vh, 36px);
}

.dashboard-screen.is-quiz-screen .quiz-game-question,
.dashboard-screen.is-quiz-screen .quiz-game-context {
  position: relative;
  top: clamp(30px, 3.3vh, 40px);
}

.dashboard-screen.is-quiz-screen .quiz-game-question {
  min-height: 0;
  padding: clamp(10px, 1.5vh, 18px) clamp(16px, 1.8vw, 24px);
}

.dashboard-screen.is-quiz-screen .quiz-game-context {
  min-height: 0;
  padding: 8px clamp(12px, 1.6vw, 20px);
  line-height: 1.2;
}

.dashboard-screen.is-quiz-screen .quiz-game-options {
  grid-template-rows: repeat(2, auto);
  align-content: center;
  align-items: center;
  gap: clamp(6px, 1.3vh, 12px) clamp(10px, 2vw, 24px);
  min-height: 0;
  margin: 0;
}

.dashboard-screen.is-quiz-screen .quiz-game-option {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 0;
  max-height: 128px;
  aspect-ratio: 494 / 104;
  padding: 8px 16px 8px 21%;
  overflow: hidden;
}

.dashboard-screen.is-quiz-screen .quiz-game-option:focus-visible {
  outline-offset: -5px;
}

.dashboard-screen.is-quiz-screen .quiz-game-option-letter {
  position: absolute;
  top: 50%;
  left: 4%;
  display: grid;
  place-items: center;
  width: 12%;
  height: 56%;
  transform: translateY(-50%);
  font-size: clamp(1.25rem, 2.4vw, 2.2rem);
}

.dashboard-screen.is-quiz-screen .quiz-game-option-text {
  flex: 1 1 auto;
}

.dashboard-screen.is-quiz-screen .quiz-game-footer {
  min-height: 54px;
  margin: 0;
  padding: 0;
}

.dashboard-screen.is-quiz-screen .quiz-game-graphic-button {
  width: clamp(112px, 23%, 220px);
}

.dashboard-screen.is-quiz-screen .quiz-game-graphic-button img {
  max-height: 68px;
  object-fit: contain;
}

.dashboard-screen.is-quiz-screen .quiz-game-rail {
  min-height: 0;
}

.dashboard-screen.is-quiz-screen .quiz-game-avatar {
  width: 100px;
  height: 110px;
}

@media (max-width: 1180px) {
  .dashboard-screen.is-quiz-screen .dashboard-main {
    padding: 10px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-view {
    grid-template-columns: minmax(0, 1fr) minmax(190px, 26%);
    gap: 10px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-rail {
    gap: 10px;
    padding: 12px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-avatar {
    width: 76px;
    height: 84px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-achievements {
    min-height: 0;
    padding: 10px;
  }
}

@media (max-width: 980px) {
  .dashboard-screen.is-quiz-screen .quiz-game-view {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 26%);
  }

  .dashboard-screen.is-quiz-screen .quiz-game-achievements {
    display: none;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-player {
    gap: 8px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-player strong {
    font-size: 1rem;
  }
}

@media (max-width: 760px) {
  .dashboard-screen.is-quiz-screen {
    display: block;
  }

  .dashboard-screen.is-quiz-screen .dashboard-layout {
    display: block;
  }

  .dashboard-screen.is-quiz-screen .side-nav,
  .dashboard-screen.is-quiz-screen .mobile-nav {
    display: none;
  }

  .dashboard-screen.is-quiz-screen .dashboard-main {
    width: 100%;
    height: 100%;
    padding: 8px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-view {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 5px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-panel {
    grid-row: 2;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-rail {
    grid-row: 1;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: 0 5px;
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-avatar {
    width: 58px;
    height: 64px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-player strong {
    font-size: 1rem;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-player > div > span {
    font-size: 0.75rem;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-board {
    grid-template-rows: auto minmax(72px, auto) minmax(0, auto) minmax(0, 1fr) auto;
    padding: 8px 12px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-question {
    padding: 9px 12px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-options {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-option {
    min-height: 0;
    max-height: none;
    height: 100%;
    aspect-ratio: auto;
    padding-inline: 20%;
    font-size: 0.88rem;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2px 8px;
    min-height: 54px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-footer > span {
    order: 0;
    grid-column: 1 / -1;
    width: auto;
    font-size: 0.9rem;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-graphic-button {
    justify-self: center;
    width: min(100%, 150px);
  }
}

@media (max-width: 650px) {
  .dashboard-screen.is-quiz-screen .quiz-game-board {
    grid-template-rows: auto minmax(68px, auto) minmax(0, auto) minmax(0, 1fr) auto;
    gap: 5px;
    padding: 7px 10px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-timer {
    min-height: 30px;
    padding: 2px 12px;
    font-size: 0.95rem;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-timer img {
    width: 22px;
    height: 22px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-question-head > span {
    font-size: 0.58rem;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-question h2 {
    font-size: 0.9rem;
    line-height: 1.1;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-hint-button {
    width: 30px;
    height: 30px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-context {
    padding: 5px 8px;
    font-size: 0.7rem;
    line-height: 1.12;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-option {
    min-height: 0;
    font-size: 0.76rem;
    line-height: 1.08;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-option-letter {
    font-size: 1.2rem;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-footer {
    min-height: 46px;
  }
}

@media (max-height: 650px) {
  .dashboard-screen.is-quiz-screen .quiz-game-board {
    grid-template-rows: auto minmax(66px, auto) minmax(38px, auto) minmax(0, 1fr) auto;
    gap: 4px;
    padding: 5px 14px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-timer {
    min-height: 27px;
    padding: 1px 10px;
    font-size: 0.9rem;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-timer img {
    width: 20px;
    height: 20px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-question {
    padding-block: 6px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-question h2 {
    font-size: clamp(0.82rem, 1.4vw, 1rem);
  }

  .dashboard-screen.is-quiz-screen .quiz-game-context {
    padding-block: 4px;
    font-size: 0.78rem;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-footer {
    min-height: 36px;
  }

  .dashboard-screen.is-quiz-screen .quiz-game-graphic-button img {
    max-height: 42px;
  }
}

/* Quiz results follow the supplied pass/fail mockups while keeping the same reusable game frame and player rail. */
.quiz-result-board {
  display: grid;
  grid-template-columns: minmax(220px, 0.82fr) minmax(0, 1.18fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "banner banner"
    "score stats"
    "note stats"
    "actions actions";
  align-items: center;
  gap: clamp(8px, 1.5vh, 18px) clamp(18px, 3vw, 48px);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: clamp(14px, 2.4vw, 36px) clamp(16px, 3vw, 44px);
  overflow: hidden;
  color: #784626;
  background:
    radial-gradient(ellipse at 23% 51%, rgba(255, 250, 239, 0.45), transparent 34%),
    linear-gradient(135deg, #ffe6c7 0%, #f4d3ae 54%, #ebc39e 100%);
}

.quiz-result-banner {
  grid-area: banner;
  justify-self: center;
  width: min(38%, 414px);
  max-height: 86px;
  object-fit: contain;
}

.quiz-result-score {
  grid-area: score;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(12px, 2vh, 28px);
  min-width: 0;
}

.quiz-result-ring {
  display: grid;
  place-items: center;
  width: min(100%, clamp(150px, 18vw, 270px));
  aspect-ratio: 1;
  padding: clamp(12px, 1.7vw, 22px);
  background: rgba(255, 248, 235, 0.84);
  border-radius: 50%;
  box-shadow: 0 0 0 clamp(5px, 1vw, 12px) rgba(255, 250, 241, 0.48);
}

.quiz-result-ring-core {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 12px;
  background: #fff;
  border-radius: 50%;
}

.quiz-result-ring-core strong {
  font-family: var(--font-body);
  font-size: clamp(2.35rem, 5.5vw, 4.2rem);
  font-weight: 850;
  line-height: 1.1;
}

.quiz-result-ring-core strong.passed { color: #63d400; }
.quiz-result-ring-core strong.failed { color: #e00000; }

.quiz-result-ring-core > span {
  width: 82%;
  height: 2px;
  margin: 8px 0 10px;
  background: #858585;
}

.quiz-result-ring-core small {
  color: #888;
  font-size: clamp(0.85rem, 1.7vw, 1.35rem);
  font-weight: 800;
}

.quiz-result-status {
  display: block;
  width: min(100%, 330px);
  height: auto;
  max-height: 62px;
  object-fit: contain;
}

.quiz-result-stats {
  grid-area: stats;
  display: grid;
  grid-template-rows: repeat(5, minmax(0, 1fr));
  min-width: 0;
  min-height: 0;
  padding: 6px clamp(14px, 2vw, 28px);
  background: #fff;
  border: 1px solid #dedede;
  border-radius: 9px;
}

.quiz-result-stat {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(8px, 1.5vw, 18px);
  min-width: 0;
  padding: 5px 0;
  border-bottom: 1px solid #dedede;
  font-size: clamp(0.86rem, 1.35vw, 1.22rem);
}

.quiz-result-stat:last-child { border-bottom: 0; }

.quiz-result-stat img {
  display: block;
  width: 35px;
  height: 35px;
  object-fit: contain;
}

.quiz-result-stat strong,
.quiz-result-stat span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.quiz-result-stat strong { font-weight: 800; }
.quiz-result-stat span { font-weight: 850; }

.quiz-result-note {
  grid-area: note;
  align-self: start;
  max-width: 470px;
  margin: 0;
  color: #76543d;
  font-size: clamp(0.62rem, 0.8vw, 0.75rem);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

.quiz-result-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vw, 48px);
  width: 100%;
}

.quiz-result-action {
  display: grid;
  place-items: center;
  width: clamp(142px, 23%, 268px);
  min-height: 64px;
  padding: 8px 18px;
  color: #fff;
  background: url("assets/map/button-template.png") center / 100% 100% no-repeat;
  border: 0;
  cursor: pointer;
  font-size: clamp(1.1rem, 2vw, 1.65rem);
  line-height: 1;
  -webkit-text-stroke: 1px #57240d;
  text-shadow: 1px 2px 0 #57240d, -1px -1px 0 #57240d, 1px -1px 0 #57240d, -1px 1px 0 #57240d;
  transition: transform 150ms ease, filter 150ms ease;
}

.quiz-result-action:hover {
  filter: brightness(1.07);
  transform: translateY(-2px);
}

.quiz-result-action:focus-visible { outline-offset: -5px; }

.quiz-result-rail .quiz-game-achievements img { filter: none; }

@media (max-width: 980px) {
  .quiz-result-board {
    grid-template-columns: minmax(150px, 0.72fr) minmax(0, 1.28fr);
    gap: 8px 14px;
    padding: 12px 14px;
  }

  .quiz-result-banner { width: min(52%, 330px); }
  .quiz-result-stat { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 7px; }
  .quiz-result-stat img { width: 29px; height: 29px; }
  .quiz-result-note { font-size: 0.62rem; }
  .quiz-result-action { min-height: 54px; }
}

@media (max-width: 760px) {
  .quiz-result-board {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "banner"
      "score"
      "stats"
      "note"
      "actions";
    gap: 8px;
    padding: 9px 12px;
  }

  .quiz-result-banner { width: min(48%, 245px); max-height: 48px; }
  .quiz-result-score { grid-template-columns: auto minmax(120px, 0.75fr); justify-content: center; gap: 16px; }
  .quiz-result-ring { width: clamp(94px, 24vw, 132px); padding: 8px; }
  .quiz-result-ring-core { padding: 6px; }
  .quiz-result-ring-core strong { font-size: clamp(1.7rem, 7vw, 2.35rem); }
  .quiz-result-ring-core > span { margin: 4px 0; }
  .quiz-result-ring-core small { font-size: 0.72rem; }
  .quiz-result-status { width: min(100%, 190px); max-height: 42px; }
  .quiz-result-stats { grid-template-rows: repeat(5, minmax(30px, 1fr)); padding-inline: 12px; }
  .quiz-result-stat { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; padding-block: 2px; font-size: clamp(0.72rem, 3.2vw, 0.88rem); }
  .quiz-result-stat img { width: 24px; height: 24px; }
  .quiz-result-note { justify-self: center; max-width: 540px; font-size: 0.58rem; }
  .quiz-result-actions { gap: 10px; }
  .quiz-result-action { width: min(46%, 160px); min-height: 43px; padding: 5px 10px; font-size: 1rem; }
}

@media (max-width: 380px) {
  .quiz-result-board { gap: 5px; padding: 7px 9px; }
  .quiz-result-ring { width: 86px; }
  .quiz-result-score { grid-template-columns: auto minmax(100px, 0.75fr); gap: 12px; }
  .quiz-result-stats { grid-template-rows: repeat(5, minmax(28px, 1fr)); }
  .quiz-result-stat { font-size: 0.69rem; }
  .quiz-result-note { font-size: 0.53rem; }
  .quiz-result-action { min-height: 38px; font-size: 0.9rem; }
}

@media (min-width: 761px) and (max-height: 650px) {
  .quiz-result-board { gap: 5px 16px; padding-block: 6px; }
  .quiz-result-banner { max-height: 54px; }
  .quiz-result-ring { width: clamp(120px, 16vw, 190px); }
  .quiz-result-score { gap: 8px; }
  .quiz-result-status { max-height: 45px; }
  .quiz-result-action { min-height: 46px; }
}

@media (max-width: 760px) and (max-height: 650px) {
  .quiz-result-board { gap: 3px; padding-block: 4px; }
  .quiz-result-banner { max-height: 34px; }
  .quiz-result-ring { width: clamp(82px, 20vw, 108px); }
  .quiz-result-score { gap: 7px; }
  .quiz-result-status { max-height: 34px; }
  .quiz-result-stats { grid-template-rows: repeat(5, minmax(24px, 1fr)); }
  .quiz-result-note { font-size: 0.5rem; }
  .quiz-result-action { min-height: 34px; }
}

/* Unauthenticated players get a framed town preview and a clear sign-in gate. */
.dashboard-screen[data-auth-state="guest"] .dashboard-topbar {
  display: none;
}

.dashboard-screen[data-auth-state="guest"] .dashboard-main {
  min-width: 0;
  padding: 41px 20px 25px 0;
}

.dashboard-screen[data-auth-state="guest"] .view-root {
  width: 100%;
  max-width: none;
}

.dashboard-screen[data-auth-state="guest"] .wordmark-side {
  display: none;
}

.dashboard-screen[data-auth-state="guest"] .nav-item:disabled,
.dashboard-screen[data-auth-state="guest"] .mobile-nav-item:disabled {
  color: #8a8a8a;
  filter: grayscale(1);
  opacity: 0.68;
  cursor: not-allowed;
}

.dashboard-screen[data-auth-state="guest"] .nav-item:disabled .nav-asset {
  filter: grayscale(1);
}

/* Placeholder tabs (Belum interact): selalu disabled + tooltip, guest maupun login. */
.nav-item:disabled[data-view="community"],
.nav-item:disabled[data-view="events"],
.nav-item:disabled[data-view="settings"],
.mobile-nav-item:disabled[data-view="community"],
.mobile-nav-item:disabled[data-view="events"],
.mobile-nav-item:disabled[data-view="settings"] {
  filter: grayscale(1);
  opacity: 0.68;
  cursor: not-allowed;
}

.nav-item:disabled[data-view="community"] .nav-asset,
.nav-item:disabled[data-view="events"] .nav-asset,
.nav-item:disabled[data-view="settings"] .nav-asset {
  filter: grayscale(1);
}

/* Desktop map: toolbar atas/bawah + avatar di atas peta disembunyikan
   (avatar sudah ada di panel kanan). Tinggi Navbar/Peta/Avatar disamakan. */
@media (min-width: 981px) {
  .home-view.home-map-view {
    align-items: start;
  }

  .home-view.home-map-view .map-panel-landscape,
  .home-view.home-map-view .side-rail {
    height: calc(100dvh - 80px);
    min-height: 0;
  }

  .home-view.home-map-view .side-rail {
    overflow-y: auto;
  }

  .home-view.home-map-view .map-scroll-button,
  .home-view.home-map-view .map-player-trigger {
    display: none;
  }

  .home-view.home-map-view .map-panel-toolbar {
    display: none;
  }

  .home-view.home-map-view .map-scroll-controls {
    gap: 10px;
  }
}

/* Wide desktop: line the map grid top up with the side nav (41px). */
@media (min-width: 1181px) and (min-height: 801px) {
  .home-view.home-map-view {
    margin-top: 23px;
  }
}

.guest-home-view {
  grid-template-columns: minmax(0, 1fr) minmax(336px, min(24vw, 425px));
  align-items: stretch;
  gap: 18px;
  height: calc(100dvh - 66px);
  min-height: 600px;
}

.guest-town-frame {
  min-width: 0;
  min-height: 0;
  padding: 9px;
  overflow: hidden;
  background-color: #bd7a46;
  background-image: repeating-linear-gradient(0deg, #b46f3f 0 19px, #c8824d 19px 24px);
  border: 3px solid var(--brown-deep);
  box-shadow: 0 5px 0 rgba(56, 37, 29, 0.3);
}

.guest-town-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border: 2px solid var(--brown-deep);
}

.guest-side-rail {
  display: grid;
  grid-template-rows: auto minmax(220px, auto) 1fr;
  align-content: start;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 16px;
  background: var(--cream);
  border: 3px solid var(--brown);
  border-radius: 18px 18px 10px 10px;
  box-shadow: 0 5px 0 rgba(56, 37, 29, 0.22);
}

.guest-profile-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.guest-avatar {
  width: 104px;
  aspect-ratio: 1;
  filter: drop-shadow(0 3px 0 rgba(56, 37, 29, 0.28));
}

.guest-avatar svg {
  display: block;
  width: 100%;
  height: 100%;
}

.guest-avatar-rim {
  fill: #bcbcbc;
  stroke: #5e5e5e;
  stroke-width: 3;
}

.guest-avatar-core {
  fill: #999;
  stroke: #f5f5f5;
  stroke-width: 4;
}

.guest-avatar-silhouette {
  fill: #d6d6d6;
}

.guest-avatar-question {
  fill: #8a8a8a;
  stroke: #d6d6d6;
  stroke-width: 1.5;
  paint-order: stroke;
  font-family: var(--font-display);
  font-size: 54px;
  font-weight: 900;
}

.guest-profile-copy {
  min-width: 0;
}

.guest-profile-copy h2 {
  margin: 0;
  color: var(--brown-soft);
  font-size: clamp(1.15rem, 1.65vw, 1.55rem);
  line-height: 1.1;
}

.guest-profile-copy p {
  margin: 4px 0 9px;
  color: var(--brown);
  font-size: clamp(0.76rem, 1vw, 0.95rem);
  font-weight: 800;
  line-height: 1.2;
}

.guest-login-button {
  width: 100%;
  min-height: 43px;
  padding: 7px 12px;
  color: #fff;
  background: linear-gradient(180deg, #ffc13a, #f3910d);
  border: 2px solid var(--brown-deep);
  border-radius: 24px;
  box-shadow: 0 3px 0 var(--brown-deep);
  font-family: var(--font-display);
  font-size: clamp(0.75rem, 0.98vw, 0.95rem);
  line-height: 1.1;
  text-shadow: 1px 1px 0 #8c3a1e;
  cursor: pointer;
  transition: filter 150ms ease, transform 150ms ease;
}

.guest-login-button:hover {
  filter: brightness(1.08) saturate(1.08);
  transform: translateY(-2px);
}

.guest-auth-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.guest-auth-actions .guest-login-button,
.guest-signup-button {
  min-height: 40px;
  padding: 6px 8px;
  font-size: clamp(0.68rem, 0.9vw, 0.84rem);
}

.guest-signup-button {
  width: 100%;
  color: var(--brown-deep);
  background: #fff2d4;
  border: 2px solid var(--brown-deep);
  border-radius: 24px;
  box-shadow: 0 3px 0 var(--brown-deep);
  font-family: var(--font-display);
  line-height: 1.1;
  cursor: pointer;
  transition: filter 150ms ease, transform 150ms ease;
}

.guest-signup-button:hover {
  filter: brightness(1.05);
  transform: translateY(-2px);
}

.guest-achievements-card {
  min-width: 0;
  min-height: 220px;
  padding: 12px 15px;
  background: #fff;
  border: 2px solid #ded8ce;
  border-radius: 12px;
  box-shadow: 0 4px 0 rgba(56, 37, 29, 0.28);
}

.guest-achievements-card h2 {
  margin: 0;
  color: var(--brown-soft);
  font-size: 1rem;
}

.guest-lock-notice {
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: 270px;
  margin: 28px auto 0;
  padding: 14px 12px;
  color: #777;
  background: #f5f5f3;
  border: 1px dashed #c7c7c4;
  border-radius: 10px;
  text-align: center;
}

.guest-lock-notice svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: #858585;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.guest-lock-notice strong {
  color: var(--brown-soft);
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.guest-lock-notice span {
  max-width: 220px;
  font-size: 0.74rem;
  font-weight: 750;
  line-height: 1.3;
}

.dashboard-screen[data-auth-state="guest"] .mobile-nav {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 1180px) {
  .guest-home-view {
    grid-template-columns: minmax(0, 1fr) minmax(285px, 34%);
    gap: 13px;
  }

  .guest-side-rail {
    padding: 12px;
  }

  .guest-profile-card {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 9px;
  }

  .guest-avatar {
    width: 82px;
  }
}

/* Quiz play swaps only the center frame; keep the Home/Quiz shell fixed around it. */
body:has(#dashboard-screen.is-quiz-play) {
  overflow: hidden;
}

.dashboard-screen.is-town-shell.is-quiz-play,
.dashboard-screen.is-town-shell.is-quiz-play .dashboard-layout {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.dashboard-screen.is-town-shell.is-quiz-play .dashboard-main {
  display: flex;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 20px 20px 20px 0;
}

.dashboard-screen.is-town-shell.is-quiz-play .view-root,
.dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-play {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.town-shell-view--quiz-play {
  grid-template-columns: minmax(0, 1fr) minmax(285px, min(24vw, 425px));
}

.town-stage-frame--playing {
  min-height: 0;
  overflow: hidden;
}

.town-quiz-content--playing {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  padding: clamp(9px, 1.2vw, 17px);
}

.town-quiz-list--playing {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.town-quiz-play-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(7px, 1.2vh, 13px);
  width: 100%;
  height: 100%;
  min-height: 0;
}

.town-quiz-play-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0 clamp(3px, 0.7vw, 10px);
  color: var(--brown-deep);
}

.town-quiz-profile-trigger {
  display: none;
  width: 40px;
  height: 40px;
  flex: none;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.town-quiz-play-header .kicker {
  display: inline-block;
  max-width: 100%;
  margin: 0 0 4px;
  padding: 2px 8px;
  overflow: hidden;
  color: var(--brown-deep);
  background: rgba(255, 248, 234, 0.9);
  border-radius: 999px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(0.7rem, 0.95vw, 0.82rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-transform: uppercase;
}

.town-quiz-play-header h2 {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: clamp(0.92rem, 1.5vw, 1.4rem);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.town-quiz-exit {
  min-height: 34px;
  padding: 6px 12px;
  color: var(--brown-deep);
  background: rgba(255, 249, 233, 0.9);
  border: 2px solid var(--brown-deep);
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  cursor: pointer;
}

.town-quiz-exit:hover {
  background: #fff;
}

.town-quiz-play-body {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.quiz-game-board.town-quiz-question-board {
  display: grid;
  grid-template-rows: auto minmax(74px, auto) minmax(36px, auto) minmax(0, 1fr) auto;
  align-items: stretch;
  gap: clamp(5px, 0.9vh, 10px);
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: clamp(8px, 1.3vw, 17px) clamp(10px, 1.6vw, 22px);
  overflow: hidden;
  background: #f6ca79 url("assets/ui-horizontal/map-background-horizontal.webp") center / 100% 100% no-repeat;
  border: 2px solid var(--brown-deep);
}

.town-quiz-question-board .quiz-game-timer {
  min-height: 34px;
  padding: 3px 16px;
  font-size: clamp(0.88rem, 1.45vw, 1.2rem);
}

.town-quiz-question-board .quiz-game-timer img {
  width: 25px;
  height: 25px;
}

.town-quiz-question-board .quiz-game-question {
  min-height: 0;
  max-height: none;
  padding: clamp(10px, 1.25vh, 15px) clamp(15px, 1.8vw, 24px);
  overflow: visible;
}

.town-quiz-question-board .quiz-game-question h2 {
  display: block;
  overflow: visible;
  font-size: clamp(0.92rem, 1.55vw, 1.35rem);
  line-height: 1.18;
  overflow-wrap: anywhere;
  white-space: normal;
}

.town-quiz-question-board .quiz-game-context {
  min-height: 0;
  padding: 7px clamp(10px, 1.4vw, 18px);
  overflow: hidden;
  font-size: clamp(0.72rem, 1vw, 0.92rem);
  line-height: 1.18;
}

.town-quiz-question-board .quiz-game-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  align-content: stretch;
  align-items: stretch;
  gap: clamp(5px, 0.9vh, 10px) clamp(8px, 1.4vw, 18px);
  min-height: 0;
  margin: 0;
  overflow: hidden;
}

.town-quiz-question-board .quiz-game-option {
  position: relative;
  min-height: 0;
  max-height: 132px;
  aspect-ratio: 494 / 104;
  gap: clamp(7px, 1vw, 13px);
  padding: 7px 12px;
  overflow: hidden;
  font-size: clamp(0.76rem, 1.15vw, 1rem);
}

.town-quiz-question-board .quiz-game-option-letter {
  position: static;
  display: grid;
  place-items: center;
  width: 100%;
  height: 56%;
  transform: none;
  line-height: 1;
  text-align: center;
  flex: none;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.town-quiz-question-board .quiz-game-option-text {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.town-quiz-question-board .quiz-game-footer {
  min-height: 42px;
  margin: 0;
  padding: 0;
}

.town-quiz-question-board .quiz-game-footer > span {
  font-size: clamp(0.78rem, 1.25vw, 1.12rem);
}

.town-quiz-question-board .quiz-game-graphic-button {
  width: clamp(95px, 18%, 170px);
}

.town-quiz-question-board .quiz-game-graphic-button img {
  max-height: 48px;
  object-fit: contain;
}

.quiz-game-options--text {
  display: flex;
  align-items: center;
  justify-content: center;
}

.quiz-game-text-answer {
  display: grid;
  gap: 7px;
  width: min(100%, 760px);
  color: var(--brown-deep);
  font-weight: 850;
}

.quiz-game-text-answer input,
.quiz-game-text-answer textarea {
  width: 100%;
  max-height: 170px;
  padding: 12px 15px;
  color: var(--brown-deep);
  background: #fffdf7;
  border: 2px solid var(--brown);
  border-radius: 10px;
  font: inherit;
  resize: none;
}

.town-quiz-load-state {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  padding: 24px;
  color: var(--brown-deep);
  text-align: center;
  background: rgba(255, 249, 233, 0.92);
  border: 2px solid var(--brown-deep);
  border-radius: 12px;
}

.town-quiz-load-state strong {
  font-family: var(--font-display);
  font-size: clamp(1rem, 1.7vw, 1.5rem);
}

.town-quiz-load-state p {
  max-width: 640px;
  margin: 0;
  color: var(--brown-soft);
  font-weight: 750;
}

.town-quiz-load-state--error p {
  overflow-wrap: anywhere;
}

.town-quiz-result-board {
  border: 2px solid rgba(87, 54, 35, 0.58);
  border-radius: 10px;
}

.town-quiz-result-board .quiz-result-note {
  max-width: 650px;
  text-align: center;
}

.town-quiz-result-board .quiz-result-actions {
  gap: 10px;
}

.town-achievements-empty {
  margin: 14px 0 0;
  color: #88796c;
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.35;
}

.town-earned-badges {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 8px;
  margin-top: 14px;
}

.town-earned-badge {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 5px;
  min-width: 0;
  color: var(--brown-soft);
  font-family: var(--font-display);
  font-size: 0.68rem;
  line-height: 1.1;
  text-align: center;
}

.town-earned-badge img,
.town-earned-badge > span {
  display: grid;
  place-items: center;
  width: 56px;
  height: 62px;
  object-fit: contain;
  color: #e59d16;
  font-size: 2.1rem;
}

.town-earned-badge strong {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.map-player-achievements {
  margin-top: 13px;
  padding: 11px 12px;
  background: #fff;
  border: 2px solid #ded8ce;
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(56, 37, 29, 0.2);
}

.map-player-achievements h3 {
  margin: 0;
  color: var(--brown-soft);
  font-family: var(--font-display);
  font-size: 0.9rem;
}

.map-player-achievements .town-earned-badges {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px 8px;
  margin-top: 10px;
}

.map-player-achievements .town-achievements-empty {
  margin: 8px 0 0;
  font-size: 0.76rem;
}

.map-player-achievements .town-earned-badge img,
.map-player-achievements .town-earned-badge > span {
  width: 48px;
  height: 54px;
}

@media (max-width: 980px) {
  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-main {
    padding: 12px;
  }

  .town-shell-view--quiz-play {
    grid-template-columns: minmax(0, 1fr) minmax(210px, 30%);
    gap: 10px;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-stage-frame--playing,
  .dashboard-screen.is-town-shell.is-quiz-play .town-side-rail {
    height: 100%;
    min-height: 0;
  }

  .town-quiz-question-board .quiz-game-option {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 7px;
  }

  .town-quiz-question-board .quiz-game-option-letter {
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 760px) {
  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-main {
    height: 100%;
    padding: 7px;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-layout,
  .dashboard-screen.is-town-shell.is-quiz-play .view-root {
    height: 100%;
  }

  .town-shell-view--quiz-play {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 5px;
  }

  .town-shell-view--quiz-play .town-side-rail {
    grid-row: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
    grid-template-rows: auto;
    gap: 5px;
    height: auto;
    max-height: 78px;
    padding: 4px;
    overflow: hidden;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .town-shell-view--quiz-play .town-player-card {
    grid-template-columns: 54px minmax(0, 1fr);
    min-height: 66px;
    padding: 4px;
    gap: 5px;
  }

  .town-shell-view--quiz-play .town-player-avatar {
    width: 52px;
    height: 58px;
  }

  .town-shell-view--quiz-play .town-player-copy h2 {
    font-size: 0.8rem;
  }

  .town-shell-view--quiz-play .town-player-copy p,
  .town-shell-view--quiz-play .town-player-next {
    display: none;
  }

  .town-shell-view--quiz-play .town-player-xp-row .points-meter {
    height: 16px;
  }

  .town-shell-view--quiz-play .guest-achievements-card {
    min-height: 0;
    max-height: 70px;
    padding: 5px 7px;
    overflow: hidden;
  }

  .town-shell-view--quiz-play .guest-achievements-card h2 {
    margin: 0;
    font-size: 0.7rem;
  }

  .town-shell-view--quiz-play .town-achievements-empty {
    margin-top: 3px;
    font-size: 0.58rem;
  }

  .town-shell-view--quiz-play .town-earned-badges {
    display: flex;
    gap: 5px;
    margin-top: 3px;
  }

  .town-shell-view--quiz-play .town-earned-badge img,
  .town-shell-view--quiz-play .town-earned-badge > span {
    width: 23px;
    height: 26px;
    font-size: 1rem;
  }

  .town-shell-view--quiz-play .town-earned-badge strong {
    display: none;
  }

  .town-shell-view--quiz-play .town-stage-frame--playing {
    grid-row: 2;
    height: 100%;
    min-height: 0;
    padding: 5px;
  }

  .town-quiz-content--playing {
    padding: 6px;
  }

  .town-quiz-play-screen {
    gap: 5px;
  }

  .town-quiz-play-header .kicker {
    font-size: 0.66rem;
  }

  .town-quiz-play-header h2 {
    font-size: 0.78rem;
  }

  .town-quiz-exit {
    min-height: 27px;
    padding: 4px 8px;
    font-size: 0.58rem;
  }

  .quiz-game-board.town-quiz-question-board {
    grid-template-rows: auto minmax(58px, auto) minmax(28px, auto) minmax(0, 1fr) auto;
    gap: 4px;
    padding: 6px;
  }

  .town-quiz-question-board .quiz-game-timer {
    min-height: 25px;
    padding: 2px 10px;
    font-size: 0.76rem;
  }

  .town-quiz-question-board .quiz-game-timer img {
    width: 19px;
    height: 19px;
  }

  .town-quiz-question-board .quiz-game-question {
    padding: 6px 9px;
  }

  .town-quiz-question-board .quiz-game-question-head > span {
    font-size: 0.55rem;
  }

.town-quiz-question-board .quiz-game-question h2 {
    font-size: 0.78rem;
    line-height: 1.12;
  }

  .town-quiz-question-board .quiz-game-context {
    padding: 4px 7px;
    font-size: 0.6rem;
    line-height: 1.08;
  }

  .town-quiz-question-board .quiz-game-options {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(4, minmax(0, 1fr));
    gap: 3px;
  }

  .town-quiz-question-board .quiz-game-option {
    max-height: none;
    aspect-ratio: auto;
    gap: 7px;
    padding: 3px 8px;
    font-size: 0.66rem;
    line-height: 1.05;
  }

  .town-quiz-question-board .quiz-game-option-letter {
    width: 30px;
    height: 30px;
    font-size: 1.05rem;
  }

  .town-quiz-question-board .quiz-game-footer {
    min-height: 32px;
  }

  .town-quiz-question-board .quiz-game-footer > span {
    font-size: 0.68rem;
  }

  .town-quiz-question-board .quiz-game-graphic-button {
    width: clamp(74px, 25%, 118px);
  }

  .town-quiz-question-board .quiz-game-graphic-button img {
    max-height: 32px;
  }

  .town-quiz-result-board {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    gap: 4px 8px;
    padding: 7px;
  }

  .town-quiz-result-board .quiz-result-banner {
    max-height: 34px;
  }

  .town-quiz-result-board .quiz-result-ring {
    width: min(100%, 100px);
  }

  .town-quiz-result-board .quiz-result-ring-core strong {
    font-size: 1.55rem;
  }

  .town-quiz-result-board .quiz-result-ring-core small {
    font-size: 0.62rem;
  }

  .town-quiz-result-board .quiz-result-status {
    max-height: 30px;
  }

  .town-quiz-result-board .quiz-result-stats {
    padding-inline: 5px;
  }

  .town-quiz-result-board .quiz-result-stat {
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 3px;
    font-size: 0.56rem;
  }

  .town-quiz-result-board .quiz-result-stat img {
    width: 17px;
    height: 17px;
  }

  .town-quiz-result-board .quiz-result-note {
    font-size: 0.55rem;
    line-height: 1.1;
  }

  .town-quiz-result-board .quiz-result-action {
    min-height: 31px;
    font-size: 0.55rem;
  }
}

@media (max-height: 650px) {
  .quiz-game-board.town-quiz-question-board {
    grid-template-rows: auto minmax(52px, auto) minmax(26px, auto) minmax(0, 1fr) auto;
    gap: 3px;
    padding-block: 4px;
  }

  .town-quiz-question-board .quiz-game-question {
    padding-block: 5px;
  }

  .town-quiz-question-board .quiz-game-option {
    max-height: 92px;
    padding-block: 3px;
  }

  .town-quiz-question-board .quiz-game-footer {
    min-height: 30px;
  }

  .town-quiz-question-board .quiz-game-graphic-button img {
    max-height: 32px;
  }
}

@media (max-width: 980px) {
  .guest-home-view {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
  }

  .guest-town-frame {
    height: min(62vw, 560px);
    min-height: 340px;
  }

  .guest-side-rail {
    grid-template-rows: auto auto;
    grid-template-columns: minmax(0, 1fr);
  }

  .guest-profile-card {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .guest-avatar {
    width: 104px;
  }
}

@media (max-width: 760px) {
  .dashboard-screen[data-auth-state="guest"] .dashboard-main {
    padding: 15px 13px 22px;
  }

  .dashboard-screen[data-auth-state="guest"] .mobile-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guest-home-view {
    gap: 12px;
  }

  .guest-town-frame {
    height: clamp(230px, 60vw, 390px);
    min-height: 0;
    padding: 6px;
  }

  .guest-side-rail {
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
  }

  .guest-profile-card {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .guest-avatar {
    width: 76px;
  }

  .guest-profile-copy h2 {
    font-size: 1.1rem;
  }

  .guest-profile-copy p {
    margin-block: 3px 7px;
    font-size: 0.74rem;
  }

  .guest-login-button {
    min-height: 38px;
    font-size: 0.76rem;
  }

  .guest-auth-actions {
    gap: 6px;
  }

  .guest-auth-actions .guest-login-button,
  .guest-signup-button {
    min-height: 38px;
    padding-inline: 5px;
    font-size: 0.72rem;
  }

  .guest-achievements-card {
    min-height: 180px;
  }

  .guest-lock-notice {
    margin-top: 18px;
  }
}

@media (max-width: 380px) {
  .guest-profile-card {
    grid-template-columns: 66px minmax(0, 1fr);
    gap: 8px;
  }

  .guest-avatar {
    width: 66px;
  }
}

/* Home and the Quiz library share the same town frame and player rail. */
.dashboard-screen.is-town-shell .dashboard-topbar {
  display: none;
}

.dashboard-screen.is-town-shell .dashboard-main {
  min-width: 0;
  padding: 41px 20px 25px 0;
}

.dashboard-screen.is-town-shell .view-root {
  width: 100%;
  max-width: none;
}

.dashboard-screen.is-town-shell .wordmark-side {
  display: none;
}

.dashboard-screen.is-town-shell .mobile-nav {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.town-shell-view {
  position: relative;
}

.town-stage-frame {
  height: 100%;
}

.town-stage-frame--quiz {
  padding: 10px;
}

.town-quiz-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: clamp(18px, 2.4vw, 34px);
  overflow: hidden;
  color: var(--brown-deep);
  background:
    linear-gradient(135deg, rgba(255, 247, 224, 0.95), rgba(255, 220, 151, 0.94)),
    url("assets/ui-horizontal/map-background-horizontal.webp") center / cover no-repeat;
  border: 2px solid var(--brown-deep);
}

.town-quiz-heading {
  flex: none;
  margin-bottom: 14px;
}

.town-quiz-heading .kicker {
  margin: 0 0 5px;
  color: var(--brown-soft);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.town-quiz-heading h2 {
  margin: 0;
  color: var(--brown-deep);
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.45rem);
  line-height: 1.05;
}

.town-quiz-heading > p:last-child,
.town-quiz-intro,
.town-quiz-footnote {
  color: var(--brown-soft);
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.35;
}

.town-quiz-heading > p:last-child {
  margin: 5px 0 0;
}

.town-quiz-intro {
  flex: none;
  margin: 0 0 12px;
}

.town-quiz-list {
  min-height: 0;
  flex: 1;
  overflow: auto;
  overscroll-behavior: none;
  scrollbar-color: #b87948 rgba(255, 248, 234, 0.72);
  scrollbar-width: thin;
}

.town-shell-view--quiz:not(.town-shell-view--quiz-play):not(.town-shell-view--quiz-result) .town-quiz-list {
  padding-top: 8px;
  scroll-padding-top: 8px;
}

.town-quiz-list .resource-section {
  margin: 0;
}

.town-quiz-list .resource-section > h3 {
  margin-bottom: 8px;
}

.town-quiz-list .resource-list {
  gap: 10px;
}

.town-quiz-list .resource-card {
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 12px 14px;
  background: rgba(255, 253, 248, 0.96);
  border-color: #8a5a3d;
  box-shadow: 0 3px 0 rgba(56, 37, 29, 0.2);
}

.town-quiz-list .resource-index {
  background: var(--orange);
  color: var(--brown-deep);
}

.town-quiz-list .resource-card:nth-child(3n) .resource-index {
  background: var(--orange);
}

.town-quiz-list .resource-play-button {
  justify-content: center;
  min-height: 38px;
  padding: 7px 12px;
  color: var(--brown-deep);
  background: var(--orange);
  border: 2px solid var(--brown-deep);
  border-radius: 22px;
  box-shadow: 0 2px 0 var(--brown-deep);
  font-family: var(--font-display);
  white-space: nowrap;
}

.town-quiz-list .resource-play-button:hover {
  color: var(--brown-deep);
  background: #ffd15b;
  transform: translateY(-1px);
}

.town-quiz-footnote {
  flex: none;
  margin: 10px 0 0;
  font-size: 0.72rem;
}

.town-quiz-sync-note {
  flex: none;
  margin: 0 0 10px;
  color: var(--brown-soft);
  font-size: 0.75rem;
  font-weight: 800;
}

.lesson-quiz-catalog {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 12px;
}

.lesson-quiz-card {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "number copy action"
    "number status action";
  align-items: center;
  gap: 5px 14px;
  min-width: 0;
  min-height: 92px;
  padding: 10px 16px;
  color: var(--brown-deep);
  text-align: left;
  position: relative;
  isolation: isolate;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 0;
  box-shadow: none;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, opacity 140ms ease;
}

.lesson-quiz-card::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  box-sizing: border-box;
  border: 30px solid transparent;
  border-image-source: url("assets/quiz/lesson-card-frame-available.png");
  border-image-slice: 30 fill;
  border-image-width: 30px;
  border-image-repeat: stretch;
  content: "";
  filter: drop-shadow(0 4px 0 rgba(56, 37, 29, 0.22));
  pointer-events: none;
}

.lesson-quiz-card > * {
  position: relative;
  z-index: 1;
}

.lesson-quiz-card.is-available:not(:disabled) {
  cursor: pointer;
}

.lesson-quiz-card.is-available:not(:disabled):hover {
  transform: translateY(-2px);
}

.lesson-quiz-card:focus-visible {
  outline: 4px solid #ffb51b;
  outline-offset: 3px;
}

.lesson-quiz-card.is-disabled {
  color: #725f50;
  cursor: not-allowed;
}

.lesson-quiz-card.is-disabled::before {
  border-image-source: url("assets/quiz/lesson-card-frame-locked.png");
  filter: drop-shadow(0 3px 0 rgba(56, 37, 29, 0.13));
}

.lesson-quiz-card.is-completed {
  cursor: pointer;
}

.lesson-quiz-card.is-completed::before {
  border-image-source: url("assets/quiz/lesson-card-frame.png");
  filter: drop-shadow(0 4px 0 rgba(56, 37, 29, 0.22));
}

.lesson-quiz-number {
  grid-area: number;
  display: grid;
  min-height: 52px;
  place-items: center;
  padding: 6px;
  color: var(--brown-deep);
  background: linear-gradient(#ffcf57, #f7a21a);
  border: 2px solid var(--brown-deep);
  border-radius: 10px;
  box-shadow: 0 2px 0 rgba(56, 37, 29, 0.25);
  font-family: var(--font-display);
  font-size: 0.78rem;
  line-height: 1.1;
  text-align: center;
}

.lesson-quiz-copy {
  grid-area: copy;
  display: grid;
  min-width: 0;
  gap: 3px;
}

.lesson-quiz-title {
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-size: clamp(0.86rem, 1vw, 1.05rem);
  line-height: 1.15;
}

.lesson-quiz-assignment {
  overflow: hidden;
  display: -webkit-box;
  color: var(--brown-soft);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.2;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.lesson-quiz-badge {
  color: #8c684e;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.15;
}

.lesson-quiz-status {
  grid-area: status;
  color: #31863e;
  font-size: 0.7rem;
  font-weight: 900;
}

.lesson-quiz-status.is-unavailable {
  color: #7d6e61;
}

.lesson-quiz-status.is-completed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #287b36;
}

.lesson-quiz-status.is-in-progress {
  color: #a45d0a;
}

.lesson-quiz-done-icon {
  justify-self: center;
  width: 44px;
  height: 38px;
  object-fit: contain;
}

.lesson-quiz-completed-action {
  grid-area: action;
  display: grid;
  justify-items: center;
  gap: 2px;
}

.lesson-quiz-action {
  grid-area: action;
  justify-self: end;
  padding: 8px 10px;
  color: var(--brown-deep);
  background: #ffb21d;
  border: 2px solid var(--brown-deep);
  border-radius: 22px;
  box-shadow: 0 2px 0 var(--brown-deep);
  font-family: var(--font-display);
  font-size: 0.72rem;
  line-height: 1.1;
  white-space: nowrap;
}

.lesson-quiz-completed-action .lesson-quiz-action {
  grid-area: auto;
  justify-self: center;
}

.lesson-quiz-card.is-disabled .lesson-quiz-action {
  color: #67584c;
  background: #d0c3b1;
  border-color: #897867;
  box-shadow: none;
}

.town-quiz-state {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 110px;
  padding: 18px;
  color: var(--brown-deep);
  background: rgba(255, 253, 248, 0.94);
  border: 2px solid var(--line);
  border-radius: 12px;
}

.town-quiz-state .sync-spinner {
  flex: none;
}

.town-quiz-state strong,
.town-quiz-state p {
  display: block;
  margin: 0;
}

.town-quiz-state strong {
  font-family: var(--font-display);
}

.town-quiz-state p {
  margin-top: 4px;
  color: var(--brown-soft);
  font-size: 0.8rem;
  font-weight: 750;
}

.town-quiz-state--error {
  justify-content: space-between;
}

.town-side-rail {
  position: relative;
}

.town-floating-avatar {
  display: none;
}

.town-player-card {
  grid-template-columns: 96px minmax(0, 1fr);
  min-height: 112px;
}

.town-player-avatar {
  width: 92px;
  height: 102px;
  flex: none;
}

.town-player-copy h2 {
  font-size: clamp(1rem, 1.4vw, 1.42rem);
  overflow-wrap: anywhere;
}

.town-player-copy p {
  margin: 4px 0 3px;
}

.town-player-xp-row {
  margin-top: 5px;
}

.town-player-xp-row .points-meter {
  position: relative;
  height: 22px;
  margin: 0;
  background: #aaa8a1;
  border: 3px solid var(--brown);
}

.town-player-xp-row .points-meter strong {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fffdf7;
  font-family: var(--font-display);
  font-size: 0.72rem;
  line-height: 1;
  text-shadow: 0 1px 2px #5b3a2b, 1px 0 1px #5b3a2b, -1px 0 1px #5b3a2b;
}

.town-player-next {
  display: block;
  margin-top: 3px;
  color: var(--brown-soft);
  font-size: 0.65rem;
  font-weight: 800;
}

.town-side-rail .guest-achievements-card {
  min-height: 220px;
}

@media (max-width: 1180px) {
  .town-player-card {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .town-player-avatar {
    width: 80px;
    height: 90px;
  }
}

@media (max-width: 980px) {
  .dashboard-screen.is-town-shell .dashboard-main {
    padding: 15px 13px 22px;
  }

  .town-shell-view {
    height: auto;
    min-height: 0;
  }

  .town-stage-frame {
    height: min(62vw, 560px);
    min-height: 340px;
  }

  .town-stage-frame--quiz {
    min-height: 410px;
  }

  .town-quiz-content {
    padding: 18px;
  }

  .town-side-rail {
    grid-template-rows: auto auto;
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .dashboard-screen.is-town-shell .dashboard-main {
    padding: 15px 13px 22px;
  }

  .town-shell-view {
    gap: 12px;
  }

  .town-stage-frame {
    height: clamp(230px, 60vw, 390px);
    min-height: 0;
  }

  .town-stage-frame--quiz {
    height: clamp(410px, 112vw, 620px);
    min-height: 410px;
    padding: 6px;
  }

  .town-quiz-content {
    padding: 13px;
  }

  .town-quiz-heading {
    margin-bottom: 10px;
  }

  .town-quiz-intro {
    margin-bottom: 8px;
    font-size: 0.74rem;
  }

  .lesson-quiz-catalog {
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
  }

  .lesson-quiz-card {
    grid-template-columns: 54px minmax(0, 1fr) auto;
    gap: 4px 9px;
    min-height: 82px;
    padding: 9px;
  }

  .lesson-quiz-number {
    min-height: 46px;
    font-size: 0.68rem;
  }

  .lesson-quiz-title {
    font-size: 0.82rem;
  }

  .lesson-quiz-assignment {
    font-size: 0.65rem;
  }

  .lesson-quiz-status {
    font-size: 0.62rem;
  }

  .lesson-quiz-action {
    padding: 6px 8px;
    font-size: 0.62rem;
  }

  .lesson-quiz-done-icon {
    width: 36px;
    height: 31px;
  }

  .lesson-quiz-retake {
    padding: 5px 7px;
    font-size: 0.58rem;
  }

  .town-quiz-list .resource-card {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 8px;
    padding: 9px;
  }

  .town-quiz-list .resource-index {
    width: 32px;
    height: 32px;
    font-size: 0.76rem;
  }

  .town-quiz-list .resource-card h4 {
    font-size: 0.83rem;
  }

  .town-quiz-list .resource-card p {
    font-size: 0.68rem;
  }

  .town-quiz-list .resource-play-button {
    grid-column: 2;
    justify-self: start;
    min-height: 32px;
    padding: 5px 10px;
    font-size: 0.72rem;
  }

  .town-quiz-list .lesson-quiz-card.quest-course-card {
    grid-template-columns: 100px minmax(0, 1fr) auto;
    min-height: 112px;
    padding: 9px 12px;
  }

  .town-quiz-list .lesson-quiz-card.quest-course-card > .quest-course-image,
  .town-quiz-list .lesson-quiz-card.quest-course-card > .quest-course-image--fallback {
    width: 96px;
    height: 60px;
  }

  .course-dialog-facts {
    grid-template-columns: 1fr;
  }

  .town-quiz-footnote {
    margin-top: 7px;
    font-size: 0.63rem;
  }

  .town-player-card {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .town-player-avatar {
    width: 74px;
    height: 84px;
  }

  .town-side-rail .guest-achievements-card {
    min-height: 180px;
  }
}

@media (max-width: 380px) {
  .town-player-card {
    grid-template-columns: 66px minmax(0, 1fr);
    gap: 8px;
  }

  .town-player-avatar {
    width: 64px;
    height: 74px;
  }
}

@media (max-width: 760px), (max-width: 980px) and (orientation: portrait) {
  .town-shell-view--player .town-side-rail {
    display: none;
  }

  .town-floating-avatar {
    position: fixed;
    z-index: 20;
    right: calc(14px + env(safe-area-inset-right, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    display: block;
    width: 60px;
    height: 68px;
    padding: 0;
    background: rgba(255, 248, 234, 0.92);
    border: 2px solid var(--brown-deep);
    border-radius: 50%;
    box-shadow: 0 4px 0 rgba(56, 37, 29, 0.35);
  }

  .town-floating-avatar:hover,
  .town-floating-avatar[aria-expanded="true"] {
    transform: translateY(-2px) scale(1.03);
  }

  .town-shell-view > .map-player-popover:not([hidden]) {
    position: fixed;
    z-index: 30;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    padding: max(18px, env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
    overflow: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overscroll-behavior: none;
  }

  .town-shell-view > .map-player-popover:not([hidden]) .map-player-close {
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    width: 40px;
    height: 40px;
  }

  .town-shell-view > .map-player-popover:not([hidden]) .map-player-popover-head > div {
    padding-right: 28px;
  }
}

/* Quiz flow visual pass: lesson cards, answer framing, and result states. */
.lesson-quiz-copy {
  align-content: center;
}

.lesson-quiz-description {
  display: -webkit-box;
  overflow: hidden;
  color: #82634d;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.lesson-quiz-lock-icon {
  grid-area: action;
  display: grid;
  justify-items: center;
  gap: 2px;
  align-self: center;
  color: #9a6e34;
  font-family: var(--font-display);
  font-size: 0.65rem;
  line-height: 1.1;
  text-align: center;
}

.lesson-quiz-lock-icon svg {
  display: block;
  width: 26px;
  height: 26px;
  fill: #e8901f;
  filter: drop-shadow(0 1px 0 #fff);
}

.quiz-game-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.quiz-game-progress-label {
  color: #fffdf8;
  font-family: var(--font-display);
  font-size: clamp(0.82rem, 1.3vw, 1.08rem);
  line-height: 1.1;
  text-shadow: 0 1px 2px #76533b;
}

.town-quiz-question-board .quiz-game-timer {
  justify-self: end;
  align-self: center;
  margin: 0;
}

.quiz-game-board.town-quiz-question-board:not(.has-context) {
  grid-template-rows: auto minmax(74px, auto) minmax(0, 1fr) auto;
}

.town-quiz-result-board .quiz-result-action {
  width: min(46%, 270px);
  min-height: 0;
  padding: 0;
  background: none;
  border: 0;
  -webkit-text-stroke: 0;
  text-shadow: none;
}

.town-quiz-result-board .quiz-result-review-action {
  aspect-ratio: 313 / 74;
  padding: 0 10px;
  color: #fff;
  background: url("assets/map/button-template.png") center / 100% 100% no-repeat;
  -webkit-text-stroke: 1px #57240d;
  text-shadow: 1px 2px 0 #57240d, -1px -1px 0 #57240d, 1px -1px 0 #57240d, -1px 1px 0 #57240d;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2vw, 1.65rem);
  font-weight: 900;
  line-height: 1;
}

.town-quiz-result-board .quiz-result-action img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.town-quiz-result-board .quiz-result-ring-core strong.pending {
  color: #8b7561;
}

.town-quiz-result-board .quiz-result-status-text {
  display: grid;
  place-items: center;
  width: min(100%, 330px);
  min-height: 42px;
  padding: 7px 16px;
  color: #fff;
  background: #8b7561;
  border-radius: 9px;
  font-family: var(--font-display);
  text-align: center;
}

@media (max-width: 760px) {
  .dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-play {
    display: grid;
    height: 100%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-side-rail {
    display: none;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-stage-frame--playing {
    grid-row: 1;
    height: 100%;
    min-height: 0;
    padding: 6px;
  }

  .town-quiz-content--playing {
    padding: 6px;
  }

  .town-quiz-play-screen {
    grid-template-rows: auto minmax(0, 1fr);
    gap: 6px;
  }

  .town-quiz-play-header {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 7px;
    min-height: 38px;
    padding-inline: 3px;
  }

  .town-quiz-profile-trigger {
    width: 34px;
    height: 36px;
  }

  .town-quiz-profile-trigger .avatar-map-trigger {
    width: 32px;
    height: 32px;
  }

  .town-quiz-play-header .kicker {
    margin-bottom: 2px;
    font-size: 0.66rem;
  }

  .town-quiz-play-header h2 {
    display: -webkit-box;
    overflow: hidden;
    font-size: clamp(0.65rem, 2.6vw, 0.8rem);
    line-height: 1.05;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .town-quiz-exit {
    min-height: 27px;
    padding: 4px 7px;
    font-size: 0.55rem;
    white-space: nowrap;
  }

  .town-quiz-play-body {
    min-height: 0;
  }

  .quiz-game-board.town-quiz-question-board {
    grid-template-rows: auto minmax(64px, auto) minmax(28px, auto) minmax(0, 1fr) auto;
    gap: 5px;
    padding: 7px;
  }

  .quiz-game-board.town-quiz-question-board:not(.has-context) {
    grid-template-rows: auto minmax(64px, auto) minmax(0, 1fr) auto;
  }

  .quiz-game-progress {
    min-height: 30px;
  }

  .quiz-game-progress-label {
    display: block;
    font-size: clamp(0.74rem, 3vw, 0.9rem);
  }

  .town-quiz-question-board .quiz-game-timer {
    min-width: 94px;
    min-height: 29px;
    padding: 3px 9px;
    font-size: 0.72rem;
  }

  .town-quiz-question-board .quiz-game-timer img {
    width: 19px;
    height: 19px;
  }

  .town-quiz-question-board .quiz-game-question {
    min-height: 64px;
    padding: 7px 10px 9px;
  }

  .town-quiz-question-board .quiz-game-question-head > span {
    font-size: 0.53rem;
  }

  .town-quiz-question-board .quiz-game-question h2 {
    font-size: clamp(0.77rem, 3.4vw, 0.94rem);
    line-height: 1.15;
  }

  .town-quiz-question-board .quiz-game-context {
    padding: 5px 8px;
    font-size: clamp(0.58rem, 2.6vw, 0.7rem);
    line-height: 1.14;
  }

  .town-quiz-question-board .quiz-game-options {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-auto-rows: minmax(0, 1fr);
    gap: 5px;
  }

  .town-quiz-question-board .quiz-game-option {
    grid-template-columns: 38px minmax(0, 1fr);
    min-height: 54px;
    max-height: none;
    gap: 8px;
    padding: 5px 9px;
    font-size: clamp(0.65rem, 2.9vw, 0.79rem);
    line-height: 1.12;
  }

  .town-quiz-question-board .quiz-game-option-letter {
    width: 36px;
    height: 34px;
    font-size: 1.1rem;
  }

  .town-quiz-question-board .quiz-game-option-text {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .town-quiz-question-board .quiz-game-footer {
    min-height: 38px;
    padding: 0;
  }

  .town-quiz-question-board .quiz-game-footer > span {
    display: none;
  }

  .town-quiz-question-board .quiz-game-graphic-button {
    width: min(37%, 124px);
  }

  .town-quiz-question-board .quiz-game-graphic-button img {
    max-height: 38px;
  }

  .town-quiz-result-board {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(138px, 0.9fr) minmax(128px, 1fr) auto auto;
    grid-template-areas:
      "banner"
      "score"
      "stats"
      "note"
      "actions";
    gap: 5px;
    padding: 8px 9px;
  }

  .town-quiz-result-board .quiz-result-banner {
    width: min(78%, 320px);
    max-height: 50px;
  }

  .town-quiz-result-board .quiz-result-score {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    justify-items: center;
    align-content: center;
    gap: 7px;
    width: 100%;
    min-height: 0;
  }

  .town-quiz-result-board .quiz-result-ring {
    width: clamp(112px, 35vw, 174px);
    padding: 8px;
  }

  .town-quiz-result-board .quiz-result-ring-core strong {
    font-size: clamp(1.65rem, 7vw, 2.35rem);
  }

  .town-quiz-result-board .quiz-result-ring-core small {
    font-size: 0.72rem;
  }

  .town-quiz-result-board .quiz-result-status,
  .town-quiz-result-board .quiz-result-status-text {
    width: min(84%, 320px);
    max-height: 40px;
    min-height: 34px;
  }

  .town-quiz-result-board .quiz-result-stats {
    grid-template-rows: repeat(5, minmax(24px, 1fr));
    padding: 3px 10px;
  }

  .town-quiz-result-board .quiz-result-stat {
    grid-template-columns: 27px minmax(0, 1fr) auto;
    gap: 7px;
    padding: 2px 0;
    font-size: clamp(0.68rem, 3vw, 0.82rem);
  }

  .town-quiz-result-board .quiz-result-stat img {
    width: 23px;
    height: 23px;
  }

  .town-quiz-result-board .quiz-result-note {
    max-height: 2.5em;
    overflow: hidden;
    padding: 0;
    font-size: clamp(0.53rem, 2.4vw, 0.64rem);
    line-height: 1.2;
  }

  .town-quiz-result-board .quiz-result-actions {
    justify-content: space-between;
    gap: 10px;
  }

  .town-quiz-result-board .quiz-result-action {
    width: calc(50% - 5px);
  }
}

@media (max-width: 380px) {
  .lesson-quiz-card {
    grid-template-columns: 50px minmax(0, 1fr) auto;
    gap: 4px 7px;
    min-height: 74px;
    padding: 7px;
  }

  .lesson-quiz-number {
    min-height: 42px;
    font-size: 0.64rem;
  }

  .lesson-quiz-title {
    font-size: 0.76rem;
  }

  .lesson-quiz-assignment,
  .lesson-quiz-description {
    font-size: 0.59rem;
  }

  .lesson-quiz-action {
    padding: 5px 6px;
    font-size: 0.55rem;
  }

  .lesson-quiz-lock-icon span {
    font-size: 0.55rem;
  }

  .lesson-quiz-lock-icon svg {
    width: 22px;
    height: 22px;
  }
}

@media (max-width: 760px) and (max-height: 650px) {
  .quiz-game-board.town-quiz-question-board {
    grid-template-rows: auto minmax(54px, auto) minmax(24px, auto) minmax(0, 1fr) auto;
    gap: 3px;
    padding: 5px;
  }

  .town-quiz-question-board .quiz-game-option {
    min-height: 45px;
    padding-block: 3px;
    font-size: 0.63rem;
  }

  .town-quiz-question-board .quiz-game-option-letter {
    width: 31px;
    height: 29px;
    font-size: 0.98rem;
  }

  .quiz-game-board.town-quiz-question-board:not(.has-context) {
    grid-template-rows: auto minmax(54px, auto) minmax(0, 1fr) auto;
  }

  .town-quiz-question-board .quiz-game-option {
    min-height: 38px;
  }

  .town-quiz-question-board .quiz-game-footer,
  .town-quiz-question-board .quiz-game-graphic-button img {
    max-height: 32px;
  }

  .town-quiz-result-board {
    grid-template-rows: auto minmax(100px, 0.8fr) minmax(118px, 1fr) auto auto;
    gap: 3px;
    padding: 5px 7px;
  }

  .town-quiz-result-board .quiz-result-banner {
    max-height: 37px;
  }

  .town-quiz-result-board .quiz-result-ring {
    width: clamp(94px, 27vw, 125px);
  }

  .town-quiz-result-board .quiz-result-status,
  .town-quiz-result-board .quiz-result-status-text {
    min-height: 29px;
    max-height: 32px;
  }

  .town-quiz-result-board .quiz-result-stats {
    grid-template-rows: repeat(5, minmax(21px, 1fr));
  }

  .town-quiz-result-board .quiz-result-stat {
    font-size: 0.62rem;
  }

  .town-quiz-result-board .quiz-result-stat img {
    width: 20px;
    height: 20px;
  }

  .town-quiz-result-board .quiz-result-action img {
    max-height: 32px;
  }
}

/* Mobile quiz play: match the compact sky header and framed, scrollable answer board. */
.town-quiz-mobile-meta {
  display: none;
}

@media (max-width: 760px) {
  .dashboard-screen.is-town-shell.is-quiz-play {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    padding-block: env(safe-area-inset-top, 0px) env(safe-area-inset-bottom, 0px);
    background: #43b9f3;
  }

  .dashboard-screen.is-town-shell.is-quiz-play::before,
  .dashboard-screen.is-town-shell.is-quiz-play .mobile-nav,
  .dashboard-screen.is-town-shell.is-quiz-play .side-nav {
    display: none;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-layout {
    display: flex;
    flex: 1 1 auto;
    width: 100%;
    height: auto;
    min-height: 0;
    order: 0;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-main {
    display: flex;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0 !important;
    overflow: hidden;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .view-root {
    display: flex;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-play {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 4px;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-side-rail,
  .dashboard-screen.is-town-shell.is-quiz-play .town-floating-avatar {
    display: none;
  }

  .town-quiz-mobile-meta {
    display: flex;
    grid-row: 1;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    min-height: 43px;
    padding: 0 18px;
    color: #fff;
  }

  .town-quiz-mobile-meta .quiz-game-progress-label {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: #fff;
    font-size: clamp(0.82rem, 3.6vw, 1rem);
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .town-quiz-mobile-meta .quiz-game-timer {
    position: relative;
    z-index: 0;
    isolation: isolate;
    flex: none;
    min-width: 112px;
    min-height: 35px;
    justify-content: center;
    padding: 4px 13px;
    background: transparent;
    border-radius: 0;
    font-size: 0.9rem;
  }

  .town-quiz-mobile-meta .quiz-game-timer::before,
  .town-quiz-mobile-meta .quiz-game-timer::after {
    position: absolute;
    z-index: -1;
    content: "";
    background: #fff8e7;
  }

  .town-quiz-mobile-meta .quiz-game-timer::before {
    inset: 11px 0 1px;
    border-radius: 999px;
  }

  .town-quiz-mobile-meta .quiz-game-timer::after {
    top: 1px;
    left: 24%;
    width: 21px;
    height: 20px;
    border-radius: 50%;
    box-shadow: 18px -2px 0 2px #fff8e7, 37px 0 0 -1px #fff8e7, 54px 3px 0 -3px #fff8e7;
  }

  .town-quiz-mobile-meta .quiz-game-timer > * {
    position: relative;
    z-index: 1;
  }

  .town-quiz-mobile-meta .quiz-game-timer img {
    width: 21px;
    height: 21px;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-stage-frame--playing {
    grid-row: 2;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 7px;
  }

  .town-stage-frame--playing .town-quiz-content--playing {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    overflow: hidden;
  }

  .town-quiz-list--playing,
  .town-quiz-play-screen--question,
  .town-quiz-play-body {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
  }

  .town-quiz-play-screen--question {
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
  }

  .town-quiz-play-screen--question > .town-quiz-play-header {
    display: none;
  }

  .town-quiz-play-body {
    overflow: hidden;
  }

  .quiz-game-board.town-quiz-question-board {
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px;
    overflow: hidden;
    background-position: center;
    background-size: cover;
    border: 2px solid var(--brown-deep);
  }

  .quiz-game-board.town-quiz-question-board.has-context {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  .town-quiz-question-board .quiz-game-progress {
    display: none;
  }

  .town-quiz-question-board .quiz-game-question {
    min-height: clamp(96px, 16vh, 150px);
    padding: 13px 17px 15px;
  }

  .town-quiz-question-board .quiz-game-question h2 {
    font-size: clamp(0.94rem, 4vw, 1.12rem);
    line-height: 1.28;
  }

  .town-quiz-question-board .quiz-game-context {
    min-height: 52px;
    max-height: 96px;
    padding: 9px 13px;
    overflow-y: auto;
    font-size: clamp(0.76rem, 3.2vw, 0.9rem);
    line-height: 1.3;
  }

  .town-quiz-question-board .quiz-game-options {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-auto-rows: max-content;
    align-content: start;
    gap: 8px;
    min-height: 0;
    padding: 2px 1px 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
    scrollbar-color: #8b6346 rgba(255, 248, 231, 0.55);
    scrollbar-width: thin;
  }

  .town-quiz-question-board .quiz-game-option {
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    min-height: clamp(78px, 10.8vh, 106px);
    max-height: none;
    gap: 10px;
    padding: 8px 12px;
    aspect-ratio: auto;
    font-size: clamp(0.78rem, 3.2vw, 0.94rem);
    line-height: 1.25;
  }

  .town-quiz-question-board .quiz-game-option-letter {
    width: 40px;
    height: 56px;
    font-size: 1.25rem;
  }

  .town-quiz-question-board .quiz-game-option-text {
    display: block;
    overflow: visible;
    overflow-wrap: anywhere;
    -webkit-line-clamp: unset;
  }

  .town-quiz-question-board .quiz-game-footer {
    justify-content: space-between;
    gap: 12px;
    min-height: 46px;
    padding: 0 3px;
  }

  .town-quiz-question-board .quiz-game-footer > span {
    display: none;
  }

  .town-quiz-question-board .quiz-game-graphic-button {
    width: min(46%, 164px);
  }

  .town-quiz-question-board .quiz-game-graphic-button img {
    max-height: 46px;
  }
}

@media (max-width: 760px) and (max-height: 680px) {
  .town-quiz-mobile-meta {
    min-height: 37px;
  }

  .town-quiz-question-board .quiz-game-question {
    min-height: 82px;
    padding-block: 9px 11px;
  }

  .town-quiz-question-board .quiz-game-context {
    min-height: 44px;
    max-height: 68px;
    padding-block: 6px;
  }

  .town-quiz-question-board .quiz-game-option {
    min-height: 70px;
  }

  .town-quiz-question-board .quiz-game-option-letter {
    height: 48px;
  }

  .town-quiz-question-board .quiz-game-footer,
  .town-quiz-question-board .quiz-game-graphic-button img {
    max-height: 39px;
  }
}

/* Keep answer-state art authoritative after the legacy quiz-screen selectors. */
.town-quiz-question-board .quiz-game-option:hover:not(.is-correct):not(.is-incorrect):not(:disabled),
.town-quiz-question-board .quiz-game-option.is-selected:not(.is-correct):not(.is-incorrect) {
  background-color: #3d9ddd;
  background-image: url("assets/quiz/selected.png");
}

.town-quiz-question-board .quiz-game-option.is-correct,
.town-quiz-question-board .quiz-game-option.is-correct:hover:not(:disabled) {
  background-color: #77ca2e;
  background-image: url("assets/quiz/answer-correct.png");
}

.town-quiz-question-board .quiz-game-option.is-incorrect,
.town-quiz-question-board .quiz-game-option.is-incorrect:hover:not(:disabled) {
  background-color: #e60700;
  background-image: url("assets/quiz/answer-incorrect.png");
}

@media (min-width: 761px) {
  .dashboard-screen.is-town-shell .town-quiz-question-board .quiz-game-option {
    display: grid;
    grid-template-columns: 12% minmax(0, 1fr);
    align-items: center;
    gap: 5%;
    padding: 7px 4%;
    font-size: clamp(0.94rem, 1.3vw, 1.4rem);
  }

  .dashboard-screen.is-town-shell .town-quiz-question-board .quiz-game-option-letter {
    position: static;
    width: 100%;
    height: 56%;
    transform: none;
    background: transparent;
    font-size: clamp(1.4rem, 2.2vw, 2.2rem);
  }
}

/* Match Desktop - 8: one desert playfield inside the wood frame, with mockup answer states. */
.town-quiz-content--question {
  padding: 0;
  background: transparent;
  border: 0;
}

.town-quiz-play-screen--question {
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}

.town-quiz-play-screen--question > .town-quiz-play-header {
  display: none;
}

.town-quiz-question-board {
  grid-template-rows: minmax(48px, 72px) minmax(100px, auto) minmax(54px, auto) minmax(0, 1fr) minmax(60px, auto);
  padding: clamp(12px, 1.5vw, 24px) clamp(18px, 2.4vw, 38px);
  background-position: center;
  border: 0;
}

.town-quiz-question-board .quiz-game-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: visible;
}

.town-quiz-question-board .quiz-game-timer {
  position: relative;
  z-index: 0;
  isolation: isolate;
  min-width: 150px;
  min-height: 48px;
  justify-content: center;
  padding: 7px 22px;
  background: transparent;
}

.town-quiz-question-board .quiz-game-timer::before,
.town-quiz-question-board .quiz-game-timer::after {
  position: absolute;
  z-index: -1;
  content: "";
  background: #fff8e7;
}

.town-quiz-question-board .quiz-game-timer::before {
  inset: 15px 0 2px;
  border-radius: 999px;
}

.town-quiz-question-board .quiz-game-timer::after {
  top: 4px;
  left: 27%;
  width: 29px;
  height: 27px;
  border-radius: 50%;
  box-shadow: 25px -4px 0 3px #fff8e7, 51px -1px 0 0 #fff8e7, 75px 5px 0 -4px #fff8e7;
}

.town-quiz-question-board .quiz-game-timer > * {
  position: relative;
  z-index: 1;
}

.town-quiz-question-board .quiz-game-question {
  position: relative;
  display: flex;
  justify-content: center;
  padding-right: clamp(62px, 6vw, 92px);
}

.town-quiz-question-board .quiz-game-question-head {
  position: absolute;
  top: 50%;
  right: clamp(12px, 1.5vw, 22px);
  z-index: 2;
  transform: translateY(-50%);
}

.town-quiz-question-board .quiz-game-context {
  min-height: clamp(54px, 4.2vw, 76px);
  background: url("assets/quiz/hint-panel.png") center / 100% 100% no-repeat;
  border-radius: 0;
  padding: 8px clamp(15px, 1.8vw, 26px);
}

.town-quiz-question-board .quiz-game-context.is-hint {
  background-image: url("assets/quiz/hint-panel.png");
}

.town-quiz-question-board .quiz-game-option:hover:not(:disabled) {
  background-image: url("assets/quiz/selected.png");
  filter: none;
  transform: translateY(-2px);
}

.town-quiz-question-board .quiz-game-option.is-selected {
  background-image: url("assets/quiz/selected.png");
}

.town-quiz-question-board .quiz-game-option.is-correct,
.town-quiz-question-board .quiz-game-option.is-correct:hover:not(:disabled) {
  background-image: url("assets/quiz/answer-correct.png");
}

.town-quiz-question-board .quiz-game-option.is-incorrect,
.town-quiz-question-board .quiz-game-option.is-incorrect:hover:not(:disabled) {
  background-image: url("assets/quiz/answer-incorrect.png");
}

.town-quiz-question-board .quiz-game-options {
  grid-template-rows: repeat(2, auto);
  align-content: start;
  padding-top: clamp(18px, 3vh, 34px);
}

.town-quiz-question-board .quiz-game-option {
  height: auto;
}

.town-quiz-question-board .quiz-game-footer {
  min-height: 60px;
}

.town-quiz-question-board .quiz-game-graphic-button {
  width: clamp(140px, 23%, 268px);
}

.town-quiz-question-board .quiz-game-graphic-button img {
  max-height: 68px;
}

@media (max-width: 760px) {
  .town-quiz-content--question {
    padding: 6px;
  }

  .town-quiz-play-screen--question {
    grid-template-rows: auto minmax(0, 1fr);
    gap: 6px;
  }

  .town-quiz-play-screen--question > .town-quiz-play-header {
    display: grid;
  }

  .town-quiz-question-board {
    grid-template-rows: auto minmax(64px, auto) minmax(28px, auto) minmax(0, 1fr) auto;
    padding: 7px;
    border: 0;
  }

  .town-quiz-question-board .quiz-game-progress {
    min-height: 30px;
  }

  .town-quiz-question-board .quiz-game-timer {
    min-width: 112px;
    min-height: 34px;
    padding: 4px 14px;
    font-size: 0.72rem;
  }

  .town-quiz-question-board .quiz-game-timer::before {
    inset: 11px 0 1px;
  }

  .town-quiz-question-board .quiz-game-timer::after {
    top: 1px;
    left: 25%;
    width: 20px;
    height: 19px;
    box-shadow: 18px -2px 0 2px #fff8e7, 36px 0 0 -1px #fff8e7, 52px 3px 0 -3px #fff8e7;
  }

  .town-quiz-question-board .quiz-game-question {
    padding-right: 45px;
  }

  .town-quiz-question-board .quiz-game-question-head {
    right: 8px;
  }

  .town-quiz-question-board .quiz-game-context {
    min-height: 42px;
    padding: 6px 10px;
  }

  .town-quiz-question-board .quiz-game-options {
    align-content: stretch;
    padding-top: 0;
  }

  .town-quiz-question-board .quiz-game-hint-button {
    width: 30px;
    height: 30px;
  }

  .town-quiz-question-board .quiz-game-option:hover:not(:disabled) {
    transform: none;
  }

  .town-quiz-question-board .quiz-game-footer {
    min-height: 38px;
  }

  .town-quiz-question-board .quiz-game-graphic-button {
    width: min(34%, 116px);
  }

  .town-quiz-question-board .quiz-game-graphic-button img {
    max-height: 38px;
  }
}

@media (min-width: 381px) and (max-width: 760px) {
  .town-quiz-question-board .quiz-game-footer > span {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.62rem;
    white-space: nowrap;
  }
}

@media (max-width: 380px) {
  .town-quiz-question-board .quiz-game-footer > span {
    display: none;
  }
}

@media (max-width: 760px) and (max-height: 650px) {
  .town-quiz-question-board .quiz-game-footer {
    min-height: 34px;
  }

  .town-quiz-question-board .quiz-game-graphic-button img {
    max-height: 32px;
  }
}

@media (max-width: 980px) and (orientation: portrait) {
  .dashboard-screen.is-town-shell .dashboard-main {
    padding: 0;
  }

  .town-shell-view--player:not(.town-shell-view--quiz-play):not(.town-shell-view--quiz-result) {
    width: 100%;
    gap: 0;
  }

  .town-shell-view--player:not(.town-shell-view--quiz-play):not(.town-shell-view--quiz-result) > .town-stage-frame {
    width: 100%;
    height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    min-height: 0;
  }

  .town-shell-view--player.town-shell-view--quiz:not(.town-shell-view--quiz-play):not(.town-shell-view--quiz-result) .town-quiz-list {
    margin-bottom: 80px;
    padding-bottom: 80px;
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  .town-shell-view--player:not(.town-shell-view--quiz-play):not(.town-shell-view--quiz-result) > .town-stage-frame {
    height: calc(100dvh - 86px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  /* Quest course list gets the same 8px breathing room as the lesson map frame. */
  .dashboard-screen.is-town-shell[data-active-view="quest"] .dashboard-main {
    padding: 8px;
  }

  .dashboard-screen.is-town-shell[data-active-view="quest"] .town-shell-view--player:not(.town-shell-view--quiz-play):not(.town-shell-view--quiz-result) > .town-stage-frame {
    height: calc(100dvh - 86px - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
}

/* Keep the shared Home/Quiz chrome in one viewport while a quiz is active. */
.dashboard-screen.is-town-shell.is-quiz-play,
.dashboard-screen.is-town-shell.is-quiz-play .dashboard-layout,
.dashboard-screen.is-town-shell.is-quiz-play .dashboard-main {
  min-height: 0;
  overflow: hidden;
}

.dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-play {
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
}

@media (min-width: 761px) and (max-width: 980px) {
  .dashboard-screen.is-town-shell.is-quiz-play,
  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-layout {
    height: 100dvh;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-main {
    height: 100%;
    padding: 12px;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-play {
    grid-template-columns: minmax(0, 1fr) minmax(210px, 30%);
    grid-template-rows: minmax(0, 1fr);
    gap: 10px;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-side-rail {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .guest-achievements-card {
    min-height: 0;
    overflow: hidden;
  }
}

@keyframes profile-dialog-in {
  from { opacity: 0; transform: translate(-50%, -47%) scale(0.98); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.map-player-backdrop {
  display: none;
}

@media (max-width: 760px), (max-width: 980px) and (orientation: portrait) {
  .map-player-backdrop {
    position: fixed;
    z-index: 29;
    inset: 0;
    display: block;
    background: rgba(25, 38, 45, 0.48);
    backdrop-filter: blur(1px);
  }

  .town-shell-view > .map-player-popover:not([hidden]) {
    position: fixed;
    z-index: 30;
    inset: auto;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: min(380px, 86vw);
    height: auto;
    min-height: min(68dvh, 640px);
    max-height: min(86dvh, 760px);
    display: block;
    padding: 20px 16px 16px;
    overflow-y: auto;
    overscroll-behavior: none;
    color: var(--brown-deep);
    background: var(--cream);
    border: 3px solid var(--brown-deep);
    border-radius: 20px;
    box-shadow: 0 7px 0 rgba(56, 37, 29, 0.36);
    transform: translate(-50%, -50%);
    animation: profile-dialog-in 160ms ease-out both;
  }

  .town-shell-view > .map-player-popover:not([hidden]) .map-player-close {
    top: 9px;
    right: 9px;
    width: 44px;
    height: 44px;
    color: #fff;
    background: linear-gradient(180deg, #ffc23a, #f4970d);
    border: 2px solid var(--brown-deep);
    box-shadow: 0 3px 0 rgba(56, 37, 29, 0.38);
    font-family: Arial, sans-serif;
    font-size: 1.85rem;
    font-weight: 900;
    text-shadow: 1px 1px 0 var(--brown-deep);
  }

  .town-shell-view > .map-player-popover:not([hidden]) .map-player-popover-head {
    padding-right: 42px;
  }

  .town-shell-view > .map-player-popover:not([hidden]) .map-player-close {
    position: sticky;
    z-index: 2;
    top: 0;
    right: auto;
    float: right;
    margin: -10px -5px -44px auto;
  }

  .town-shell-view > .map-player-popover:not([hidden]) .map-player-popover-head > div {
    padding-right: 0;
  }

  .town-shell-view > .map-player-popover:not([hidden]) .map-player-popover-points {
    margin-top: 12px;
  }
}

.town-quiz-load-state--notice {
  background: rgba(245, 251, 232, 0.96);
  border-color: #73924f;
}

.town-quiz-load-state--notice strong {
  color: #45632f;
}

@media (prefers-reduced-motion: reduce) {
  .town-shell-view > .map-player-popover:not([hidden]) {
    animation: none;
  }
}

/* On mobile Home, let the town art fill the space below the compact navigation. */
@media (max-width: 760px) and (orientation: portrait) {
  .dashboard-screen.is-town-shell[data-active-view="home"] {
    display: flex;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .dashboard-screen.is-town-shell[data-active-view="home"] .mobile-nav {
    flex: none;
    margin: calc(10px + env(safe-area-inset-top, 0px)) 10px 0;
  }

  .dashboard-screen.is-town-shell[data-active-view="home"] .dashboard-layout {
    flex: 1 1 0;
    width: 100%;
    height: 0;
    min-height: 0;
    overflow: hidden;
  }

  .dashboard-screen.is-town-shell[data-active-view="home"] .dashboard-main {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0 !important;
    overflow: hidden;
  }

  .dashboard-screen.is-town-shell[data-active-view="home"] .view-root {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .dashboard-screen.is-town-shell[data-active-view="home"] .town-shell-view--home {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    height: 100%;
    min-height: 0;
    gap: 0;
  }

  .dashboard-screen.is-town-shell[data-active-view="home"] .town-shell-view--home > .town-stage-frame {
    grid-column: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    background: none;
    border: 0;
    box-shadow: none;
  }

  .dashboard-screen.is-town-shell[data-active-view="home"] .guest-town-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border: 0;
  }

  .dashboard-screen.is-town-shell[data-active-view="home"] .town-side-rail {
    display: none;
  }

  .dashboard-screen.is-town-shell[data-active-view="home"] .town-floating-avatar {
    right: calc(18px + env(safe-area-inset-right, 0px));
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .dashboard-screen.is-town-shell[data-active-view="home"] .town-floating-avatar--guest {
    display: grid;
    width: 62px;
    height: 62px;
    place-items: center;
    padding: 2px;
    background: rgba(255, 248, 234, 0.94);
    border: 2px solid #5c3a28;
    border-radius: 50%;
    box-shadow: 0 3px 0 rgba(56, 37, 29, 0.38);
  }

  .town-floating-avatar--guest .guest-avatar {
    display: block;
    width: 100%;
    height: 100%;
    filter: none;
  }

  .town-floating-avatar--guest .guest-avatar svg {
    display: block;
    width: 100%;
    height: 100%;
  }
}

.town-quiz-result-board {
  row-gap: clamp(16px, 2vh, 22px);
}

.town-quiz-result-board .quiz-result-note {
  padding-top: 12px;
}

@media (max-width: 760px) {
  .town-quiz-result-board {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "banner"
      "score"
      "stats"
      "note"
      "actions";
    row-gap: 4px;
    padding: 5px 7px;
  }

  .town-quiz-result-board .quiz-result-score {
    grid-template-columns: 86px minmax(0, 1fr);
    justify-content: center;
    gap: 9px;
    width: min(100%, 250px);
    min-height: 91px;
  }

  .town-quiz-result-board .quiz-result-ring {
    width: min(100%, 82px);
    padding: 6px;
  }

  .town-quiz-result-board .quiz-result-ring-core strong {
    font-size: clamp(1.25rem, 6vw, 1.55rem);
  }

  .town-quiz-result-board .quiz-result-ring-core small {
    font-size: 0.58rem;
  }

  .town-quiz-result-board .quiz-result-status {
    width: min(100%, 145px);
    max-height: 34px;
  }

  .town-quiz-result-board .quiz-result-note {
    padding-top: 2px;
    font-size: 0.62rem;
  }

  .town-quiz-result-board .quiz-result-action {
    min-height: 35px;
    font-size: 0.68rem;
  }
}

@media (max-width: 760px) {
  .dashboard-screen.is-town-shell.is-quiz-play {
    display: flex;
    flex-direction: column;
    height: 100dvh;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-layout {
    display: block;
    flex: 1 1 0;
    height: 0;
    min-height: 0;
    order: 1;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-main {
    height: 100%;
    padding: 7px;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .view-root {
    height: 100%;
    min-height: 0;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-play {
    height: 100%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 5px;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-side-rail {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
    grid-template-rows: auto;
    grid-row: 1;
    height: auto;
    max-height: 78px;
    overflow: hidden;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-stage-frame--playing {
    grid-row: 2;
    height: 100%;
    min-height: 0;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .guest-achievements-card {
    min-height: 0;
    overflow: hidden;
  }
}

@media (max-width: 760px), (max-width: 980px) and (orientation: portrait) {
  .town-shell-view--quiz-play .town-floating-avatar,
  .town-shell-view--quiz-result .town-floating-avatar {
    display: none;
  }

  .town-quiz-play-header {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    gap: 6px;
  }

  .town-quiz-profile-trigger {
    display: grid;
    width: 36px;
    height: 38px;
  }

  .town-quiz-profile-trigger .avatar-map-trigger {
    width: 34px;
    height: 34px;
    border-width: 2px;
  }

  .town-quiz-play-header > div {
    min-width: 0;
  }

  .town-quiz-play-header h2 {
    display: -webkit-box;
    overflow: hidden;
    font-size: clamp(0.66rem, 2.5vw, 0.82rem);
    text-overflow: clip;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .town-quiz-exit {
    min-height: 28px;
    padding: 4px 7px;
    font-size: 0.58rem;
  }
}

/* Final flow sizing: the result template must fill the same mobile frame as questions. */
.quiz-game-board.town-quiz-question-board:not(.has-context) {
  grid-template-rows: auto minmax(64px, auto) minmax(0, 1fr) auto;
}

.town-quiz-question-board .quiz-game-option.is-selected:not(.is-correct):not(.is-incorrect) {
  background-color: #3d9ddd;
  border-radius: 10px;
}

@media (min-width: 761px) {
  .town-quiz-result-board {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    column-gap: clamp(30px, 4vw, 56px);
  }

  .town-quiz-result-board .quiz-result-score {
    width: min(100%, 300px);
  }

  .town-quiz-result-board .quiz-result-ring {
    width: min(100%, clamp(140px, 16vw, 230px));
  }

  .town-quiz-result-board .quiz-result-status,
  .town-quiz-result-board .quiz-result-status-text {
    width: min(100%, 300px);
  }
}

@media (max-width: 760px) {
  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-layout {
    display: block;
    flex: 1 1 0;
    height: 0;
    min-height: 0;
    order: 1;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-main,
  .dashboard-screen.is-town-shell.is-quiz-play .view-root {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-main {
    display: flex;
    padding: 7px;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-play,
  .dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-result {
    display: grid;
    width: 100%;
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    overflow: hidden;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-side-rail {
    display: none;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-stage-frame--playing {
    grid-row: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 6px;
  }

  .town-quiz-content--playing,
  .town-quiz-list--playing,
  .town-quiz-play-screen,
  .town-quiz-play-body {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .town-quiz-content--playing {
    padding: 6px;
  }

  .town-quiz-play-screen {
    grid-template-rows: auto minmax(0, 1fr);
    gap: 6px;
  }

  .town-quiz-play-header {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 7px;
    min-height: 38px;
    padding-inline: 3px;
  }

  .town-quiz-profile-trigger {
    display: grid;
    width: 34px;
    height: 36px;
  }

  .town-quiz-profile-trigger .avatar-map-trigger {
    width: 32px;
    height: 32px;
  }

  .town-quiz-play-header h2 {
    display: -webkit-box;
    overflow: hidden;
    font-size: clamp(0.65rem, 2.6vw, 0.8rem);
    line-height: 1.05;
    text-overflow: clip;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .town-quiz-exit {
    min-height: 27px;
    padding: 4px 7px;
    font-size: 0.55rem;
    white-space: nowrap;
  }

  .quiz-game-board.town-quiz-question-board {
    grid-template-rows: auto minmax(64px, auto) minmax(28px, auto) minmax(0, 1fr) auto;
    gap: 5px;
    padding: 7px;
  }

  .quiz-game-board.town-quiz-question-board:not(.has-context) {
    grid-template-rows: auto minmax(64px, auto) minmax(0, 1fr) auto;
  }

  .quiz-game-progress {
    min-height: 30px;
  }

  .quiz-game-progress-label {
    display: block;
    font-size: clamp(0.74rem, 3vw, 0.9rem);
  }

  .town-quiz-question-board .quiz-game-timer {
    min-width: 94px;
    min-height: 29px;
    padding: 3px 9px;
    font-size: 0.72rem;
  }

  .town-quiz-question-board .quiz-game-timer img {
    width: 19px;
    height: 19px;
  }

  .town-quiz-question-board .quiz-game-question {
    min-height: 64px;
    padding: 7px 10px 9px;
  }

  .town-quiz-question-board .quiz-game-question-head > span {
    font-size: 0.53rem;
  }

  .town-quiz-question-board .quiz-game-question h2 {
    font-size: clamp(0.77rem, 3.4vw, 0.94rem);
    line-height: 1.15;
  }

  .town-quiz-question-board .quiz-game-context {
    padding: 5px 8px;
    font-size: clamp(0.58rem, 2.6vw, 0.7rem);
    line-height: 1.14;
  }

  .town-quiz-question-board .quiz-game-options {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-auto-rows: minmax(0, 1fr);
    gap: 5px;
  }

  .town-quiz-question-board .quiz-game-option {
    grid-template-columns: 38px minmax(0, 1fr);
    min-height: 54px;
    max-height: none;
    gap: 8px;
    padding: 5px 9px;
    font-size: clamp(0.65rem, 2.9vw, 0.79rem);
    line-height: 1.12;
  }

  .town-quiz-question-board .quiz-game-option-letter {
    width: 36px;
    height: 34px;
    font-size: 1.1rem;
  }

  .town-quiz-question-board .quiz-game-option-text {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .town-quiz-question-board .quiz-game-footer {
    min-height: 38px;
    padding: 0;
  }

  .town-quiz-question-board .quiz-game-footer > span {
    display: none;
  }

  .town-quiz-question-board .quiz-game-graphic-button {
    width: min(37%, 124px);
  }

  .town-quiz-question-board .quiz-game-graphic-button img {
    max-height: 38px;
  }

  .town-quiz-result-board {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(138px, 0.9fr) minmax(128px, 1fr) auto auto;
    grid-template-areas:
      "banner"
      "score"
      "stats"
      "note"
      "actions";
    gap: 5px;
    padding: 8px 9px;
  }

  .town-quiz-result-board .quiz-result-banner {
    width: min(78%, 320px);
    max-height: 50px;
  }

  .town-quiz-result-board .quiz-result-score {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    justify-items: center;
    align-content: center;
    gap: 7px;
    width: 100%;
    min-height: 0;
  }

  .town-quiz-result-board .quiz-result-ring {
    width: clamp(112px, 35vw, 174px);
    padding: 8px;
  }

  .town-quiz-result-board .quiz-result-ring-core strong {
    font-size: clamp(1.65rem, 7vw, 2.35rem);
  }

  .town-quiz-result-board .quiz-result-ring-core small {
    font-size: 0.72rem;
  }

  .town-quiz-result-board .quiz-result-status,
  .town-quiz-result-board .quiz-result-status-text {
    width: min(84%, 320px);
    max-height: 40px;
    min-height: 34px;
  }

  .town-quiz-result-board .quiz-result-stats {
    grid-template-rows: repeat(5, minmax(24px, 1fr));
    padding: 3px 10px;
  }

  .town-quiz-result-board .quiz-result-stat {
    grid-template-columns: 27px minmax(0, 1fr) auto;
    gap: 7px;
    padding: 2px 0;
    font-size: clamp(0.68rem, 3vw, 0.82rem);
  }

  .town-quiz-result-board .quiz-result-stat img {
    width: 23px;
    height: 23px;
  }

  .town-quiz-result-board .quiz-result-note {
    max-height: 2.5em;
    overflow: hidden;
    padding: 0;
    font-size: clamp(0.53rem, 2.4vw, 0.64rem);
    line-height: 1.2;
  }

  .town-quiz-result-board .quiz-result-actions {
    justify-content: space-between;
    gap: 10px;
  }

  .town-quiz-result-board .quiz-result-action {
    width: calc(50% - 5px);
  }
}

@media (max-width: 760px) and (max-height: 650px) {
  .quiz-game-board.town-quiz-question-board {
    grid-template-rows: auto minmax(54px, auto) minmax(24px, auto) minmax(0, 1fr) auto;
    gap: 3px;
    padding: 5px;
  }

  .quiz-game-board.town-quiz-question-board:not(.has-context) {
    grid-template-rows: auto minmax(54px, auto) minmax(0, 1fr) auto;
  }

  .town-quiz-question-board .quiz-game-option {
    min-height: 45px;
    padding-block: 3px;
    font-size: 0.63rem;
  }

  .town-quiz-question-board .quiz-game-option-letter {
    width: 31px;
    height: 29px;
    font-size: 0.98rem;
  }

  .town-quiz-question-board .quiz-game-footer,
  .town-quiz-question-board .quiz-game-graphic-button img {
    max-height: 32px;
  }

  .town-quiz-result-board {
    grid-template-rows: auto minmax(100px, 0.8fr) minmax(118px, 1fr) auto auto;
    gap: 3px;
    padding: 5px 7px;
  }

  .town-quiz-result-board .quiz-result-banner {
    max-height: 37px;
  }

  .town-quiz-result-board .quiz-result-ring {
    width: clamp(94px, 27vw, 125px);
  }

  .town-quiz-result-board .quiz-result-status,
  .town-quiz-result-board .quiz-result-status-text {
    min-height: 29px;
    max-height: 32px;
  }

  .town-quiz-result-board .quiz-result-stats {
    grid-template-rows: repeat(5, minmax(21px, 1fr));
  }

  .town-quiz-result-board .quiz-result-stat {
    font-size: 0.62rem;
  }

  .town-quiz-result-board .quiz-result-stat img {
    width: 20px;
    height: 20px;
  }

  .town-quiz-result-board .quiz-result-action img {
    max-height: 32px;
  }
}
/* Authoritative mobile question layout: progress above the board, answers
   scroll inside it, and the page shell itself remains fixed. */
@media (max-width: 760px) {
  .dashboard-screen.is-town-shell.is-quiz-play {
    background: #43b9f3;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .dashboard-main {
    padding: 0 14px 10px !important;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-play {
    grid-template-rows: min-content minmax(0, 1fr) !important;
    gap: 5px;
  }

  .town-shell-view--quiz-play > .town-quiz-mobile-meta {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    min-height: 47px;
    padding-inline: 2px;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-stage-frame--playing {
    grid-column: 1;
    grid-row: 2 !important;
    min-height: 0;
  }

  .town-quiz-play-screen--question > .town-quiz-play-header {
    display: none !important;
  }

  .town-quiz-play-screen--question {
    display: flex;
    flex-direction: column;
    height: 100% !important;
    min-height: 0;
    overflow: hidden;
  }

  .town-quiz-play-screen--question > .town-quiz-play-body {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    width: 100%;
    height: 0 !important;
    min-height: 0;
    overflow: hidden;
  }

  .quiz-game-board.town-quiz-question-board {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    width: 100%;
    height: 100% !important;
    min-height: 0;
    gap: 8px;
    padding: 8px;
  }

  .town-quiz-question-board .quiz-game-progress {
    display: none !important;
  }

  .town-quiz-question-board .quiz-game-question {
    flex: 0 0 auto;
    min-height: clamp(92px, 13vh, 124px);
  }

  .town-quiz-question-board .quiz-game-question h2 {
    font-size: clamp(1rem, 4vw, 1.22rem);
    line-height: 1.2;
  }

  .town-quiz-question-board .quiz-game-context {
    flex: 0 0 auto;
  }

  .town-quiz-question-board .quiz-game-options {
    display: grid;
    flex: 1 1 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-auto-rows: max-content;
    align-content: start;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .town-quiz-question-board .quiz-game-option {
    grid-template-columns: 12% minmax(0, 1fr);
    min-height: clamp(70px, 11.5vh, 106px);
    gap: 5%;
    padding: 8px 4%;
    font-size: clamp(0.82rem, 3.6vw, 1rem);
    line-height: 1.2;
    background: url("assets/quiz/option.png") center / 100% 100% no-repeat;
    border: 0;
    border-radius: 0;
  }

  .town-quiz-question-board .quiz-game-option:hover:not(.is-correct):not(.is-incorrect):not(:disabled),
  .town-quiz-question-board .quiz-game-option.is-selected:not(.is-correct):not(.is-incorrect) {
    background: url("assets/quiz/selected.png") center / 100% 100% no-repeat;
  }

  .town-quiz-question-board .quiz-game-option.is-correct,
  .town-quiz-question-board .quiz-game-option.is-correct:hover:not(:disabled) {
    background: url("assets/quiz/answer-correct.png") center / 100% 100% no-repeat;
  }

  .town-quiz-question-board .quiz-game-option.is-incorrect,
  .town-quiz-question-board .quiz-game-option.is-incorrect:hover:not(:disabled) {
    background: url("assets/quiz/answer-incorrect.png") center / 100% 100% no-repeat;
  }

  .town-quiz-question-board .quiz-game-option-letter {
    position: static;
    width: 100%;
    height: 56%;
    transform: none;
    font-size: 1.28rem;
    line-height: 1;
    text-align: center;
  }

  .dashboard-screen.is-town-shell .town-quiz-question-board .quiz-game-option {
    display: grid;
    grid-template-columns: 12% minmax(0, 1fr);
    align-items: center;
  }

  .dashboard-screen.is-town-shell .town-quiz-question-board .quiz-game-option-letter {
    position: static;
    width: 100%;
    height: 56%;
    transform: none;
  }

  .town-quiz-question-board .quiz-game-footer {
    flex: 0 0 auto;
  }
}

@media (max-width: 760px) and (max-height: 650px) {
  .town-shell-view--quiz-play > .town-quiz-mobile-meta {
    min-height: 40px;
  }

  .town-quiz-question-board .quiz-game-question {
    min-height: 72px;
  }

  .town-quiz-question-board .quiz-game-option {
    min-height: 60px;
  }
}

/* Completed quiz answer review: keep the same game frame and choice art, but make every choice read-only. */
.quiz-game-board.town-quiz-review-board {
  display: grid;
  grid-template-rows: auto minmax(74px, auto) minmax(42px, auto) minmax(0, 1fr) auto;
  align-items: stretch;
  gap: clamp(6px, 1vh, 12px);
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: clamp(8px, 1.3vw, 17px) clamp(10px, 1.6vw, 22px);
  overflow: hidden;
  background: #f6ca79 url("assets/ui-horizontal/map-background-horizontal.webp") center / 100% 100% no-repeat;
  border: 2px solid var(--brown-deep);
}

.quiz-review-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  color: var(--brown-deep);
  font-family: var(--font-display);
}

.quiz-review-progress > span {
  color: #80654c;
  font-size: 0.85em;
}

.quiz-review-progress > span.is-correct { color: #238b33; }
.quiz-review-progress > span.is-incorrect { color: #b5231e; }

.town-quiz-review-board .quiz-game-question {
  min-height: 0;
  max-height: none;
  padding: clamp(10px, 1.25vh, 15px) clamp(15px, 1.8vw, 24px);
}

.quiz-review-feedback {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0;
  line-height: 1.25;
}

.quiz-review-feedback > small {
  color: #72563e;
  font-weight: 750;
}

.quiz-review-option-mark {
  display: block;
  margin-top: 3px;
  color: #f8fff4;
  font-size: 0.76em;
  font-weight: 800;
  line-height: 1.1;
}

.town-quiz-review-board .quiz-game-option:disabled {
  cursor: default;
  opacity: 1;
}

.town-quiz-review-board .quiz-game-option.is-incorrect {
  outline: 3px solid #d71920;
  outline-offset: 1px;
}

.quiz-review-text-answer {
  display: grid;
  align-content: center;
  gap: 6px;
  min-height: 78px;
  padding: 14px 18px;
  color: var(--brown-deep);
  background: #fff8ed;
  border: 2px solid var(--brown-deep);
  border-radius: 12px;
}

.quiz-review-text-answer p { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 760px), (max-width: 980px) and (orientation: portrait) {
  .town-quiz-result-board .quiz-result-actions { gap: 5px; }

  .town-quiz-result-board .quiz-result-action {
    flex: 0 1 48%;
    width: 48%;
    min-width: 0;
    min-height: 34px;
    padding: 0;
  }

  .town-quiz-result-board .quiz-result-review-action {
    aspect-ratio: 313 / 74;
    min-height: 34px;
    padding: 0 6px;
    font-size: clamp(0.8rem, 4vw, 1.1rem);
  }

  .town-quiz-result-board .quiz-result-action img {
    max-height: clamp(34px, 9vw, 44px);
  }

  .town-quiz-review-board {
    grid-template-rows: auto minmax(62px, auto) minmax(38px, auto) minmax(0, 1fr) auto;
    gap: 5px;
    padding: 6px;
  }

  .town-quiz-review-board .quiz-game-question { padding: 7px 10px; }
  .town-quiz-review-board .quiz-game-question h2 { font-size: clamp(0.84rem, 3.7vw, 1rem); }
  .town-quiz-review-board .quiz-game-options {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-auto-rows: minmax(0, 1fr);
    gap: 4px;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .town-quiz-review-board .quiz-game-option {
    display: grid;
    grid-template-columns: 12% minmax(0, 1fr);
    min-height: 58px;
    max-height: none;
    gap: 5%;
    padding: 6px 4%;
    font-size: clamp(0.72rem, 3.2vw, 0.9rem);
    line-height: 1.12;
  }
  .town-quiz-review-board .quiz-game-option-letter { position: static; width: 100%; height: auto; transform: none; }
  .town-quiz-review-board .quiz-game-footer { min-height: 34px; }
  .town-quiz-review-board .quiz-game-footer > span { font-size: 0.68rem; }
  .town-quiz-review-board .quiz-game-graphic-button { width: clamp(74px, 25%, 118px); }
  .town-quiz-review-board .quiz-game-graphic-button img { max-height: 32px; }
}

@media (max-width: 380px) {
  .town-quiz-result-board .quiz-result-review-action { font-size: 0.78rem; }
  .town-quiz-review-board .quiz-review-progress { gap: 5px; font-size: 0.76rem; }
  .town-quiz-review-board .quiz-review-progress > span { font-size: 0.72em; }
}

/* Result has no progress strip, so keep its frame in row one instead of the
   question screen's reserved row two. */
@media (max-width: 760px), (max-width: 980px) and (orientation: portrait) {
  .dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-result {
    grid-template-rows: minmax(0, 1fr) !important;
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-result > .town-stage-frame--playing {
    grid-row: 1 !important;
    grid-column: 1;
  }
}

@media (min-width: 761px) {
  .dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-result {
    grid-template-columns: minmax(0, 1fr) minmax(285px, min(24vw, 425px));
  }

  .dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-result > .town-stage-frame--playing {
    grid-column: 1;
    grid-row: 1;
  }
}

.dashboard-screen.is-town-shell.is-quiz-play .view-root,
.dashboard-screen.is-town-shell.is-quiz-play .town-shell-view--quiz-result {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Milestone 2: lesson route, lesson reading, and the badge collection. */
.map-terrain-tile { display: none; }
.is-milestone-map .map-panel-toolbar { justify-content: flex-end; }
.desktop-nav .nav-item { min-width: 0; max-width: 100%; }
.is-milestone-map .dashboard-topbar { display: none; }
.dashboard-screen[data-active-view="badges"] .dashboard-topbar { display: none; }
.dashboard-screen[data-active-view="badges"] .dashboard-main { padding: 18px; }
.is-milestone-map .dashboard-main { padding: 18px; min-height: 0; }
.is-milestone-map .view-root, .is-milestone-map .home-map-view { height: 100%; min-height: 0; }
.is-milestone-map .side-rail { height: calc(100dvh - 82px); min-height: 0; overflow-y: auto; }
.is-milestone-map .map-panel-landscape { display: flex; flex-direction: column; min-height: 0; }
.is-milestone-map .map-panel-landscape > .game-content-frame { flex: 1; min-height: 0; }
.is-milestone-map .map-scroll-horizontal { height: 100%; overflow-x: auto; overflow-y: hidden; }
.is-milestone-map .map-board-landscape { height: 100%; min-height: 0; zoom: 1; }
.is-milestone-map .map-player-popover { position: fixed; z-index: 50; top: 12%; right: 24px; max-height: 80dvh; overflow: auto; }
.milestone-lesson-intro { margin: 20px 0; line-height: 1.6; color: #80573d; }
.milestone-lesson-dialog { background: #fff8eb; }
.lesson-material-heading { margin: 16px 0 12px; }
.milestone-map-status { padding: 10px; color: #fff8eb; }
.milestone-lesson-copy { line-height: 1.7; max-height: 42dvh; overflow: auto; padding-right: 12px; }
.milestone-lesson-copy p { margin: 0 0 16px; }
.milestone-lesson-reward { display: grid; gap: 5px; margin: 22px 0; padding: 16px; border-radius: 12px; background: #f3dfb7; }
.milestone-lesson-reward span { font-size: 14px; color: #80573d; }
.milestone-lesson-error { color: #a12820; }
/* Achievements sit in the same wood frame as Quest; on desktop it lines up with the side nav. */
.milestone-achievements-frame { display: flex; flex-direction: column; min-height: 100%; padding: 9px; border-radius: 0; background-color: #bd7a46; background-image: repeating-linear-gradient(0deg, #b46f3f 0 19px, #c8824d 19px 24px); border: 3px solid var(--brown-deep); box-shadow: 0 5px 0 rgba(56, 37, 29, 0.3); }
.milestone-achievements { flex: 1; min-height: 0; padding: clamp(20px, 3vw, 42px); background: linear-gradient(135deg, #fff8e8, #f9dfaa); border: 2px solid var(--brown-deep); }
.dashboard-screen[data-active-view="badges"] .view-root { max-width: none; }
@media (max-width: 760px) and (orientation: portrait) {
  /* Same 8px inset as the Quest frame (outranks the later 980px badges padding). */
  .dashboard-screen.dashboard-screen[data-active-view="badges"] .dashboard-main { padding: 8px; }
  .milestone-achievements-frame { min-height: calc(100dvh - 86px - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
}
@media (min-width: 1181px) {
  .dashboard-screen[data-active-view="badges"] .dashboard-main { padding: 41px 20px 39px 15px; }
  .milestone-achievements-frame { height: calc(100dvh - 80px); min-height: 0; }
  .milestone-achievements { overflow-y: auto; overscroll-behavior: none; }
}
@media (min-width: 1181px) and (max-height: 800px) {
  .dashboard-screen[data-active-view="badges"] .dashboard-main { padding: 20px 20px 20px 15px; }
  .milestone-achievements-frame { height: calc(100dvh - 40px); }
}
.milestone-achievements-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.milestone-achievements-header h2 { margin: 5px 0 12px; }
.milestone-achievements-header p { max-width: 520px; line-height: 1.5; }
.milestone-collection-count { display: grid; flex-shrink: 0; text-align: center; gap: 4px; padding: 16px 25px; border: 2px solid #d2ad74; border-radius: 16px; background: #fffaf1; }
.milestone-collection-count strong { font-size: 36px; color: #795034; }
.milestone-collection-count strong span { font-size: 20px; color: #a88c70; }
.milestone-collection-count > span { font-size: 13px; }
.milestone-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 26px 0; }
.milestone-filters button { padding: 10px 19px; border: 2px solid #ad8661; border-radius: 99px; color: #795034; background: #fffaf2; cursor: pointer; font: inherit; }
.milestone-filters button[aria-pressed="true"] { background: #ffcb42; border-color: #795034; }
.milestone-badge-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(225px, 1fr)); gap: 20px; }
.milestone-badge-card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 23px 20px; border: 2px solid #cbb79b; border-radius: 18px; background: #fffdf8; box-shadow: 0 5px 0 #cdbb9a; }
.milestone-badge-card.is-earned { border-color: #52a44e; }
.milestone-badge-status { align-self: flex-end; padding: 4px 9px; border-radius: 8px; font-size: 12px; background: #e9e5df; color: #746d62; }
.is-earned .milestone-badge-status { background: #e0f4d7; color: #377b2d; }
.milestone-badge-art { display: grid; place-items: center; height: 138px; width: 138px; margin: 12px 0; background: #fff2d8; border-radius: 50%; }
.milestone-badge-art img { width: 100px; height: 118px; object-fit: contain; }
.is-locked .milestone-badge-art img { filter: grayscale(1); opacity: .45; }
.milestone-badge-card h3 { margin: 12px 0 8px; font-size: 21px; }
.milestone-badge-card p { margin: 0 0 20px; line-height: 1.5; font-size: 14px; color: #876f59; }
.milestone-badge-card .button, .milestone-badge-future { margin-top: auto; }
.milestone-badge-future { font-size: 13px; color: #927b63; }
.milestone-badge-empty { padding: 30px 0; }
@media (max-width: 980px) {
  /* The map exposes this navigation up to 980px, not just the older 760px
     phone breakpoint. Keep its frame/buttons/SVG dimensions consistent. */
  .dashboard-screen .mobile-nav {
    position: static;
    order: 0;
    margin: 10px 10px 0;
    gap: 5px;
    padding: 6px;
    background: var(--cream);
    border: 3px solid var(--brown-deep);
    border-radius: 14px;
    box-shadow: 0 5px 0 rgba(56, 37, 29, 0.27);
  }
  .dashboard-screen .mobile-nav, .dashboard-screen.is-town-shell .mobile-nav { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  /* The nav follows the layout in the DOM and is moved up with `order`. Safari
     paints equal z-index by DOM order, so the nav covered dialog tops; the
     layout (and the dialogs inside it) must stack above the nav. */
  .dashboard-screen > .dashboard-layout { z-index: 2; }
  .dashboard-screen .mobile-nav-item {
    min-width: 0; min-height: 58px;
    display: grid; place-items: center; gap: 2px; padding: 5px 4px;
    color: var(--brown-deep); background: transparent;
    border: 2px solid transparent; border-radius: 8px;
    font-size: 10px; font-weight: 900; line-height: 1.05;
    white-space: nowrap; cursor: pointer;
  }
  .dashboard-screen .mobile-nav-item span { max-width: 100%; text-align: center; font-size: 10px; }
  .dashboard-screen .mobile-nav-item svg { width: 22px; height: 22px; }
  .dashboard-screen .mobile-nav-item.is-active { background: var(--orange-light); border-color: var(--brown-deep); }
  .dashboard-screen .mobile-nav-item:not(.is-active):hover { background: transparent; border-color: transparent; }
  .dashboard-screen[data-active-view="badges"] .dashboard-main { padding: 10px; }
  .dashboard-screen.is-milestone-map { display: flex; flex-direction: column; height: 100dvh; min-height: 0; overflow: hidden; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .is-milestone-map .mobile-nav { display: grid; order: 0; flex: none; margin: 10px 10px 0; }
  .is-milestone-map .side-nav { display: none; }
  .is-milestone-map .dashboard-layout { order: 1; display: flex; flex: 1; width: 100%; min-height: 0; overflow: hidden; }
  .is-milestone-map .dashboard-main { display: flex; flex: 1; width: 100%; min-height: 0; padding: 8px; overflow: hidden; }
  .is-milestone-map .view-root { display: flex; flex: 1; height: auto; min-height: 0; }
  .is-milestone-map .home-map-view { display: flex; align-items: stretch; flex: 1; height: auto; min-height: 0; min-width: 0; }
  .is-milestone-map .side-rail { display: none; }
  .is-milestone-map .home-map-view .map-panel { position: relative; flex: 1; width: 100%; height: auto; min-height: 0; }
  .is-milestone-map .map-panel-toolbar .map-player-trigger { display: none; }
  .is-milestone-map .map-panel > .town-floating-avatar {
    position: absolute;
    z-index: 20;
    right: 12px;
    bottom: 12px;
    display: block;
    width: 60px;
    height: 68px;
    padding: 0;
    background: rgba(255, 248, 234, 0.92);
    border: 2px solid var(--brown-deep);
    border-radius: 50%;
    box-shadow: 0 4px 0 rgba(56, 37, 29, 0.35);
  }
  .is-milestone-map .map-panel-toolbar { display: none; }
  .is-milestone-map .map-panel-toolbar > div:first-child { flex: 1; min-width: 0; }
  .is-milestone-map .map-panel-toolbar .kicker { font-size: clamp(10px, 2.8vw, 12px); }
  .is-milestone-map .map-scroll-controls { flex: none; }
  .is-milestone-map .map-panel-toolbar h2 { font-size: 17px; }
  .is-milestone-map .map-scroll-controls > span { display: none; }
  .is-milestone-map .map-scroll-button[data-action="map-left"],
  .is-milestone-map .map-scroll-button[data-action="map-right"] { display: none; }
  .is-milestone-map .map-scroll-horizontal { touch-action: pan-x pinch-zoom; overscroll-behavior-x: none; scrollbar-width: none; }
  .is-milestone-map .map-scroll-horizontal::-webkit-scrollbar { display: none; }
  /* Crop only the border baked into the original 1147×832 terrain artwork.
     Its clean interior is x:20..1136, y:36..814. Keep the wood frame intact.
     Each tile fills its viewport height, including after browser chrome resizes. */
  .is-milestone-map .home-map-view .map-board-landscape { background-image: none; }
  .is-milestone-map .home-map-view .map-board-landscape .map-world-next { display: none; }
  .is-milestone-map .map-terrain-tile {
    display: block;
    position: absolute;
    top: 0;
    width: 1147px;
    height: 100%;
    pointer-events: none;
    background-image: url("assets/ui-horizontal/map-background-horizontal.webp");
    background-repeat: no-repeat;
    background-size: 102.777778% 106.940874%;
    background-position: 64.516129% 66.666667%;
  }
  .is-milestone-map .map-board-landscape .map-node { top: 70%; width: 90px; }
  .is-milestone-map .map-board-landscape .node-orb { width: 80px; height: 80px; }
  .is-milestone-map .home-map-view .map-board-landscape .map-node .node-note { top: auto; left: 50%; right: auto; bottom: 85px; width: 185px; min-height: 76px; padding: 10px 12px; transform: translateX(-50%); }
  .is-milestone-map .home-map-view .map-board-landscape .map-node .node-note::after { top: auto; left: 50%; right: auto; bottom: -12px; transform: translateX(-50%) rotate(45deg); border: 0; border-right: 3px solid var(--brown); border-bottom: 3px solid var(--brown); }
  .milestone-achievements-header { align-items: flex-start; gap: 12px; }
  .milestone-collection-count { padding: 12px; }
  .milestone-collection-count strong { font-size: 26px; }
  .milestone-badge-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .milestone-badge-card { padding: 12px 10px; }
  .milestone-badge-card h3 { font-size: 17px; }
  .milestone-badge-art { width: 112px; height: 112px; }
  .milestone-badge-art img { width: 78px; height: 98px; }
  .milestone-badge-card .button { padding: 9px 6px; font-size: 12px; }
}
@media (max-width: 360px) {
  .milestone-badge-grid { grid-template-columns: 1fr; }
  .milestone-achievements-header { flex-wrap: wrap; }
}

/* Approved 2026-10-26: one vertical route on every device. */
.is-milestone-map .home-map-view .map-scroll-vertical {
  height: 100%; overflow-x: hidden; overflow-y: auto;
  touch-action: pan-y pinch-zoom; overscroll-behavior-y: none;
  scrollbar-width: thin;
}
.is-milestone-map .home-map-view .map-frame { border-width: 12px; border-image-width: 12px; }
.is-milestone-map .home-map-view .map-board-vertical {
  width: 100%; height: var(--lesson-map-height); min-height: var(--lesson-map-height);
  zoom: 1; border: 0; border-radius: 0;
  background: #f8d17e;
}
.is-milestone-map .map-vertical-terrain-tile { position: absolute; left: 0; width: 100%; height: 1400px; overflow: hidden; pointer-events: none; z-index: 0; }
/* Original 1177×1594 art contains a border: show only x35..1173/y6..1526. */
.is-milestone-map .map-vertical-terrain-tile img { position: absolute; max-width: none; left: -3.075571%; top: -0.394737%; width: 103.427065%; height: 104.868421%; }
.is-milestone-map .lesson-map-road {
  --road-width: clamp(60px, 9vw, 110px);
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none;
}
.is-milestone-map .lesson-map-road path { fill: none; stroke: #fff3b9; stroke-width: var(--road-width); vector-effect: non-scaling-stroke; }
.is-milestone-map .lesson-map-road .lesson-road-shadow { stroke: #d5a33d; stroke-width: calc(var(--road-width) + 8px); transform: translateY(6px); }
.is-milestone-map .map-vertical-scenery {
  position: absolute; left: 0; right: 0; height: 1000px; z-index: 2; pointer-events: none;
}
.is-milestone-map .map-vertical-scenery img { position: absolute; width: 30%; height: auto; }
.is-milestone-map .map-vertical-scenery .map-place-vertical-city { top: 5px; left: -4%; }
.is-milestone-map .map-vertical-scenery .map-place-vertical-frontier { top: 350px; right: -4%; }
.is-milestone-map .map-vertical-scenery .map-place-vertical-island { top: 720px; left: -3%; }
.is-milestone-map .home-map-view.map-layout-vertical .map-board-vertical .map-node {
  top: var(--lesson-top); left: 72%; width: 80px; transform: translateX(-50%);
}
.is-milestone-map .home-map-view.map-layout-vertical .map-board-vertical .map-node-left { left: 28%; }
.is-milestone-map .home-map-view.map-layout-vertical .map-board-vertical .node-orb { width: 80px; height: 80px; }
.is-milestone-map .home-map-view.map-layout-vertical .map-board-vertical .node-orb::after { display: none; }
.is-milestone-map .home-map-view.map-layout-vertical .map-board-vertical .map-node .node-note {
  top: 84px; bottom: auto; right: 16px; left: auto;
  width: clamp(145px, 45vw, 240px); min-height: 90px;
  padding: 10px 12px; transform: none;
}
.is-milestone-map .home-map-view.map-layout-vertical .map-board-vertical .map-node-left .node-note { left: 16px; right: auto; }
.is-milestone-map .home-map-view.map-layout-vertical .map-board-vertical .map-node .node-note::after {
  top: -10px; left: auto; right: 13px; bottom: auto;
  width: 16px; height: 16px;
  border-top: 3px solid var(--brown); border-left: 3px solid var(--brown);
  border-right: 0; border-bottom: 0;
  transform: rotate(45deg);
}
.is-milestone-map .home-map-view.map-layout-vertical .map-board-vertical .map-node-left .node-note::after { left: 13px; right: auto; }
.is-milestone-map .map-board-vertical .node-note .node-subtitle { color: #23833a; }
@media (max-width: 980px) {
  .is-milestone-map .home-map-view .map-scroll-vertical { scrollbar-width: none; }
  .is-milestone-map .map-scroll-vertical::-webkit-scrollbar { display: none; }
  .is-milestone-map .home-map-view.map-layout-vertical .map-board-vertical .map-node .node-note { width: min(180px, 49vw); }
  .is-milestone-map .home-map-view.map-layout-vertical .map-board-vertical .node-note strong { font-size: 15px; }
}
/* Quest revamp (2026-10-28): course list, sequential lock, map back link. */
.quest-course-card .quest-course-image { width: 100%; max-height: 120px; object-fit: cover; border-radius: 12px; }

/* Quest course cards: bigger artwork, subtitle, enrollment-aware actions. */
.lesson-quiz-card.quest-course-card {
  grid-template-columns: 160px minmax(0, 1fr) auto;
  grid-template-rows: auto;
  grid-template-areas: "thumb copy action";
  align-items: center;
  min-height: 150px;
  padding: 12px 18px;
}

.lesson-quiz-card.quest-course-card > .quest-course-image,
.lesson-quiz-card.quest-course-card > .quest-course-image--fallback {
  grid-area: thumb;
  width: 160px;
  height: 96px;
  margin-left: 4px;
  object-fit: cover;
  border: 2px solid var(--brown-deep);
  border-radius: 12px;
  background: var(--sand);
}

.quest-course-image--fallback {
  display: grid;
  place-items: center;
  color: var(--cream);
  background: var(--brown-deep);
  font-family: var(--font-display);
  font-size: 1.6rem;
}

.lesson-quiz-card.quest-course-card .lesson-quiz-copy {
  gap: 4px;
}

.quest-course-subtitle {
  display: -webkit-box;
  overflow: hidden;
  color: var(--brown-soft);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.lesson-quiz-card.quest-course-card .lesson-quiz-action {
  white-space: nowrap;
}

.lesson-quiz-card.quest-course-card .quest-course-side {
  grid-area: action;
  display: grid;
  justify-items: center;
  justify-self: end;
  align-content: center;
  gap: 6px;
}

.lesson-quiz-card.quest-course-card .quest-course-side .lesson-quiz-action {
  grid-area: auto;
  justify-self: center;
}

.quest-course-students {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--brown-soft);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.quest-course-students svg {
  width: 16px;
  height: 16px;
}

/* Course detail dialog (quest list → not enrolled). */
.course-dialog .course-dialog-flag {
  position: absolute;
  top: 14px;
  right: 54px;
  padding: 4px 14px;
  color: var(--cream);
  background: var(--orange);
  border: 2px solid var(--brown-deep);
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.8rem;
}

.course-dialog-art {
  width: 100%;
  height: 170px;
  margin: 12px 0 4px;
  object-fit: cover;
  border: 2px solid var(--brown-deep);
  border-radius: 12px;
}

.course-dialog-subtitle {
  margin: 8px 0 0;
  color: var(--brown-soft);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.4;
}

.course-dialog-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  margin: 14px 0 0;
  padding: 12px 14px;
  background: rgba(255, 229, 161, 0.35);
  border: 2px solid rgba(91, 58, 43, 0.25);
  border-radius: 12px;
}

.course-dialog-facts > div {
  min-width: 0;
}

.course-dialog-facts dt {
  color: var(--brown-soft);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.course-dialog-facts dd {
  margin: 2px 0 0;
  color: var(--brown-deep);
  font-size: 0.92rem;
  font-weight: 800;
}

.course-coming-soon {
  margin: 14px 0 0;
  padding: 14px;
  text-align: center;
  background: rgba(255, 229, 161, 0.42);
  border: 2px dashed var(--brown-deep);
  border-radius: 12px;
}

.course-coming-soon strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.course-coming-soon p {
  margin: 6px 0 0;
  color: var(--brown-soft);
  font-size: 0.85rem;
}

.course-dialog-description {
  margin: 8px 0 0;
  color: var(--brown-soft);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.5;
}

.course-dialog-description p {
  margin: 0 0 0.7em;
}

.course-dialog-curriculum {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  list-style: none;
  border: 2px solid rgba(91, 58, 43, 0.25);
  border-radius: 12px;
}

.course-dialog-curriculum > li > strong {
  font-family: var(--font-display);
  font-size: 0.98rem;
}

.course-dialog-curriculum .lesson-children-list {
  margin-top: 6px;
  padding-left: 4px;
  font-size: 0.88rem;
}

.course-dialog .lesson-dialog-actions {
  position: sticky;
  bottom: -24px;
  z-index: 2;
  margin-bottom: -24px;
  padding: 12px 0 24px;
  background: var(--cream);
}

@media (max-width: 760px) {
  .course-dialog .lesson-dialog-actions {
    bottom: -18px;
    margin-bottom: -18px;
    padding-bottom: 18px;
  }
}

.lesson-children-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

/* Section reading uses the same framed desert board as quiz questions. */
.quiz-game-board.town-quiz-question-board.town-material-board:not(.has-context) {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
}
.town-material-board .town-material-copy {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px;
  border-radius: 12px;
  background: rgba(255, 248, 234, .92);
  color: var(--brown-deep);
  line-height: 1.6;
  overscroll-behavior: none;
}
.town-material-copy p { margin: 0 0 1em; }
@media (max-width: 760px) {
  .quiz-game-board.town-quiz-question-board.town-material-board:not(.has-context) { display: flex; flex-direction: column; gap: 8px; }
  .town-material-board .town-material-copy { flex: 1 1 0; padding: 12px 14px; }
}

.lesson-children-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--brown-deep);
  font-weight: 700;
}

.lesson-child-bullet {
  flex: none;
  width: 9px;
  height: 9px;
  align-self: center;
  border: 2px solid var(--brown-deep);
  border-radius: 50%;
  background: transparent;
}

.lesson-child-title {
  overflow-wrap: anywhere;
}

.lesson-child-type {
  display: inline-flex;
  align-items: center;
  flex: none;
  margin-left: -4px;
  padding: 2px 8px;
  line-height: 1;
  color: var(--cream);
  background: var(--brown-deep);
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.home-view.home-map-view .map-panel { position: relative; }
.map-back-fab {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 8px;
  color: var(--brown-deep);
  background: var(--cream);
  border: 3px solid var(--brown-deep);
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(56, 37, 29, 0.3);
  font-family: var(--font-display);
  font-size: 0.85rem;
  cursor: pointer;
}
.map-back-fab:hover { background: var(--orange-light); }
.map-back-fab-arrow { width: 18px; height: 18px; transform: scaleX(-1); }
.map-node.is-locked .node-art { filter: grayscale(1); opacity: 0.75; }
.map-node.is-locked .node-orb:disabled { cursor: not-allowed; }
.map-back-button { font: inherit; font-weight: 900; color: var(--brown-deep); background: transparent; border: 2px solid transparent; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.map-back-button:hover { border-color: var(--brown-deep); }

/* Keep lesson images inside the scrollable material on every screen size. */
.town-material-copy img { display: block; max-width: 100%; height: auto; margin: 1em auto; }

/* Shared loading state (2026-10-31): same orange spinner as the quiz loader. */
.town-loading {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  padding: 24px 16px;
  color: var(--brown-deep);
  text-align: center;
}
.town-loading strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
}
.map-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.map-loading strong {
  padding: 6px 14px;
  background: rgba(255, 248, 234, 0.92);
  border: 2px solid var(--brown-deep);
  border-radius: 999px;
}
.map-loading .sync-spinner {
  background: rgba(255, 248, 234, 0.9);
}
.town-material-copy .town-loading {
  min-height: 100%;
}
.quiz-footer-placeholder {
  width: 48px;
}

/* Course name beside the floating Quests pill on the lesson map. */
.map-course-title {
  position: absolute;
  top: 24px;
  left: 128px;
  right: 24px;
  z-index: 6;
  max-width: max-content;
  margin: 0;
  padding: 6px 14px;
  overflow: hidden;
  color: var(--brown-deep);
  background: var(--cream);
  border: 3px solid var(--brown-deep);
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(56, 37, 29, 0.3);
  font-family: var(--font-display);
  font-size: 0.95rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

@media (max-width: 760px) {
  .map-course-title {
    display: -webkit-box;
    border-radius: 16px;
    font-size: 0.82rem;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
}

/* Busy overlay (2026-10-31): blurs and blocks the page during any in-app loading. */
.busy-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 60;
  background: rgba(31, 39, 52, 0.35);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.busy-overlay[hidden] {
  display: none;
}
.town-loading {
  min-height: 120px;
  padding: 0;
}


/* iOS Safari zooms into any focused field under 16px and does not zoom back out. */
@media (hover: none) and (pointer: coarse) {
  /* Scroll panels stop at their edges instead of bouncing. Only real scrollers:
     on non-scrolling children `none` would block swipes reaching the map. */
  .login-dialog,
  .login-panel-content,
  .lesson-dialog,
  .map-player-popover,
  .side-rail,
  .quiz-game-board,
  .quiz-game-context,
  .quiz-game-options,
  .town-quiz-intro-copy,
  .milestone-lesson-copy,
  .town-material-copy {
    overscroll-behavior: none;
  }

  input:not([type="file"]),
  select,
  textarea {
    font-size: max(16px, 1em) !important;
  }
}
