:root{
  --bg1:#050613;
  --bg2:#0b1333;
  --glass: rgba(255,255,255,.10);
  --glass2: rgba(255,255,255,.06);
  --txt: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.65);
  --stroke: rgba(255,255,255,.14);
  --shadow: 0 18px 55px rgba(0,0,0,.55);
}

*{ box-sizing:border-box; }

html, body{
  height:100%;
  width:100%;
  overflow-x:hidden; /* FIX: evita shift/scroll laterale su iOS */
}

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color:var(--txt);

  /* sfondo */
  background:
    linear-gradient(rgba(5,6,19,.70), rgba(5,6,19,.85)),
    url("/bg.jpg") no-repeat center center;

  /* vuoi vedere tutta l'immagine */
  background-size: contain;
  background-color: #050613;

  /* iOS: "fixed" spesso fa glitch nei webview/PWA */
  background-attachment: scroll;

  display:grid;
  place-items:center;

  /* FIX: safe-area notch + padding simmetrico */
  padding-top: max(24px, env(safe-area-inset-top));
  padding-right: max(24px, env(safe-area-inset-right));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  padding-left: max(24px, env(safe-area-inset-left));
}

/* Utility: testo presente ma invisibile */
.sr-only{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

.phone{
  width:min(390px, 96vw);
  height:min(820px, 92vh);
  border-radius:34px;
  padding:14px;
  background: rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.10);
  box-shadow: var(--shadow);
  position:relative;
  overflow:hidden;

  /* FIX: centratura reale su iOS */
  margin: 0 auto;
  left: 0; right: 0;

  max-width: 100%;
}

.phone:before{
  content:"";
  position:absolute;
  inset:-120px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.12), transparent 30%),
    radial-gradient(circle at 80% 35%, rgba(255,150,70,.18), transparent 35%),
    radial-gradient(circle at 25% 75%, rgba(0,220,255,.16), transparent 40%);
  filter: blur(10px);
  pointer-events:none;
}

/* === Screen === */
.screen{
  height:100%;
  position:relative;
  z-index:2;
  padding:8px 8px 24px;
  display:flex;
  flex-direction:column;
  gap:14px;

  overflow-y:auto;
  -webkit-overflow-scrolling: touch;

  max-width: 100%;
}

/* === Header === */
.header{
  position:relative;
  text-align:center;
  padding-top:8px;
}

.cloud{
  width:110px; height:60px;
  margin:0 auto;
  background:
    radial-gradient(circle at 30% 60%, rgba(255,255,255,.9), rgba(255,255,255,.1) 55%, transparent 60%),
    radial-gradient(circle at 55% 40%, rgba(255,255,255,.85), rgba(255,255,255,.1) 55%, transparent 60%),
    radial-gradient(circle at 75% 62%, rgba(255,255,255,.75), rgba(255,255,255,.1) 55%, transparent 60%);
  filter: drop-shadow(0 10px 25px rgba(255,190,80,.28));
  opacity:.95;
  pointer-events:none;
  position:relative;
  z-index:0;
}

.header > *:not(.cloud){
  position:relative;
  z-index:1;
}

.header-banner{
  display:block;
  width:min(320px, 78%);
  height:auto;
  margin:12px auto 12px;
  border-radius:14px;
  object-fit:cover;
  background: transparent;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.header h1{
  margin:8px 0 2px;
  font-size:34px;
  font-weight:800;
}

.subtitle{
  margin:0;
  color:var(--muted);
}

/* === Cards / glass blocks === */
.card{
  background: var(--glass2);
  border:1px solid var(--stroke);
  border-radius:22px;
  padding:14px;
  backdrop-filter: blur(10px);
}

.card h2{
  margin:0 0 10px;
  font-size:18px;
  color:rgba(255,255,255,.86);
  font-weight:700;
}

.subh{
  margin-top:12px !important;
}

/* === Dreams list === */
.dreams{
  display:flex;
  flex-direction:column;
  gap:10px;
}

/* DREAM BUTTON (background-image via JS) */
.dream-item{
  position: relative;
  width: 100%;
  height: 72px;
  padding: 0;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  cursor: pointer;
  overflow: hidden;

  -webkit-appearance: none;
  appearance: none;
  outline: none;

  isolation: isolate;

  background-color: rgba(255,255,255,.06);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  transition: transform .12s ease, border-color .12s ease, filter .12s ease;
}

.dream-item::after{
  content:"";
  position:absolute;
  inset:0;
  background: linear-gradient(90deg, rgba(0,0,0,.50), rgba(0,0,0,.26));
  pointer-events:none;
  z-index: 1;
}

.dream-item:hover{
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.24);
  filter: saturate(1.06) contrast(1.02);
}

.dream-item:active{
  transform: translateY(0px) scale(.99);
}

/* Glow dietro, non sopra */
.dream-item.glow::before{
  content:"";
  position:absolute;
  inset:-2px;
  border-radius: 20px;
  background: linear-gradient(90deg, rgba(0,255,200,.35), rgba(70,120,255,.35), rgba(255,120,50,.35));
  filter: blur(12px);
  opacity:.55;
  pointer-events:none;
  z-index: -1;
}

.dream-item.selected{
  outline: 2px solid rgba(255,255,255,.35);
  border-color: rgba(255,255,255,.30);
}

/* Testo e freccia: visibili sopra l'immagine */
.dream-item .label{
  position: absolute;
  left: 10px;
  bottom: 10px;
  max-width: calc(100% - 52px);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,.96);
  background: rgba(5,6,19,.58);
  backdrop-filter: blur(2px);
  text-shadow: 0 1px 1px rgba(0,0,0,.55);
  z-index: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dream-item .chev{
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  color: rgba(255,255,255,.95);
  text-shadow: 0 1px 2px rgba(0,0,0,.65);
  z-index: 2;
}

/* === Glass settings === */
.glass{
  background: var(--glass);
  border:1px solid var(--stroke);
  border-radius:22px;
  padding:14px;
  backdrop-filter: blur(12px);
}

.settings{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:10px 10px;
  border-radius:16px;
  background: rgba(0,0,0,.10);
  border:1px solid rgba(255,255,255,.08);
}

.row-stretch{ align-items:stretch; }
.left{ display:flex; align-items:center; gap:10px; }
.left.top{ align-items:flex-start; }
.ico{ font-size:18px; }
.k{ font-weight:900; font-size:13px; }
.hint{ font-size:12px; color:var(--muted); margin-top:2px; }

.right{
  display:flex;
  align-items:center;
  gap:8px;
  justify-content:flex-end;
}

.right.col{
  flex-direction:column;
  align-items:stretch;
  width:55%;
  gap:8px;
}

input[type="time"], select, textarea{
  background: rgba(255,255,255,.07);
  border:1px solid rgba(255,255,255,.14);
  color: var(--txt);
  padding:8px 10px;
  border-radius:12px;
  outline:none;
}

textarea{
  resize:none;
  padding:10px 10px;
}

.dash{ opacity:.6; }

/* === Start area === */
.start-area{
  margin-top:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
  align-items:center;
  padding-bottom:4px;
}

.start{
  width:82%;
  padding:14px 18px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  color: var(--txt);
  font-size:18px;
  font-weight:900;
  cursor:pointer;
  position:relative;
  overflow:hidden;
}

.glow-btn:before{
  content:"";
  position:absolute;
  inset:-10px;
  background: linear-gradient(90deg, rgba(255,120,50,.45), rgba(70,120,255,.35), rgba(0,255,200,.30));
  filter: blur(14px);
  opacity:.85;
  pointer-events:none;
}

.selected{
  font-size:12.5px;
  color: var(--muted);
  text-align:center;
}

/* Toggle iOS-like */
.switch{ position:relative; display:inline-block; width:54px; height:30px; }
.switch input{ display:none; }
.slider{
  position:absolute; cursor:pointer; inset:0;
  background: rgba(255,255,255,.18);
  border:1px solid rgba(255,255,255,.18);
  transition:.2s;
  border-radius:999px;
}
.slider:before{
  content:"";
  position:absolute; height:24px; width:24px; left:3px; top:2px;
  background:white; border-radius:50%;
  transition:.2s;
}
.switch input:checked + .slider{
  background: rgba(0,255,200,.35);
}
.switch input:checked + .slider:before{
  transform: translateX(24px);
}

.mini-btn{
  padding:9px 10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.10);
  color: var(--txt);
  cursor:pointer;
  font-weight:800;
}

/* Phrase chips */
.phrase-list{
  margin-top:10px;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.phrase-chip{
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  padding:8px 10px;
  border-radius:999px;
  font-weight:800;
  font-size:12.5px;
  color: rgba(255,255,255,.85);
}
