/* ============================================================================
   Up and Down! — page shell & overlay UI
   The gameplay is drawn on the PixiJS <canvas>; everything here is the DOM
   "chrome" around it (preloader, mic indicator, therapist settings panel).
   Design language: Sago Mini minimalism — clean, big, contrasty, pastel-juicy.
   ========================================================================== */

:root {
  --bg-a: #ffe1a8;
  --bg-b: #ffb4a2;
  --ink: #3d2b56;
  --accent: #ff5d8f;
  --accent-2: #4ecdc4;
  --panel: #fffdf7;
  --shadow: rgba(61, 43, 86, 0.25);
  --radius: 22px;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: 'Baloo 2', 'Comic Sans MS', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  /* Bright, clean, contrasty pastel backdrop behind the canvas */
  background: radial-gradient(circle at 50% 30%, var(--bg-a), var(--bg-b));
}

#stage,
#stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* -------------------------------- Preloader ------------------------------- */
#preloader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(circle at 50% 40%, var(--bg-a), var(--bg-b));
  z-index: 40;
}

.preloader__spinner {
  width: 64px;
  height: 64px;
  border: 8px solid rgba(255, 255, 255, 0.6);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.preloader__text {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.preloader__bar {
  width: min(60vw, 320px);
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  overflow: hidden;
}

.preloader__bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s ease;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------- Start gate ------------------------------- */
.start-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 20px 40px;
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  box-shadow: 0 12px 0 #d33a6d, 0 18px 30px var(--shadow);
  cursor: pointer;
  z-index: 30;
  animation: pop 0.4s ease;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.start-btn:active {
  transform: translate(-50%, -50%) translateY(8px);
  box-shadow: 0 4px 0 #d33a6d, 0 8px 16px var(--shadow);
}

.start-btn__icon {
  font-size: 1.2em;
}

@keyframes pop {
  from {
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 0;
  }
}

/* ---------------------------- Mic indicator ------------------------------- */
.mic-indicator {
  position: absolute;
  left: 50%;
  bottom: 6%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  box-shadow: 0 8px 20px var(--shadow);
  font-weight: 700;
  z-index: 20;
}

.mic-indicator__dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 0.9s ease-in-out infinite;
}

.mic-indicator__label {
  color: var(--ink);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.7);
    box-shadow: 0 0 0 0 rgba(255, 93, 143, 0.6);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 0 14px rgba(255, 93, 143, 0);
  }
}

/* ------------------------------ Settings gear ----------------------------- */
.settings-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 54px;
  height: 54px;
  font-size: 1.7rem;
  line-height: 1;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 50%;
  box-shadow: 0 6px 16px var(--shadow);
  cursor: pointer;
  z-index: 20;
  transition: transform 0.2s ease;
}

.settings-btn:hover {
  transform: rotate(45deg);
}

/* ----------------------------- Settings panel ----------------------------- */
.settings-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(92vw, 380px);
  background: var(--panel);
  box-shadow: -10px 0 40px var(--shadow);
  z-index: 25;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.25s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
  }
}

.settings-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 2px solid #f0ece2;
}

.settings-panel__header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.settings-panel__body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #f0ece2;
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
  font-size: 1rem;
}

.field__label em {
  font-style: normal;
  color: var(--accent);
  font-weight: 800;
}

.field__hint {
  color: #8a7f97;
  font-size: 0.82rem;
  line-height: 1.3;
}

.field input[type='url'] {
  padding: 12px 14px;
  border: 2px solid #e6e0d4;
  border-radius: 12px;
  font: inherit;
  color: var(--ink);
}

.field input[type='url']:focus {
  outline: none;
  border-color: var(--accent-2);
}

/* Big, chunky, touch-friendly sliders */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: #ece6da;
  cursor: pointer;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  border: 4px solid #fff;
  box-shadow: 0 2px 8px var(--shadow);
}

input[type='range']::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 4px solid #fff;
}

/* Live mic level meter (helps the therapist calibrate the threshold) */
.meter {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: #ece6da;
  overflow: hidden;
}

.meter__fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.06s linear;
}

.settings-panel__actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 14px;
  font: inherit;
  font-weight: 800;
  background: #ece6da;
  color: var(--ink);
  cursor: pointer;
}

.btn--primary {
  background: var(--accent-2);
  color: #06403c;
}

.btn:active {
  transform: translateY(2px);
}
