:root {
  --bg: #05080e;
  --ink: #e9eef7;
  --muted: #93a6c0;
  --faint: #6f8299;
  --sun: #ffcb6b;
  --moon: #7aa7ff;
  --line: rgba(140, 170, 210, 0.16);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 620px at 50% -8%, #122138 0%, #070c14 52%, #04070c 100%);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 48px) clamp(16px, 3vw, 32px) 40px;
}

/* ---------- testata ---------- */

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: clamp(20px, 3vw, 34px);
}

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

.mark { width: 26px; height: 26px; color: var(--muted); flex: none; }

.name {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.name .tld { color: var(--faint); font-weight: 400; }

.tagline {
  margin: 0;
  font-size: 12.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---------- orologio ---------- */

.clock {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(18px, 4vw, 48px);
  flex-wrap: wrap;
  margin-bottom: clamp(18px, 2.4vw, 28px);
}

.date {
  font-size: 12.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  min-height: 1em;
}

.time {
  font-size: clamp(46px, 9vw, 84px);
  line-height: 0.98;
  font-weight: 200;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 10px;
}

.zone-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: #b9c8dc;
  background: rgba(255, 255, 255, 0.02);
}

.zone-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 8px rgba(255, 203, 107, 0.8);
}

.clock-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 4px;
  min-width: 210px;
}

.utc-line, .subsol {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  font-size: 12.5px;
  color: var(--muted);
}

.utc-line .v, .subsol .v {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.utc-line .k { letter-spacing: 0.16em; }

.subsol .v { font-size: 12.5px; color: #c9d6e8; }

/* ---------- mappa ---------- */

.map-wrap {
  position: relative;
  cursor: crosshair;
  width: 100%;
  aspect-ratio: 2 / 1;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #060b14;
  box-shadow:
    0 40px 90px -50px rgba(0, 0, 0, 0.95),
    inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  isolation: isolate;
}

.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.layer.over { pointer-events: none; }

#night {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: normal;
}

.graticule line { stroke: rgba(160, 190, 230, 0.14); stroke-width: 0.7; }
.graticule line.equator { stroke: rgba(180, 210, 250, 0.24); }

.bands rect { fill: rgba(255, 255, 255, 0.018); }
.bands rect.alt { fill: rgba(255, 255, 255, 0.042); }
.bands line { stroke: rgba(160, 190, 230, 0.13); stroke-width: 0.7; }
.bands line.major { stroke: rgba(180, 210, 250, 0.24); stroke-width: 0.9; }

.land {
  fill: #1b2c45;
  stroke: rgba(140, 180, 226, 0.36);
  stroke-width: 0.6;
  stroke-linejoin: round;
  paint-order: stroke fill;
}

.terminator {
  fill: none;
  stroke: #ffcf8a;
  stroke-width: 1.7;
  stroke-linecap: round;
  opacity: 0.9;
}

.sun-mark circle.core { fill: #ffdda0; }
.sun-mark circle.ring { fill: none; stroke: rgba(255, 217, 160, 0.55); stroke-width: 1; }

.cities circle.dot { fill: #cfe0ff; }
.cities circle.dot.night { fill: #8fb4ff; }
.cities circle.halo { fill: rgba(207, 224, 255, 0.16); }
.cities circle.halo.night { fill: rgba(143, 180, 255, 0.14); }

.band-labels text {
  fill: rgba(232, 238, 247, 0.55);
  font-size: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.06em;
  text-anchor: middle;
}
.band-labels text.utc { fill: rgba(255, 203, 107, 0.85); }

.readout {
  position: absolute;
  left: 12px;
  bottom: 12px;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid rgba(140, 170, 210, 0.18);
  border-radius: 8px;
  background: rgba(6, 11, 20, 0.72);
  backdrop-filter: blur(6px);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: #c8d6e8;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.readout.on { opacity: 1; }

.readout b { color: var(--ink); font-weight: 500; }
.readout .dim { color: var(--faint); }

.map-legend {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--faint);
  background: rgba(6, 11, 20, 0.55);
  border-radius: 8px;
  padding: 5px 9px;
  backdrop-filter: blur(6px);
}

.map-legend span { display: inline-flex; align-items: center; gap: 6px; }

.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.night-key { background: rgba(3, 7, 14, 0.9); border: 1px solid rgba(140, 170, 210, 0.35); }
.line-key { background: #ffcf8a; height: 2px; border-radius: 2px; }
.band-key { background: rgba(255, 255, 255, 0.14); }

/* ---------- città ---------- */

.cities-wrap { margin-top: clamp(22px, 3vw, 34px); }

.cities-title {
  margin: 0 0 12px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

.cities {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.city {
  padding: 10px 12px 11px;
  border: 1px solid rgba(140, 170, 210, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.022);
}

.city.local {
  border-color: rgba(255, 203, 107, 0.30);
  background: rgba(255, 203, 107, 0.05);
}

.city-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.city-name i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  align-self: center;
  background: var(--sun);
  box-shadow: 0 0 6px rgba(255, 203, 107, 0.7);
}

.city-name i.night { background: var(--moon); box-shadow: 0 0 6px rgba(122, 167, 255, 0.6); }

.city-time {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.city-off {
  margin-top: 1px;
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- fondo ---------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-top: clamp(26px, 4vw, 44px);
  padding-top: 16px;
  border-top: 1px solid rgba(140, 170, 210, 0.10);
  font-size: 11.5px;
  color: var(--faint);
}

.foot a { color: var(--muted); text-decoration-color: rgba(147, 166, 192, 0.4); }

.noscript {
  max-width: 640px;
  margin: 40px auto;
  padding: 16px;
  border: 1px solid rgba(255, 203, 107, 0.3);
  border-radius: 10px;
  color: var(--ink);
  font-size: 14px;
}

@media (max-width: 720px) {
  .clock { align-items: flex-start; }
  .band-labels { display: none; }
  .clock-side { min-width: 0; width: 100%; }
  .map-legend { display: none; }
  .readout { font-size: 10.5px; left: 8px; bottom: 8px; }
  .cities { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .city-time { font-size: 17px; }
}

@media (max-width: 430px) {
  .cities { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .city-time { font-size: 16.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .readout { transition: none; }
}
