/* ---------- Page: all black ---------- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #000;
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 24px;
  text-align: center;
}

.title {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.04em;
}

.hint {
  margin: 0;
  color: #888;
}

/* ---------- The 8 ball ---------- */
.ball {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  /* A soft highlight in the top-left makes the black ball look round */
  background: radial-gradient(circle at 35% 30%, #3a3a3a 0%, #111 35%, #000 70%);
  box-shadow: 0 0 0 1px #1c1c1c, 0 20px 60px rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.window {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: #000;
  border: 2px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.answer {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

/* The big "8" shown before the first shake */
.answer.start {
  font-size: 4rem;
}

/* While shaking, answers flicker by in grey */
.answer.flicker {
  color: #777;
}

/* The final answer fades and grows in */
.answer.reveal {
  animation: reveal 0.4s ease-out;
}

@keyframes reveal {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- The shake animation ---------- */
.shaking {
  animation: shake 0.45s ease-in-out infinite;
}

@keyframes shake {
  0%   { transform: translate(0, 0) rotate(0); }
  20%  { transform: translate(-10px, 4px) rotate(-6deg); }
  40%  { transform: translate(9px, -5px) rotate(5deg); }
  60%  { transform: translate(-7px, 3px) rotate(-4deg); }
  80%  { transform: translate(6px, -2px) rotate(3deg); }
  100% { transform: translate(0, 0) rotate(0); }
}

/* ---------- The CTA button ---------- */
.cta {
  min-width: 180px;
  padding: 14px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  background: #000;
  border: 2px solid #fff;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.cta:hover,
.cta:focus-visible {
  background: #fff;
  color: #000;
  outline: none;
}

.cta:disabled {
  cursor: wait;
}

/* ---------- Add to Home Screen button ---------- */
.install {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.9rem;
  color: #aaa;
  background: transparent;
  border: 1px solid #333;
  border-radius: 999px;
  cursor: pointer;
}

.install[hidden] {
  display: none;
}

.install img {
  border-radius: 50%;
}

.install:hover,
.install:focus-visible {
  color: #fff;
  border-color: #fff;
  outline: none;
}

/* ---------- The how-to popup ---------- */
.steps {
  width: min(90vw, 360px);
  padding: 24px;
  color: #fff;
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 16px;
  text-align: left;
}

.steps::backdrop {
  background: rgba(0, 0, 0, 0.8);
}

.steps h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.steps ol {
  margin: 0 0 20px;
  padding-left: 20px;
  line-height: 1.6;
  color: #ccc;
}

.steps .cta {
  display: block;
  width: 100%;
}

/* ---------- Question box + mic ---------- */
.ask {
  display: flex;
  gap: 8px;
  width: min(100%, 340px);
}

.question {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  font: inherit;
  font-size: 1rem; /* 16px+ stops iPhones from zooming in on tap */
  color: #fff;
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 999px;
  outline: none;
}

.question:focus {
  border-color: #fff;
}

.question::placeholder {
  color: #666;
}

.mic {
  flex: none;
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 50%;
  cursor: pointer;
}

.mic[hidden] {
  display: none;
}

.mic:hover,
.mic:focus-visible {
  border-color: #fff;
  outline: none;
}

/* Red pulsing ring while listening */
.mic.listening {
  color: #ff4d4d;
  border-color: #ff4d4d;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(255, 77, 77, 0); }
}

/* ---------- Status, help and small links ---------- */
.status {
  margin: -8px 0 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: #888;
}

.help {
  margin: -8px 0 0;
  max-width: 320px;
  font-size: 0.9rem;
  color: #ccc;
}

.help[hidden],
.error[hidden] {
  display: none;
}

.link {
  padding: 4px 8px;
  font: inherit;
  font-size: 0.85rem;
  color: #888;
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
}

.link:hover,
.link:focus-visible {
  color: #fff;
  outline: none;
}

.dialog-text {
  margin: 0 0 16px;
  color: #ccc;
  line-height: 1.4;
}

#codeForm .question {
  width: 100%;
  margin-bottom: 12px;
}

#codeForm .link {
  display: block;
  margin: 8px auto 0;
}

.error {
  margin: 0 0 12px;
  color: #ff6b6b;
  font-size: 0.9rem;
}

/* Smaller ball on short phone screens so everything fits */
@media (max-height: 760px) {
  .app { gap: 16px; }
  .ball { width: 250px; height: 250px; }
  .window { width: 140px; height: 140px; }
  .title { font-size: 1.6rem; }
}

/* If the computer is set to reduce motion, skip the wobble */
@media (prefers-reduced-motion: reduce) {
  .shaking,
  .answer.reveal {
    animation: none;
  }
}
