/* Hebrew: settings read right to left */
html[dir="rtl"] #settings label { text-align: right; }
#settings .note { text-align: start; background: rgba(255, 214, 10, 0.12); border-radius: 10px; padding: 8px 10px; }

:root {
  --bg: #14093c;
  --card: rgba(24, 14, 70, 0.92);
  --text: #ffffff;
  --muted: #c9c3ff;
  --accent: #06d6a0;
  --accent-text: #08263a;
  --line: rgba(255, 255, 255, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Baloo 2", "Rubik", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#cam {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror: kids move right, they move right on screen */
}

#stage {
  position: fixed;
  inset: 0;
}

/* Grown-up controls along the top. Mute is always visible; the rest depend on the state. */
#topbar {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  z-index: 30; /* above the start screen and menus, so mute always works */
}
.tb {
  display: grid;
  place-items: center;
  padding: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(20, 10, 60, 0.55);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.7);
  cursor: pointer;
}
/* Phone screen mirrored to the TV is only ~360px tall: keep the buttons small and see-through there */
@media (max-height: 500px) {
  #topbar { top: 4px; gap: 10px; }
  .tb { width: 42px; height: 42px; opacity: 0.8; }
  .tb svg { width: 20px; height: 20px; }
}
#mute .off { display: none; }
body.muted #mute .on { display: none; }
body.muted #mute .off { display: block; }
body.muted #mute { background: #c9184a; border-color: #ffccd5; }
#stop { background: rgba(160, 20, 50, 0.6); }

#pause, #stop { display: none; }
body[data-state="play"] #pause,
body[data-state="countdown"] #pause { display: grid; }
body:not([data-state="off"]):not([data-state=""]) #stop { display: grid; }
body[data-state="play"] #gear,
body[data-state="countdown"] #gear,
body[data-state="paused"] #gear { display: none; }

/* "All done" buttons (calm mode): only a tap on the phone starts another round */
#done-menu {
  position: fixed;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  display: none;
  gap: 16px;
  z-index: 8;
}
body[data-state="done"] #done-menu { display: flex; }
#done-menu button { font-size: 26px; padding: 12px 36px; }
#done-menu .secondary { background: rgba(20, 10, 60, 0.7); }

#pause-menu .big { font-size: 34px; padding: 14px 64px; margin: 8px 0 16px; }
#pause-menu .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#pause-menu .grid button { font-size: 18px; padding: 12px 10px; }

#gate, #settings, #pause-menu {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 50% 30%, #3a0ca3, var(--bg));
}
#settings { background: rgba(10, 5, 30, 0.6); z-index: 20; }
#pause-menu { background: rgba(10, 5, 30, 0.55); z-index: 10; }
#gate[hidden], #settings[hidden], #pause-menu[hidden] { display: none; }

.card {
  width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
}
.card h1 { margin: 0 0 8px; font-size: 40px; line-height: 1.1; }
.card h2 { margin: 0 0 12px; font-size: 28px; }
.card p { color: var(--muted); margin: 8px 0; line-height: 1.4; }
.card .small { font-size: 15px; min-height: 1.4em; }

button {
  font: inherit;
  font-weight: 800;
  font-size: 22px;
  border: 0;
  border-radius: 999px;
  padding: 10px 32px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
button:disabled { opacity: 0.6; }
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); font-size: 16px; }
#gate-btn { font-size: 30px; padding: 14px 56px; margin-top: 12px; }

#settings label {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 4px;
  margin: 10px 0;
  font-weight: 600;
}
#settings label.check { flex-direction: row; align-items: center; gap: 10px; }
#settings select {
  font: inherit;
  font-size: 16px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #241a5c;
  color: var(--text);
  width: 100%;
}
#settings input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.row { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
