:root {
  --bg: #080a14;
  --panel: rgba(15, 18, 35, 0.95);
  --border: rgba(255, 255, 255, 0.08);
  --acc: #6366f1;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --text: #e2e8f0;
  --dim: #64748b;
  --card-w: 160px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 20% 0%, #1a1040 0%, #080a14 50%);
  color: var(--text);
  font-family: "Inter", sans-serif;
  overflow: hidden;
}

body {
  min-height: 100vh;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(10, 12, 25, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
}

.logo {
  font-size: 13px;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--dim);
}

.st-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.st-dot.g {
  background: var(--green);
  box-shadow: 0 0 5px var(--green);
}

.st-dot.r {
  background: var(--red);
}

.hsp {
  flex: 1;
}

.header-field {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.header-field label {
  font-size: 10px;
  color: var(--dim);
  white-space: nowrap;
}

.header-field input,
.header-field select {
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 11px;
}

.header-field input {
  width: 210px;
}

.header-select select {
  width: 90px;
  cursor: pointer;
}

.zoom-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--dim);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 80px;
  height: 3px;
  background: rgba(99, 102, 241, 0.25);
  border-radius: 2px;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--acc);
}

.hbtn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--dim);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.hbtn:hover {
  background: rgba(99, 102, 241, 0.15);
  color: var(--acc);
  border-color: rgba(99, 102, 241, 0.3);
}

#file-import {
  display: none;
}

#grid-area {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

#grid-area::-webkit-scrollbar {
  width: 4px;
}

#grid-area::-webkit-scrollbar-thumb {
  background: #1d2235;
  border-radius: 2px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr));
  gap: 8px;
  align-content: start;
}

.phone-card {
  aspect-ratio: 388 / 690;
  background: #090c1a;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s;
}

.phone-card:hover {
  border-color: rgba(99, 102, 241, 0.35);
}

.phone-card.connected {
  border-color: rgba(16, 185, 129, 0.3);
}

.phone-card.error {
  border-color: rgba(239, 68, 68, 0.3);
}

.phone-card.paused .paused-badge {
  display: block;
}

.phone-card.is-selected {
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.5);
}

.vs {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #000;
  position: relative;
}

.vs canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  background: #000;
  touch-action: none;
  cursor: crosshair;
}

.covl {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.82);
  transition: opacity 0.3s;
  z-index: 10;
}

.covl.gone {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--acc);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.covl-txt {
  font-size: 9px;
  color: var(--dim);
  text-align: center;
  padding: 0 6px;
}

.paused-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 7px;
  color: var(--dim);
  z-index: 20;
  display: none;
}

.clbl {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 5px;
  background: rgba(8, 10, 20, 0.95);
  border-top: 1px solid var(--border);
  pointer-events: none;
}

.ldot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ldot.on {
  background: var(--green);
  box-shadow: 0 0 4px var(--green);
}

.ldot.off {
  background: var(--red);
}

.ldot.ing {
  background: var(--yellow);
}

.cname {
  font-size: 8px;
  color: rgba(255, 255, 255, 0.75);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cip {
  font-size: 7px;
  color: var(--dim);
  font-family: monospace;
  flex-shrink: 0;
}

.btn-del {
  display: none;
  padding: 1px 5px;
  border: none;
  border-radius: 3px;
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  font-size: 9px;
  cursor: pointer;
  pointer-events: all;
  transition: background 0.15s;
}

.btn-del:hover {
  background: rgba(239, 68, 68, 0.4);
}

.phone-card:hover .btn-del {
  display: inline-block;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 900;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
}

.mbox {
  position: relative;
  margin: 12vh auto 0;
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.mtitle {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

.mf {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.mf label {
  font-size: 10px;
  color: var(--dim);
}

.mf input {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 12px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

.mf input:focus {
  border-color: var(--acc);
}

.mf input::placeholder {
  color: var(--dim);
}

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

.mbtns button {
  flex: 1;
  padding: 9px;
  border-radius: 8px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-cancel {
  background: rgba(255, 255, 255, 0.06);
  color: var(--dim);
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-add {
  background: var(--acc);
  color: #fff;
}

.btn-add:hover {
  background: #5254cc;
}

.empty-state {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--dim);
  pointer-events: none;
}

.empty-state.hidden {
  display: none !important;
}

#tc {
  position: fixed;
  bottom: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 999;
}

.tst {
  padding: 7px 13px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11px;
  animation: tin 0.2s ease-out, tout 0.3s ease-in 2.7s forwards;
  max-width: 220px;
}

@keyframes tin {
  from {
    transform: translateX(110%);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes tout {
  to {
    opacity: 0;
    pointer-events: none;
  }
}

.hidden-support {
  display: none !important;
}
