* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #05060f;
  color: #eef1ff;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#c, #deep, #sand, #lanterns, #woodfish, #bamboo, #pane, #hearth {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
#c.grab { cursor: grab; }
#c.grabbing { cursor: grabbing; }

.title {
  position: fixed;
  top: max(28px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  text-align: center;
  pointer-events: none;
  transition: opacity 2.5s ease, transform 2.5s ease;
}
.title h1 {
  margin: 0;
  font-weight: 300;
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  text-transform: lowercase;
  opacity: 0.9;
  text-shadow: 0 0 30px #9bb4ff66;
}
.title p {
  margin: 10px 0 0;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  opacity: 0.55;
}
.title.fade { opacity: 0; transform: translate(-50%, -12px); }

.bar {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  max-width: calc(100% - 32px);
  transition: opacity 0.6s ease;
  opacity: 0.55;
}
.bar:hover, .bar:focus-within { opacity: 1; }

.bar button {
  display: flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 0.85rem;
  color: inherit;
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease;
}
.bar button:hover { background: rgba(255, 255, 255, 0.1); }
.bar button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.14); }
.bar button:active { transform: scale(0.96); }
.bar button:focus-visible { outline: 2px solid rgba(155, 180, 255, 0.7); outline-offset: 1px; }

.ico { width: 16px; text-align: center; opacity: 0.85; }
.swatch {
  height: 14px;
  width: 14px;
  border-radius: 50%;
  background: conic-gradient(#7cf5d2, #6aa8ff, #b28dff, #ff8ad8, #7cf5d2);
  box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.35), inset 2px 2px 3px rgba(255, 255, 255, 0.4);
}

.size {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
}
.speed-ico { font-size: 1rem; line-height: 1; opacity: 0.8; }
#auto-speed-wrap { margin-left: -6px; transition: opacity 0.2s ease; }
#auto-speed-wrap.off { opacity: 0.4; }
.bar input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
}
.bar input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 35% 30%, #fff, #c9d6ff 40%, #6a7fd0);
  box-shadow: 0 0 10px rgba(155, 180, 255, 0.6);
}
.bar input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 35% 30%, #fff, #c9d6ff 40%, #6a7fd0);
  box-shadow: 0 0 10px rgba(155, 180, 255, 0.6);
}
.bar input[type="range"]:focus-visible { box-shadow: 0 0 0 2px rgba(155, 180, 255, 0.7); }

#caption {
  position: fixed;
  left: 50%;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 64px);
  transform: translate(-50%, 8px);
  font-weight: 300;
  font-size: 1rem;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  text-transform: lowercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s ease, transform 1.2s ease;
  text-shadow: 0 0 18px rgba(155, 180, 255, 0.6);
}
#caption.show { opacity: 0.75; transform: translate(-50%, 0); }

/* the bar has many controls: drop text labels before it runs out of room */
@media (max-width: 1080px) {
  #bar .lbl { display: none; }
  #bar button { padding: 9px 12px; }
}

/* phones: the orb bar is too wide for one row, so the sliders drop to a second row */
@media (max-width: 640px) {
  #bar {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 2px;
    border-radius: 26px;
    width: calc(100% - 32px);
  }
  #bar .size { order: 1; flex: 1 1 40%; min-width: 0; padding: 4px 8px 2px; }
  #bar .size input[type="range"] { flex: 1; min-width: 0; width: auto; }
  #bar #auto-speed-wrap { margin-left: 0; }
}

@media (max-width: 520px) {
  .bar input[type="range"] { width: 70px; }
  .bar button { padding: 9px 11px; }
  .bar .lbl { display: none; }
  .bar { opacity: 0.8; }
}

#deep { cursor: pointer; }

/* ---------- Places ---------- */
[hidden] { display: none !important; }
:where([data-for]) { transition: opacity 0.7s ease, visibility 0s linear 0s; }
[data-for].away {
  opacity: 0 !important;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.7s ease, visibility 0s linear 0.7s !important;
}

#places {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  opacity: 0.6;
  transition: opacity 0.6s ease;
  z-index: 2;
}
#places:hover, #places:focus-within { opacity: 1; }
#places button {
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.8rem;
  color: inherit;
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
#places button:hover { background: rgba(255, 255, 255, 0.1); }
#places button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.16); }
#places button:focus-visible { outline: 2px solid rgba(155, 180, 255, 0.7); outline-offset: 1px; }

#deep-title h1 { text-shadow: 0 0 30px rgba(110, 230, 255, 0.55); }

@media (max-width: 520px) {
  #places .lbl { display: none; }
  .title { top: calc(max(16px, env(safe-area-inset-top)) + 52px); }
}

/* ---------- Lanterns ---------- */
#lanterns { cursor: crosshair; }
#lanterns-title h1 { text-shadow: 0 0 30px rgba(255, 170, 90, 0.55); }

/* a quote read off a lantern, and the box for writing one; both sit just above the bar */
#lantern-note, #lanterns-write-panel {
  position: fixed;
  left: 50%;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 66px);
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  border-radius: 18px;
  background: rgba(24, 20, 44, 0.55);
  border: 1px solid rgba(255, 200, 140, 0.18);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), 0 0 40px rgba(255, 160, 80, 0.08);
  z-index: 2;
}
#lantern-note {
  padding: 16px 20px 14px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
#lantern-note.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
#lantern-note-text {
  margin: 0;
  font-family: ui-serif, "Iowan Old Style", Georgia, serif;
  font-size: 1.08rem;
  line-height: 1.45;
  color: #fff3e2;
  text-shadow: 0 0 18px rgba(255, 170, 90, 0.35);
  overflow-wrap: anywhere;
  -webkit-user-select: text;
  user-select: text;
}
#lantern-note-meta { display: block; margin-top: 8px; font-size: 0.75rem; letter-spacing: 0.04em; opacity: 0.5; }

#lanterns-write-panel { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
#lanterns-write-panel label { font-size: 0.85rem; opacity: 0.75; padding: 0 2px; }
#lanterns-quote {
  font: inherit;
  font-family: ui-serif, "Iowan Old Style", Georgia, serif;
  font-size: 1rem;
  line-height: 1.4;
  color: #fff3e2;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  resize: none;
  -webkit-user-select: text;
  user-select: text;
}
#lanterns-quote:focus { outline: 2px solid rgba(255, 190, 120, 0.55); outline-offset: 0; }
#lanterns-quote::placeholder { color: rgba(255, 240, 220, 0.35); }
.lw-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.75rem; opacity: 0.6; padding: 0 2px; }
.lw-actions { opacity: 1; justify-content: flex-end; }
.lw-actions button {
  font: inherit;
  font-size: 0.85rem;
  color: inherit;
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}
.lw-actions button:hover { background: rgba(255, 255, 255, 0.1); }
#lanterns-write-send { background: rgba(255, 170, 90, 0.25); }
#lanterns-write-send:hover { background: rgba(255, 170, 90, 0.38); }
.lw-actions button:focus-visible { outline: 2px solid rgba(255, 190, 120, 0.7); outline-offset: 1px; }

/* ---------- Sand: a light place, so dark ink ---------- */
#sand { cursor: crosshair; }
#sand.grab { cursor: grab; }
#sand.grabbing { cursor: grabbing; }
#sand-title { color: #3f3528; }
#sand-title h1 { text-shadow: 0 0 30px rgba(255, 248, 230, 0.8); }
#sand-title p { opacity: 0.7; }
#sand-bar {
  color: #3d3428;
  background: rgba(255, 250, 238, 0.32);
  border-color: rgba(70, 56, 36, 0.16);
  box-shadow: 0 10px 40px rgba(80, 60, 30, 0.18);
  opacity: 0.75;
}
#sand-bar:hover, #sand-bar:focus-within { opacity: 1; }
#sand-bar button:hover { background: rgba(70, 56, 36, 0.1); }
#sand-bar button[aria-pressed="true"] { background: rgba(70, 56, 36, 0.12); }
#sand-bar button:focus-visible { outline-color: rgba(70, 56, 36, 0.6); }
#sand-bar input[type="range"] { background: rgba(70, 56, 36, 0.22); }
#sand-bar input[type="range"]::-webkit-slider-thumb { background: radial-gradient(circle at 35% 30%, #fff, #d8ccb4 45%, #8a7a60); box-shadow: 0 1px 4px rgba(60, 40, 20, 0.4); }
#sand-bar input[type="range"]::-moz-range-thumb { background: radial-gradient(circle at 35% 30%, #fff, #d8ccb4 45%, #8a7a60); box-shadow: 0 1px 4px rgba(60, 40, 20, 0.4); }
#sand-bar .lbl#sand-tines-lbl { font-size: 0.8rem; opacity: 0.75; min-width: 3.6em; }
.tine-ico { font-size: 0.8rem; letter-spacing: -0.05em; width: auto; min-width: 16px; }
body[data-place="sand"] #places {
  color: #3d3428;
  background: rgba(255, 250, 238, 0.32);
  border-color: rgba(70, 56, 36, 0.16);
}
body[data-place="sand"] #places button:hover { background: rgba(70, 56, 36, 0.1); }
body[data-place="sand"] #places button[aria-pressed="true"] { background: rgba(70, 56, 36, 0.14); }

/* ---------- Ambient sounds (top-right, shared by every place) ---------- */
#sounds {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
#sounds-btn, #sounds-panel {
  background: rgba(20, 24, 40, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  color: #eef1ff;
}
#sounds-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.8rem;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.4s ease, background 0.2s ease;
}
#sounds-btn:hover, #sounds-btn[aria-expanded="true"], #sounds-btn.on { opacity: 1; }
#sounds-btn.on { background: rgba(60, 70, 110, 0.45); }
#sounds-btn:focus-visible { outline: 2px solid rgba(155, 180, 255, 0.7); outline-offset: 1px; }
#sounds-panel {
  width: 236px;
  padding: 10px;
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
#sounds-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
#sounds-list button {
  display: flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 0.82rem;
  color: inherit;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}
#sounds-list button:hover { background: rgba(255, 255, 255, 0.08); }
#sounds-list button[aria-checked="true"] { background: rgba(255, 255, 255, 0.18); }
#sounds-list button:focus-visible { outline: 2px solid rgba(155, 180, 255, 0.7); outline-offset: -2px; }
.sounds-vol { display: flex; align-items: center; gap: 8px; padding: 10px 6px 2px; opacity: 0.85; font-size: 0.9rem; }
.sounds-vol input { flex: 1; min-width: 0; accent-color: #b8c8ff; }

@media (max-width: 520px) {
  #sounds-btn .lbl { display: none; }
}

/* the place switcher is wide now, so titles sit under it instead of beside it */
@media (min-width: 521px) {
  .title { top: calc(max(16px, env(safe-area-inset-top)) + 56px); }
}

/* ---------- Wooden fish ---------- */
#woodfish { cursor: pointer; }
#woodfish-title h1 { text-shadow: 0 0 30px rgba(255, 170, 90, 0.5); }
#woodfish-tempo-wrap { transition: opacity 0.2s ease; }
#woodfish-tempo-wrap.off { opacity: 0.45; }
#woodfish-tempo-wrap .bpm { font-size: 0.78rem; min-width: 52px; opacity: 0.8; font-variant-numeric: tabular-nums; }
#woodfish-words .ico { width: auto; font-size: 0.75rem; font-weight: 600; }

/* ---------- Bamboo ---------- */
#bamboo { cursor: pointer; }
#bamboo-title h1 { text-shadow: 0 0 30px rgba(200, 230, 160, 0.45); }
#bamboo-title p { text-shadow: 0 1px 10px rgba(10, 22, 6, 0.85); opacity: 0.8; }

/* seven places: below tablet width the switcher shows icons only (each has a title tooltip) */
@media (max-width: 900px) {
  #places .lbl { display: none; }
}
@media (max-width: 520px) {
  #places { gap: 2px; }
  #places button { padding: 6px 8px; }
}

/* ---------- Window ---------- */
#pane { cursor: pointer; }
#pane-title h1 { text-shadow: 0 0 30px rgba(170, 190, 255, 0.5); }

/* ---------- Hearth ---------- */
#hearth { cursor: pointer; }
#hearth-title h1 { text-shadow: 0 0 30px rgba(255, 140, 60, 0.6); }
