:root {
  --bg: #0e1117;
  --bg-2: #151a23;
  --bg-3: #1c2230;
  --panel: #161c27;
  --line: #263041;
  --line-soft: #1f2735;
  --text: #e7ecf4;
  --muted: #93a1b8;
  --muted-2: #6b7a92;
  --accent: #6c8cff;
  --accent-2: #8f7bff;
  --ok: #34c98a;
  --warn: #ffb63d;
  --bad: #ff6b6b;
  --secret: #c084fc;
  --paper: #f6efdd;
  --paper-ink: #2c2416;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(108, 140, 255, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(143, 123, 255, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--accent);
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.4em;
  line-height: 1.25;
}

h1 {
  font-size: clamp(1.4rem, 4vw, 2rem);
}
h2 {
  font-size: clamp(1.15rem, 3vw, 1.45rem);
}
h3 {
  font-size: 1.05rem;
}

p {
  margin: 0 0 0.8em;
}

/* ------------------------------ layout ------------------------------ */

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
}

.wrap-wide {
  max-width: 1500px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(10px);
  background: rgba(14, 17, 23, 0.86);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-inner.wide {
  max-width: 1500px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}

.brand small {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
}

/*
 * Le sezioni vanno a capo su più righe invece di scorrere di lato: sul
 * telefono si vedono tutte insieme, senza doverle cercare trascinando.
 */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0;
}

.tab {
  flex: 0 1 auto;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--text);
  border-color: #34415a;
}

.tab.active {
  background: linear-gradient(180deg, var(--accent), #5878f0);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.tab .count {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0 7px;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.tab:not(.active) .count {
  background: var(--bg-3);
}

.tab .count.alert {
  background: var(--bad);
  color: #fff;
}

.view {
  display: none;
}
.view.active {
  display: block;
  animation: fade 0.18s ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* ------------------------------ card ------------------------------ */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.card.tight {
  padding: 12px 14px;
}

/*
 * Testi lunghi: una parola senza spazi (un link, un codice, una parola
 * inventata) non deve sfondare il riquadro né far scorrere la pagina di lato,
 * altrimenti sul telefono finisce fuori schermo e non si legge.
 */
.card,
.story,
.md,
.letter,
.notice,
.text-block,
.mail-item {
  overflow-wrap: anywhere;
}

/*
 * Anteprima abbreviata nelle liste di regia: il taglio si deve VEDERE
 * (puntini di sospensione), non sparire in silenzio. Il testo completo
 * resta nell'editor.
 */
.clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}

/* Blocco di testo di una prova: cresce quanto serve, senza tagli. */
.text-block {
  white-space: pre-wrap;
  margin-bottom: 10px;
  max-width: 100%;
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.card-head h3 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 180px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.row.end {
  justify-content: flex-end;
}

.spacer {
  flex: 1 1 auto;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.86rem;
}
.tiny {
  font-size: 0.78rem;
}
.mono {
  font-family: var(--mono);
}
.center {
  text-align: center;
}
.nowrap {
  white-space: nowrap;
}
.hidden {
  display: none !important;
}

/* ------------------------------ badge ------------------------------ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge.ok {
  background: rgba(52, 201, 138, 0.14);
  color: var(--ok);
  border-color: rgba(52, 201, 138, 0.35);
}
.badge.pending {
  background: rgba(255, 182, 61, 0.14);
  color: var(--warn);
  border-color: rgba(255, 182, 61, 0.35);
}
.badge.bad {
  background: rgba(255, 107, 107, 0.14);
  color: var(--bad);
  border-color: rgba(255, 107, 107, 0.35);
}
.badge.info {
  background: rgba(108, 140, 255, 0.14);
  color: var(--accent);
  border-color: rgba(108, 140, 255, 0.35);
}
.badge.secret {
  background: rgba(192, 132, 252, 0.14);
  color: var(--secret);
  border-color: rgba(192, 132, 252, 0.35);
}
.badge.neutral {
  background: var(--bg-3);
  color: var(--muted);
  border-color: var(--line);
}

.pts {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.pts.plus {
  color: var(--ok);
}
.pts.minus {
  color: var(--bad);
}

/* ------------------------------ form ------------------------------ */

label.field {
  display: block;
  margin-bottom: 12px;
}

label.field > span,
.field-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.18);
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

textarea.tall {
  min-height: 200px;
}

input[type="color"] {
  width: 46px;
  height: 38px;
  padding: 2px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  vertical-align: -3px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.inline-fields {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

/* ------------------------------ button ------------------------------ */

.btn {
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: filter 0.15s, transform 0.05s, background 0.15s;
  text-decoration: none;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.15);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(180deg, var(--accent), #5878f0);
  border-color: transparent;
  color: #fff;
}
.btn.ok {
  background: linear-gradient(180deg, #3ad596, #23a874);
  border-color: transparent;
  color: #05261a;
}
.btn.danger {
  background: linear-gradient(180deg, #ff7a7a, #e14b4b);
  border-color: transparent;
  color: #2c0808;
}
.btn.warn {
  background: linear-gradient(180deg, #ffc45c, #eda224);
  border-color: transparent;
  color: #2e2005;
}
.btn.ghost {
  background: transparent;
}
.btn.small {
  padding: 6px 11px;
  font-size: 0.85rem;
}
.btn.block {
  width: 100%;
}

/* ------------------------------ table ------------------------------ */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 520px;
}

table.data th,
table.data td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

table.data th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

table.data tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

/* --------------------------- leaderboard --------------------------- */

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  margin-bottom: 8px;
}

.lb-row.me {
  border-color: var(--accent);
  background: rgba(108, 140, 255, 0.09);
}

.lb-pos {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--bg-3);
  font-variant-numeric: tabular-nums;
}

.lb-row:nth-child(1) .lb-pos {
  background: linear-gradient(160deg, #ffd76a, #d19b1b);
  color: #3a2a00;
}
.lb-row:nth-child(2) .lb-pos {
  background: linear-gradient(160deg, #dfe6ef, #9aa7b8);
  color: #23272e;
}
.lb-row:nth-child(3) .lb-pos {
  background: linear-gradient(160deg, #e5a877, #b3703c);
  color: #2e1a08;
}

.lb-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------ letters ------------------------------ */

.mail-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 14px;
  align-items: start;
}

@media (max-width: 820px) {
  .mail-layout {
    grid-template-columns: 1fr;
  }
  .mail-layout.reading .mail-list {
    display: none;
  }
}

.mail-list {
  max-height: 70vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.mail-item {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.mail-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.mail-item.active {
  background: rgba(108, 140, 255, 0.12);
  box-shadow: inset 3px 0 0 var(--accent);
}

.mail-item.unread .mail-subject {
  font-weight: 700;
}

.mail-item.unread .dot {
  background: var(--accent);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  flex: 0 0 8px;
  margin-top: 7px;
}

.mail-subject {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.letter {
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  background-image: linear-gradient(rgba(0, 0, 0, 0.035) 1px, transparent 1px);
  background-size: 100% 28px;
  line-height: 28px;
}

.letter h3 {
  font-family: Georgia, "Times New Roman", serif;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(44, 36, 22, 0.2);
  padding-bottom: 8px;
}

.letter .body {
  white-space: pre-wrap;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02rem;
}

.letter .hint {
  margin-top: 16px;
  padding: 12px 14px;
  border-left: 4px solid #c08a2b;
  background: rgba(192, 138, 43, 0.14);
  border-radius: 0 8px 8px 0;
  line-height: 1.5;
}

.letter .meta {
  margin-top: 16px;
  font-size: 0.8rem;
  color: #6b5f45;
  border-top: 1px dashed rgba(44, 36, 22, 0.25);
  padding-top: 8px;
  line-height: 1.4;
}

/* ------------------------------ story ------------------------------ */

.story {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  white-space: pre-wrap;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.03rem;
  line-height: 1.7;
  box-shadow: var(--shadow);
}

/* La storia non viene mai troncata: si legge tutta, sempre. */
.story > div {
  white-space: pre-wrap;
}

/* ------------------- testo scritto in Markdown ------------------- */

.md,
.md > div {
  white-space: normal;
}

.md > *:first-child {
  margin-top: 0;
}
.md > *:last-child {
  margin-bottom: 0;
}

.md h1,
.md h2,
.md h3,
.md h4,
.md h5,
.md h6 {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.25;
  margin: 1.1em 0 0.45em;
}

.md h1 {
  font-size: 1.5rem;
  border-bottom: 1px solid rgba(44, 36, 22, 0.25);
  padding-bottom: 0.25em;
}
.md h2 {
  font-size: 1.28rem;
}
.md h3 {
  font-size: 1.12rem;
}
.md h4,
.md h5,
.md h6 {
  font-size: 1rem;
}

.md p {
  margin: 0 0 0.85em;
}

.md ul,
.md ol {
  margin: 0 0 0.85em;
  padding-left: 1.5em;
}

.md li {
  margin-bottom: 0.3em;
}

.md li > ul,
.md li > ol {
  margin: 0.3em 0 0;
}

.md blockquote {
  margin: 0.8em 0;
  padding: 0.5em 0.9em;
  border-left: 4px solid #c08a2b;
  background: rgba(192, 138, 43, 0.13);
  border-radius: 0 8px 8px 0;
}

.md blockquote p:last-child {
  margin-bottom: 0;
}

.md hr {
  border: none;
  border-top: 1px solid rgba(44, 36, 22, 0.28);
  margin: 1.2em 0;
}

.md code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: rgba(44, 36, 22, 0.09);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.md pre {
  background: rgba(44, 36, 22, 0.09);
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0 0 0.85em;
}

.md pre code {
  background: none;
  padding: 0;
}

.md a {
  color: #7a4bd0;
  text-decoration: underline;
}

.md strong {
  font-weight: 700;
}

.md table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 0.85em;
  display: block;
  overflow-x: auto;
}

.md th,
.md td {
  border: 1px solid rgba(44, 36, 22, 0.25);
  padding: 6px 10px;
  text-align: left;
}

.md th {
  background: rgba(44, 36, 22, 0.08);
}

/* Anteprima nel pannello di regia: fondo scuro, non "carta". */
.md.on-dark {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  font-family: inherit;
}

.md.on-dark h1 {
  border-bottom-color: var(--line);
}
.md.on-dark blockquote {
  background: rgba(108, 140, 255, 0.1);
  border-left-color: var(--accent);
}
.md.on-dark hr {
  border-top-color: var(--line);
}
.md.on-dark code,
.md.on-dark pre {
  background: rgba(255, 255, 255, 0.07);
}
.md.on-dark a {
  color: var(--accent);
}
.md.on-dark th,
.md.on-dark td {
  border-color: var(--line);
}
.md.on-dark th {
  background: rgba(255, 255, 255, 0.05);
}

.story-sep {
  border: none;
  border-top: 1px dashed var(--line);
  margin: 22px 0 16px;
}

.story-part-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.story-part-head strong {
  font-size: 1.06rem;
}

.story-part-date {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: "Segoe UI", system-ui, sans-serif;
}

/* Documenti allegati alla storia: foto di scena, referti, registrazioni. */
.story-docs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 14px 0 4px;
  white-space: normal;
}

.story-doc {
  margin: 0;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.story-doc img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 5px;
  display: block;
  background: var(--bg);
}

.story-doc audio {
  width: 100%;
}

/* Anteprima cliccabile: si capisce che c'è qualcosa da aprire. */
.story-doc-open,
.thumb-open {
  display: block;
  position: relative;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  border-radius: 6px;
  overflow: hidden;
}

.thumb-open {
  width: auto;
  display: inline-block;
}

.story-doc-open:focus-visible,
.thumb-open:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.story-doc-zoom {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: "Segoe UI", system-ui, sans-serif;
  pointer-events: none;
  white-space: nowrap;
}

.thumb-zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.85rem;
  pointer-events: none;
}

.story-doc-open:hover img,
.thumb-open:hover img {
  filter: brightness(1.08);
}

.story-doc figcaption {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.35;
}

/* ------------------------------ media ------------------------------ */

.media-box {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--bg-2);
}

.preview img {
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--radius-sm);
  display: block;
  border: 1px solid var(--line);
}

.preview audio {
  width: 100%;
  margin-top: 6px;
}

.thumb {
  max-width: 100%;
  max-height: 240px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bad);
  display: inline-block;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

/* ------------------------------ misc ------------------------------ */

.locked {
  opacity: 0.72;
  border-style: dashed;
}

.timer {
  font-family: var(--mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.notice {
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  margin-bottom: 12px;
}

.notice.warn {
  border-color: rgba(255, 182, 61, 0.4);
  background: rgba(255, 182, 61, 0.1);
}
.notice.bad {
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.1);
}
.notice.ok {
  border-color: rgba(52, 201, 138, 0.4);
  background: rgba(52, 201, 138, 0.1);
}
.notice.info {
  border-color: rgba(108, 140, 255, 0.4);
  background: rgba(108, 140, 255, 0.1);
}

.stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.stat .v {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat .k {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.code-chip {
  font-family: var(--mono);
  font-size: 1.15rem;
  letter-spacing: 3px;
  background: var(--bg-3);
  border: 1px dashed var(--accent);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  display: inline-block;
  font-weight: 700;
}

/* ------------------ visore documenti a schermo intero ------------------ */

dialog.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  overflow: hidden;
}

dialog.lightbox::backdrop {
  background: rgba(6, 8, 12, 0.94);
}

.lb-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 56px 12px 72px;
  /* Toccare qui chiude: è l'area vuota attorno al documento. */
  cursor: zoom-out;
  overflow: auto;
}

.lb-media {
  max-width: 100%;
  max-height: 100%;
  display: grid;
  place-items: center;
}

.lb-img {
  max-width: 100%;
  max-height: calc(100dvh - 128px);
  object-fit: contain;
  border-radius: 8px;
  cursor: zoom-in;
  display: block;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  animation: lb-in 0.18s ease-out;
}

/* Secondo tocco: dimensione reale, si trascina per esplorare il documento. */
.lb-media.zoomed .lb-img {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}

@keyframes lb-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}

.lb-audio {
  width: min(560px, 88vw);
}

.lb-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(20, 24, 33, 0.85);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.lb-close:hover {
  background: rgba(60, 68, 84, 0.95);
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 64px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(20, 24, 33, 0.6);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.lb-nav:hover {
  background: rgba(60, 68, 84, 0.9);
}

.lb-prev {
  left: 8px;
}
.lb-next {
  right: 8px;
}

.lb-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, transparent, rgba(6, 8, 12, 0.85) 45%);
  color: #e7ecf4;
  font-size: 0.88rem;
}

.lb-caption {
  flex: 1 1 auto;
  min-width: 0;
}

.lb-counter {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lb-btn {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(20, 24, 33, 0.85);
  color: #fff;
  border-radius: 8px;
  padding: 7px 12px;
  text-decoration: none;
  white-space: nowrap;
  font-size: 0.85rem;
}

.lb-btn:hover {
  background: rgba(60, 68, 84, 0.95);
}

@media (max-width: 620px) {
  .lb-nav {
    width: 38px;
    height: 54px;
    font-size: 1.6rem;
  }
  .lb-stage {
    padding: 52px 6px 66px;
  }
}

.toasts {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 28px));
}

.toast {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  box-shadow: var(--shadow);
  animation: slide 0.2s ease-out;
  font-size: 0.92rem;
}

.toast.ok {
  border-left-color: var(--ok);
}
.toast.bad {
  border-left-color: var(--bad);
}
.toast.warn {
  border-left-color: var(--warn);
}

@keyframes slide {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
}

dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0;
  max-width: min(720px, calc(100vw - 24px));
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

dialog::backdrop {
  background: rgba(6, 8, 12, 0.7);
  backdrop-filter: blur(2px);
}

dialog .dlg-head,
dialog .dlg-foot {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}

dialog .dlg-foot {
  border-bottom: none;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

dialog .dlg-body {
  padding: 18px;
  max-height: min(70vh, 640px);
  overflow-y: auto;
}

.splash {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.splash .card {
  max-width: 460px;
  width: 100%;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.seg button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  font: inherit;
  cursor: pointer;
}

.seg button.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.sortable-item {
  cursor: grab;
}

.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

@media (max-width: 620px) {
  .wrap {
    padding: 12px;
  }
  .card {
    padding: 13px;
  }
  .letter,
  .story {
    padding: 16px;
  }

  /* Schede più compatte: entrano in meno righe e restano toccabili. */
  .tabs {
    gap: 5px;
    padding: 6px 0;
  }

  .tab {
    flex: 1 1 auto;
    justify-content: center;
    padding: 9px 10px;
    font-size: 0.85rem;
    gap: 5px;
  }

  /* La barra in alto non resta appiccicata: con più righe ruberebbe
     troppo schermo alla lettura. */
  .topbar {
    position: static;
  }

  .topbar-inner {
    padding: 8px 12px;
    gap: 6px;
  }

  /* Intestazione compatta: più spazio al contenuto. */
  .brand {
    font-size: 0.95rem;
  }

  .brand small {
    font-size: 0.7rem;
  }

  .topbar-inner .badge {
    font-size: 0.72rem;
    padding: 2px 7px;
  }

  .topbar-inner .btn.small {
    padding: 5px 9px;
    font-size: 0.8rem;
  }
}

/* Soluzione del caso: si vede solo a partita finita, ed è la notizia del
   giorno — quindi si distingue dal resto della sezione Cluedo. */
.card.solution {
  border-color: rgba(192, 132, 252, 0.45);
  background: linear-gradient(180deg, rgba(192, 132, 252, 0.12), transparent 60%);
}
.card.solution h3 {
  color: var(--secret);
}
