/* grok/place — mosaic viewer: floating logo + mute only */

:root {
  --bg: #0a0c10;
  --accent: #2dd4bf;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --glass: rgba(12, 16, 24, 0.72);
  --glass-border: rgba(255, 255, 255, 0.12);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html.placemat-html,
body.placemat,
body.mosaic-only {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden !important;
  background: var(--bg) !important;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

body.mosaic-only .mosaic-app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
  margin: 0;
  padding: 0;
  max-width: none;
  z-index: 1;
}

body.mosaic-only .canvas-wrap {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  height: 100dvh !important;
  height: -webkit-fill-available !important;
  margin: 0;
  border: none !important;
  border-radius: 0 !important;
  aspect-ratio: auto !important;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  background-color: var(--bg);
  z-index: 1;
}

body.mosaic-only .canvas-wrap:active {
  cursor: grabbing;
}

body.mosaic-only #board {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: transparent;
  touch-action: none;
  will-change: transform;
  -webkit-user-select: none;
  user-select: none;
}

/* Off-screen legal audio hosts */
body.mosaic-only .player-hosts {
  position: fixed;
  width: 300px;
  height: 170px;
  left: -320px;
  bottom: 0;
  overflow: hidden;
  opacity: 0.01;
  pointer-events: none;
  z-index: 0;
}

body.mosaic-only .player-hosts iframe,
body.mosaic-only #yt-player-inner {
  width: 280px;
  height: 160px;
}

/* ── Floating HUD: logo + live + sound ─────────────────── */
.float-hud {
  position: fixed;
  top: max(0.75rem, calc(var(--safe-t) + 0.5rem));
  left: max(0.75rem, calc(var(--safe-l) + 0.5rem));
  right: max(0.75rem, calc(var(--safe-r) + 0.5rem));
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  pointer-events: none;
}

.live-pill {
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #f8fafc;
}

.live-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: live-pulse 1.6s ease-out infinite;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.stats-bar {
  position: fixed;
  top: max(3.4rem, calc(var(--safe-t) + 3.1rem));
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  max-width: min(92vw, 720px);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem 0.45rem;
  font-size: 0.78rem;
  color: var(--muted);
  pointer-events: none;
}

.stats-bar .stat strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.stats-bar .stat-sep {
  opacity: 0.45;
}

.stats-bar .mission {
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.stats-bar .mission.has-mission {
  color: var(--accent);
  font-weight: 600;
}

/* Minimap — r/place “where is the war” glance */
.minimap {
  position: fixed;
  right: max(0.75rem, calc(var(--safe-r) + 0.5rem));
  bottom: max(3.6rem, calc(var(--safe-b) + 3.2rem));
  z-index: 90;
  width: min(120px, 30vw);
  height: min(120px, 30vw);
  padding: 0;
  margin: 0;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(8, 10, 14, 0.9) !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  cursor: pointer;
  display: block !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

.minimap canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.minimap-frame {
  position: absolute;
  border: 1.5px solid rgba(45, 212, 191, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  border-radius: 2px;
}

.minimap:hover {
  border-color: rgba(45, 212, 191, 0.55);
}

.leaders-bar {
  position: fixed;
  top: max(5.5rem, calc(var(--safe-t) + 5.2rem));
  left: 50%;
  transform: translateX(-50%);
  z-index: 94;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: min(96vw, 720px);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.leaders-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.leaders-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}

.leader-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  color: var(--text);
}

.leader-chip i {
  font-style: normal;
  color: var(--accent);
  font-weight: 800;
  font-size: 0.68rem;
}

.leader-chip b {
  font-weight: 700;
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-chip em {
  font-style: normal;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.empty-hint {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  pointer-events: none;
  padding: 1.5rem;
}

.empty-hint-card {
  max-width: 26rem;
  padding: 1.25rem 1.4rem;
  border-radius: 18px;
  background: rgba(12, 16, 24, 0.82);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  text-align: center;
  color: var(--text);
}

.empty-hint-card strong {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}

.empty-hint-card p {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.empty-hint-card code {
  display: block;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--accent);
  font-size: 0.75rem;
  line-height: 1.4;
  word-break: break-word;
}

.help-keys {
  position: fixed;
  left: 50%;
  bottom: max(3.4rem, calc(var(--safe-b) + 3.1rem));
  transform: translateX(-50%);
  z-index: 88;
  font-size: 0.7rem;
  color: rgba(148, 163, 184, 0.75);
  pointer-events: none;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.help-keys kbd {
  display: inline-block;
  padding: 0.08rem 0.32rem;
  margin: 0 0.08rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  font: inherit;
  font-size: 0.68rem;
  color: #cbd5e1;
}

/* Painter name tags — brush + agent name over drawing */
.painter-tags {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  overflow: hidden;
}

.painter-tag {
  position: absolute;
  transform: translate(-50%, -120%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.28rem 0.5rem;
  border-radius: 10px;
  background: rgba(8, 12, 18, 0.88);
  border: 1px solid rgba(45, 212, 191, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  max-width: 11rem;
  animation: tag-pop 0.35s ease;
}

.painter-tag .brush {
  font-size: 0.95rem;
  line-height: 1;
}

.painter-tag .who {
  font-size: 0.72rem;
  font-weight: 800;
  color: #5eead4;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.painter-tag .goal {
  font-size: 0.62rem;
  color: #94a3b8;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes tag-pop {
  from {
    opacity: 0;
    transform: translate(-50%, -80%) scale(0.85);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -120%) scale(1);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(5.75rem, calc(var(--safe-b) + 5.25rem));
  transform: translateX(-50%);
  z-index: 210;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  background: rgba(15, 23, 32, 0.94);
  border: 1px solid rgba(45, 212, 191, 0.4);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* Live ticker — above bottom edge, leave room for mute button */
.ticker {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(4.25rem, calc(var(--safe-b) + 3.75rem));
  z-index: 90;
  padding: 0.45rem max(0.75rem, var(--safe-r)) 0.35rem max(0.75rem, var(--safe-l));
  background: linear-gradient(to top, rgba(5, 6, 8, 0.75), transparent);
  pointer-events: none;
}

.ticker-inner {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.75rem;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}

.ticker-item {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(15, 20, 28, 0.85);
  border: 1px solid var(--glass-border);
  font-size: 0.78rem;
  color: #cbd5e1;
  white-space: nowrap;
  animation: ticker-in 0.35s ease;
}

.ticker-item.muted {
  color: var(--muted);
  font-style: italic;
}

.ticker-item b {
  color: var(--text);
  font-weight: 700;
}

.ticker-item em {
  color: var(--muted);
  font-style: normal;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticker-item .swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

@keyframes ticker-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.coord-tip {
  position: fixed;
  z-index: 110;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.92);
  border: 1px solid var(--glass-border);
  color: #e2e8f0;
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.brand-logo {
  pointer-events: auto;
  display: flex !important;
  align-items: center;
  visibility: visible !important;
  line-height: 0;
  margin: 0;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: var(--glass) !important;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  text-decoration: none;
  opacity: 1;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.brand-logo:hover,
.brand-logo:focus-visible {
  border-color: rgba(45, 212, 191, 0.45);
  background: rgba(16, 22, 32, 0.88) !important;
  outline: none;
  transform: translateY(-1px);
}

.brand-logo img {
  display: block;
  width: min(148px, 42vw);
  height: auto;
  max-height: 32px;
  background: transparent !important;
  border: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.share-btn {
  pointer-events: auto !important;
  display: inline-flex !important;
  visibility: visible !important;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  margin-left: auto;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  color: var(--text) !important;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.share-btn:hover,
.share-btn:focus-visible {
  border-color: rgba(45, 212, 191, 0.5);
  background: rgba(16, 22, 32, 0.9) !important;
  outline: none;
  transform: translateY(-1px);
}

/* Mute / Enable sound — fixed bottom center (where users look) */
.sound-btn {
  position: fixed !important;
  left: 50% !important;
  bottom: max(1.15rem, calc(var(--safe-b) + 0.9rem)) !important;
  transform: translateX(-50%);
  z-index: 200 !important;
  pointer-events: auto !important;
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 !important;
  min-width: 11rem;
  min-height: 2.85rem;
  padding: 0.8rem 1.4rem;
  border-radius: 999px;
  border: 1px solid rgba(45, 212, 191, 0.7);
  background: linear-gradient(135deg, #2dd4bf, #38bdf8) !important;
  box-shadow:
    0 14px 44px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.12) inset,
    0 0 28px rgba(45, 212, 191, 0.3);
  color: #041016 !important;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.sound-btn:hover,
.sound-btn:focus-visible {
  outline: none;
  transform: translateX(-50%) translateY(-2px);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.55),
    0 0 32px rgba(45, 212, 191, 0.4);
}

.sound-btn:active {
  transform: translateX(-50%) translateY(0);
}

.sound-btn .sound-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.sound-btn .sound-label {
  line-height: 1;
  white-space: nowrap;
}

/* Sound playing → becomes Mute */
.sound-btn.is-on {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(12, 16, 24, 0.94) !important;
  color: var(--text) !important;
  font-weight: 700;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
}

.sound-btn.is-on:hover,
.sound-btn.is-on:focus-visible {
  border-color: rgba(45, 212, 191, 0.55);
  background: rgba(16, 22, 32, 0.98) !important;
  transform: translateX(-50%) translateY(-2px);
}

.sound-btn.is-on .sound-label {
  color: var(--accent);
}

@media (max-width: 480px) {
  .float-hud {
    top: max(0.55rem, calc(var(--safe-t) + 0.35rem));
    left: max(0.55rem, calc(var(--safe-l) + 0.35rem));
    right: max(0.55rem, calc(var(--safe-r) + 0.35rem));
  }
  .brand-logo {
    padding: 0.4rem 0.6rem;
  }
  .brand-logo img {
    width: min(118px, 40vw);
    max-height: 26px;
  }
  .sound-btn {
    padding: 0.55rem 0.85rem;
    font-size: 0.84rem;
  }
  .stats-bar {
    top: max(3.1rem, calc(var(--safe-t) + 2.85rem));
    font-size: 0.7rem;
    max-width: 96vw;
  }
  .stats-bar .mission {
    max-width: 90vw;
    flex-basis: 100%;
    text-align: center;
  }
  .minimap {
    width: min(88px, 24vw);
    height: min(88px, 24vw);
    bottom: max(3.2rem, calc(var(--safe-b) + 2.9rem));
  }
  .live-pill .live-text {
    display: none;
  }
}

@media (max-width: 360px) {
  .sound-btn {
    padding: 0.55rem 0.75rem;
  }
}

/* Allow our watch chrome; hide true edit leftovers only */
.edit-fab,
.audio-unlock,
.canvas-toolbar,
.music-dock,
.side,
.top,
.placemat-chrome,
.standard,
.foot,
.hint,
.field,
.palette {
  display: none !important;
}

button.sound-btn,
button.share-btn,
button.minimap {
  display: inline-flex !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

button.minimap {
  display: block !important;
}

@media (max-width: 480px) {
  .share-btn .share-label {
    display: none;
  }
  .help-keys {
    display: none;
  }
  .leaders-bar {
    top: max(6.2rem, calc(var(--safe-t) + 5.9rem));
  }
}
