:root {
  color-scheme: dark;
  font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
  background: #88c9f2;
}

* { box-sizing: border-box; }

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

body { background: linear-gradient(#78bee9, #d8effa); }

.topbar {
  position: fixed;
  z-index: 10;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  width: min(calc(100% - 24px), 720px);
  min-height: 58px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 18px;
  background: rgba(18, 42, 35, .76);
  box-shadow: 0 12px 36px rgba(25, 56, 68, .22);
  backdrop-filter: blur(12px);
}

.topbar > strong {
  color: #fff;
  font-size: .98rem;
  text-align: center;
}

.back, #language-toggle, #comments-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 13px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  text-decoration: none;
  font: 900 .85rem/1 inherit;
  cursor: pointer;
}

.back { font-size: 1.45rem; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

#comments-button {
  position: relative;
  padding: 0;
  font-size: 1.25rem;
}

#comment-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border: 2px solid #213e34;
  border-radius: 10px;
  color: #1d3a2e;
  background: #d9f08b;
  font-size: .61rem;
  line-height: 1;
}

#comment-count:empty { display: none; }

#world, #game-canvas {
  width: 100%;
  height: 100%;
}

#game-canvas {
  display: block;
  touch-action: none;
  cursor: default;
}

#game-canvas.camera-turning { cursor: grabbing; }

.welcome {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), 520px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 18px;
  background: rgba(24, 61, 42, .82);
  box-shadow: 0 12px 32px rgba(25, 56, 68, .2);
  backdrop-filter: blur(10px);
  pointer-events: none;
  transition: opacity .4s, transform .4s;
}

.welcome.hide {
  opacity: 0;
  transform: translate(-50%, 18px);
}

.paw { font-size: 1.8rem; }
.welcome h1 { margin: 0; color: #fff; font-size: 1rem; }
.welcome p { margin: 3px 0 0; color: #d5f4df; font-size: .78rem; line-height: 1.35; }

.drag-hint {
  position: fixed;
  z-index: 4;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 20px;
  background: rgba(20, 48, 41, .62);
  color: #fff;
  font-size: .74rem;
  font-weight: 800;
  pointer-events: none;
}

@media (max-width: 520px) {
  .topbar { top: max(6px, env(safe-area-inset-top)); }
  .drag-hint { top: 80px; }
  .welcome { bottom: max(14px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .welcome { transition: none; }
}
