* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #DCEBF5;
  font-family: "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  color: #2F2A24;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#viewport {
  position: fixed;
  inset: 0;
}

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

#stats {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 5;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #CFC6B8;
  color: #2F2A24;
  font-size: 11px;
  line-height: 1.2;
  padding: 4px 8px;
  border-radius: 999px;
  pointer-events: none;
}

#stats[data-visible="1"] {
  display: block;
}

#btn-reset-view {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: calc(10px + env(safe-area-inset-right, 0px));
  z-index: 6;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #CFC6B8;
  color: #2F2A24;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

#btn-reset-view:focus-visible {
  outline: 2px solid #2F2A24;
  outline-offset: 2px;
}

#toolbar {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  flex-direction: row;
  gap: 8px;
  width: min(720px, calc(100% - 24px));
  pointer-events: auto;
}

#toolbar button {
  flex: 1 1 0;
  min-height: 48px;
  height: auto;
  padding: 6px 8px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #CFC6B8;
  color: #2F2A24;
  font: 600 12px/1.2 "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: normal;
  text-align: center;
}

#toolbar button.active {
  background: #F0A43A;
  border-color: #F0A43A;
  color: #2F2A24;
}

#toolbar button:focus-visible {
  outline: 2px solid #2F2A24;
  outline-offset: 2px;
}

@media (max-width: 420px) {
  #toolbar {
    flex-direction: column;
    width: calc(100% - 24px);
  }
  #toolbar button {
    flex: 0 0 auto;
    width: 100%;
    min-height: 48px;
    font-size: 13px;
    padding: 10px 12px;
  }
}

.bot-label,
.bot-bubble {
  pointer-events: none;
  font-family: "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  color: #2F2A24;
}

.bot-label {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  background: rgba(255, 255, 255, 0.85);
  padding: 2px 8px;
  border-radius: 8px;
}

.bot-label.compact {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 6px;
}

.bot-bubble {
  white-space: normal;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
  max-width: 11.5em;
  text-align: center;
  background: #FFFFFF;
  padding: 5px 9px;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(47, 42, 36, 0.12);
}

@media (max-width: 420px) {
  .bot-label { font-size: 11px; }
  .bot-bubble { font-size: 11px; max-width: 10.5em; }
}

@media (max-height: 420px) {
  .bot-label { font-size: 11px; }
  .bot-bubble { font-size: 11px; max-width: 10.5em; padding: 4px 7px; }
}
