:root {
  --bg1: #6d5bd0;
  --bg2: #b06ab3;
  --card: #ffffff;
  --ink: #241b46;
  --muted: #6b6390;
  --accent: #ff8a3d;
  --accent-dark: #ef6d19;
  --good: #1fae74;
  --bad: #e9557a;
  --line: #e8e4f5;
  --radius: 22px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: Fredoka, "Trebuchet MS", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
}

.screen { display: none; min-height: 100dvh; padding: 20px 16px 32px; }
.screen.active { display: flex; align-items: center; justify-content: center; }

.card {
  width: min(680px, 100%);
  background: var(--card);
  border-radius: var(--radius);
  padding: 26px 22px;
  box-shadow: 0 18px 50px rgba(30, 12, 60, .28);
}
.card.narrow { max-width: 380px; text-align: center; }

h1 { font-size: clamp(1.4rem, 4.5vw, 1.9rem); margin: 0 0 6px; }
.muted { color: var(--muted); margin: 0 0 18px; }
.tiny { font-size: .8rem; margin-top: 14px; }
.big-emoji { font-size: 3rem; line-height: 1; margin-bottom: 6px; }

input[type=text], input[type=password], select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 13px 15px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fbfaff;
  color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--bg1); }
.narrow-field { flex: 0 1 150px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); flex: 1 1 220px; }
label em { font-style: normal; opacity: .7; }
.row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }

.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 6px 0 var(--accent-dark); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:disabled { background: #c9c4dd; box-shadow: 0 6px 0 #b0aac8; cursor: default; }
.btn.ghost { background: #f2effb; color: var(--muted); }
.btn.big { width: 100%; font-size: 1.1rem; padding: 16px; }
.btn.tiny-btn { padding: 8px 12px; font-size: .85rem; }

#gate-form { display: flex; flex-direction: column; gap: 12px; }

/* pitanja */
.q-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.q-num {
  flex: 0 0 30px; height: 30px; border-radius: 50%;
  background: var(--bg1); color: #fff;
  display: grid; place-items: center; font-size: .85rem; font-weight: 600;
}
.q-row .fields { flex: 1; display: flex; gap: 8px; flex-wrap: wrap; }
.q-row .fields input { flex: 1 1 180px; }
.q-del {
  flex: 0 0 34px; height: 34px; border: none; border-radius: 10px;
  background: #fdeef2; color: var(--bad); font-size: 1.1rem; cursor: pointer;
}
.actions { margin-top: 20px; }
#add-q { margin-top: 6px; }

.error { color: var(--bad); font-weight: 600; margin: 12px 0 0; }
.warn { background: #fff6ec; color: #8a5a2b; font-size: .82rem; line-height: 1.5; padding: 10px 12px; border-radius: 12px; margin: 10px 0 0; }

.voice-box { margin-top: 18px; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.voice-box summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.voice-box[open] summary { margin-bottom: 12px; }
.voice-box .row { margin-bottom: 10px; }
.voice-box b { color: var(--ink); }
input[type=range] { accent-color: var(--bg1); padding: 0; }

/* igra */
.game-wrap {
  width: min(640px, 100%);
  min-height: 100dvh;
  display: flex; flex-direction: column; gap: 14px;
  padding-block: 8px;
}
.game-head { display: flex; align-items: center; gap: 12px; }
.progress { display: flex; gap: 6px; flex-wrap: wrap; }
.dot { width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,.3); }
.dot.done { background: #ffd75e; }
.dot.now { background: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.25); }

.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }

.bubble {
  background: #fff; border-radius: 20px; padding: 18px 20px;
  font-size: clamp(1.05rem, 3.6vw, 1.3rem); line-height: 1.45;
  box-shadow: 0 12px 34px rgba(30, 12, 60, .25);
  max-width: 100%;
}
.bubble.narrator { min-height: 3em; display: flex; align-items: center; justify-content: center; }
.bubble.kid { background: #2c2350; color: #fff; font-size: 1rem; padding: 10px 16px; }

.mic {
  position: relative;
  width: 118px; height: 118px; border-radius: 50%;
  border: none; cursor: pointer;
  background: #fff;
  display: grid; place-items: center;
  box-shadow: 0 12px 30px rgba(30, 12, 60, .3);
  transition: transform .12s ease;
}
.mic-icon { font-size: 3rem; }
.mic-ring {
  position: absolute; inset: -10px; border-radius: 50%;
  border: 5px solid rgba(255,255,255,.5);
  transform: scale(var(--level, 1));
  transition: transform .1s linear, opacity .2s;
  opacity: 0;
}
.mic.listening { background: #fff6ec; }
.mic.listening .mic-ring { opacity: 1; }
.mic.talking { transform: scale(.94); opacity: .75; }

.status { color: #fff; font-size: 1.05rem; font-weight: 500; margin: 0; min-height: 1.4em; text-shadow: 0 2px 8px rgba(0,0,0,.2); }

.verdict { font-size: 2.6rem; }
.verdict.good { animation: pop .45s ease; }
.verdict.bad { animation: shake .4s ease; }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-9px); } 75% { transform: translateX(9px); } }

.game-foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.typed { flex: 1 1 220px; display: flex; gap: 8px; }
.typed input { flex: 1; padding: 10px 14px; font-size: .95rem; }
.note { color: #ffe7c9; font-size: .85rem; text-align: center; margin: 0; }

.confetti {
  position: fixed; top: -20px; width: 12px; height: 12px; border-radius: 3px;
  pointer-events: none; animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(105dvh) rotate(720deg); opacity: .9; } }

@media (max-width: 420px) {
  .card { padding: 20px 16px; }
  .mic { width: 104px; height: 104px; }
}
