:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-strong: #eef4f2;
  --ink: #182023;
  --muted: #5d686d;
  --line: #dce3e0;
  --accent: #0f6c73;
  --accent-strong: #0a4f55;
  --warm: #d56f3e;
  --green: #3d7d48;
  --gold: #b98522;
  --radius: 8px;
  --shadow: 0 18px 45px rgba(22, 32, 35, 0.14);
  --header-height: 66px;
  --max: 1440px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  margin: 0;
  min-width: 320px;
}

body.is-panel-open {
  overflow: hidden;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

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

:where(a, button, canvas, [tabindex], video[controls]):focus-visible {
  outline: 3px solid rgba(11, 105, 112, 0.5);
  outline-offset: 3px;
}

.skip-link {
  background: var(--ink);
  border-radius: 0 0 6px 6px;
  color: #fff;
  font-weight: 800;
  left: 1rem;
  padding: 0.65rem 0.9rem;
  position: fixed;
  text-decoration: none;
  top: -5rem;
  z-index: 200;
}

.skip-link:focus {
  top: 0;
}

.world-header {
  align-items: center;
  backdrop-filter: blur(16px);
  background: rgba(246, 247, 242, 0.9);
  border-bottom: 1px solid rgba(220, 227, 224, 0.92);
  display: flex;
  justify-content: space-between;
  min-height: var(--header-height);
  padding: 0.65rem max(1rem, calc((100vw - var(--max)) / 2));
  position: sticky;
  top: 0;
  z-index: 60;
}

.brand {
  align-items: center;
  display: flex;
  font-weight: 850;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: var(--ink);
  border-radius: 7px;
  color: #fff;
  display: inline-flex;
  height: 2rem;
  justify-content: center;
  width: 2rem;
}

.world-header-actions {
  align-items: center;
  display: flex;
  gap: 0.75rem;
}

.world-mode-label {
  background: rgba(15, 108, 115, 0.09);
  border: 1px solid rgba(15, 108, 115, 0.15);
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.35rem 0.55rem;
}

.back-link {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  text-underline-offset: 0.2rem;
}

.world-main {
  margin: 0 auto;
  max-width: var(--max);
  padding: 2.4rem 1.25rem 4rem;
}

.world-intro {
  align-items: end;
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 1.4rem;
}

.eyebrow,
.stage-kicker,
.loading-category {
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  margin: 0 0 0.35rem;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  font-size: clamp(2.35rem, 5vw, 4.8rem);
  letter-spacing: -0.04em;
  line-height: 0.98;
  margin: 0 0 0.8rem;
}

h2,
h3 {
  line-height: 1.08;
  margin-top: 0;
}

.world-intro > div:first-child > p:last-child {
  color: var(--muted);
  margin: 0;
  max-width: 760px;
}

.world-legend {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 0.9rem;
  justify-content: flex-end;
}

.world-legend > span {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 750;
  gap: 0.35rem;
}

.legend-dot {
  border-radius: 50%;
  display: inline-block;
  height: 0.65rem;
  width: 0.65rem;
}

.legend-avatar {
  background: var(--warm);
  box-shadow: 0 0 0 2px rgba(213, 111, 62, 0.18);
}

.legend-tool {
  background: #f4cf64;
  box-shadow: 0 0 0 2px rgba(244, 207, 100, 0.2);
}

kbd {
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.1rem 0.3rem;
}

.room-navigation {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 1rem;
}

.room-button {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 0.65rem;
  grid-template-columns: auto 1fr auto;
  min-height: 72px;
  padding: 0.75rem 0.9rem;
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.room-button:hover,
.room-button:focus-visible {
  border-color: rgba(15, 108, 115, 0.4);
  transform: translateY(-1px);
}

.room-button.is-active {
  background: #173033;
  border-color: #173033;
  box-shadow: 0 10px 24px rgba(22, 32, 35, 0.15);
  color: #fff;
}

.room-button-marker {
  background: var(--room-color, var(--accent));
  border: 3px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(22, 32, 35, 0.16);
  height: 1.15rem;
  width: 1.15rem;
}

.room-button strong,
.room-button small {
  display: block;
}

.room-button strong {
  font-size: 0.9rem;
}

.room-button small {
  color: var(--muted);
  font-size: 0.68rem;
  margin-top: 0.08rem;
}

.room-button.is-active small {
  color: #c9dad7;
}

.room-button-arrow {
  color: var(--muted);
  font-weight: 850;
}

.room-button.is-active .room-button-arrow {
  color: #fff;
}

.world-experience {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}

.world-experience.has-panel {
  grid-template-columns: minmax(0, 1fr) minmax(350px, 410px);
}

.world-stage,
.clip-panel,
.fallback-explorer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(22, 32, 35, 0.08);
}

.world-stage {
  min-width: 0;
  overflow: hidden;
}

.stage-heading {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  min-height: 88px;
  padding: 0.9rem 1rem;
}

.stage-heading h2 {
  font-size: 1.55rem;
  margin: 0;
}

.stage-heading > p {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0;
  max-width: 480px;
  text-align: right;
}

.canvas-shell {
  background:
    radial-gradient(circle at 50% 30%, rgba(134, 198, 189, 0.34), transparent 42%),
    linear-gradient(180deg, #dcebea, #c7d8d5);
  height: clamp(480px, 58vw, 690px);
  overflow: hidden;
  position: relative;
}

#world-canvas {
  display: block;
  height: 100%;
  touch-action: none;
  width: 100%;
}

#world-canvas.is-pointing {
  cursor: pointer;
}

.loading-screen {
  align-items: center;
  background:
    radial-gradient(circle at 50% 45%, rgba(15, 108, 115, 0.12), transparent 38%),
    #eef4f2;
  display: flex;
  flex-direction: column;
  inset: 0;
  justify-content: center;
  padding: 1.5rem;
  position: absolute;
  text-align: center;
  transition: opacity 200ms ease, visibility 200ms ease;
  z-index: 20;
}

.loading-screen.is-complete {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.loading-screen.is-error {
  background: #f8f3ee;
}

.loading-mark {
  align-items: center;
  background: #173033;
  border-radius: 10px;
  color: #fff;
  display: flex;
  font-size: 1.45rem;
  font-weight: 900;
  height: 3.5rem;
  justify-content: center;
  margin-bottom: 1.1rem;
  width: 3.5rem;
}

.loading-screen strong {
  font-size: 1.1rem;
}

.loading-track {
  background: rgba(15, 108, 115, 0.14);
  border-radius: 999px;
  height: 0.38rem;
  margin: 1rem 0 0.35rem;
  max-width: 260px;
  overflow: hidden;
  width: 70%;
}

.loading-track span {
  background: linear-gradient(90deg, var(--accent), var(--warm));
  border-radius: inherit;
  display: block;
  height: 100%;
  transition: width 180ms ease;
  width: 8%;
}

.loading-percent {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.retry-button,
.secondary-button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.55rem 0.7rem;
}

.retry-button {
  margin-top: 1rem;
}

.canvas-hud {
  align-items: center;
  display: flex;
  gap: 0.55rem;
  left: 0.75rem;
  position: absolute;
  top: 0.75rem;
  z-index: 4;
}

.canvas-room-chip,
.canvas-instruction,
.tool-tooltip {
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(22, 32, 35, 0.12);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.38rem 0.55rem;
}

.canvas-room-chip {
  background: rgba(23, 48, 51, 0.9);
  color: #fff;
}

.canvas-instruction {
  background: rgba(255, 255, 255, 0.85);
  color: #324247;
}

.fallback-switch {
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  bottom: 0.75rem;
  color: #324247;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.4rem 0.6rem;
  position: absolute;
  right: 0.75rem;
  z-index: 4;
}

.tool-tooltip {
  background: rgba(23, 48, 51, 0.94);
  color: #fff;
  left: 0;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  transform: translate(-50%, calc(-100% - 10px));
  transition: opacity 100ms ease;
  white-space: nowrap;
  z-index: 5;
}

.tool-tooltip.is-visible {
  opacity: 1;
}

.tool-navigation {
  border-top: 1px solid var(--line);
  padding: 0.9rem 1rem 1rem;
}

.tool-navigation-heading {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.tool-navigation-heading h3 {
  font-size: 1rem;
  margin: 0;
}

.tool-navigation-heading > p {
  color: var(--muted);
  font-size: 0.7rem;
  margin: 0;
  max-width: 330px;
  text-align: right;
}

.tool-button-list {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tool-button {
  align-items: center;
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  gap: 0.55rem;
  min-height: 54px;
  padding: 0.55rem 0.65rem;
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.tool-button:hover,
.tool-button:focus-visible,
.tool-button.is-selected {
  background: rgba(15, 108, 115, 0.08);
  border-color: rgba(15, 108, 115, 0.38);
}

.tool-button.is-selected {
  box-shadow: inset 3px 0 0 var(--accent);
}

.tool-button-icon {
  align-items: center;
  background: #173033;
  border-radius: 5px;
  color: #fff;
  display: flex;
  flex: 0 0 auto;
  font-size: 0.63rem;
  font-weight: 900;
  height: 1.85rem;
  justify-content: center;
  width: 1.85rem;
}

.tool-button strong,
.tool-button small {
  display: block;
}

.tool-button strong {
  font-size: 0.78rem;
  line-height: 1.2;
}

.tool-button small {
  color: var(--muted);
  font-size: 0.62rem;
  margin-top: 0.15rem;
}

.clip-panel {
  display: none;
  min-height: 0;
  overflow: hidden;
}

.clip-panel.is-open {
  display: block;
}

.clip-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.clip-panel-header {
  align-items: start;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.95rem 0.95rem 0.75rem;
}

.clip-panel-header h2 {
  font-size: 1.45rem;
  margin: 0.15rem 0 0;
}

.clip-domain {
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 850;
  margin: 0;
  text-transform: uppercase;
}

.panel-close {
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex: 0 0 auto;
  font-size: 1.2rem;
  height: 2.35rem;
  justify-content: center;
  line-height: 1;
  width: 2.35rem;
}

.clip-media {
  background: #162426;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  width: 100%;
}

.clip-media video {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.clip-content {
  display: grid;
  gap: 0.75rem;
  overflow-y: auto;
  padding: 0.9rem 0.95rem 1rem;
}

.clip-action {
  color: #28373b;
  font-size: 0.9rem;
  font-weight: 750;
  margin: 0;
}

.clip-content dl {
  display: grid;
  gap: 0.2rem;
  margin: 0;
}

.clip-content dt {
  color: var(--accent-strong);
  font-size: 0.67rem;
  font-weight: 850;
  margin-top: 0.45rem;
  text-transform: uppercase;
}

.clip-content dd {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0;
}

.clip-content .explanation {
  background: rgba(15, 108, 115, 0.07);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  color: #334448;
  padding: 0.6rem 0.65rem;
}

.clip-actions {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr 1fr auto;
  margin-top: 0.15rem;
}

.clip-actions button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.5rem 0.55rem;
}

.clip-actions button:hover,
.clip-actions button:focus-visible {
  background: var(--surface-strong);
}

.share-status {
  color: var(--green);
  font-size: 0.67rem;
  font-weight: 750;
  margin: -0.25rem 0 0;
  min-height: 1rem;
}

.fallback-explorer {
  margin-top: 1rem;
  padding: 1rem;
}

.fallback-explorer > .clip-panel.is-open {
  margin-top: 1rem;
}

.fallback-heading {
  align-items: start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.fallback-heading h2 {
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  margin-bottom: 0.55rem;
}

.fallback-heading p:last-child {
  color: var(--muted);
  margin: 0 0 1rem;
}

.fallback-room-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.fallback-room-card {
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
  overflow: hidden;
}

.fallback-room-card-header {
  border-top: 4px solid var(--room-color, var(--accent));
  padding: 0.85rem 0.85rem 0.7rem;
}

.fallback-room-card h3 {
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

.fallback-room-card p {
  color: var(--muted);
  font-size: 0.7rem;
  margin: 0;
}

.fallback-tools {
  display: grid;
  gap: 1px;
}

.fallback-tool-button {
  align-items: center;
  background: #fff;
  border: 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  gap: 0.6rem;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
  text-align: left;
  width: 100%;
}

.fallback-tool-button:hover,
.fallback-tool-button:focus-visible,
.fallback-tool-button.is-selected {
  background: rgba(15, 108, 115, 0.07);
}

.fallback-tool-button strong {
  display: block;
  font-size: 0.75rem;
}

.fallback-tool-button small {
  color: var(--muted);
  display: block;
  font-size: 0.62rem;
  margin-top: 0.12rem;
}

.fallback-tool-button span:last-child {
  color: var(--accent-strong);
  font-weight: 850;
}

.noscript-message {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 1rem;
  padding: 1.25rem;
}

.world-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  font-size: 0.68rem;
  gap: 1rem;
  justify-content: space-between;
  margin: 0 auto;
  max-width: var(--max);
  padding: 1.25rem;
}

.world-footer p {
  margin: 0;
}

@media (max-width: 1100px) {
  .world-experience.has-panel {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
  }

  .canvas-shell {
    height: clamp(470px, 62vw, 620px);
  }

  .fallback-room-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .world-intro {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .world-legend {
    justify-content: flex-start;
  }

  .room-button {
    grid-template-columns: auto 1fr;
  }

  .room-button-arrow {
    display: none;
  }

  .world-experience.has-panel {
    grid-template-columns: 1fr;
  }

  .stage-heading {
    align-items: start;
    flex-direction: column;
    gap: 0.35rem;
  }

  .stage-heading > p {
    max-width: 100%;
    text-align: left;
  }

  .canvas-shell {
    height: min(70vh, 580px);
    min-height: 430px;
  }

  .tool-navigation-heading > p {
    display: none;
  }

  .clip-panel.is-open {
    background: #fff;
    border-radius: 12px 12px 0 0;
    bottom: 0;
    box-shadow: 0 -18px 45px rgba(22, 32, 35, 0.22);
    left: 0;
    max-height: min(82vh, 760px);
    overflow-y: auto;
    position: fixed;
    right: 0;
    z-index: 100;
  }

  .clip-panel.is-open::before {
    background: rgba(13, 20, 22, 0.58);
    content: "";
    inset: -100vh 0 100% 0;
    pointer-events: none;
    position: absolute;
  }

  .clip-panel-inner {
    height: auto;
  }

  .clip-media {
    aspect-ratio: 16 / 8.5;
  }
}

@media (max-width: 620px) {
  .world-header-actions {
    gap: 0.45rem;
  }

  .world-mode-label {
    display: none;
  }

  .back-link {
    font-size: 0.72rem;
  }

  .world-main {
    padding: 1.6rem 0.8rem 3rem;
  }

  .world-intro {
    gap: 1rem;
  }

  .room-navigation {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scroll-snap-type: x mandatory;
  }

  .room-button {
    flex: 0 0 76%;
    min-height: 64px;
    scroll-snap-align: start;
  }

  .stage-heading {
    padding: 0.8rem;
  }

  .canvas-shell {
    height: 54vh;
    min-height: 360px;
  }

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

  .canvas-instruction {
    max-width: 220px;
  }

  .tool-navigation {
    padding: 0.8rem;
  }

  .tool-button-list {
    grid-template-columns: 1fr;
  }

  .clip-actions {
    grid-template-columns: 1fr 1fr;
  }

  .clip-actions button:last-child {
    grid-column: 1 / -1;
  }

  .fallback-heading {
    flex-direction: column;
  }

  .world-footer {
    flex-direction: column;
  }
}

@media (hover: none), (pointer: coarse) {
  .canvas-instruction {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
