:root {
  color-scheme: dark;
  --bg-1: #050914;
  --bg-2: #081325;
  --panel: rgba(9, 18, 34, 0.78);
  --panel-strong: rgba(8, 16, 30, 0.92);
  --line: rgba(145, 204, 255, 0.16);
  --line-strong: rgba(145, 204, 255, 0.28);
  --text: #e8f3ff;
  --muted: #8aa3c6;
  --accent: #59d8ff;
  --accent-2: #ffd166;
  --danger: #ff7a90;
  --good: #68f0a8;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(89, 216, 255, 0.16), transparent 30%),
    radial-gradient(circle at top right, rgba(255, 209, 102, 0.14), transparent 26%),
    linear-gradient(180deg, #07101f 0%, #040810 100%);
}

body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, black 46%, transparent 96%);
}

body::after {
  background: radial-gradient(circle at center, transparent 55%, rgba(0, 0, 0, 0.5) 100%);
}

button,
input,
summary {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  color: var(--text);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.page-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(9, 18, 34, 0.75);
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
}

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

.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(9, 18, 34, 0.75);
  color: var(--muted);
  box-shadow: var(--shadow);
}

.status-pill[data-tone='online'] {
  color: var(--good);
  border-color: rgba(104, 240, 168, 0.3);
}

.status-pill[data-tone='offline'] {
  color: #ff9eb0;
  border-color: rgba(255, 122, 144, 0.32);
}

.status-pill[data-tone='busy'] {
  color: var(--accent-2);
  border-color: rgba(255, 209, 102, 0.34);
}

.status-pill.ghost {
  color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) minmax(280px, 320px);
  gap: 18px;
  align-items: start;
}

.panel {
  background: linear-gradient(180deg, rgba(15, 26, 47, 0.92), rgba(7, 14, 26, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(89, 216, 255, 0.08), transparent 28%, transparent 72%, rgba(255, 209, 102, 0.06));
}

.setup-column,
.arena-column,
.sidebar {
  display: grid;
  gap: 18px;
}

.hero,
.systems-panel,
.sidebar-panel,
.arena-panel {
  padding: 24px;
}

.eyebrow,
.label {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
  margin: 0 0 10px;
}

h1,
h2 {
  margin: 0;
  font-family: 'Syncopate', sans-serif;
}

h1 {
  font-size: clamp(1.8rem, 2.6vw, 2.5rem);
  line-height: 1.1;
}

h2 {
  font-size: 1.06rem;
  line-height: 1.2;
}

.lede,
.status-text,
.invite-help,
.footer-copy,
.mini-status,
.guide-item p,
.feature-item p,
.fact p {
  color: var(--muted);
}

.lede {
  margin: 14px 0 0;
  line-height: 1.55;
}

.step-strip,
.guide-list,
.feature-list,
.facts {
  display: grid;
  gap: 12px;
}

.step-strip {
  margin-top: 22px;
}

.step-card,
.guide-item,
.feature-item,
.fact {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(145, 204, 255, 0.12);
  background: rgba(8, 16, 30, 0.58);
}

.step-card div,
.guide-item,
.feature-item,
.fact {
  display: block;
}

.step-number {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(89, 216, 255, 0.22), rgba(255, 209, 102, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-weight: 700;
}

.step-card strong,
.guide-item strong,
.feature-item strong,
.fact strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.step-card p,
.guide-item p,
.feature-item p,
.fact p {
  margin: 0;
  line-height: 1.5;
  font-size: 0.95rem;
}

.field-grid {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.field-grid label,
.advanced-field {
  display: grid;
  gap: 8px;
}

.field-grid span,
.advanced-field span {
  color: var(--muted);
  font-size: 0.88rem;
}

input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(145, 204, 255, 0.18);
  background: rgba(5, 12, 24, 0.72);
  color: var(--text);
}

input:focus {
  outline: 2px solid rgba(89, 216, 255, 0.26);
  border-color: rgba(89, 216, 255, 0.4);
}

.hero-actions,
.invite-row,
.arena-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-actions {
  margin-top: 18px;
}

.primary,
.secondary,
.hero-actions button,
.arena-actions button,
.touch-boost {
  padding: 13px 16px;
  border-radius: 16px;
  border: 1px solid rgba(145, 204, 255, 0.18);
  background: rgba(10, 20, 36, 0.8);
}

.primary {
  background: linear-gradient(135deg, rgba(89, 216, 255, 0.24), rgba(255, 209, 102, 0.18));
  border-color: rgba(89, 216, 255, 0.34);
}

.invite-panel,
.advanced-panel {
  margin-top: 18px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(145, 204, 255, 0.12);
  background: rgba(7, 14, 27, 0.64);
}

.invite-header,
.panel-heading,
.arena-footer,
.player-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.advanced-panel summary {
  cursor: pointer;
  color: var(--text);
}

.advanced-field {
  margin-top: 16px;
}

.status-text {
  margin: 18px 0 0;
  line-height: 1.55;
}

.arena-panel {
  padding-bottom: 18px;
}

.arena-header {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.combat-strip {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) repeat(2, minmax(180px, 0.8fr));
  gap: 12px;
  margin-bottom: 16px;
}

.hud-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(5, 12, 24, 0.68);
  border: 1px solid rgba(145, 204, 255, 0.12);
}

.feed-card,
.feed-mini {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(5, 12, 24, 0.68);
  border: 1px solid rgba(145, 204, 255, 0.12);
}

.feed-card {
  background:
    linear-gradient(135deg, rgba(89, 216, 255, 0.08), rgba(255, 209, 102, 0.08)),
    rgba(5, 12, 24, 0.74);
}

.feed-text,
.mini-copy {
  margin: 0;
  line-height: 1.45;
}

.feed-text {
  color: var(--text);
}

.mini-copy {
  color: var(--muted);
}

.hud-value {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.room-code {
  letter-spacing: 0.2em;
}

.arena-stage {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(145, 204, 255, 0.16);
  background:
    radial-gradient(circle at top, rgba(89, 216, 255, 0.12), transparent 28%),
    linear-gradient(180deg, rgba(4, 10, 19, 0.96), rgba(1, 4, 10, 1));
}

.arena-stage::before {
  content: '';
  display: block;
  padding-top: 56.25%;
}

#gameCanvas,
.mobile-controls {
  position: absolute;
  inset: 0;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.arena-footer {
  margin-top: 16px;
  padding: 0 6px 0 2px;
  align-items: center;
}

.sidebar-panel .panel-heading {
  margin-bottom: 12px;
}

.player-cards {
  display: grid;
  gap: 12px;
}

.player-card {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(145, 204, 255, 0.12);
  background: rgba(8, 16, 30, 0.58);
}

.player-name {
  font-size: 1.02rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.player-role {
  color: var(--muted);
  font-size: 0.92rem;
}

.inline-chip {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(89, 216, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(89, 216, 255, 0.16);
  white-space: nowrap;
}

.empty-chip {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.player-stats {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.meter {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.meter-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #59d8ff, #68f0a8);
}

.meter-fill.danger {
  background: linear-gradient(90deg, #ff7a90, #ffb067);
}

.meter-fill.boost {
  background: linear-gradient(90deg, #ffd166, #fff2a6);
}

.meter-fill.xp {
  background: linear-gradient(90deg, #9a7dff, #59d8ff);
}

.mobile-controls {
  display: none;
  pointer-events: none;
}

.touch-pad,
.touch-boost {
  pointer-events: auto;
}

.touch-pad {
  position: absolute;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  background: rgba(5, 12, 24, 0.36);
  border: 1px solid rgba(145, 204, 255, 0.12);
  backdrop-filter: blur(12px);
  touch-action: none;
}

.move-pad {
  left: 18px;
  bottom: 18px;
}

.touch-cluster {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 14px;
  justify-items: end;
}

.aim-pad {
  position: relative;
}

.touch-boost {
  min-width: 96px;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.16);
  border-color: rgba(255, 209, 102, 0.28);
}

.touch-ring {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.14);
}

.touch-knob {
  position: absolute;
  width: 52px;
  height: 52px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(89, 216, 255, 0.9), rgba(255, 209, 102, 0.92));
  box-shadow: 0 10px 26px rgba(89, 216, 255, 0.28);
}

.touch-label {
  position: absolute;
  inset: auto 0 18px;
  text-align: center;
  font-size: 0.76rem;
  color: var(--text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 18px);
  opacity: 0;
  padding: 13px 18px;
  border-radius: 999px;
  background: rgba(5, 12, 24, 0.92);
  border: 1px solid rgba(145, 204, 255, 0.18);
  color: var(--text);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 20;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1320px) {
  .layout {
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  }

  .sidebar {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .page-shell {
    padding: 14px;
  }

  .topbar,
  .topbar-status,
  .arena-footer,
  .invite-header {
    flex-direction: column;
    align-items: stretch;
  }

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

  .combat-strip {
    grid-template-columns: 1fr;
  }

  .hero,
  .systems-panel,
  .sidebar-panel,
  .arena-panel {
    padding: 18px;
  }
}

@media (pointer: coarse) {
  .mobile-controls {
    display: block;
  }

  .footer-copy {
    padding-bottom: 104px;
  }
}
