@font-face {
  font-family: Vazirmatn;
  src: url("/fonts/vazirmatn-arabic.woff2") format("woff2");
  font-weight: 100 900;
  unicode-range: U+0600-06FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC;
}

@font-face {
  font-family: Vazirmatn;
  src: url("/fonts/vazirmatn-latin.woff2") format("woff2");
  font-weight: 100 900;
  unicode-range: U+0000-00FF, U+2000-206F;
}

:root {
  color-scheme: dark;
  font-family: Vazirmatn, sans-serif;
  color: #fff7e7;
  background: #211d32;
}

* {
  box-sizing: border-box;
}

html,
body,
#stage {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

/* Touching the game should move the camp, not trigger browser pinch zoom. */
html { touch-action: pan-y; }

/* Indigo evening from the current «یاران برگشتن» camp, with a low fire glow. */
body {
  background: linear-gradient(180deg, #14102c 0%, #2a2458 48%, #6a3a48 78%, #c47a52 100%);
}

#stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.title-card,
.hud,
.connection-status,
.world-label,
.character-label {
  position: fixed;
  z-index: 2;
  pointer-events: none;
}

.title-card,
.hud {
  z-index: 4;
}

.title-card {
  top: 28px;
  right: 32px;
  text-shadow: 0 2px 12px #17121e;
}

.eyebrow {
  /* Cream instead of gold: gold on the lilac sky fell below AA contrast. */
  color: #fff0c8;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
}

h1 {
  margin: 1px 0 0;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1.1;
}

.hud {
  top: 28px;
  left: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  max-width: calc(100% - 280px);
}

.hud-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border-radius: 16px;
  background: rgb(23 18 36 / 42%);
}

.mission-group {
  border: 1px solid rgb(243 199 90 / 55%);
}

.camp-group {
  border: 1px solid rgb(255 255 255 / 12%);
}

.group-label {
  flex: 1 0 100%;
  margin: 0 4px;
  color: #fff0c8;
  font-size: 12px;
  font-weight: 800;
}

.hud-card {
  min-width: 132px;
  padding: 8px 12px;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 12px;
  background: rgb(33 29 50 / 82%);
  box-shadow: 0 8px 24px rgb(25 16 27 / 20%);
}

.growth-prompt {
  display: inline-block;
  margin: 8px 0 0;
  padding: 4px 10px;
  border-radius: 8px;
  color: #f3c75a;
  background: rgb(33 29 50 / 88%);
  font-size: 15px;
  font-weight: 800;
}

body.growing .event-feed {
  top: 148px;
}

.hud span {
  display: block;
  color: #d9cde7;
  font-size: 12px;
}

.hud strong {
  display: block;
  color: #f3c75a;
  font-size: 22px;
  font-weight: 850;
}

.hud strong b {
  font: inherit;
}

.hud-card.mission {
  min-width: 156px;
  border-color: rgb(243 199 90 / 45%);
}

.hud-card.mission strong {
  font-size: 18px;
}

.world-label.attention {
  color: #2b1d12;
  background: #f3c75a;
}

.world-label,
.character-label {
  top: 0;
  left: 0;
  white-space: nowrap;
  text-align: center;
  will-change: transform;
}

.world-label {
  padding: 4px 10px;
  border-radius: 7px;
  color: #23325b;
  background: rgb(246 238 220 / 90%);
  box-shadow: 0 4px 12px rgb(24 20 34 / 22%);
  font-size: 12px;
  font-weight: 800;
}

/* Name pills as in the Episode 2 camp film: lapis plate, cream name, a thin stem to the head. */
.character-label {
  padding: 3px 9px 4px;
  border-radius: 7px;
  color: #f6eedc;
  background: rgb(35 50 91 / 94%);
  box-shadow: 0 4px 10px rgb(24 20 34 / 26%);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  opacity: 0;
  transition: opacity 200ms linear;
}

.character-label.shown {
  opacity: 1;
}

.character-label.story-plate {
  z-index: 4;
  padding: 5px 12px 6px;
  color: #2b1d12;
  background: rgb(232 181 60 / 96%);
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgb(24 20 34 / 28%);
}

.character-label.story-plate .label-stem {
  width: 2px;
  margin-left: -1px;
  background: #e8b53c;
}

.character-label.from-telegram {
  color: #23325b;
  background: rgb(232 181 60 / 96%);
}

.character-name {
  display: block;
}

.character-role {
  display: none;
}

.character-label.with-role .character-role {
  display: block;
  color: #f3c75a;
  font-size: 11px;
  font-weight: 700;
}

.character-label.from-telegram.with-role .character-role {
  color: #6b3f12;
}

/* A new member, a new role, or a role change keeps this plate on that person. */
.character-label.spotlight {
  z-index: 5;
  padding: 6px 12px 7px;
  color: #2b1d12;
  background: #f3c75a;
  box-shadow: 0 10px 22px rgb(24 16 30 / 38%);
  font-size: 16px;
  font-weight: 800;
}

.character-label.spotlight .character-role {
  color: #6b3f12;
  font-size: 12px;
}

.character-label.spotlight .label-stem {
  width: 2px;
  margin-left: -1px;
  background: #f3c75a;
}

/* Until the first layout pass a label has no position; keep it out of sight. */
.world-label:not(.placed),
.character-label:not(.placed) {
  visibility: hidden;
}

.label-stem {
  position: absolute;
  top: 100%;
  width: 1.4px;
  margin-left: -0.7px;
  background: #f6e8d8;
  opacity: .9;
}

/* Live event feed, below the title. */
.event-feed {
  position: fixed;
  z-index: 3;
  top: 104px;
  right: 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(330px, 42vw);
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}

.event {
  padding: 7px 12px;
  border-radius: 9px;
  color: #f6eedc;
  background: rgb(33 29 50 / 80%);
  box-shadow: 0 6px 16px rgb(24 16 30 / 24%);
  font-size: 14px;
  font-weight: 700;
  animation: event-in .45s cubic-bezier(.2, 1.4, .4, 1) both;
}

.event.gold {
  color: #2b1d12;
  background: rgb(232 181 60 / 95%);
}

.event.lapis {
  background: rgb(47 90 168 / 94%);
}

.event.leaving {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .6s ease, transform .6s ease;
}

@keyframes event-in {
  from { opacity: 0; transform: translateX(24px) scale(.96); }
  to { opacity: 1; transform: none; }
}

/* Coins fall into the treasury card; numbers pop when they change. */
.coin {
  position: fixed;
  z-index: 4;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff1b0, #e8b53c 55%, #9a6a1a);
  box-shadow: 0 3px 8px rgb(0 0 0 / 25%);
  pointer-events: none;
  animation: coin-drop .9s cubic-bezier(.5, 0, .9, .5) both;
}

@keyframes coin-drop {
  from { opacity: 0; transform: translateY(calc(var(--fall) * -1)) rotateY(0); }
  15% { opacity: 1; }
  to { opacity: 0; transform: translateY(-14px) rotateY(720deg); }
}

.pop {
  animation: hud-pop .5s cubic-bezier(.2, 1.6, .4, 1);
}

@keyframes hud-pop {
  40% { transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .event,
  .pop {
    animation: none;
  }

  .character-label {
    transition: none;
  }
}

.character-label.sample::after {
  content: "نمونه";
  position: absolute;
  top: -7px;
  left: -7px;
  padding: 1px 5px;
  border-radius: 6px;
  color: #243659;
  background: #f0d7a1;
  font-size: 11px;
}

.connection-status {
  bottom: 17px;
  left: 50%;
  margin: 0;
  padding: 6px 12px;
  transform: translateX(-50%);
  border-radius: 9px;
  color: #d9cde7;
  background: rgb(33 29 50 / 74%);
  font-size: 11px;
  transition: opacity .25s ease;
}

.connection-status.connected {
  opacity: 0;
}

.connection-status.error {
  color: #ffd9d0;
  background: rgb(109 45 43 / 88%);
}

.audio-toggle,
.audio-test {
  position: fixed;
  z-index: 6;
  pointer-events: auto;
  font: inherit;
}

.audio-toggle {
  left: 20px;
  bottom: 16px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 999px;
  color: #fff7e7;
  background: rgb(33 29 50 / 88%);
  box-shadow: 0 6px 16px rgb(24 16 30 / 22%);
  cursor: pointer;
}

.audio-toggle.is-pending {
  border-color: #e8b53c;
}

.audio-toggle.is-live {
  opacity: 0.55;
  min-width: 44px;
}

.audio-toggle.is-muted {
  opacity: 0.8;
}

.audio-toggle:focus {
  outline: none;
}

.audio-toggle:focus-visible,
.audio-test button:focus-visible {
  outline: 2px solid #e8b53c;
  outline-offset: 2px;
}

.audio-test {
  left: 20px;
  bottom: 60px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 40px);
  padding: 6px;
  border: 1px dashed rgb(232 181 60 / 70%);
  border-radius: 12px;
  color: #fff7e7;
  background: rgb(33 29 50 / 92%);
  direction: ltr;
}

.audio-test span {
  padding-inline: 6px;
  color: #f3c75a;
  font-size: 12px;
  font-weight: 800;
}

.audio-test button {
  min-height: 32px;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  color: #243659;
  background: #efe3c8;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 640px) {
  .title-card {
    top: 18px;
    right: 18px;
  }

  .hud {
    top: auto;
    bottom: 18px;
    left: 50%;
    width: calc(100% - 36px);
    transform: translateX(-50%);
  }

  .hud > div {
    flex: 1;
    min-width: 0;
  }

  .connection-status {
    bottom: 105px;
  }

  .audio-toggle {
    top: 18px;
    bottom: auto;
  }

  .audio-test {
    top: 62px;
    bottom: auto;
    flex-wrap: wrap;
  }
}

/* The scene gets its own rectangle: chrome never covers the camp, even on rotation. */
[hidden] { display: none !important; }
body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.preview-banner {
  flex: 0 0 auto;
  margin: 0;
  padding: 6px 12px;
  color: #fff7e7;
  background: #241838;
  text-align: center;
  font-size: 12px;
}
.scene-note {
  margin: 0;
  padding: 0 14px 8px;
  color: #fff0c8;
  font-size: 13px;
  line-height: 1.6;
}
.quality-control { position: relative; }
#quality-status {
  color: #fff0c8;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #211d32;
  z-index: 6;
}
.title-card { position: static; flex-shrink: 0; }
h1 { font-size: clamp(20px, 2.6vw, 32px); }
.scene-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; }
.scene-controls label { display: grid; gap: 2px; font-size: 12px; }
select, input, button { font: inherit; }
select, .roster-panel input, .roster-panel button {
  min-height: 44px;
  max-width: 100%;
  padding: 6px 10px;
  color: #fff7e7;
  background: #211d32;
  border: 1px solid #a89ab5;
  border-radius: 8px;
}
select { width: 160px; font-size: 13px; }
:focus-visible { outline: 3px solid #f3c75a; outline-offset: 2px; }
#audio-control { display: flex; }
.audio-toggle { position: static; min-height: 44px; opacity: 1; }
.audio-toggle.is-live, .audio-toggle.is-muted { opacity: 1; }
#stage { flex: 1 1 auto; min-height: 100px; width: 100%; height: auto; position: relative; }
#stage canvas { touch-action: manipulation; }
.camp-panel {
  flex: 0 0 auto;
  max-height: 43dvh;
  overflow: auto;
  background: #211d32;
  border-top: 1px solid #a89ab5;
  z-index: 6;
  overscroll-behavior: contain;
}
summary { min-height: 44px; padding: 10px 14px; cursor: pointer; }
.camp-panel > summary { position: sticky; top: 0; background: #211d32; z-index: 1; }
.panel-close, .camp-panel[open] .panel-open { display: none; }
.camp-panel[open] .panel-close { display: inline; }
.panel-open, .panel-close { color: #e7c787; font-size: 12px; }
#camp-summary { display: block; color: #e7c787; font-size: 12px; }
.hud { position: static; pointer-events: auto; transform: none; width: auto; max-width: none; padding: 0 10px 10px; gap: 8px; }
.hud-group { flex: 1 1 300px; }
.hud-card, .hud-card.mission { flex: 1 1 120px; min-width: 0; }
.hud strong { font-size: 20px; }
.roster-panel { padding: 0 12px 12px; }
.roster-panel label { display: block; }
.roster-panel input { width: 100%; font-size: 16px; }
#roster-list { list-style: none; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); }
#roster-list button { width: 100%; text-align: start; cursor: pointer; overflow-wrap: anywhere; }
.character-label { max-width: min(220px, 65vw); }
.character-name { overflow: hidden; text-overflow: ellipsis; }
.character-label:not(.shown) { will-change: auto; visibility: hidden; }
.character-label.shown { will-change: transform; }
.world-label, .character-label { z-index: 2; }
.event-feed, body.growing .event-feed { top: var(--scene-top, 120px); right: max(12px, env(safe-area-inset-right)); width: min(300px, 80vw); }
.event-feed:empty { display: none; }
.connection-status { bottom: calc(76px + env(safe-area-inset-bottom)); max-width: calc(100% - 24px); text-align: center; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .title-card { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
  .scene-controls { width: 100%; flex-wrap: nowrap; gap: 6px; }
  .scene-controls label { flex: 1; min-width: 0; }
  select { width: 100%; }
  .hud > div { flex: 1 1 100%; }
}
@media (max-height: 500px) and (min-width: 641px) {
  .topbar { padding: 4px 10px; }
  .eyebrow { font-size: 11px; }
  h1 { font-size: 20px; }
  .scene-controls label { display: flex; align-items: center; }
  select { width: 150px; }
  .camp-panel { max-height: 46dvh; }
  #camp-summary { display: inline; margin-inline-start: 12px; }
  .preview-banner { padding: 3px 10px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Keep the camp as the main screen; place optional controls in a small game menu. */
.topbar {
  min-height: 62px;
  padding: 7px 16px;
  border-bottom: 1px solid #6f5b70;
  background: rgb(25 20 43 / 96%);
  box-shadow: 0 5px 18px rgb(12 9 25 / 30%);
}
.title-card { display: block; }
.title-card .eyebrow { display: block; font-size: 11px; line-height: 1.2; }
.title-card h1 { margin: 0; font-size: clamp(18px, 2vw, 24px); line-height: 1.25; }
.growth-prompt { margin: 0 8px; font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
#reset-view,
.scene-menu > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 7px 13px;
  border: 1px solid #bca16b;
  border-radius: 10px;
  color: #fff4d8;
  background: #30263f;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
#join-game {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 42px;
  padding: 7px 14px;
  border: 1px solid #f3c75a;
  border-radius: 10px;
  color: #211929;
  background: #f3c75a;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}
#join-game:hover { background: #ffe08b; }
#join-game:focus-visible { outline: 3px solid #fff7e7; outline-offset: 2px; }
#reset-view:hover,
.scene-menu > summary:hover { background: #46344d; }
.scene-menu { position: relative; }
.scene-menu > summary { list-style: none; }
.scene-menu > summary::-webkit-details-marker { display: none; }
.scene-menu .scene-controls {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(290px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid #bca16b;
  border-radius: 14px;
  background: #251d35;
  box-shadow: 0 16px 36px rgb(10 8 20 / 55%);
  z-index: 9;
}
.scene-menu[open] .scene-controls { display: grid; gap: 12px; }
.scene-menu .scene-controls label { display: grid; gap: 5px; width: 100%; color: #fff4d8; font-size: 13px; }
.scene-menu select { width: 100%; }
.scene-menu #audio-control { display: block; }
.scene-menu .audio-toggle { width: 100%; text-align: center; }
#stage canvas { touch-action: none; cursor: grab; }
#stage.dragging canvas { cursor: grabbing; }
.drag-hint {
  position: fixed;
  top: calc(var(--scene-top, 90px) + 9px);
  left: max(12px, env(safe-area-inset-left));
  z-index: 4;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid rgb(255 231 179 / 55%);
  border-radius: 9px;
  color: #fff4d8;
  background: rgb(30 24 46 / 88%);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}
body.is-exploring .drag-hint { display: none; }
.camp-panel { border-top-color: #806a70; touch-action: pan-y; }
.camp-panel > summary { color: #fff4d8; font-weight: 800; }
@media (max-width: 640px) {
  .topbar { flex-wrap: nowrap; gap: 6px; padding: 6px 10px; }
  .title-card { display: block; min-width: 0; }
  .title-card h1 { font-size: 18px; }
  .topbar-actions { gap: 5px; }
  #reset-view, .scene-menu > summary { padding: 6px 8px; font-size: 11px; }
  #join-game { padding: 6px 9px; font-size: 11px; }
  .scene-menu .scene-controls { left: 0; }
  .scene-menu .scene-controls label { display: grid; }
  .drag-hint { font-size: 11px; }
}
@media (max-width: 380px) {
  .topbar { flex-wrap: wrap; padding-inline: 7px; }
  .title-card, .topbar-actions { width: 100%; }
  .topbar-actions { justify-content: space-between; }
  .title-card .eyebrow { display: none; }
  .title-card h1 { font-size: 15px; }
  .topbar-actions { gap: 4px; }
  #reset-view, .scene-menu > summary, #join-game { padding-inline: 6px; font-size: 11px; }
}
