:root {
  --bg: #0b111c;
  --bg2: #18263d;
  --panel: rgba(12, 18, 30, 0.84);
  --line: rgba(138, 214, 255, 0.3);
  --text: #e9f5ff;
  --muted: #9ab7cf;
  --accent: #8effd7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 520px at 10% 0%, rgba(142, 255, 215, 0.12), transparent 58%),
    radial-gradient(820px 470px at 95% 0%, rgba(140, 180, 255, 0.1), transparent 54%),
    linear-gradient(155deg, var(--bg), var(--bg2));
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 14px 14px, 22px 22px;
}

.wrap {
  width: min(1000px, 94vw);
  margin: 1.2rem auto 1.8rem;
  position: relative;
  z-index: 1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
  padding: 0.9rem;
  margin-bottom: 0.85rem;
}

.hero h1,
h2,
h3 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
}

.eyebrow {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: var(--accent);
}

.hero p { color: var(--muted); }

.home-link,
button {
  border: 1px solid rgba(138, 214, 255, 0.55);
  border-radius: 10px;
  color: var(--text);
  background: rgba(24, 40, 64, 0.9);
  text-decoration: none;
  padding: 0.42rem 0.68rem;
  font-family: "Orbitron", sans-serif;
  font-size: 0.74rem;
  cursor: pointer;
}

.lock-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#ptPassword {
  flex: 1;
  min-width: 220px;
  border: 1px solid rgba(138, 214, 255, 0.35);
  border-radius: 10px;
  background: rgba(9, 18, 30, 0.85);
  color: var(--text);
  padding: 0.48rem 0.6rem;
  font-size: 0.92rem;
}

.error {
  color: #ff9fad;
  margin: 0.45rem 0 0;
}

.content ul {
  margin: 0.45rem 0 0.85rem;
  color: #d4e8f8;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.55rem;
  margin-top: 0.5rem;
}

.grid article {
  border: 1px solid rgba(138, 214, 255, 0.22);
  border-radius: 11px;
  background: rgba(11, 20, 33, 0.75);
  padding: 0.55rem;
}

.grid p,
.note {
  color: var(--muted);
  margin: 0.3rem 0 0;
}

.match-topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.match-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

label,
select {
  font-size: 0.78rem;
  font-family: "Orbitron", sans-serif;
}

select {
  border: 1px solid rgba(138, 214, 255, 0.35);
  border-radius: 10px;
  color: var(--text);
  background: rgba(9, 18, 30, 0.85);
  padding: 0.42rem 0.5rem;
}

.battle-wrap {
  margin-top: 0.75rem;
  border: 1px solid rgba(80, 160, 130, 0.25);
  border-radius: 14px;
  background: rgba(4, 10, 18, 0.85);
  padding: 0.55rem;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.55);
}

/* ── Nameplates ── */
.nameplate {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.65rem;
  border-radius: 10px;
  background: rgba(8, 16, 28, 0.85);
  border: 1px solid rgba(138, 214, 255, 0.14);
}

.nameplate-b {
  margin-bottom: 0.45rem;
  border-color: rgba(255, 90, 90, 0.32);
}

.nameplate-a {
  margin-top: 0.45rem;
  border-color: rgba(74, 174, 255, 0.32);
}

.np-left {
  display: flex;
  flex-direction: column;
  min-width: 96px;
}

.np-name {
  font-family: "Orbitron", sans-serif;
  font-size: 0.7rem;
  color: var(--text);
}

.np-towers {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  margin-top: 0.12rem;
}

.nameplate-a .np-towers { color: #4aaeff; }
.nameplate-b .np-towers { color: #ff6060; }

.np-bars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.bar-lbl {
  font-family: "Orbitron", sans-serif;
  font-size: 0.52rem;
  color: var(--muted);
  width: 18px;
  text-align: right;
  letter-spacing: 0.04em;
}

.bar-track {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 80ms linear;
}

.hp-fill {
  background: linear-gradient(90deg, #1aee6e, #5affca);
  box-shadow: 0 0 6px rgba(80, 255, 160, 0.4);
}

.en-fill {
  background: linear-gradient(90deg, #1a8eff, #80d4ff);
  box-shadow: 0 0 6px rgba(40, 160, 255, 0.35);
}

.bar-num {
  font-family: "Orbitron", sans-serif;
  font-size: 0.6rem;
  min-width: 34px;
  text-align: right;
  color: var(--text);
}

.np-gold {
  font-family: "Orbitron", sans-serif;
  font-size: 0.62rem;
  color: #ffd966;
  min-width: 72px;
  text-align: right;
}

/* ── Deck ── */
.deck {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
}

.deck-top {
  margin-bottom: 0.42rem;
}

.deck-bottom {
  margin-top: 0.42rem;
}

/* ── Unit Cards ── */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid rgba(80, 140, 220, 0.38);
  border-radius: 10px;
  background: linear-gradient(170deg, rgba(14, 24, 44, 0.97), rgba(6, 10, 22, 0.99));
  color: var(--text);
  padding: 0.5rem 0.35rem 0;
  min-height: 92px;
  cursor: grab;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  overflow: hidden;
  text-align: center;
  gap: 0.08rem;
}

.card:hover:not([data-disabled="1"]) {
  border-color: rgba(120, 210, 255, 0.75);
  box-shadow: 0 0 18px rgba(80, 160, 255, 0.35), inset 0 0 8px rgba(80, 160, 255, 0.06);
  transform: translateY(-3px);
}

.card:active { cursor: grabbing; }

.card[data-disabled="1"] {
  opacity: 0.36;
  cursor: not-allowed;
}

.card[data-selected="1"] {
  border-color: var(--accent);
  box-shadow: 0 0 22px rgba(142, 255, 215, 0.5), inset 0 0 10px rgba(142, 255, 215, 0.08);
  transform: translateY(-3px);
}

.card-icon {
  font-size: 1.6rem;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(100, 190, 255, 0.6));
}

.card-cost {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Orbitron", sans-serif;
  font-size: 0.64rem;
  font-weight: 900;
  color: #050d18;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.cost-low  { background: linear-gradient(135deg, #4eff8e, #00e0b0); }
.cost-mid  { background: linear-gradient(135deg, #ffd54f, #ffb020); }
.cost-high { background: linear-gradient(135deg, #ffaa30, #ff7010); }
.cost-max  { background: linear-gradient(135deg, #ff6060, #cc1030); color: #fff; }

.card-name {
  font-family: "Orbitron", sans-serif;
  font-size: 0.56rem;
  letter-spacing: 0.05em;
  color: var(--text);
}

.card-hp {
  color: var(--muted);
  font-size: 0.56rem;
}

.card-cd-bar {
  display: block;
  width: 100%;
  height: 5px;
  background: rgba(0, 0, 0, 0.5);
  margin-top: auto;
  overflow: hidden;
}

.card-cd-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #00e5ff, #6affe0);
  transition: width 220ms linear;
}

.card[data-disabled="1"] .card-cd-bar i {
  background: rgba(255, 90, 50, 0.45);
}

.board {
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(80, 160, 120, 0.4);
  border-radius: 12px;
  min-height: 300px;
  background-color: #08160e;
  background-image:
    linear-gradient(90deg, rgba(30, 120, 220, 0.18) 0%, rgba(30, 120, 220, 0.05) 28%, transparent 40%),
    linear-gradient(270deg, rgba(220, 60, 60, 0.18) 0%, rgba(220, 60, 60, 0.05) 28%, transparent 40%),
    repeating-linear-gradient(
      180deg,
      transparent 0px, transparent 98px,
      rgba(80, 180, 120, 0.22) 98px, rgba(80, 180, 120, 0.22) 100px
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0px, transparent 38px,
      rgba(80, 160, 100, 0.05) 38px, rgba(80, 160, 100, 0.05) 40px
    );
  box-shadow:
    0 0 24px rgba(0, 0, 0, 0.6),
    inset 0 0 40px rgba(0, 0, 0, 0.35);
}

.board::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 2px);
  width: 4px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(60, 180, 230, 0.5) 12%,
    rgba(80, 200, 255, 0.6) 50%,
    rgba(60, 180, 230, 0.5) 88%,
    transparent
  );
  box-shadow: 0 0 12px rgba(80, 200, 255, 0.4);
  pointer-events: none;
  z-index: 6;
}

.lane {
  position: relative;
  height: 100px;
  border-bottom: 1px solid rgba(80, 180, 120, 0.22);
}

.lane:last-child {
  border-bottom: 0;
}

.lane[data-drop="1"] {
  background: rgba(142, 255, 215, 0.07);
}

.lane-label {
  position: absolute;
  left: 8px;
  top: 6px;
  font-family: "Orbitron", sans-serif;
  font-size: 0.54rem;
  letter-spacing: 0.12em;
  color: rgba(120, 190, 150, 0.45);
}

.structure-layer,
.unit-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.unit-layer { z-index: 3; }

.structure {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  border-radius: 6px;
  border: 2px solid;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.95);
  font-weight: 700;
  transition: opacity 200ms ease, box-shadow 200ms ease;
}

.structure.team-a {
  background: rgba(18, 72, 180, 0.65);
  border-color: #4aaeff;
  box-shadow: 0 0 14px rgba(74, 174, 255, 0.8), inset 0 0 8px rgba(74, 174, 255, 0.25);
}

.structure.team-b {
  background: rgba(180, 36, 36, 0.65);
  border-color: #ff5555;
  box-shadow: 0 0 14px rgba(255, 70, 70, 0.8), inset 0 0 8px rgba(255, 70, 70, 0.25);
}

.structure.base {
  width: 38px;
  height: 38px;
  margin-left: -19px;
  margin-top: -19px;
  border-radius: 8px;
  border-width: 3px;
  font-size: 15px;
}

.structure[data-alive="0"] {
  opacity: 0.1;
  box-shadow: none;
  filter: grayscale(1);
}

.hp {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -9px;
  height: 4px;
  width: calc(100% + 10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  overflow: hidden;
  background: rgba(4, 10, 22, 0.9);
}

.hp > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #1aee6e, #5affca);
  transition: width 80ms linear;
}

.unit {
  position: absolute;
  border-radius: 4px;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  transition: left 80ms linear, top 80ms linear;
}

.unit.team-a {
  background: linear-gradient(135deg, #5ae0ff, #2055ff);
  box-shadow: 0 0 8px rgba(60, 180, 255, 0.85);
}

.unit.team-b {
  background: linear-gradient(135deg, #ff8080, #ff2040);
  box-shadow: 0 0 8px rgba(255, 60, 60, 0.85);
}

.unit[data-type="siege"] {
  width: 22px;
  height: 22px;
  margin-left: -11px;
  margin-top: -11px;
}

.unit[data-type="scout"] {
  width: 13px;
  height: 13px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 2px;
}

.unit[data-type="brawler"] {
  width: 20px;
  height: 20px;
  margin-left: -10px;
  margin-top: -10px;
  border-radius: 3px;
}

.unit[data-type="guardian"] {
  border-radius: 50%;
}

.upgrades {
  margin-top: 0.8rem;
}

.upgrade-grid {
  margin-top: 0.55rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.5rem;
}

.upgrade-grid article {
  border: 1px solid rgba(138, 214, 255, 0.22);
  border-radius: 10px;
  background: rgba(11, 20, 33, 0.75);
  padding: 0.5rem;
}

.upgrade-grid h4 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: 0.76rem;
}

.upgrade-grid p {
  color: var(--muted);
  font-size: 0.76rem;
  margin: 0.25rem 0 0.5rem;
}

@media (max-width: 820px) {
  .nameplate {
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .np-left {
    min-width: 80px;
  }

  .deck {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lane {
    height: 92px;
  }
}

.lobby-panel {
  margin-top: 0.75rem;
}

.lobby-desc {
  font-size: 0.76rem;
  margin-bottom: 0.35rem;
}

.lobby-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.lobby-or {
  color: var(--muted);
  font-size: 0.78rem;
}

.btn-primary {
  background: linear-gradient(135deg, rgba(40, 120, 200, 0.7), rgba(30, 80, 160, 0.8));
  border-color: rgba(80, 170, 255, 0.6);
  font-weight: 700;
}

.btn-primary:hover {
  box-shadow: 0 0 14px rgba(80, 160, 255, 0.5);
}

#ptJoinCode {
  flex: 1;
  min-width: 120px;
  max-width: 180px;
  border: 1px solid rgba(138, 214, 255, 0.35);
  border-radius: 10px;
  background: rgba(9, 18, 30, 0.85);
  color: var(--text);
  padding: 0.42rem 0.5rem;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ── Share box ── */
.share-box {
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(12, 30, 55, 0.7);
  border: 1px solid rgba(80, 170, 255, 0.35);
}

.share-label {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.share-link-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.share-link {
  flex: 1;
  border: 1px solid rgba(138, 214, 255, 0.3);
  border-radius: 8px;
  background: rgba(5, 12, 24, 0.9);
  color: var(--accent);
  padding: 0.4rem 0.55rem;
  font-size: 0.76rem;
  font-family: 'Space Grotesk', monospace;
  letter-spacing: 0.02em;
}

.share-code {
  margin: 0.35rem 0 0;
  font-size: 0.7rem;
  color: var(--muted);
}

.share-code strong {
  font-family: 'Orbitron', sans-serif;
  color: var(--accent);
  letter-spacing: 0.14em;
  font-size: 0.82rem;
}

.lobby-status {
  margin: 0.55rem 0 0;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.72rem;
  color: var(--muted);
}

.room-code {
  font-family: "Orbitron", sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-top: 0.55rem;
}
