:root {
  --teal: #00aec7;
  --orange: #f89406;
  --navy: #011627;
  --sand: #e8c98a;
  --sand-deep: #c4a05a;
  --ink: #1a2430;
  --glass: rgba(255, 255, 255, 0.88);
  font-family: "Outfit", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--navy); color: var(--ink); }
canvas#c { display: block; width: 100%; height: 100%; touch-action: none; }

.splash {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.5rem;
  background:
    radial-gradient(120% 80% at 20% 0%, rgba(0, 174, 199, 0.35), transparent 55%),
    radial-gradient(100% 70% at 90% 100%, rgba(248, 148, 6, 0.4), transparent 50%),
    linear-gradient(165deg, #043047 0%, #011627 55%, #1a1208 100%);
}

/* Author display:flex beats the UA [hidden] rule — without this, login never leaves. */
.splash[hidden],
.hud[hidden],
.gov-box[hidden],
.feat-box[hidden],
.impulse-box[hidden],
.bubble[hidden],
.login-card [hidden],
.error[hidden],
.admin-link[hidden] {
  display: none !important;
}

.splash-logo {
  width: min(420px, 88vw);
  height: auto;
  filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.35));
  animation: floatIn 0.9s ease-out both;
}

.tagline {
  margin: 0 0 1rem;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.04em;
  font-weight: 400;
  animation: floatIn 1s 0.1s ease-out both;
}

.login-card {
  width: min(360px, 92vw);
  padding: 1.1rem 1.2rem 1.25rem;
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  display: grid;
  gap: 0.75rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  animation: floatIn 1.05s 0.15s ease-out both;
}

.login-card label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
}

.login-card select,
.login-card input {
  font: inherit;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  border: 1.5px solid rgba(1, 22, 39, 0.15);
  background: #fff;
}

#enterBtn {
  margin-top: 0.25rem;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1rem;
  font: inherit;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--teal), #0891a8 45%, var(--orange));
}

#enterBtn:active { transform: scale(0.98); }
.error { color: #b42318; margin: 0; font-size: 0.85rem; }

.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud > * { pointer-events: auto; }

.topbar {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 0.75rem;
  right: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.hud-icon { width: 36px; height: 36px; border-radius: 9px; }
.muted { color: #5b6b7c; font-weight: 400; font-size: 0.9rem; }

#claimBtn {
  margin-left: auto;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--orange);
  cursor: pointer;
}

.bubble {
  position: absolute;
  left: 50%;
  bottom: 7.5rem;
  transform: translateX(-50%);
  width: min(520px, 92vw);
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: rgba(1, 22, 39, 0.88);
  color: #f4fbff;
  line-height: 1.35;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(0, 174, 199, 0.45);
}

.tikki-transcript {
  position: absolute;
  left: 12px;
  top: 4.5rem;
  z-index: 14;
  width: min(320px, calc(100vw - 24px));
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  background: rgba(1, 22, 39, 0.9);
  border: 1px solid rgba(248, 148, 6, 0.45);
  color: #f4fbff;
  font-size: 0.88rem;
  line-height: 1.35;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}
.tikki-transcript strong {
  color: #f89406;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tikki-asked { margin: 0.35rem 0 0; }
.tikki-child { margin: 0.45rem 0 0; color: #9fe7f2; }
.tikki-child::before { content: "Du: "; color: #7ec8d4; font-weight: 600; }
.tikki-routed { margin: 0.4rem 0 0; font-size: 0.78rem; opacity: 0.85; }
.tikki-transcript.mini {
  position: static;
  width: auto;
  margin: 0.5rem 0;
  box-shadow: none;
}

.lang-toggle {
  display: inline-flex;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(1, 22, 39, 0.15);
  background: rgba(1, 22, 39, 0.06);
}
.lang-btn {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  color: #011627;
  min-width: 2.4rem;
}
.lang-btn.active {
  background: linear-gradient(135deg, #00aec7, #0d7a8a);
  color: #fff;
}
.idea-voice-hint {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: #9bb4c4;
  line-height: 1.3;
}
.admin-voice-btn.pulse-invite {
  animation: invitePulse 1.2s ease-in-out infinite;
  box-shadow: 0 0 0 3px rgba(248, 148, 6, 0.45);
}
@keyframes invitePulse {
  50% { transform: scale(1.04); box-shadow: 0 0 0 8px rgba(248, 148, 6, 0.12); }
}
body.kid-play .kid-text-hidden textarea,
body.kid-play .kid-text-hidden #ideaBtn {
  display: none !important;
}

.dock {
  position: absolute;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}

.mic {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.1rem;
  font: inherit;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--teal), var(--orange));
}

.mic.listening {
  animation: pulse 1.2s ease-in-out infinite;
  background: #1a7f4b;
}

.mic-indicator {
  position: absolute;
  left: 50%;
  bottom: 5.6rem;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #05321c;
  background: #b8ffd4;
  z-index: 12;
  pointer-events: none;
}

.live-transcript {
  position: absolute;
  left: 50%;
  bottom: 7.2rem;
  transform: translateX(-50%);
  margin: 0;
  max-width: min(92vw, 420px);
  padding: 0.45rem 0.85rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  color: #102418;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 12;
  pointer-events: none;
}
.live-transcript.interim {
  color: #3a5548;
  font-weight: 500;
}

.mic-help {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%);
  width: min(400px, 94vw);
  padding: 1.1rem 1.15rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  z-index: 30;
  text-align: center;
}
.mic-help p { margin: 0.5rem 0 0.75rem; font-size: 0.9rem; line-height: 1.35; }
.mic-help-steps {
  text-align: left;
  margin: 0.4rem 0 0.9rem;
  padding-left: 1.2rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #234;
}
.mic-allow-btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 0.95rem 1rem;
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #0a7a4a, #e07020);
  margin-bottom: 0.55rem;
}
.https-jump {
  display: inline-block;
  margin-top: 0.35rem;
  font-weight: 800;
  font-size: 1.05rem;
  color: #0a5c6b;
  word-break: break-all;
}
.insecure-banner {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translateX(-50%);
  width: min(440px, 94vw);
  padding: 1rem 1.1rem;
  border-radius: 16px;
  background: #fff4e8;
  border: 2px solid #e07020;
  z-index: 28;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}
.insecure-banner p { margin: 0.4rem 0; font-size: 0.88rem; line-height: 1.35; }
.insecure-alt { font-size: 0.78rem !important; color: #445; }
.insecure-alt a { color: #0a5c6b; font-weight: 700; }

.admin-voice-btn, .control-review-btn {
  position: absolute;
  right: max(0.75rem, env(safe-area-inset-right));
  z-index: 14;
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.75rem;
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
}
.admin-voice-btn {
  bottom: max(1rem, env(safe-area-inset-bottom));
  background: #011627;
}
.control-review-btn {
  bottom: 3.6rem;
  background: #0a5c6b;
}
.admin-voice-panel {
  position: absolute;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: 4.5rem;
  width: min(300px, 92vw);
  padding: 0.85rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
  z-index: 15;
  pointer-events: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}
.admin-voice-panel h3 { margin: 0 0 0.35rem; font-size: 0.9rem; }
.admin-hint { margin: 0 0 0.55rem; font-size: 0.75rem; color: #445; line-height: 1.35; }
.bug-report-box {
  margin: 0.75rem 0;
  padding: 0.65rem 0.7rem;
  border-radius: 12px;
  background: rgba(248, 148, 6, 0.12);
  border: 1px solid rgba(248, 148, 6, 0.45);
  text-align: left;
}
.bug-report-box strong {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
  color: #9a4a00;
}
.bug-report-box textarea {
  width: 100%;
  font: inherit;
  font-size: 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(1, 22, 39, 0.15);
  padding: 0.45rem 0.55rem;
  resize: vertical;
  min-height: 3.2rem;
}
.bug-report-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.45rem;
}
.bug-report-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  max-height: 140px;
  overflow: auto;
  font-size: 0.72rem;
  line-height: 1.35;
}
.bug-report-list li {
  padding: 0.35rem 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.bug-report-list button {
  margin-left: 0.25rem;
  font-size: 0.68rem;
}
.admin-status { font-size: 0.75rem; min-height: 1.2em; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.voice-picker select { max-width: min(42vw, 180px); }

.mic-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
}

#voiceSelect, #stopTalkBtn {
  font: inherit;
  border-radius: 999px;
  border: 1px solid rgba(1, 22, 39, 0.12);
  padding: 0.55rem 0.7rem;
  background: #fff;
  max-width: 140px;
}

#stopTalkBtn { cursor: pointer; }

.login-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.15rem;
}
.login-tabs .tab {
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem;
  font: inherit;
  font-weight: 600;
  background: rgba(1, 22, 39, 0.08);
  color: var(--navy);
  cursor: pointer;
}
.login-tabs .tab.active {
  background: linear-gradient(135deg, var(--teal), var(--orange));
  color: #fff;
}

.admin-link {
  margin-left: auto;
  margin-right: 0.4rem;
  color: var(--teal);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.85rem;
}

.stats-panel {
  position: absolute;
  top: calc(max(0.75rem, env(safe-area-inset-top)) + 4.2rem);
  right: 0.75rem;
  width: min(260px, 42vw);
  max-height: calc(100vh - 11rem);
  overflow: auto;
  padding: 0.85rem 0.9rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
}
.stats-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.panel-toggle {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}
.stats-panel.collapsed {
  width: auto;
  max-height: none;
  padding: 0.55rem 0.65rem;
}
.stats-panel.collapsed .stats-panel-head { margin: 0; }
.stats-panel.collapsed .stats-panel-body { display: none; }
.stats-panel-body { margin-top: 0.5rem; }
.stats-panel h2, .stats-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--navy);
}
.stats-panel h3 { margin-top: 0.75rem; font-size: 0.85rem; color: var(--teal); }
.stats-panel dl {
  margin: 0;
  display: grid;
  gap: 0.35rem;
}
.stats-panel dl > div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
}
.stats-panel dt { color: #5b6b7c; }
.stats-panel dd { margin: 0; font-weight: 700; }
.ref-line { font-size: 0.72rem; color: #5b6b7c; margin: 0.6rem 0; word-break: break-all; }
.ref-line code { color: var(--navy); font-weight: 700; }
.mini {
  border: 0;
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--teal);
  color: #fff;
}
.mini.yes { background: #1a7f4b; }
.mini.no { background: #b42318; }
.idea-box, .gov-box, .feat-box, .impulse-box {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(1, 22, 39, 0.08);
}
.idea-box label { font-size: 0.75rem; font-weight: 700; display: block; margin-bottom: 0.25rem; }
.avatar-tip { margin: 0 0 0.4rem; font-size: 0.7rem; line-height: 1.35; color: #556; }
.avatar-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.avatar-preview {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--teal);
  background: #eee;
}
.avatar-box input[type="file"] { font-size: 0.7rem; max-width: 100%; }
.avatar-status { margin: 0.35rem 0 0; font-size: 0.7rem; color: #1a7f4b; }
.idea-box textarea {
  width: 100%;
  font: inherit;
  font-size: 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(1, 22, 39, 0.15);
  padding: 0.4rem;
  resize: vertical;
}
.gov-box p, .feat-box p, .impulse-box p { margin: 0 0 0.4rem; font-size: 0.75rem; line-height: 1.35; color: #334; }
.impulse-box h3, .feat-box h3, .gov-box h3 {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  color: #011627;
}
.impulse-theme { font-weight: 600; color: #00AEC7 !important; }
.impulse-box ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.72rem;
  line-height: 1.4;
  color: #334;
}
.impulse-box li { margin-bottom: 0.25rem; }
.gov-actions { display: flex; gap: 0.35rem; }

.status {
  position: absolute;
  left: 50%;
  bottom: 5.2rem;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #fff;
  background: rgba(1, 22, 39, 0.45);
  pointer-events: none;
  max-width: 92vw;
  text-align: center;
}

.vision-cue {
  position: absolute;
  left: 50%;
  top: 4.6rem;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #011627;
  background: linear-gradient(120deg, #00aec7 0%, #f89406 100%);
  box-shadow: 0 4px 14px rgba(1, 22, 39, 0.22);
  pointer-events: none;
  animation: visionCueIn 0.45s ease-out both;
  z-index: 12;
}
.vision-cue[hidden] { display: none !important; }

@keyframes visionCueIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 174, 199, 0.5); }
  50% { box-shadow: 0 0 0 12px rgba(248, 148, 6, 0); }
}

@media (max-width: 720px) {
  .stats-panel {
    width: min(200px, 46vw);
    font-size: 0.9rem;
    top: auto;
    bottom: 7.5rem;
    max-height: 38vh;
  }
  #voiceSelect { max-width: 96px; font-size: 0.75rem; }
}

@media (max-width: 520px) {
  .stats-panel { display: none; } /* keep mobile uncluttered; topbar still shows JASMA/land */
  #voiceSelect { max-width: 96px; font-size: 0.75rem; }
}
