/* Matter Mixer — flat bright kid aesthetic, touch-first, no fonts/images fetched.
   Visual language adapted from drippy-3d / Gobble v5 style.css. */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: "Trebuchet MS", "Comic Sans MS", Verdana, sans-serif;
  /* cozy warm lab gradient: the WebGL canvas has a transparent clear color,
     so the room behind the bench IS this gradient (zero draw cost). */
  background: linear-gradient(180deg, #ffe9c9 0%, #ffd9a8 55%, #f6c48b 100%);
  touch-action: none; -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
#game3d { position: fixed; inset: 0; display: block; touch-action: none; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: calc(10px + env(safe-area-inset-top)); right: 14px; z-index: 8;
  display: flex; gap: 10px;
}
.pillBtn {
  width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.85); color: #9a5b2d; font-size: 26px; cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
}
.pillBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.15); }
.pillBtn.off { opacity: .45; }

/* ---------- big state word-label ---------- */
#stateLabel {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  max-width: 66vw; padding: 14px 36px; border-radius: 30px;
  background: #ffffff; color: #2b3a55;
  font-size: clamp(26px, 5vmin, 52px); font-weight: 900; text-align: center;
  box-shadow: 0 5px 0 rgba(0,0,0,.15);
  z-index: 7; pointer-events: none; min-height: 1em;
}
#stateLabel[data-state="solid"]  { background: #d9f4ff; color: #1c6ea3; }
#stateLabel[data-state="liquid"] { background: #d3f0ff; color: #0b6aa0; }
#stateLabel[data-state="gas"]    { background: #ffe3c9; color: #b04a12; }
#stateLabel.pop { animation: labelPop .5s ease-out; }
@keyframes labelPop { 0% { transform: translateX(-50%) scale(.5); opacity: 0; }
                      60% { transform: translateX(-50%) scale(1.12); opacity: 1; }
                      100% { transform: translateX(-50%) scale(1); } }

/* ---------- substance chips ---------- */
#chips {
  position: fixed; left: 14px; top: calc(12px + env(safe-area-inset-top)); z-index: 7;
  display: flex; flex-direction: column; gap: 10px;
}
.chip {
  border: 0; border-radius: 24px; padding: 14px 20px; cursor: pointer;
  background: rgba(255,255,255,.75); color: #6b4a2b;
  font-family: inherit; font-size: clamp(16px, 2.6vmin, 24px); font-weight: 900;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
  transition: transform .15s ease, background .15s ease;
}
.chip.on { background: #ffffff; color: #d06a1f; transform: scale(1.08);
           box-shadow: 0 4px 0 rgba(0,0,0,.2), 0 0 0 4px rgba(255,158,61,.55); }
.chip:active { transform: translateY(3px) scale(1.02); }

/* ---------- heat dial (right side, vertical) ---------- */
#dial {
  --heat: 0.15;
  position: fixed; right: max(16px, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%);
  width: 76px; height: min(62vh, 460px); z-index: 8;
  border-radius: 40px; cursor: grab; touch-action: none;
  background:
    linear-gradient(180deg, #ff7b2e 0%, #ffd94a calc(50% - 2px), #7fd4ff calc(50% + 2px), #2f9fd8 100%);
  box-shadow: 0 6px 0 rgba(0,0,0,.18), inset 0 0 0 6px rgba(255,255,255,.55);
}
#dial:active { cursor: grabbing; }
#dialThumb {
  position: absolute; left: 6px; width: 64px; height: 44px; border-radius: 22px;
  background: #ffffff; box-shadow: 0 4px 0 rgba(0,0,0,.25);
  bottom: calc(0.15 * (100% - 64px) + 10px);
  transition: bottom .05s linear;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
#dialThumb::after { content: "\1F525"; }
.dialIcon {
  position: absolute; left: 50%; transform: translateX(-50%); font-size: 26px;
  pointer-events: none; text-shadow: 0 2px 4px rgba(0,0,0,.3);
}
.dialIcon.top { top: -36px; }
.dialIcon.bottom { bottom: -36px; }

/* ---------- onboarding hint ---------- */
#handHint {
  position: fixed; right: max(110px, calc(env(safe-area-inset-right) + 94px));
  top: 50%; transform: translateY(-50%);
  padding: 12px 22px; border-radius: 26px; z-index: 7;
  background: #fff; color: #d06a1f; font-weight: 900;
  font-size: clamp(18px, 3vmin, 30px);
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
  opacity: 0; pointer-events: none;
  transition: opacity .4s ease;
}
#handHint.show { opacity: 1; animation: hintNudge 1.4s ease-in-out infinite; }
#handHint.gone { opacity: 0; }
@keyframes hintNudge { 0%,100% { transform: translateY(-50%) translateX(0); }
                       50% { transform: translateY(-50%) translateX(10px); } }

/* ---------- phone: keep the big word-label clear of the topbar pills and
   the chip column when the app runs full-screen in portrait ---------- */
@media (max-width: 768px) {
  #stateLabel { top: calc(130px + env(safe-area-inset-top)); }
}

/* 2026-11-05 phone layout fixes (Claude Code, Ryan: "fix and finish all 18 learning apps").
   left:50% + translateX(-50%) with no width made these shrink-to-fit inside HALF the screen: on a phone the hint
   wrapped to 5-6 lines in a 192px bubble and two-word titles broke onto two lines. max-content + a screen-wide cap fixes it. */
#handHint { width: max-content; max-width: calc(100vw - 32px); text-align: center; }

/* phones: the read/bulb/lessons/mute buttons take the whole top-right, so the substance chips drop to a row below them */
@media (max-width: 520px) {
  #chips { top: calc(74px + env(safe-area-inset-top)); left: 10px; flex-direction: row; gap: 8px; }
  .chip { padding: 10px 14px; font-size: 17px; }
  #topbar { right: 10px; gap: 6px; }
}

/* five substances now: the chip row wraps on phones and uses a smaller chip */
@media (max-width: 520px) { #chips { flex-wrap: wrap; max-width: calc(100vw - 20px); } .chip { padding: 8px 12px; font-size: 15px; } #stateLabel { top: calc(158px + env(safe-area-inset-top)); } }
