html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0f0f0f;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
  overscroll-behavior: none;
}

#screen {
  width: 100vw;
  height: 100vh;
  display: block;
  background: #111;
  cursor: none;
}

body.panning #screen {
  cursor: grab;
}

#toolbar {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  background: rgba(0,0,0,0.75);
  color: white;
  padding: 10px 12px;
  border-radius: 14px;
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  user-select: none;
}

.title {
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-right: 4px;
  white-space: nowrap;
}

button {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.12);
  color: white;
  font: inherit;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

.control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}

input[type="color"] {
  width: 38px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 0;
}

input[type="range"] {
  width: 90px;
}

#palette {
  display: flex;
  gap: 5px;
  align-items: center;
}

.swatch {
  width: 26px;
  height: 26px;
  min-width: 26px;
  padding: 0;
  border-radius: 999px;
  background: var(--swatch);
  border: 2px solid rgba(255,255,255,0.35);
}

.swatch[data-color="#ffffff"] {
  border-color: rgba(0,0,0,0.4);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.5);
}

.swatch.active {
  outline: 2px solid white;
  outline-offset: 2px;
}

#zoomInfo, #onlineCount {
  color: rgba(255,255,255,0.85);
  font-weight: 700;
  min-width: 42px;
}

#saveStatus {
  width: 18px;
  text-align: center;
  color: #999;
  font-size: 18px;
  line-height: 1;
}

#saveStatus.saving { color: #ffd166; }
#saveStatus.saved { color: #5cff9d; }
#saveStatus.error { color: #ff5555; }

#showToolbar {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 11;
  display: none;
  background: rgba(0,0,0,0.75);
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}

body.toolbar-collapsed #toolbar {
  display: none;
}

body.toolbar-collapsed #showToolbar {
  display: block;
}

#hint {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 8;
  background: rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.78);
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
  pointer-events: none;
  user-select: none;
}

#qrOverlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
}

#qrOverlay.hidden {
  display: none;
}

#qrBox {
  position: relative;
  width: min(420px, calc(100vw - 36px));
  background: #111;
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 22px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0,0,0,0.55);
}

#qrBox h2 {
  margin: 0 0 16px;
}

#qrBox img {
  width: min(300px, 70vw);
  height: auto;
  background: white;
  padding: 10px;
  border-radius: 14px;
}

#qrUrl {
  margin-top: 12px;
  opacity: 0.8;
  word-break: break-all;
  font-size: 14px;
}

#closeQr {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 22px;
  line-height: 1;
  width: 42px;
  height: 42px;
  padding: 0;
}

#kioskQr {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: none;
  background: rgba(0,0,0,0.72);
  color: white;
  padding: 12px;
  border-radius: 16px;
  text-align: center;
  font-weight: 800;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}

#kioskQr img {
  display: block;
  width: 120px;
  height: 120px;
  margin-top: 8px;
  background: white;
  padding: 6px;
  border-radius: 10px;
}

body.kiosk #toolbar,
body.kiosk #showToolbar,
body.kiosk #hint {
  display: none !important;
}

body.kiosk #kioskQr {
  display: block;
}

@media (max-width: 700px) {
  #toolbar {
    top: 8px;
    left: 8px;
    max-width: calc(100vw - 16px);
    padding: 8px;
    gap: 6px;
  }

  .title {
    width: 100%;
  }

  button {
    padding: 7px 9px;
  }

  input[type="range"] {
    width: 90px;
  }

  #hint {
    display: none;
  }
}