:root {
  --bg: #08080c;
  --bg-soft: #0f0f18;
  --card: #14141e;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f1e8;
  --muted: #a6a2b2;
  --gold: #e9c46a;
  --gold-2: #f4d58d;
  --gold-3: #b07d2b;
  --red: #e63946;
  --teal: #2a9d8f;
  --radius: 22px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.page-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 8% -5%, rgba(230, 57, 70, 0.20), transparent 62%),
    radial-gradient(800px 600px at 96% 8%, rgba(233, 196, 106, 0.12), transparent 62%),
    radial-gradient(700px 520px at 55% 112%, rgba(42, 157, 143, 0.10), transparent 62%);
}

/* ------------------------------------------------------------------ */
/* Barra superiore                                                    */
/* ------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px clamp(16px, 4vw, 42px);
  background: rgba(8, 8, 12, 0.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  color: var(--gold);
  filter: drop-shadow(0 4px 14px rgba(233, 196, 106, 0.25));
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  min-width: 0;
}

.brand-text strong {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand-text small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  gap: 7px;
  flex: none;
}

.view-tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
}

.view-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.03em;
  border: 0;
  border-radius: 999px;
  background: transparent;
  transition: color 0.15s ease, background 0.15s ease;
}

.view-tab:hover {
  color: var(--text);
}

.view-tab.active {
  color: #171006;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  box-shadow: 0 5px 18px rgba(233, 196, 106, 0.18);
}

.tab-badge {
  display: inline-grid;
  min-width: 19px;
  height: 19px;
  place-items: center;
  padding: 0 5px;
  color: inherit;
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.view-tab.active .tab-badge {
  background: rgba(0, 0, 0, 0.16);
}

/* ------------------------------------------------------------------ */
/* Layout                                                             */
/* ------------------------------------------------------------------ */

.layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 30px);
}

.view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
  align-items: start;
  gap: 18px;
}

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(25, 25, 38, 0.94), rgba(13, 13, 21, 0.97));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 28%);
}

/* ------------------------------------------------------------------ */
/* Hero e ruota                                                       */
/* ------------------------------------------------------------------ */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.95fr);
  align-items: center;
  gap: 10px 24px;
  padding: clamp(22px, 3vw, 38px);
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  top: -140px;
  right: -120px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(233, 196, 106, 0.12), transparent 70%);
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  font-family: var(--font-display);
  font-size: clamp(36px, 4.1vw, 58px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.02em;
}

h1 em {
  color: var(--gold);
  font-style: italic;
}

.lede {
  max-width: 42ch;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.6;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-stats span {
  padding: 8px 11px;
  color: var(--muted);
  font-size: 10.5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.hero-stats strong {
  color: var(--text);
  font-size: 11.5px;
}

.wheel-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 430px);
  margin: 0 auto;
}

.wheel-pointer {
  position: absolute;
  top: -12px;
  left: 50%;
  z-index: 6;
  width: 0;
  height: 0;
  border-top: 28px solid var(--gold);
  border-right: 15px solid transparent;
  border-left: 15px solid transparent;
  filter: drop-shadow(0 4px 9px rgba(0, 0, 0, 0.65));
  transform: translateX(-50%);
}

.wheel-pointer::after {
  content: "";
  position: absolute;
  top: -36px;
  left: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 18px rgba(233, 196, 106, 0.85);
}

.wheel-outer {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 9px;
  border-radius: 50%;
  background: conic-gradient(
    from 20deg,
    #6f4e1a,
    #e9c46a,
    #8a5a1e,
    #f4d58d,
    #6f4e1a,
    #e9c46a,
    #8a5a1e
  );
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.58),
    0 0 0 1px rgba(233, 196, 106, 0.25),
    inset 0 0 22px rgba(0, 0, 0, 0.55);
}

#wheel {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #08080c;
}

#wheel-rotor {
  transform-box: view-box;
  transform-origin: 250px 250px;
  will-change: transform;
}

.hub {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 31%;
  aspect-ratio: 1;
  padding: 0;
  color: #171006;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #f9e4a9, #e9c46a 42%, #b07d2b 100%);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.55),
    inset 0 2px 8px rgba(255, 255, 255, 0.55),
    0 0 0 6px rgba(8, 8, 12, 0.92);
  transform: translate(-50%, -50%);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.hub:hover {
  filter: brightness(1.05);
  transform: translate(-50%, -50%) scale(1.035);
}

.hub:active {
  transform: translate(-50%, -50%) scale(0.975);
}

.hub:disabled {
  cursor: wait;
}

.hub.is-spinning {
  animation: hub-pulse 1.5s ease-in-out infinite;
}

.hub-icon {
  width: 26%;
  color: #171006;
  opacity: 0.9;
}

.hub-icon svg {
  display: block;
  width: 100%;
  height: auto;
}

.hub-label {
  font-size: clamp(10px, 1.5vw, 13px);
  font-weight: 900;
  letter-spacing: 0.16em;
}

@keyframes hub-pulse {
  0%,
  100% {
    box-shadow:
      0 10px 30px rgba(0, 0, 0, 0.55),
      inset 0 2px 8px rgba(255, 255, 255, 0.55),
      0 0 0 6px rgba(8, 8, 12, 0.92);
  }
  50% {
    box-shadow:
      0 10px 44px rgba(233, 196, 106, 0.5),
      inset 0 2px 8px rgba(255, 255, 255, 0.55),
      0 0 0 6px rgba(8, 8, 12, 0.92);
  }
}

.wheel-hint {
  max-width: 34ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Filtro tempo                                                       */
/* ------------------------------------------------------------------ */

.controls {
  padding: clamp(20px, 2.4vw, 28px);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.1;
}

.time-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-inline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 10.5px;
}

.input-unit {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-unit:focus-within {
  border-color: rgba(233, 196, 106, 0.55);
  box-shadow: 0 0 0 3px rgba(233, 196, 106, 0.09);
}

.input-unit input {
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 750;
  border: 0;
  outline: none;
  background: transparent;
}

.input-unit input::placeholder {
  color: rgba(166, 162, 178, 0.55);
  font-weight: 500;
}

.input-unit span {
  flex: none;
  color: var(--muted);
  font-size: 10.5px;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0 16px;
}

.chips button {
  padding: 7px 11px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.chips button:hover {
  color: var(--text);
  border-color: rgba(233, 196, 106, 0.35);
}

.chips button.active {
  color: var(--gold-2);
  border-color: rgba(233, 196, 106, 0.55);
  background: rgba(233, 196, 106, 0.16);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.switch-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease, background 0.2s ease;
}

.switch-row input:checked + .switch {
  border-color: rgba(233, 196, 106, 0.8);
  background: rgba(233, 196, 106, 0.55);
}

.switch-row input:checked + .switch::after {
  background: #171006;
  transform: translateX(16px);
}

.switch-row input:focus-visible + .switch {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.match-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(233, 196, 106, 0.22);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(233, 196, 106, 0.12), rgba(42, 157, 143, 0.08));
}

.match-main {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.match-main strong {
  color: var(--gold-2);
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1;
}

.match-main span {
  color: var(--muted);
  font-size: 10.5px;
}

.match-range {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
  text-align: right;
}

.match-box.no-match {
  border-color: rgba(230, 57, 70, 0.28);
  background: linear-gradient(135deg, rgba(230, 57, 70, 0.14), rgba(230, 57, 70, 0.04));
}

.match-box.no-match .match-main strong {
  color: #ff8a94;
}

.controls-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.microcopy {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

/* ------------------------------------------------------------------ */
/* Bottoni                                                            */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 999px;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease, filter 0.15s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-primary {
  color: #171006;
  background: linear-gradient(135deg, #f4d58d, #e9c46a 55%, #d4a73c);
  box-shadow: 0 8px 24px rgba(233, 196, 106, 0.18);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  color: var(--text);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.btn-ghost:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
}

.btn-danger {
  color: #ffb3b9;
  border-color: rgba(230, 57, 70, 0.45);
  background: rgba(230, 57, 70, 0.15);
}

.btn-danger:hover {
  background: rgba(230, 57, 70, 0.25);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 10.5px;
}

.btn-big {
  width: 100%;
  padding: 14px 18px;
  font-size: 13.5px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.icon-btn.danger:hover {
  color: #ff9aa2;
  background: rgba(230, 57, 70, 0.15);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

/* ------------------------------------------------------------------ */
/* Watchlist                                                          */
/* ------------------------------------------------------------------ */

.library {
  padding: clamp(20px, 3vw, 30px);
}

.library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.readonly-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
  border: 1px solid rgba(233, 196, 106, 0.2);
  border-radius: 12px;
  background: rgba(233, 196, 106, 0.08);
}

.library-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.search {
  display: flex;
  flex: 1 1 220px;
  align-items: center;
  gap: 8px;
  min-width: 180px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.search svg {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.search input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 12.5px;
}

.search input::placeholder {
  color: rgba(166, 162, 178, 0.7);
}

.segmented {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.segmented button {
  padding: 7px 11px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.segmented button.active {
  color: var(--gold-2);
  background: rgba(233, 196, 106, 0.16);
}

select {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 10.5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  background: rgba(255, 255, 255, 0.03);
}

.film-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.film-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.028);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.film-card:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
}

.film-card.is-watched {
  opacity: 0.62;
}

.poster {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 50px;
  height: 68px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: linear-gradient(145deg, hsl(var(--hue) 55% 38%), hsl(calc(var(--hue) + 35) 55% 22%));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.poster::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.09) 0 2px, transparent 2px 8px);
  opacity: 0.35;
}

.poster span {
  position: relative;
  color: rgba(255, 255, 255, 0.86);
  font-family: var(--font-display);
  font-size: 20px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.film-body {
  flex: 1;
  min-width: 0;
}

.film-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.film-title {
  margin: 0 0 4px;
  overflow-wrap: anywhere;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.25;
}

.film-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.pill.watched {
  color: #9fe3d8;
  border-color: rgba(42, 157, 143, 0.3);
  background: rgba(42, 157, 143, 0.12);
}

.film-actions {
  display: flex;
  flex: none;
  gap: 2px;
}

.film-notes {
  display: -webkit-box;
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.empty {
  padding: 48px 20px 38px;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  display: block;
  margin-bottom: 8px;
  font-size: 38px;
  filter: grayscale(0.2);
}

.empty h3 {
  margin-bottom: 6px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
}

.empty p {
  max-width: 48ch;
  margin: 0 auto 18px;
  font-size: 12.5px;
  line-height: 1.55;
}

/* ------------------------------------------------------------------ */
/* Footer                                                             */
/* ------------------------------------------------------------------ */

.footer {
  padding: 24px 18px calc(26px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-align: center;
}

.footer p {
  margin: 0;
}

/* ------------------------------------------------------------------ */
/* Dialoghi                                                           */
/* ------------------------------------------------------------------ */

dialog.modal {
  width: min(540px, calc(100vw - 28px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  overflow: auto;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  background: linear-gradient(180deg, #181824, #0e0e16);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.7);
}

dialog.modal::backdrop {
  background: rgba(3, 3, 6, 0.72);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

dialog.modal[open] {
  animation: modal-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-small {
  width: min(430px, calc(100vw - 28px));
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.1;
}

.modal-copy {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.modal-copy code {
  padding: 1px 5px;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 10.5px;
}

.field em {
  font-style: normal;
  opacity: 0.65;
}

.field input,
.field textarea,
#import-text {
  width: 100%;
  padding: 11px 12px;
  color: var(--text);
  font-size: 13.5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field textarea:focus,
#import-text:focus {
  border-color: rgba(233, 196, 106, 0.55);
  box-shadow: 0 0 0 3px rgba(233, 196, 106, 0.1);
}

.field small {
  min-height: 12px;
  color: var(--gold);
  font-size: 9.5px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-error {
  margin: 4px 0 12px;
  padding: 9px 11px;
  color: #ff9aa2;
  font-size: 11.5px;
  line-height: 1.45;
  border: 1px solid rgba(230, 57, 70, 0.25);
  border-radius: 10px;
  background: rgba(230, 57, 70, 0.1);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

#import-text {
  min-height: 160px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  resize: vertical;
}

.result-modal {
  overflow: hidden;
  text-align: center;
}

.result-glow {
  position: absolute;
  top: -40%;
  right: -20%;
  left: -20%;
  height: 260px;
  pointer-events: none;
  background: radial-gradient(circle, rgba(233, 196, 106, 0.3), transparent 65%);
}

.result-modal h2 {
  margin: 8px 0 12px;
  color: var(--gold-2);
  font-family: var(--font-display);
  font-size: clamp(34px, 6vw, 52px);
  font-weight: 500;
  line-height: 1;
  text-wrap: balance;
}

.result-meta {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.result-notes {
  max-width: 42ch;
  margin: 0 auto 14px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 22px;
}

.install-steps {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.install-steps p {
  margin-bottom: 12px;
}

.install-steps strong {
  color: var(--text);
}

/* ------------------------------------------------------------------ */
/* Banner, toast, altro                                               */
/* ------------------------------------------------------------------ */

.offline-banner {
  padding: 9px 16px;
  color: #ffe1a8;
  font-size: 11px;
  text-align: center;
  border-bottom: 1px solid rgba(233, 196, 106, 0.25);
  background: rgba(233, 196, 106, 0.1);
}

.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 100;
  max-width: min(92vw, 500px);
  padding: 11px 16px;
  color: var(--text);
  font-size: 11.5px;
  text-align: center;
  border: 1px solid rgba(233, 196, 106, 0.35);
  border-radius: 999px;
  background: #1b1b28;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.warn {
  border-color: rgba(230, 57, 70, 0.5);
}

.noscript {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 200;
  padding: 14px;
  color: #171006;
  font-weight: 700;
  text-align: center;
  border-radius: 12px;
  background: var(--gold);
}

/* ------------------------------------------------------------------ */
/* Candidati in gara                                                  */
/* ------------------------------------------------------------------ */

.candidates {
  padding: clamp(18px, 2.6vw, 26px);
}

.candidates-summary {
  flex: none;
  padding: 7px 12px;
  color: var(--gold-2);
  font-size: 10.5px;
  font-weight: 700;
  border: 1px solid rgba(233, 196, 106, 0.24);
  border-radius: 999px;
  background: rgba(233, 196, 106, 0.08);
}

.candidate-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px;
  max-height: 390px;
  padding-right: 4px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(233, 196, 106, 0.35) transparent;
}

.candidate-list::-webkit-scrollbar {
  width: 7px;
}

.candidate-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(233, 196, 106, 0.3);
}

.candidate-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.028);
}

.candidate-card.is-watched {
  opacity: 0.55;
}

.candidate-dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 10px var(--dot);
}

.candidate-body {
  min-width: 0;
}

.candidate-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.candidate-meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
}

.candidate-flag {
  flex: none;
  margin-left: auto;
}

.candidates-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.candidates-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.candidates-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.candidates-foot .microcopy {
  margin: 0;
  text-align: right;
}

/* ------------------------------------------------------------------ */
/* Responsive                                                         */
/* ------------------------------------------------------------------ */

@media (max-width: 980px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .view-tabs {
    order: 3;
    flex: 1 0 100%;
    justify-content: center;
  }

  .top-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 24px 18px 26px;
  }

  .hero-copy {
    order: 1;
    text-align: center;
  }

  .lede {
    margin-right: auto;
    margin-left: auto;
  }

  .hero-stats {
    justify-content: center;
  }

  .wheel-stage {
    order: 2;
    width: min(100%, 390px);
    margin-top: 8px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 10px 14px;
  }

  .brand-text strong {
    font-size: 16px;
  }

  .brand-text small {
    display: none;
  }

  .top-actions .btn {
    padding: 7px 10px;
    font-size: 9.5px;
  }

  .view-tab {
    flex: 1;
    justify-content: center;
    padding: 7px 10px;
  }

  .candidate-list {
    grid-template-columns: 1fr;
    max-height: 340px;
  }

  .candidates-foot {
    align-items: flex-start;
    flex-direction: column;
  }

  .candidates-foot .microcopy {
    text-align: left;
  }

  .hero {
    gap: 4px;
    padding: 18px 14px 20px;
  }

  .hero h1 {
    font-size: clamp(30px, 9vw, 38px);
    line-height: 0.98;
  }

  .lede {
    display: none;
  }

  .hero-stats {
    gap: 6px;
    margin-top: 10px;
  }

  .hero-stats span {
    padding: 5px 8px;
    font-size: 10px;
  }

  .wheel-stage {
    width: min(100%, 318px);
  }

  .time-input-row {
    grid-template-columns: 1fr;
  }

  .film-list {
    grid-template-columns: 1fr;
  }

  .library-tools {
    align-items: stretch;
  }

  .search {
    flex-basis: 100%;
  }

  .segmented {
    flex: 1;
    justify-content: center;
  }

  select {
    flex: 1;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  dialog.modal {
    padding: 20px;
  }

  .readonly-banner {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
