:root {
  --bg: #000;
  --fg: #d9ffd2;
  --accent: #39ff14;
  --glow: rgba(57, 255, 20, 0.35);
  --line: #1f5c16;
  --muted: #86c97a;
  --field: #050d04;
  --danger: #ff5a5a;
  --warn: #ffd23f;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html {
  background: var(--bg);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding: calc(8px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.view { max-width: 480px; margin: 0 auto; }

h1 {
  margin: 16vh 0 2rem;
  text-align: center;
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 5px var(--accent), 0 0 18px var(--accent), 0 0 40px #00ff41;
}
h2 { font-size: 1.3rem; color: var(--accent); }
h3 { font-size: 1rem; color: var(--accent); margin: 18px 0 8px; }

button {
  font: inherit;
  color: var(--accent);
  background: transparent;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  min-height: 50px;
  padding: 0 10px;
  box-shadow: 0 0 8px var(--glow), inset 0 0 8px rgba(57, 255, 20, 0.08);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
button:active, button.pressed { background: var(--accent); color: #000; }
button:disabled { cursor: default; }
button.primary { background: var(--accent); color: #000; font-weight: 700; }
button.primary:active { background: #b9ff9e; }
button.big { width: 100%; min-height: 56px; font-size: 1.1rem; }
button.danger { color: var(--danger); border-color: var(--danger); box-shadow: 0 0 8px rgba(255, 90, 90, 0.3); }
button.danger:active { background: var(--danger); color: #000; }
button.link {
  min-height: 0; padding: 0; border: 0; box-shadow: none; background: none;
  color: var(--accent); text-decoration: underline; font-weight: 600;
}
button.icon { width: 50px; padding: 0; display: grid; place-items: center; }
button.armed { background: var(--danger); border-color: var(--danger); color: #000; }

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg .solid { fill: currentColor; stroke: none; }

input[type=password], input[type=text] {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  font: inherit;
  font-size: 16px;               /* stops iOS zooming in */
  color: var(--fg);
  background: var(--field);
  border: 1.5px solid var(--line);
  border-radius: 10px;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 10px var(--glow); }
input[type=range] { width: 100%; accent-color: var(--accent); }

#login-form { display: grid; gap: 12px; }
.msg { min-height: 1.4em; color: var(--warn); text-align: center; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 6px 2px 10px; }

.bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.status { flex: 1; display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #444; flex: none; }
.dot.on { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.dot.starting, .dot.stopping { background: var(--warn); box-shadow: 0 0 10px var(--warn); }

.warning {
  border: 1.5px solid var(--warn);
  color: var(--warn);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 0.95rem;
}
.warning .link { color: var(--warn); }

.vpn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}
.vpn svg { width: 16px; height: 16px; color: var(--accent); }

.panel { border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; display: grid; gap: 10px; }

fieldset { border: 0; min-width: 0; }
fieldset:disabled { opacity: 0.4; }

.row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; margin: 8px 0; }

.sites {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin: 8px 0;
}
.sites button { line-height: 1.15; padding: 4px 8px; overflow-wrap: anywhere; }

.btn-list { list-style: none; display: grid; gap: 8px; margin-bottom: 10px; }
.btn-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name del" "url del";
  align-items: center;
  column-gap: 10px;
  padding: 8px 8px 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
}
.btn-list .btn-name { grid-area: name; font-weight: 600; }
.btn-list small { grid-area: url; color: var(--muted); overflow-wrap: anywhere; }
.btn-list button { grid-area: del; }
.btn-form { display: grid; gap: 10px; }

.pad {
  height: 40vh;
  min-height: 210px;
  max-height: 420px;
  margin: 8px 0;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(57, 255, 20, 0.07), transparent 70%), var(--field);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.pad.active { border-color: var(--accent); }
.pad.dragging { border-color: var(--accent); box-shadow: inset 0 0 30px var(--glow); }
.pad-hint small { font-size: 0.8rem; opacity: 0.8; }

.volume { grid-template-columns: 1fr 1fr 1fr 1fr; grid-auto-flow: row; }
.vol { display: grid; place-items: center; font-weight: 700; color: var(--accent); }

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-areas: ". up ." "left ok right" ". down .";
  gap: 8px;
  max-width: 300px;
  margin: 14px auto;
}
.dpad .up { grid-area: up; }
.dpad .left { grid-area: left; }
.dpad .ok { grid-area: ok; font-weight: 700; }
.dpad .right { grid-area: right; }
.dpad .down { grid-area: down; }

.type { display: flex; gap: 8px; margin-top: 14px; }

.conn, .toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: #0d1f0a;
  border: 1.5px solid var(--accent);
  color: var(--fg);
  box-shadow: 0 0 14px var(--glow);
  text-align: center;
}
.conn { border-color: var(--warn); }

dialog {
  margin: auto;
  width: min(440px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  background: #030803;
  color: var(--fg);
  border: 1.5px solid var(--accent);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 0 30px var(--glow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.75); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
#pw-form { display: grid; gap: 10px; }
#pw-form h3 { margin-bottom: 0; }
.stack { display: grid; gap: 10px; margin-top: 18px; }
