:root {
  --night: #0a0f24;
  --night-2: #141b3d;
  --ink: #f4efe4;
  --muted: #b9b6c9;
  --gold: #e0ad4f;
  --gold-deep: #b5822a;
  --danger: #ff8a65;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* Noćno nebo — Galilejev teleskop */
.sky {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(1px 1px at 12% 18%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 12%, #fff8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 64% 30%, #fffc 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 8%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 40%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 6% 44%, #fffa 50%, transparent 51%),
    radial-gradient(1px 1px at 46% 22%, #fff5 50%, transparent 51%),
    radial-gradient(ellipse at 50% 120%, #2a2a5e 0%, transparent 60%),
    radial-gradient(ellipse at 50% -20%, var(--night-2) 0%, var(--night) 70%);
}

.stage { position: fixed; inset: 0; z-index: 1; }
body.mode-simli .stage { display: none; }

/* Robot Gordan */
.robot-wrap {
  position: absolute; inset: 0; display: flex; justify-content: center; align-items: flex-start;
  padding-top: max(64px, calc(env(safe-area-inset-top, 0px) + 56px));
}
.robot { width: min(86vw, 52vh); height: auto; overflow: visible; }
.r-bob { animation: r-bob 3.2s ease-in-out infinite; transform-origin: 200px 300px; }
.robot.speaking .r-bob { animation-duration: 1.6s; }
@keyframes r-bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-6px) rotate(.6deg); } }
.r-antenna { transition: fill .2s; }
.robot.speaking .r-antenna { filter: drop-shadow(0 0 8px #ff8a5c); }
.r-led1 { animation: r-led 1.4s steps(2) infinite; }
.r-led2 { animation: r-led 1.4s steps(2) .7s infinite; }
@keyframes r-led { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .r-bob, .r-led1, .r-led2 { animation: none; } }

/* Simli video lice: puni zaslon, pojavljuje se kad stigne prva slika */
.video {
  position: fixed; inset: 0; z-index: 1; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 30%;
  opacity: 0; transition: opacity .6s; background: transparent;
}
body.video-on .video { opacity: 1; }
.stage canvas { display: block; }

.topbar {
  position: fixed; z-index: 2; left: 0; right: 0; top: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  font-size: 13px; letter-spacing: .02em; color: var(--muted);
  background: linear-gradient(var(--night) 0%, transparent 100%);
}
.festival { font-family: var(--serif); font-style: italic; }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink);
  padding: 4px 10px; border-radius: 999px; border: 1px solid #ffffff33; background: #0a0f2499;
}
.timer.low { color: var(--danger); border-color: var(--danger); }

/* Kontrole na dnu */
.controls {
  position: fixed; z-index: 2; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 40px 16px calc(20px + var(--safe-b));
  background: linear-gradient(transparent 0%, #0a0f24e6 35%, var(--night) 100%);
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
body.live .controls { opacity: 1; pointer-events: auto; }

.caption {
  margin: 0; max-width: 560px; width: 100%;
  font-family: var(--serif); font-size: 18px; line-height: 1.4; text-align: center;
  text-shadow: 0 1px 8px #000;
}
.status { margin: 0; font-size: 14px; color: var(--muted); min-height: 1.4em; text-align: center; }

.talk {
  width: 92px; height: 92px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #f5cd7d, var(--gold) 45%, var(--gold-deep));
  box-shadow: 0 0 0 6px #e0ad4f26, 0 8px 24px #0008;
  display: grid; place-items: center;
  touch-action: none; transition: transform .12s, box-shadow .2s;
}
.talk svg { width: 40px; height: 40px; fill: var(--night); }
.talk.active {
  transform: scale(1.08);
  box-shadow: 0 0 0 10px #e0ad4f40, 0 0 0 22px #e0ad4f1a, 0 8px 24px #0008;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 14px #e0ad4f33, 0 0 0 30px #e0ad4f10, 0 8px 24px #0008; } }
.talk:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
.talk-label { font-size: 13px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

/* Uvodni i završni zaslon */
.sheet {
  position: fixed; inset: 0; z-index: 3;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px 16px calc(16px + var(--safe-b));
  background: linear-gradient(transparent 20%, #0a0f24cc 55%, var(--night) 100%);
}
.sheet[hidden] { display: none; }
.card { width: 100%; max-width: 440px; text-align: center; }
.eyebrow { margin: 0 0 6px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
h1, h2 { margin: 0 0 10px; font-family: var(--serif); font-weight: 600; line-height: 1.1; }
h1 { font-size: clamp(30px, 9vw, 40px); }
h2 { font-size: 28px; }
.lead { margin: 0 0 14px; font-size: 16px; line-height: 1.5; color: var(--ink); }
.hints {
  list-style: none; margin: 0 0 16px; padding: 12px 14px; text-align: left;
  font-size: 14px; line-height: 1.5; color: var(--muted);
  border: 1px solid #ffffff1f; border-radius: 12px; background: #ffffff08;
}
.hints li + li { margin-top: 4px; }
.hints b { color: var(--ink); font-weight: 600; }

.progress { height: 3px; border-radius: 3px; background: #ffffff1a; margin: 0 0 12px; overflow: hidden; }
.progress[hidden] { display: none; }
.progress-bar { height: 100%; width: 0; background: var(--gold); transition: width .2s; }

.primary {
  width: 100%; padding: 16px; border: 0; border-radius: 12px; cursor: pointer;
  font: 600 17px var(--sans); color: var(--night); background: var(--gold);
}
.primary:disabled { opacity: .55; cursor: default; }
.primary:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.notice { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { .talk.active { animation: none; } }

/* Bez mikrofona: polje za upis pitanja umjesto gumba */
.ask { display: none; width: 100%; max-width: 560px; gap: 8px; }
body.no-mic .ask { display: flex; }
body.no-mic .talk, body.no-mic .talk-label { display: none; }
.ask input {
  flex: 1; min-width: 0; padding: 14px; border-radius: 12px; border: 1px solid #ffffff33;
  background: #0a0f24cc; color: var(--ink); font: 16px var(--sans);
  -webkit-user-select: text; user-select: text;
}
.ask input:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.ask .ask-send { width: auto; padding: 14px 18px; }

/* Široki ekran / projektor: veći titlovi i kontrole, video bez rezanja */
@media (orientation: landscape) and (min-width: 900px) {
  .video { object-fit: contain; object-position: 50% 50%; }
  .caption { max-width: 1100px; font-size: clamp(24px, 2.6vw, 40px); }
  .status { font-size: 18px; }
  .controls { padding-bottom: 28px; background: linear-gradient(transparent 0%, #0a0f24b3 40%, #0a0f24e6 100%); }
  .ask { max-width: 900px; }
  .ask input { font-size: 20px; }
}

@media (orientation: landscape) and (min-width: 900px) {
  .robot { width: auto; height: 62vh; }
}

/* Živi logo festivala */
body.logo-on { background: #13294b; }
body.logo-on .sky { display: none; }
.logo-wrap {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding-top: max(52px, calc(env(safe-area-inset-top, 0px) + 44px));
}
.logo-canvas { width: min(100vw, 46vh); height: min(100vw, 46vh); flex: none; }
.logo-title {
  margin-top: 4px; text-align: center; color: #fff;
  font: 900 clamp(22px, 6.6vw, 34px)/1.02 "Arial Black", "Helvetica Neue", Arial, sans-serif; letter-spacing: .5px;
}
.logo-slogan { margin-top: 10px; color: #e2452b; font: 700 13px system-ui, sans-serif; letter-spacing: .22em; text-transform: uppercase; }
body.logo-on.live .logo-title { font-size: clamp(16px, 4.6vw, 24px); }
body.logo-on .controls { background: linear-gradient(transparent 0%, #13294be6 35%, #13294b 100%); }
body.logo-on .sheet { background: linear-gradient(transparent 30%, #13294bdd 55%, #13294b 100%); }
@media (orientation: landscape) and (min-width: 900px) {
  .logo-canvas { width: 50vh; height: 50vh; }
}
/* Logo način: naslov ispod logotipa samo tijekom razgovora; naglasci u narančastoj boji plakata */
body.logo-on:not(.live) .logo-title, body.logo-on:not(.live) .logo-slogan { opacity: 0; }
body.logo-on .eyebrow { color: #ff8a5c; }
body.logo-on .primary { background: #e2452b; color: #fff; }
body.logo-on .progress-bar { background: #e2452b; }
body.logo-on .talk { background: radial-gradient(circle at 35% 30%, #ff9a72, #e2452b 50%, #b5301c); box-shadow: 0 0 0 6px #e2452b26, 0 8px 24px #0008; }
body.logo-on .talk svg { fill: #fff; }
body.logo-on .talk.active { box-shadow: 0 0 0 10px #e2452b40, 0 0 0 22px #e2452b1a, 0 8px 24px #0008; }

/* Što je lik čuo od posjetitelja */
.caption.heard { font-family: var(--sans); font-style: italic; font-size: 16px; color: var(--muted); }

/* Mobitel uspravno: tijekom razgovora sakrij natpis ispod logotipa da se ne preklapa s titlom */
@media (orientation: portrait), (max-width: 899px) {
  body.logo-on.live .logo-title, body.logo-on.live .logo-slogan { display: none; }
}

/* Naslov festivala na sredini, ispod brojača i iznad kugle */
.festival {
  position: absolute; left: 16px; right: 16px; top: calc(52px + var(--safe-t));
  text-align: center; font-size: 16px; line-height: 1.35; color: #fff; opacity: .9; white-space: pre-line;
}
.topbar { justify-content: flex-end; min-height: 48px; }
body.logo-on .logo-wrap { padding-top: max(84px, calc(env(safe-area-inset-top, 0px) + 80px)); }

/* Autor, sitno u gornjem lijevom kutu */
.credit {
  position: fixed; z-index: 4; left: 14px; top: calc(16px + var(--safe-t));
  font: 11px var(--sans); color: #ffffff80; letter-spacing: .02em; pointer-events: none;
}

/* Izbor jezika HR / ITA */
.lang {
  position: fixed; z-index: 5; right: 14px; top: calc(10px + var(--safe-t));
  display: inline-flex; border: 1px solid #ffffff40; border-radius: 999px; overflow: hidden; background: #0a0f24b3;
}
.lang button {
  border: 0; padding: 8px 18px; cursor: pointer; background: transparent; color: var(--ink);
  font: 600 14px var(--sans); letter-spacing: .06em;
}
.lang button[aria-pressed="true"] { background: #e2452b; color: #fff; }
.lang button:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.link { margin-top: 10px; border: 0; background: none; color: var(--muted); font: 14px var(--sans); text-decoration: underline; cursor: pointer; padding: 8px; }

/* Brojač vremena samo tijekom razgovora; prekidač jezika samo izvan razgovora — nikad zajedno */
body:not(.live) .timer { display: none !important; }
body.live .lang { display: none; }

/* Naslov festivala: uspravno, veće, Montserrat */
.festival { font-family: "Montserrat", var(--sans); font-style: normal; white-space: normal; opacity: 1; }
.fest-name {
  display: block; font-weight: 800; text-transform: uppercase; color: #fff;
  font-size: clamp(15px, 4.6vw, 24px); letter-spacing: .06em; line-height: 1.2;
}
.fest-place { display: block; margin-top: 4px; font-weight: 500; color: #ff8a5c; font-size: clamp(13px, 3.8vw, 18px); letter-spacing: .12em; }

/* Potpis u donjem lijevom kutu */
.credit { top: auto; bottom: calc(6px + var(--safe-b)); left: 12px; font-size: 10px; }
.sheet { padding-bottom: calc(26px + var(--safe-b)); }
.controls { padding-bottom: calc(24px + var(--safe-b)); }
.festival { top: calc(84px + var(--safe-t)); }
/* Potpis na sredini dna, 1 px veći */
.credit { left: 0; right: 0; text-align: center; font-size: 11px; }

/* ═══ Lik s plakata: dijete i robot (Oleg Morović) ═══ */
body.poster-on { background: #003457; }
body.poster-on .topbar { background: linear-gradient(#003457 0%, transparent 100%); }
body.poster-on .controls { background: linear-gradient(transparent 0%, #003457e6 30%, #003457 100%); }
body.poster-on .sheet { background: linear-gradient(transparent 38%, #003457e0 52%, #003457 100%); }
body.poster-on .lang { background: #00213a99; }
body.poster-on .lang button[aria-pressed="true"], body.poster-on .primary { background: #e2311d; color: #fff; }

.poster-wrap { position: absolute; inset: 0; display: flex; justify-content: center; padding-top: calc(150px + var(--safe-t)); }
.poster-stage { --s: min(56vw, 30vh); --lvl: 0; --mix: 0; position: relative; width: var(--s); height: var(--s); flex: none; }
.poster-photo {
  position: absolute; inset: 0; border-radius: 50%;
  background: #ddd url(img/dijete-robot.jpg) center / cover;
  filter: sepia(calc(var(--mix) * .35)) saturate(calc(1 + var(--mix) * .6)) brightness(calc(1 + var(--mix) * .06 + var(--lvl) * .12));
  box-shadow: 0 0 calc(var(--mix) * 46px) calc(var(--mix) * 10px) #ff8a5c99, 0 0 0 calc(var(--mix) * 5px) #ff8a5c;
}
.poster-photo::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; mix-blend-mode: screen;
  background: radial-gradient(circle at 68% 32%, #ffd9a8 0%, #ff8a5c88 24%, transparent 58%);
  opacity: calc(var(--mix) * (.55 + var(--lvl) * .6));
}
/* crveni krug s natpisom — točno preko kruga s plakata */
.poster-badge {
  position: absolute; z-index: 2; left: -13.8%; top: -7.4%; width: 46%; height: 46%; border-radius: 50%;
  background: #e2311d; color: #003457; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: 800 calc(var(--s) * .062)/1.05 "Montserrat", var(--sans); letter-spacing: .01em;
}
.pb-wave { width: 58%; height: calc(var(--s) * .07); margin-top: 5%; overflow: visible; }
.pb-wave polyline { stroke: #003457; stroke-width: 2.4; }
/* sluša: crveni prsten */
.poster-ring { position: absolute; inset: -6%; border-radius: 50%; border: 4px solid #e2311d; opacity: 0; transition: opacity .2s; }
.poster-stage[data-state="listening"] .poster-ring { opacity: 1; animation: pr-pulse 1s ease-in-out infinite; }
@keyframes pr-pulse { 50% { transform: scale(1.03); } }
/* razmišlja: isprekidani prsten kruži */
.poster-stage[data-state="thinking"] .poster-ring { opacity: .85; border: 4px dashed #ffffffcc; animation: pr-spin 2.4s linear infinite; }
@keyframes pr-spin { to { transform: rotate(360deg); } }
/* govori: valovi */
.poster-rings { position: absolute; inset: -4%; border-radius: 50%; opacity: var(--mix); pointer-events: none;
  box-shadow: 0 0 0 calc(4px + var(--lvl) * 14px) #ff8a5c33, 0 0 0 calc(18px + var(--lvl) * 30px) #ff8a5c1a, 0 0 0 calc(34px + var(--lvl) * 46px) #ff8a5c0d; }
@media (prefers-reduced-motion: reduce) { .poster-ring { animation: none !important; } }

/* Uvodni zaslon u stilu plakata */
body.poster-on .card { text-align: left; }
body.poster-on .eyebrow { font: 800 18px "Montserrat", var(--sans); color: #e2311d; letter-spacing: .01em; text-transform: uppercase; margin-bottom: 4px; }
body.poster-on h1 { font: 900 clamp(26px, 8vw, 34px)/1.02 "Montserrat", var(--sans); text-transform: uppercase; }
body.poster-on h2 { font-family: "Montserrat", var(--sans); font-weight: 800; }
body.poster-on .lead { font-family: "Montserrat", var(--sans); font-size: 15px; }
body.poster-on .hints { font-family: "Montserrat", var(--sans); font-size: 13px; }
body.poster-on .notice, body.poster-on .card .link { text-align: center; }
body.poster-on #end .card { text-align: center; }
body.poster-on .caption { font-family: "Montserrat", var(--sans); font-weight: 500; font-size: 17px; }
body.poster-on .caption.heard { font-style: italic; font-size: 15px; }
@media (orientation: landscape) and (min-width: 900px) {
  .poster-stage { --s: 40vh; }
  body.poster-on .caption { font-size: clamp(22px, 2.4vw, 36px); }
}
/* Uvodni zaslon: manji krug i zbijeniji tekst da se ne preklapaju */
body.poster-on .poster-wrap { padding-top: calc(156px + var(--safe-t)); }
body.poster-on:not(.live) .poster-stage { --s: min(48vw, 23vh); }
body.poster-on h1 { font-size: clamp(24px, 7.4vw, 32px); margin-bottom: 8px; }
body.poster-on .lead { font-size: 14px; line-height: 1.45; margin-bottom: 10px; }
body.poster-on .hints { font-size: 12.5px; padding: 9px 12px; margin-bottom: 12px; }
body.poster-on .primary { padding: 14px; }
.poster-stage { transition: width .4s, height .4s; }
/* Niski zasloni (npr. iPhone SE): bez okvira s uputama, manji krug */
@media (max-height: 720px) {
  body.poster-on .poster-wrap { padding-top: calc(140px + var(--safe-t)); }
  body.poster-on:not(.live) .poster-stage { --s: 21vh; }
  body.poster-on .hints { display: none; }
  body.poster-on .lead { font-size: 13.5px; }
}

/* iOS i ostali: prekidač jezika uvijek gore desno (izvan razgovora), naslov više, slika niže */
.lang { position: fixed; z-index: 6; right: 14px; top: calc(10px + var(--safe-t)); }
body.poster-on .festival { top: calc(56px + var(--safe-t)); }
body.poster-on .poster-wrap { padding-top: calc(158px + var(--safe-t)); }
body.poster-on:not(.live) .poster-stage { --s: min(46vw, 21vh); }

/* Računalo / projektor: slika niže i malo manja, titlovi manji da stanu ispod slike */
@media (orientation: landscape) and (min-width: 900px) {
  body.poster-on .poster-wrap { padding-top: calc(15vh + 80px + var(--safe-t)); }
  body.poster-on.live .poster-stage { --s: 32vh; }
  body.poster-on .caption { font-size: clamp(19px, 1.9vw, 30px); max-width: 1000px; }
}
