/* Questionnaire, loading and story player. Mobile first. */
.app { max-width: 680px; margin: 0 auto; padding: 24px 16px calc(48px + env(safe-area-inset-bottom)); }

.quest { display: grid; gap: 20px; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 16px; }
.card h2 { margin: 0 0 16px; font: 400 1.6rem/1.1 var(--font-display); color: var(--lavender); }

.entry { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; display: grid; gap: 12px; }
.entry:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.entry h3 { margin: 0; font: 400 1.2rem/1.2 var(--font-display); color: var(--coral); }

.field { display: grid; gap: 6px; position: relative; border: 0; padding: 0; margin: 0; min-width: 0; }
.field label, .field legend, .field .label { font-size: .875rem; color: var(--muted); padding: 0; }
.input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  font: 16px/1.2 var(--font-body); /* 16px avoids iOS zoom on focus */
}
.input:focus { border-color: var(--lavender); outline: none; }
.input-hours { max-width: 160px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }

.title-row { display: flex; gap: 8px; align-items: center; }
.title-row .input { flex: 1; }
.counter { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }
.counter.over { color: var(--danger); font-weight: 700; }

.field-error { margin: 0; min-height: 0; font-size: .85rem; color: var(--danger); }
.field-error:empty { display: none; }
.hint { margin: 0; font-size: .85rem; color: var(--muted); }
.hint.warn { color: var(--coral); }

.chip-row, .options { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .option { position: relative; cursor: pointer; }
.chip input, .option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span, .option span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: .9rem;
}
.option { flex: 1 1 100%; }
.option span { width: 100%; border-radius: 12px; min-height: 48px; }
.chip input:checked + span, .option input:checked + span { border-color: var(--lime); color: var(--lime); }
.chip input:focus-visible + span, .option input:focus-visible + span { outline: 2px solid var(--lime); outline-offset: 2px; }
.quiz legend { font-size: 1rem; color: var(--text); margin-bottom: 8px; }

.image-row { display: flex; gap: 12px; align-items: flex-start; }
.image-row > div { display: grid; gap: 6px; justify-items: start; }
.thumb { width: 72px; height: 72px; border-radius: 12px; background: var(--surface); border: 1px dashed var(--line); overflow: hidden; flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.btn-link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 4px 0; font: inherit; font-size: .85rem; }

.picker {
  position: absolute; top: calc(100% - 2px); left: 0; right: 0; z-index: 10; list-style: none; margin: 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; max-height: 320px; overflow-y: auto;
  box-shadow: 0 16px 40px rgb(0 0 0 / .5);
}
.picker li { display: flex; gap: 10px; align-items: center; min-height: 44px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.picker li[aria-selected="true"] { background: var(--line); }
@media (hover: hover) { .picker li:hover { background: var(--line); } }
.picker li:last-child { color: var(--muted); font-size: .9rem; }
.picker img { width: 32px; height: 43px; object-fit: cover; border-radius: 4px; flex: none; }

.btn-primary[type="submit"] { width: 100%; min-height: 56px; font-size: 1.05rem; }
.credit { text-align: center; font-size: .8rem; color: var(--muted); margin: 0; }

/* Loading */
.loading { min-height: 70dvh; display: grid; align-content: center; justify-items: center; gap: 24px; text-align: center; padding: 24px; }
.loading-bar { width: min(420px, 100%); height: 8px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.loading-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--lavender), var(--lime)); transform-origin: left; transform: scaleX(0); transition: transform .12s linear; }
.loading-phrase { margin: 0; min-height: 3em; max-width: 28ch; font: 400 1.35rem/1.3 var(--font-display); color: var(--lavender); }

/* Story player */
.player {
  position: fixed; inset: 0; z-index: 50; background: #000; display: grid; grid-template-rows: 1fr auto;
  justify-items: center; padding: env(safe-area-inset-top) 0 calc(12px + env(safe-area-inset-bottom)); outline: none;
}
.player-frame {
  position: relative; align-self: center; height: 100%; max-height: calc(100dvh - 96px); aspect-ratio: 9 / 16; max-width: 100vw;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.scene-host { position: absolute; inset: 0; border-radius: 10px; overflow: hidden; background: #0d0b14; container-type: size; }
.scene { position: absolute; inset: 0; }
.story { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
/* Hold to pause: every scene animation stops with the progress bar. */
.player.paused .scene, .player.paused .scene * { animation-play-state: paused !important; }
.bars { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 4px; z-index: 2; }
.bar { flex: 1; height: 3px; border-radius: 2px; background: rgb(255 255 255 / .35); overflow: hidden; }
.bar i { display: block; height: 100%; background: #fff; transform-origin: left; transform: scaleX(0); }
/* Keyboard-only: pointer taps go through to the scene (card flip, swipes) and are handled on the frame. */
.tap { position: absolute; top: 0; bottom: 0; background: none; border: 0; padding: 0; z-index: 1; pointer-events: none; }
.tap.prev { left: 0; width: 33%; }
.tap.next { right: 0; width: 67%; }
.tap:focus-visible { outline-offset: -4px; }
/* «Versione post»: slides side by side, one per swipe; no gap so the strip seams line up while dragging. */
.carousel-frame { position: relative; align-self: center; width: min(100vw, 560px, (100dvh - 150px) * .8); }
.carousel-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; touch-action: pan-x;
  scrollbar-width: none; border-radius: 10px; outline: none;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-slide {
  flex: 0 0 100%; width: 100%; aspect-ratio: 4 / 5; display: block; background: #0d0b14; object-fit: cover;
  scroll-snap-align: start; scroll-snap-stop: always; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
/* Arrows for mouse users (a vertical wheel does not scroll sideways); touch screens swipe. */
.carousel-nav {
  display: none; position: absolute; top: calc(50% - 31px); width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgb(0 0 0 / .55); color: #fff; font-size: 28px; line-height: 1; cursor: pointer;
}
.carousel-nav.prev { left: 8px; }
.carousel-nav.next { right: 8px; }
.carousel-nav:disabled { opacity: 0; pointer-events: none; }
@media (hover: hover) and (pointer: fine) { .carousel-nav { display: block; } }
.carousel-dots { display: flex; justify-content: center; gap: 6px; padding-top: 12px; }
.carousel-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgb(255 255 255 / .35); transition: background-color .2s; }
.carousel-dots i[data-on] { background: #fff; }
.player-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 12px 12px 0; }
.player-actions button { min-height: 44px; }

/* Steam games list */
.steam-list { margin-top: 12px; }
.steam-list summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 10px; font-weight: 600; list-style: none; }
.steam-list summary::-webkit-details-marker { display: none; }
/* Arrow: down = tap to open, up = tap to close. Decorative: <details> already tells screen readers. */
.steam-list summary::after { content: ""; display: inline-block; flex: none; width: 8px; height: 8px; margin-left: auto; border: solid var(--lavender); border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); }
.steam-list[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.steam-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.steam-row {
  display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; column-gap: 12px; row-gap: 2px; align-items: center;
  width: 100%; padding: 8px; text-align: left; color: var(--text); font: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.steam-row[aria-expanded="true"], .steam-row:focus-visible { border-color: var(--coral); }
.steam-cover { grid-row: 1 / 3; width: 48px; height: 64px; border-radius: 6px; overflow: hidden; background: var(--bg-2); }
.steam-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.steam-title { font-weight: 600; overflow-wrap: anywhere; align-self: end; }
.steam-meta { font-size: .85rem; color: var(--muted); align-self: start; }
.steam-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0 4px; }
.steam-actions[hidden] { display: none; }
.steam-actions .btn-secondary { flex: 1 1 auto; min-width: 0; }

/* Two-step questionnaire */
.step { display: grid; gap: inherit; }
.step[hidden] { display: none; }
.step-nav { display: flex; gap: 12px; }
.step-nav .btn-primary { flex: 1; }
