* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: #000; color: #fff; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans TC", sans-serif;
  user-select: none;
}
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; }

/* ---- room select ---- */
#room-select {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #111;
  z-index: 25; /* above #display — in clock-only mode both are in the DOM at once */
}
#room-select h1 { font-size: 1.4rem; margin-bottom: 1rem; }
#room-list { list-style: none; padding: 0; margin: 0; width: min(90vw, 420px); }
#room-list li {
  padding: 1rem; margin-bottom: 0.5rem; background: #222; border-radius: 8px;
  text-align: center; font-size: 1.1rem; cursor: pointer;
}
#room-list li:active { background: #333; }

/* ---- display ---- */
#display { touch-action: none; }
.el {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  white-space: nowrap; text-align: center; font-variant-numeric: tabular-nums;
}
.el.stale { opacity: 0.35; }
.el.editing { outline: 1px dashed rgba(255,255,255,0.8); outline-offset: 4px; }
.el.editing.selected { outline-color: #4fc3f7; }
/* clock-only / pre-first-round: element has no data — not rendered at all
   (edit mode overrides it with placeholder text so it stays grabbable) */
.el.empty:not(.editing) { display: none; }

#btn-pick-room, #btn-fullscreen {
  position: fixed; bottom: 8px; z-index: 10;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 6px;
  padding: 4px 10px; font-size: 0.75rem;
}
#btn-fullscreen { right: 8px; }
#btn-pick-room { right: 52px; }

#conn-dot {
  position: fixed; left: 6px; bottom: 6px; width: 6px; height: 6px; border-radius: 50%;
  background: #e53935; z-index: 10;
}
#conn-dot.connected { background: #43a047; }

/* ---- edit toolbar ---- */
#edit-toolbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(20,20,20,0.95); padding: 10px; display: flex; gap: 8px;
  align-items: center; flex-wrap: wrap;
}
#color-swatches { display: flex; gap: 6px; }
#color-swatches span {
  width: 24px; height: 24px; border-radius: 50%; display: inline-block;
  border: 1px solid rgba(255,255,255,0.4);
}
#hex-input { width: 90px; padding: 4px; }
#edit-toolbar button { padding: 6px 14px; }
#edit-toolbar label { color: #ddd; font-size: 0.9rem; }
#wake-status { color: #888; font-size: 0.8rem; margin-left: auto; }

/* ---- pin modal ---- */
#pin-modal {
  position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
}
.pin-box {
  background: #1c1c1c; padding: 24px; border-radius: 10px; text-align: center;
  width: min(80vw, 300px);
}
.pin-box input { width: 100%; padding: 10px; font-size: 1.2rem; text-align: center; margin: 10px 0; }
.pin-actions { display: flex; gap: 10px; justify-content: center; }
.pin-actions button { padding: 8px 16px; }
.error { color: #ef5350; font-size: 0.85rem; }
