:root{
  --bg: #14110d;
  --bg2: #1c1812;
  --brass: #c9a05c;
  --brass-dim: #7a6640;
  --paper: #ede4d3;
  --ink: #2b241a;
  --ok: #6fae7c;
  --warn: #c2694a;
  --card: rgba(255,255,255,0.03);
}
*{box-sizing:border-box;}
html,body{
  margin:0; padding:0; min-height:100%;
  background: radial-gradient(circle at 50% 20%, var(--bg2), var(--bg) 70%);
  color: var(--paper);
  font-family: 'Georgia', 'Iowan Old Style', serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x:hidden;
}
.wrap{
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display:flex;
  flex-direction:column;
  align-items:center;
  min-height:100vh;
}
header{ width:100%; text-align:center; margin-bottom: 6px; }
h1{
  font-size: 1.4rem; letter-spacing: 0.08em; text-transform: uppercase;
  font-weight: 400; color: var(--brass); margin: 0 0 2px;
}
.sub{
  font-family: 'Courier New', monospace; font-size: 0.72rem;
  letter-spacing: 0.12em; color: var(--brass-dim); text-transform: uppercase;
}

/* --- Rosa dei venti --- */
.rose-shell{
  position: relative;
  width: min(78vw, 340px);
  height: min(78vw, 340px);
  margin: 28px 0 14px;
}
.ring-outer{
  position:absolute; inset:0; border-radius:50%;
  background: repeating-conic-gradient(from 0deg, rgba(201,160,92,0.35) 0deg 1deg, transparent 1deg 6deg);
  box-shadow: 0 0 0 1px var(--brass-dim), inset 0 0 40px rgba(0,0,0,0.6), 0 20px 40px rgba(0,0,0,0.5);
  padding: 6px;
}
.rose-face{
  position:absolute; inset: 10px; border-radius:50%;
  background: radial-gradient(circle at 40% 35%, #241f17, #0f0d09 75%);
  border: 1px solid var(--brass-dim);
}
.rose-rotating{ position:absolute; inset:0; border-radius:50%; }
.cardinal{
  position:absolute; font-family: 'Courier New', monospace;
  font-size: 0.85rem; letter-spacing: 0.05em; color: var(--brass);
}
.center-dot{
  position:absolute; left:50%; top:50%; width:8px; height:8px;
  background: var(--brass); border-radius:50%; transform: translate(-50%,-50%);
  box-shadow: 0 0 6px rgba(201,160,92,0.7); z-index: 8;
}
.needle{
  position:absolute; left:50%; top:50%; width: 3px;
  transform-origin: 50% 100%; z-index: 4;
}
.needle-north{
  height: 44%; margin-top: -44%; width: 10px; margin-left: -5px;
  background: linear-gradient(to top, transparent, #d94f3a 30%, #d94f3a);
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}
.needle-south{
  height: 30%; margin-top: -30%; width: 6px; margin-left: -3px;
  background: linear-gradient(to top, var(--paper), transparent); opacity: 0.5;
}

/* --- Puntatori landmark multipli --- */
.needle-target{
  position:absolute; left:50%; top:50%; width: 4px; margin-left:-2px;
  height: 38%; margin-top: -38%; transform-origin: 50% 100%;
  clip-path: polygon(50% 0%, 100% 25%, 50% 15%, 0% 25%);
  z-index: 6; opacity: 0.95;
}
.needle-target .tag{
  position:absolute; top: -4px; left: 50%;
  transform: translate(-50%, -100%);
  font-family: 'Courier New', monospace;
  font-size: 0.62rem; letter-spacing: 0.05em;
  padding: 1px 5px; border-radius: 3px;
  background: var(--ink); white-space: nowrap;
  border: 1px solid currentColor;
}

/* --- Readout --- */
.readout{
  width:100%; display:flex; justify-content: space-between;
  font-family: 'Courier New', monospace; font-size: 0.85rem;
  padding: 10px 4px; border-top: 1px solid var(--brass-dim);
  border-bottom: 1px solid var(--brass-dim); margin-bottom: 14px;
}
.readout div{ text-align:center; flex:1; }
.readout .label{
  display:block; font-size: 0.62rem; letter-spacing: 0.1em;
  color: var(--brass-dim); text-transform: uppercase; margin-bottom:3px;
}
.val-north{ color:#e07a63; }
.val-target{ color: var(--ok); }

/* --- Lista landmark attivi (sopra il pannello) --- */
.active-list{
  width:100%; display:flex; flex-direction:column; gap:6px; margin-bottom: 16px;
}
.active-item{
  display:flex; align-items:center; gap:10px;
  font-family: 'Courier New', monospace; font-size: 0.78rem;
  background: var(--card); border: 1px solid var(--brass-dim);
  border-radius: 4px; padding: 8px 10px;
}
.active-item .dot{
  width:9px; height:9px; border-radius:50%; flex-shrink:0;
}
.active-item .name{ flex:1; color: var(--paper); }
.active-item .dist{ color: var(--brass); }
.active-item.arrived{ border-color: var(--ok); }
.active-item.arrived .dist{ color: var(--ok); }

/* --- Pannello controlli --- */
.panel{
  width:100%; background: var(--card); border: 1px solid var(--brass-dim);
  border-radius: 4px; padding: 16px;
}
.panel h2{
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--brass-dim); margin: 0 0 12px; font-weight: 400;
}
.divider{ height:1px; background: var(--brass-dim); opacity:0.4; margin: 16px 0; }

.row{ display:flex; gap: 8px; margin-bottom: 10px; }
input[type="text"]{
  flex:1; background: var(--ink); border: 1px solid var(--brass-dim);
  color: var(--paper); font-family: 'Courier New', monospace; font-size: 0.85rem;
  padding: 9px 10px; border-radius: 3px; min-width: 0;
}
input:focus{ outline: 1px solid var(--brass); }

button{
  font-family: 'Courier New', monospace; font-size: 0.72rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  background: transparent; color: var(--brass); border: 1px solid var(--brass);
  border-radius: 3px; padding: 9px 14px; cursor:pointer;
}
button:active{ background: rgba(201,160,92,0.15); }
button.primary{ width:100%; background: rgba(201,160,92,0.12); padding: 11px; margin-top: 4px; }
button.accent{ flex:1; border-color: var(--ok); color: var(--ok); }
button.accent:active{ background: rgba(111,174,124,0.15); }
button.small{ padding: 5px 9px; font-size: 0.62rem; }
button.danger{ border-color: var(--warn); color: var(--warn); }

.status{
  font-family: 'Courier New', monospace; font-size: 0.72rem;
  color: var(--brass-dim); text-align:center; margin-top: 10px; min-height: 1.2em;
}
.status.err{ color: var(--warn); }
.status.ok{ color: var(--ok); }

/* --- Lista landmark salvati --- */
.landmark-list{ display:flex; flex-direction:column; gap:8px; }
.empty-msg{
  font-family: 'Courier New', monospace; font-size: 0.75rem;
  color: var(--brass-dim); text-align:center; padding: 10px 0;
}
.landmark-row{
  display:flex; align-items:center; gap:8px;
  background: rgba(255,255,255,0.02); border: 1px solid var(--brass-dim);
  border-radius: 4px; padding: 8px 10px;
}
.landmark-row .dot{
  width:10px; height:10px; border-radius:50%; flex-shrink:0; cursor:pointer;
}
.landmark-row .info{ flex:1; min-width:0; cursor:pointer; }
.landmark-row .info .name{
  font-family: 'Courier New', monospace; font-size: 0.8rem; color: var(--paper);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.landmark-row .info .coords{
  font-family: 'Courier New', monospace; font-size: 0.62rem; color: var(--brass-dim);
}
.landmark-row.active{ border-color: var(--ok); }
.landmark-row .actions{ display:flex; gap:6px; }

/* --- Toast notifica --- */
.toast{
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120%);
  background: var(--ok); color: var(--ink); font-family: 'Courier New', monospace;
  font-size: 0.8rem; font-weight: bold; padding: 12px 20px; border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); transition: transform 0.3s ease;
  z-index: 999; max-width: 90vw; text-align:center;
}
.toast.show{ transform: translate(-50%, 0); }
