/* Tiny World Together — Day 1 styles
   Palette: warm dusk, soft natural tones. No external fonts or assets. */

:root {
  --ink: #3b3126;
  --ink-soft: #6f6252;
  --paper: #fdf7ee;
  --paper-edge: rgba(90, 70, 45, 0.12);
  --accent: #4f7a52;
  --accent-warm: #c98a45;
  --shadow-soft: 0 10px 30px rgba(84, 60, 32, 0.13);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: #f4e7d6;
  background-image:
    radial-gradient(120% 80% at 50% -10%, #fdf3e4 0%, #f6e9d8 45%, #ecdbc4 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
  padding:
    max(14px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  gap: 10px;
}

/* ---------- Top bar ---------- */

.topbar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0 2px;
  text-align: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: #eaf1e4;
  background: linear-gradient(150deg, #6f9a63 0%, #4f7a52 100%);
  box-shadow: 0 4px 10px rgba(79, 122, 82, 0.28);
}

.brand__name {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: clamp(17px, 2.6vw, 21px);
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #40352a;
}

.brand__tagline {
  margin: 0;
  font-size: clamp(11px, 1.6vw, 12.5px);
  letter-spacing: 0.35px;
  color: var(--ink-soft);
  opacity: 0.85;
}

.presence {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 4px 11px 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  letter-spacing: 0.25px;
  color: #5d6b56;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(120, 140, 110, 0.22);
  box-shadow: 0 2px 6px rgba(90, 80, 60, 0.06);
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

/* ---------- Contribution counters ---------- */

.stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 5px;
}

.tally {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  letter-spacing: 0.25px;
  color: #5d6b56;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(120, 140, 110, 0.22);
  box-shadow: 0 2px 6px rgba(90, 80, 60, 0.06);
}

.tally__total { font-variant-numeric: tabular-nums; }

.tally__kinds {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding-left: 9px;
  border-left: 1px solid rgba(120, 140, 110, 0.24);
}

.tally__kind {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-variant-numeric: tabular-nums;
  color: #6b7a62;
}

.tally__kind svg { width: 12px; height: 12px; display: block; }
.tally__kind[data-kind="tree"] svg { color: #6b9a63; }
.tally__kind[data-kind="flower"] svg { color: #e08a9c; }
.tally__kind[data-kind="lantern"] svg { color: #e0a24e; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.presence__label {
  font-variant-numeric: tabular-nums;
}

.presence__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa892;
  box-shadow: 0 0 0 3px rgba(154, 168, 146, 0.18);
  transition: background 200ms ease, box-shadow 200ms ease;
}

.presence[data-state="online"] .presence__dot {
  background: #6fa35f;
  box-shadow: 0 0 0 3px rgba(111, 163, 95, 0.2);
}

.presence[data-state="connecting"] .presence__dot,
.presence[data-state="reconnecting"] .presence__dot {
  background: #e0a94e;
  box-shadow: 0 0 0 3px rgba(224, 169, 78, 0.2);
  animation: presence-pulse 1.4s ease-in-out infinite;
}

.presence[data-state="closed"] {
  color: #8a6a5a;
  border-color: rgba(176, 74, 46, 0.24);
}

.presence[data-state="closed"] .presence__dot {
  background: #c0603f;
  box-shadow: 0 0 0 3px rgba(192, 96, 63, 0.18);
}

@keyframes presence-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .presence[data-state="connecting"] .presence__dot,
  .presence[data-state="reconnecting"] .presence__dot {
    animation: none;
  }
}

/* ---------- Stage ---------- */
.stage {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 34px;
}

#world {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 26px;
  touch-action: manipulation;
  cursor: crosshair;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-soft);
}

.hint {
  position: absolute;
  /* left+right+fit-content keeps the pill centred AND lets it use the full
     stage width; `left:50%` alone capped it at half the stage. */
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  width: fit-content;
  max-width: min(560px, calc(100% - 12px));
  padding: 8px 16px;
  font-size: 12.5px;
  line-height: 1.35;
  text-align: center;
  color: #5b4c3a;
  background: rgba(253, 247, 238, 0.82);
  border: 1px solid var(--paper-edge);
  border-radius: 18px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  white-space: normal;
  text-wrap: pretty;
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}

.hint[data-tone="warn"] {
  color: #8a5a2b;
  background: rgba(255, 244, 227, 0.94);
  border-color: rgba(201, 138, 69, 0.35);
}

.hint[data-tone="ok"] {
  color: #37543b;
  background: rgba(240, 248, 236, 0.92);
  border-color: rgba(79, 122, 82, 0.28);
}

/* ---------- Dock ---------- */

.dock {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding-bottom: 2px;
}

.dock__bar {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 6px;
  background: rgba(253, 247, 238, 0.9);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(84, 60, 32, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dock__items {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.dock__divider {
  flex: 0 0 auto;
  width: 1px;
  margin: 7px 1px;
  background: rgba(90, 70, 45, 0.13);
}

/* Share: visible in the same bar, quieter than the objects. */
.share {
  appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 62px;
  min-height: 60px;
  padding: 8px 12px;
  border-radius: 13px;
  border: 1px solid rgba(79, 122, 82, 0.26);
  background: rgba(79, 122, 82, 0.07);
  color: #405c40;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease, color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.share__icon { display: inline-flex; width: 19px; height: 19px; }
.share__icon svg { width: 100%; height: 100%; }
.share__label { line-height: 1; }

.share:hover {
  background: rgba(79, 122, 82, 0.13);
  border-color: rgba(79, 122, 82, 0.36);
}

.share:active { transform: scale(0.97); }

.share:focus-visible {
  outline: 2px solid rgba(79, 122, 82, 0.55);
  outline-offset: 2px;
}

.share[data-state="copied"] {
  background: rgba(79, 122, 82, 0.16);
  border-color: rgba(79, 122, 82, 0.45);
  color: #2f4c31;
}

.item {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 13px;
  padding: 8px 16px;
  min-width: 86px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease, border-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.item__icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  opacity: 0.75;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.item__icon svg { width: 100%; height: 100%; }

.item__label { line-height: 1; }

.item:hover {
  background: rgba(79, 122, 82, 0.07);
  color: var(--ink);
}

.item:active { transform: scale(0.97); }

.item.is-active {
  background: rgba(79, 122, 82, 0.12);
  border-color: rgba(79, 122, 82, 0.22);
  color: #33502f;
}

.item.is-active .item__icon {
  opacity: 1;
  transform: translateY(-1px);
}

.item:focus-visible {
  outline: 2px solid rgba(79, 122, 82, 0.55);
  outline-offset: 2px;
}

/* ---------- Mobile ---------- */

@media (max-width: 560px) {
  .app {
    gap: 8px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .brand__name { font-size: 16px; }
  .brand__mark { width: 27px; height: 27px; border-radius: 9px; }

  .stats { gap: 5px; margin-top: 4px; }

  .presence,
  .tally {
    font-size: 10.5px;
    padding: 3px 9px;
  }

  .tally { gap: 7px; }
  .tally__kinds { gap: 6px; padding-left: 7px; }
  .tally__kind svg { width: 11px; height: 11px; }

  #world { border-radius: 20px; }

  .stage { padding-bottom: 46px; }

  .hint {
    font-size: 11.5px;
    padding: 7px 13px;
    border-radius: 15px;
    bottom: 0;
  }

  .dock__bar {
    width: 100%;
    gap: 4px;
    padding: 5px;
  }

  .dock__items {
    flex: 1 1 auto;
    gap: 4px;
    min-width: 0;
  }

  .item {
    flex: 1 1 0;
    min-width: 0;
    min-height: 62px;
    padding: 8px 2px;
  }

  .item__label { font-size: 11.5px; }

  .share {
    min-width: 56px;
    min-height: 62px;
    padding: 6px 8px;
    font-size: 10.5px;
    gap: 2px;
  }

  .share__icon { width: 17px; height: 17px; }
}

@media (max-height: 520px) {
  .brand__tagline { display: none; }
  .item { min-height: 50px; }
  .share { min-height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
