/* ===== Design tokens ===== */
:root {
  color-scheme: dark;

  --color-deep: #120c08;
  --color-earth: #2b1d12;
  --color-earth-light: #3d2a18;
  --color-earth-warm: #50341d;
  --color-card: #221609;
  --color-card-hover: #2c1c0e;
  --color-border: rgba(255, 255, 255, 0.07);
  --color-fg: #f6ead9;
  --color-fg-dim: rgba(246, 234, 217, 0.62);

  --color-accent: #f2a93b;
  --color-accent-dark: #c9860f;
  --color-sky: #7ed6df;
  --color-berry: #d95f9f;
  --color-success: #6fbf73;
  --color-success-dark: #3f8a45;
  --color-danger: #d9694f;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-glow-accent: 0 0 0 3px rgba(242, 169, 59, 0.18);

  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Rounded", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--color-deep);
  color: var(--color-fg);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  /* iOS Safari иногда сам увеличивает текст в узких колонках ("text inflation") — из-за этого
     то, что помещается в тестах на десктопе, может переполнять контейнер именно на iPhone. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button {
  font-family: inherit;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ===== Screens ===== */

.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
}

.screen.active {
  display: flex;
  animation: screen-fade-in 0.28s ease both;
}

.game-screen.active {
  background: var(--color-earth);
}

@keyframes screen-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Buttons ===== */

.btn {
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 22px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--color-fg);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:active {
  transform: scale(0.96);
}

.btn--primary {
  background: linear-gradient(180deg, var(--color-accent), var(--color-accent-dark));
  box-shadow: var(--shadow-lift);
}

.btn--secondary {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-soft);
}

.btn--danger {
  background: linear-gradient(180deg, var(--color-danger), #a8402a);
  box-shadow: var(--shadow-lift);
}

.btn--small {
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn--icon {
  padding: 10px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--color-card);
  border: 1px solid var(--color-border);
}

/* ===== Cards ===== */

.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 16px;
}

/* ===== Title screen ===== */

.title-screen {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 28px;
  padding: 32px 20px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, rgba(242, 169, 59, 0.18), transparent 34%),
    radial-gradient(circle at 22% 76%, rgba(126, 214, 223, 0.11), transparent 28%),
    radial-gradient(circle at 78% 72%, rgba(111, 191, 115, 0.1), transparent 26%),
    linear-gradient(180deg, #24170d 0%, #100904 80%),
    var(--color-deep);
}

.title-screen__emblem {
  width: 120px;
  height: 120px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
  animation: title-bob 3.2s ease-in-out infinite;
}

@keyframes title-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

.title-screen__title {
  width: min(420px, calc(100vw - 40px));
  font-size: clamp(1.65rem, 5.4vw, 2.6rem);
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.01em;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.title-screen__subtitle {
  width: min(360px, calc(100vw - 40px));
  color: var(--color-fg-dim);
  margin: -16px 0 0;
}

.title-screen__story {
  width: min(360px, calc(100vw - 40px));
  margin: -14px 0 0;
  color: rgba(246, 234, 217, 0.82);
  font-size: 0.95rem;
  line-height: 1.36;
  overflow-wrap: break-word;
}

.title-screen__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px, calc(100vw - 40px));
}

/* ===== HUD ===== */

.hud {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  background:
    linear-gradient(180deg, rgba(43, 29, 18, 0.94), rgba(18, 12, 8, 0.96)),
    var(--color-deep);
  border-bottom: 1px solid var(--color-border);
  z-index: 3;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.hud-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  width: 100%;
  flex-wrap: wrap;
}

.hud-title {
  display: grid;
  gap: 2px;
  min-width: 132px;
}

.hud-profession {
  font-weight: 700;
  line-height: 1.15;
}

.hud-quest {
  color: var(--color-fg-dim);
  font-size: 0.76rem;
  line-height: 1.15;
}

.hud-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  background: rgba(34, 22, 9, 0.82);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.9rem;
}

.xp-bar {
  position: relative;
  width: 84px;
  height: 10px;
  background: var(--color-earth);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.xp-bar__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, var(--color-success-dark), var(--color-success));
  transition: width 0.35s ease;
}

.hud-spacer {
  flex: 1;
}

.promote-btn {
  background: linear-gradient(180deg, var(--color-success), var(--color-success-dark));
  color: var(--color-fg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  animation: promote-pulse 1.6s ease-in-out infinite;
}

.promote-btn:active {
  transform: scale(0.96);
}

@keyframes promote-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(111, 191, 115, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(111, 191, 115, 0); }
}

.toast {
  position: fixed;
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 20;
  pointer-events: none;
  box-shadow: var(--shadow-lift);
  animation: toast-pop 0.25s ease both;
}

@keyframes toast-pop {
  from { opacity: 0; transform: translate(-50%, 6px) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ===== Update prompt ===== */

.update-banner {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(360px, calc(100vw - 24px));
  padding: 10px 10px 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(43, 29, 18, 0.98), rgba(18, 12, 8, 0.98)),
    var(--color-card);
  box-shadow: var(--shadow-lift);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.update-banner[hidden] {
  display: none;
}

.update-banner.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

body:has(.game-screen.active) .update-banner {
  bottom: calc(88px + env(safe-area-inset-bottom));
}

.update-banner__copy {
  min-width: 0;
  flex: 1;
}

.update-banner__title {
  color: var(--color-accent);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.05;
}

.update-banner__text {
  margin-top: 2px;
  color: var(--color-fg-dim);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.15;
}

.update-banner__button {
  flex: 0 0 auto;
  min-height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: #2b1d12;
  background: linear-gradient(180deg, #ffd27d, var(--color-accent));
  font-size: 0.86rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.24);
}

.update-banner__button:disabled {
  cursor: wait;
  filter: saturate(0.7);
}

/* ===== Camera / world ===== */

.camera {
  position: relative;
  flex: 1;
  min-height: 240px;
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(circle at 14% 18%, rgba(242, 169, 59, 0.13), transparent 18%),
    radial-gradient(circle at 82% 22%, rgba(126, 214, 223, 0.08), transparent 18%),
    radial-gradient(circle at 45% 86%, rgba(111, 191, 115, 0.08), transparent 22%),
    var(--color-earth);
}

.mission-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 240px);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(90deg, rgba(242, 169, 59, 0.12), rgba(111, 191, 115, 0.08)),
    rgba(18, 12, 8, 0.7);
}

.mission-strip__copy {
  min-width: 0;
}

.mission-strip__label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mission-strip__timer {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(242, 169, 59, 0.18);
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: normal;
  text-transform: none;
}

.mission-strip__timer--low {
  background: rgba(217, 105, 79, 0.22);
  color: var(--color-danger);
  animation: timer-low-pulse 1s ease-in-out infinite;
}

@keyframes timer-low-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 105, 79, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(217, 105, 79, 0); }
}

.mission-strip__title {
  margin-top: 2px;
  font-size: 0.98rem;
  font-weight: 850;
  line-height: 1.2;
}

.dialogue-strip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 74px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border);
  background:
    linear-gradient(180deg, rgba(34, 22, 9, 0.96), rgba(18, 12, 8, 0.98)),
    var(--color-card);
  box-shadow: 0 -8px 18px rgba(0, 0, 0, 0.2);
}

.dialogue-strip__portrait {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  flex: 0 0 auto;
  color: #2b1d12;
  background: linear-gradient(180deg, #f6d28a, var(--color-accent));
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
  line-height: 1.1;
}

.dialogue-strip__portrait--pik {
  color: #0f2b28;
  background: linear-gradient(180deg, #9fe8de, #3fa89a);
}

.dialogue-strip__portrait--queen {
  color: #2b1230;
  background: linear-gradient(180deg, #f0c9f6, #a866c9);
}

.dialogue-strip__body {
  display: grid;
  gap: 3px;
  min-width: 0;
  max-width: 860px;
}

.dialogue-strip__meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.dialogue-strip__speaker {
  color: var(--color-accent);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.dialogue-strip__role {
  color: var(--color-fg-dim);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
}

.dialogue-strip__text {
  color: var(--color-fg);
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.25;
}

.task-meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.task-meter span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-success-dark), var(--color-success));
  transition: width 0.25s ease;
}

.micro-event-strip {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) minmax(72px, 130px);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(126, 214, 223, 0.16);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(90deg, rgba(126, 214, 223, 0.12), rgba(242, 169, 59, 0.08)),
    rgba(18, 12, 8, 0.66);
}

.micro-event-strip[hidden] {
  display: none;
}

.micro-event-strip__icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #172325;
  background: linear-gradient(180deg, #c8f4f0, var(--color-sky));
  font-size: 1rem;
  font-weight: 900;
  box-shadow: 0 0 0 4px rgba(126, 214, 223, 0.1);
}

.micro-event-strip__copy {
  min-width: 0;
}

.micro-event-strip__label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--color-sky);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.micro-event-strip__bonus {
  padding: 1px 6px;
  border-radius: 999px;
  color: #2b1d12;
  background: var(--color-accent);
  font-size: 0.62rem;
  letter-spacing: normal;
  text-transform: none;
}

.micro-event-strip__timer {
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--color-fg);
  background: rgba(126, 214, 223, 0.14);
  font-variant-numeric: tabular-nums;
  letter-spacing: normal;
  text-transform: none;
}

.micro-event-strip__title {
  margin-top: 1px;
  color: var(--color-fg);
  font-size: 0.92rem;
  font-weight: 850;
  line-height: 1.12;
}

.micro-event-strip__details {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 1px;
  color: var(--color-fg-dim);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.15;
}

.micro-event-strip__details span:last-child {
  color: rgba(246, 234, 217, 0.86);
  font-weight: 800;
}

.micro-event-strip__meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.micro-event-strip__meter span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-sky), var(--color-accent));
  transition: width 0.18s linear;
}

.world-layer {
  position: absolute;
  top: 0;
  left: 0;
  background-image:
    linear-gradient(35deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 64px),
    linear-gradient(120deg, rgba(0, 0, 0, 0.08) 0 2px, transparent 2px 92px),
    radial-gradient(circle, rgba(255, 230, 188, 0.09) 1.4px, transparent 1.8px);
  background-size: 140px 140px, 220px 220px, 28px 28px;
  background-color: var(--color-earth);
  will-change: transform;
}

.anthill,
.food,
.decor,
.micro-event-marker,
.ant-anchor {
  position: absolute;
  pointer-events: none;
  user-select: none;
}

.anthill {
  width: 72px;
  height: 72px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5));
}

.anthill--deposit {
  filter:
    drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5))
    drop-shadow(0 0 12px rgba(111, 191, 115, 0.56));
}

.anthill--deposit::after {
  content: "";
  position: absolute;
  inset: -9px;
  border: 2px dashed rgba(111, 191, 115, 0.72);
  border-radius: 50%;
  animation: target-ring 1.1s ease-in-out infinite;
}

.anthill__entrance {
  animation: anthill-pulse 2.4s ease-in-out infinite;
  transform-origin: center;
}

@keyframes anthill-pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

.anthill__dust {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  animation: dust-drift 2.4s ease-out infinite;
}

@keyframes dust-drift {
  0% { opacity: 0; transform: translateY(0); }
  15% { opacity: 0.55; }
  100% { opacity: 0; transform: translateY(-14px); }
}

.food {
  width: 30px;
  height: 30px;
  z-index: 1;
  transform: translate(-50%, -50%);
}

.food--wrong {
  opacity: 0.38;
  filter: saturate(0.55);
}

.food--target {
  opacity: 1;
  z-index: 2;
  filter: saturate(1.2) drop-shadow(0 0 7px rgba(242, 169, 59, 0.36));
}

.food--target::before {
  content: "";
  position: absolute;
  inset: -9px;
  border: 2px solid rgba(242, 169, 59, 0.78);
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(242, 169, 59, 0.12);
  animation: target-ring 1.05s ease-in-out infinite;
}

.food__visual {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.4));
  animation: food-bob 2.2s ease-in-out infinite;
}

.micro-event-marker {
  z-index: 3;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
}

.micro-event-marker::before {
  content: "";
  position: absolute;
  inset: -7px;
  border: 2px dashed rgba(126, 214, 223, 0.62);
  border-radius: 50%;
  animation: target-ring 1.15s ease-in-out infinite;
}

.micro-event-marker span {
  position: relative;
  z-index: 1;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #172325;
  background: radial-gradient(circle at 35% 30%, #f4fffb, var(--color-sky));
  font-size: 0.94rem;
  font-weight: 950;
  line-height: 1;
  box-shadow:
    0 5px 10px rgba(0, 0, 0, 0.34),
    0 0 10px rgba(126, 214, 223, 0.3);
}

.micro-event-marker--finds span,
.micro-event-marker--humor span {
  color: #2b1d12;
  background: radial-gradient(circle at 35% 30%, #ffe7ad, var(--color-accent));
}

.micro-event-marker--rescue span,
.micro-event-marker--npcHelp span {
  color: #102416;
  background: radial-gradient(circle at 35% 30%, #d9f7bf, var(--color-success));
}

.micro-event-marker--race span,
.micro-event-marker--challenge span {
  color: #221126;
  background: radial-gradient(circle at 35% 30%, #f7c7ef, #d95f9f);
}

.micro-event-marker--weather span {
  color: #172325;
  background: radial-gradient(circle at 35% 30%, #efffff, #7ed6df);
}

.micro-event-marker:not(.micro-event-marker--current) {
  opacity: 0.42;
}

.micro-event-marker--current {
  z-index: 4;
}

.micro-event-marker--current span {
  box-shadow:
    0 5px 10px rgba(0, 0, 0, 0.34),
    0 0 0 5px rgba(126, 214, 223, 0.12),
    0 0 14px rgba(126, 214, 223, 0.5);
}

.micro-event-marker strong {
  position: absolute;
  top: 38px;
  left: 50%;
  z-index: 2;
  max-width: 112px;
  padding: 4px 7px;
  overflow: hidden;
  border: 1px solid rgba(126, 214, 223, 0.2);
  border-radius: 999px;
  color: rgba(246, 234, 217, 0.94);
  background: rgba(18, 12, 8, 0.82);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28);
  font-size: 0.64rem;
  font-weight: 850;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateX(-50%);
}

.micro-event-marker:not(.micro-event-marker--current) strong {
  display: none;
}

.micro-event-pointer {
  position: absolute;
  z-index: 6;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  color: #172325;
  background: radial-gradient(circle at 35% 30%, #efffff, var(--color-sky));
  box-shadow:
    0 5px 14px rgba(0, 0, 0, 0.34),
    0 0 0 5px rgba(126, 214, 223, 0.14);
  pointer-events: none;
  animation: event-pointer-pop 0.9s ease-in-out infinite;
}

.micro-event-pointer[hidden] {
  display: none;
}

.micro-event-pointer::after {
  content: "";
  position: absolute;
  inset: -8px;
  border: 2px solid rgba(126, 214, 223, 0.52);
  border-radius: inherit;
}

.micro-event-pointer span {
  position: relative;
  z-index: 1;
  font-size: 0.95rem;
  font-weight: 950;
  line-height: 1;
}

@keyframes event-pointer-pop {
  0%, 100% { scale: 1; }
  50% { scale: 1.08; }
}

@keyframes food-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes target-ring {
  0%, 100% { scale: 0.92; opacity: 0.72; }
  50% { scale: 1.08; opacity: 1; }
}

.decor {
  z-index: 0;
  opacity: 0.88;
}

.decor--root {
  width: 74px;
  height: 28px;
}

.decor--pebble {
  width: 34px;
  height: 26px;
  opacity: 0.72;
}

.decor--mushroom,
.decor--glow,
.decor--grass {
  width: 34px;
  height: 34px;
}

.decor--glow {
  mix-blend-mode: screen;
  opacity: 0.68;
  animation: glow-breathe 2.8s ease-in-out infinite;
}

@keyframes glow-breathe {
  0%, 100% { opacity: 0.48; filter: blur(0); }
  50% { opacity: 0.84; filter: blur(0.5px); }
}

/* ===== Ant sprite =====
   Five-level structure to avoid transform conflicts: .ant-anchor (JS sets world position),
   .ant-tilt (lean into movement direction, JS sets rotate + CSS transition), .ant-flip (facing
   direction via scaleX, CSS transition), .ant-bob (vertical bob while walking, keyframe), .ant
   (pulse keyframe animation). Each level owns exactly one transform source. */

.ant-anchor {
  left: 0;
  top: 0;
  z-index: 2;
  width: 0;
  height: 0;
}

.ant-tilt {
  position: absolute;
  left: 0;
  top: 0;
  transition: transform 0.2s ease-out;
}

.ant-flip {
  position: absolute;
  left: -22px;
  top: -22px;
  width: 44px;
  height: 44px;
  transition: transform 0.15s ease;
}

.ant-flip.facing-left {
  transform: scaleX(-1);
}

.ant-bob {
  width: 100%;
  height: 100%;
  display: block;
}

.ant-bob.walking {
  animation: ant-bob 0.42s ease-in-out infinite;
}

@keyframes ant-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1.4px); }
}

.ant {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 3px rgba(255, 224, 170, 0.25));
}

.ant.tier-max {
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 3px rgba(255, 224, 170, 0.25))
    drop-shadow(0 0 7px rgba(255, 212, 100, 0.65));
}

.ant__antenna {
  transform-origin: 50% 100%;
  animation: antenna-idle 2.6s ease-in-out infinite;
}

@keyframes antenna-idle {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(4deg); }
}

.ant__leg {
  transform-box: fill-box;
  transform-origin: top center;
}

.ant.walking .ant__leg--a { animation: leg-swing 0.42s linear infinite; }
.ant.walking .ant__leg--b { animation: leg-swing 0.42s linear infinite reverse; }

/* Асимметричный трипод-гейт: быстрый взмах вперёд (0%→35%), медленный силовой толчок назад
   (35%→100%) — настоящие насекомые не машут ногами туда-обратно симметрично. Лёгкое понижение
   непрозрачности на взмахе читается как "нога оторвалась от земли" — вид сверху не даёт
   показать подъём буквально. */
@keyframes leg-swing {
  0% { transform: rotate(18deg); opacity: 1; }
  35% { transform: rotate(-20deg); opacity: 0.72; }
  100% { transform: rotate(18deg); opacity: 1; }
}

.ant__abdomen {
  transform-box: fill-box;
  transform-origin: center;
  animation: breathe 2.8s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

.ant__mandible {
  transform-box: fill-box;
  transform-origin: 0% 50%;
  animation: mandible-twitch 4.5s ease-in-out infinite;
}

@keyframes mandible-twitch {
  0%, 92%, 100% { transform: rotate(0deg); }
  95% { transform: rotate(6deg); }
}

.ant.carrying .ant__cargo {
  opacity: 1;
  transform: scale(1);
}

.ant__cargo {
  opacity: 0;
  transform: scale(0.6);
  transform-origin: center;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.ant.pulse {
  animation: ant-pulse 0.32s ease;
}

@keyframes ant-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.28, 0.78); }
  70% { transform: scale(0.92, 1.08); }
  100% { transform: scale(1); }
}

/* carry slots (backpack indicator) */

.carry-slots {
  position: absolute;
  left: 0;
  top: -6px;
  display: flex;
  gap: 2px;
  transform: translate(-50%, -100%);
  pointer-events: none;
}

.carry-slot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.25);
}

.carry-slot.filled {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

/* ===== Joystick ===== */

.joystick-base {
  position: absolute;
  width: 104px;
  height: 104px;
  margin-left: -52px;
  margin-top: -52px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
  z-index: 5;
}

.joystick-stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe3ab, var(--color-accent) 70%);
  box-shadow: var(--shadow-lift);
}

/* ===== Particles ===== */

.particle-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 4;
}

.particle {
  position: absolute;
  width: var(--size, 8px);
  height: var(--size, 8px);
  border-radius: 50%;
  background: var(--particle-color, var(--color-accent));
  animation: particle-burst var(--duration, 0.6s) ease-out forwards;
}

.guide-arrow {
  position: absolute;
  z-index: 6;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 243, 201, 0.9), rgba(242, 169, 59, 0.55) 68%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.34), 0 0 0 6px rgba(242, 169, 59, 0.14);
  pointer-events: none;
  animation: guide-pulse 1.15s ease-in-out infinite;
}

.guide-arrow svg {
  width: 60%;
  height: 60%;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

.guide-arrow[hidden] {
  display: none !important;
}

@keyframes guide-pulse {
  0%, 100% { scale: 1; }
  50% { scale: 1.08; }
}

@keyframes particle-burst {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx, 0), var(--dy, -30px)) scale(0.3);
    opacity: 0;
  }
}

/* ===== Progress screen ===== */

.progress-screen,
.settings-screen {
  padding: 16px;
  gap: 14px;
  overflow-y: auto;
  background: var(--color-deep);
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.screen-header h1 {
  font-size: 1.3rem;
  margin: 0;
}

.profession-card {
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0.7;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.profession-card.unlocked {
  opacity: 1;
}

.profession-card.current {
  opacity: 1;
  border-color: var(--color-accent);
  box-shadow: var(--shadow-glow-accent);
}

.profession-card__badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--color-earth);
  flex-shrink: 0;
}

.profession-card.current .profession-card__badge {
  background: var(--color-accent);
  color: var(--color-deep);
}

.profession-card__body {
  flex: 1;
  min-width: 0;
}

.profession-card__name {
  font-weight: 700;
}

.profession-card__mechanic {
  color: var(--color-fg-dim);
  font-size: 0.85rem;
}

.profession-card__requirements {
  font-size: 0.78rem;
  color: var(--color-fg-dim);
  margin-top: 2px;
}

/* ===== Settings screen ===== */

.settings-screen .card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-screen .card p {
  margin: 4px 0 0;
  color: var(--color-fg-dim);
  font-size: 0.85rem;
}

/* ===== Celebration overlay ===== */

.celebration {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(18, 12, 8, 0.72);
  z-index: 30;
}

.celebration.active {
  display: flex;
  animation: screen-fade-in 0.2s ease both;
}

.celebration__card {
  text-align: center;
  padding: 28px 24px;
  max-width: 320px;
}

.celebration__title {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 8px 0 4px;
}

.celebration__quote {
  color: var(--color-fg-dim);
  font-size: 0.88rem;
  font-style: italic;
  line-height: 1.35;
  margin: 6px 0 0;
}

/* ===== Responsive ===== */

@media (min-width: 720px) {
  .progress-screen,
  .settings-screen {
    padding: 32px;
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
  }
}

@media (min-width: 1024px) {
  .camera {
    margin: 0;
    width: 100%;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (max-width: 430px) {
  .title-screen {
    gap: 24px;
  }

  .title-screen__title {
    font-size: 1.52rem;
    line-height: 1.12;
  }

  .hud {
    gap: 8px;
    padding: 8px 10px;
  }

  .hud-main {
    gap: 8px;
  }

  .hud-title {
    min-width: 0;
    flex: 1 1 170px;
  }

  .hud-stats {
    width: 100%;
    padding-left: 54px;
  }

  .stat-chip {
    min-height: 30px;
    padding: 3px 9px;
  }

  .xp-bar {
    width: 70px;
  }

  .mission-strip {
    grid-template-columns: 1fr;
    gap: 7px;
    padding: 8px 9px;
  }

  .mission-strip__title {
    font-size: 0.9rem;
  }

  .micro-event-strip {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 8px;
    padding: 7px 9px;
  }

  .micro-event-strip__icon {
    width: 30px;
    height: 30px;
    font-size: 0.86rem;
  }

  .micro-event-strip__meter {
    grid-column: 1 / -1;
  }

  .micro-event-strip__title {
    font-size: 0.84rem;
  }

  .micro-event-strip__details {
    font-size: 0.72rem;
  }

  .micro-event-marker strong {
    top: 36px;
    max-width: 96px;
    padding: 4px 6px;
    font-size: 0.6rem;
  }

  .dialogue-strip {
    min-height: 76px;
    padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
  }

  .dialogue-strip__portrait {
    width: 38px;
    height: 38px;
    font-size: 0.66rem;
  }

  .dialogue-strip__text {
    font-size: 0.82rem;
    line-height: 1.22;
  }
}
