:root {
  color-scheme: dark;
  --ink: #f7f8fb;
  --muted: #9ca7b8;
  --panel: rgba(8, 13, 20, .9);
  --line: rgba(255, 255, 255, .12);
  --red: #ef3340;
  --red-hot: #ff5360;
  --blue: #55a8ff;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: #06090d;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select { font: inherit; }

.live-client,
.live-stage {
  position: relative;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
}

.live-stage {
  display: grid;
  place-items: center;
  isolation: isolate;
  background:
    linear-gradient(90deg, rgba(2, 4, 7, .94) 0%, rgba(2, 4, 7, .72) 44%, rgba(2, 4, 7, .18) 78%),
    radial-gradient(circle at 82% 40%, rgba(239, 51, 64, .12), transparent 34%),
    url("/assets/images/headers/header-live-orange.webp") center / cover no-repeat,
    #070a0f;
}

.live-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .22;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(90deg, #000 0%, transparent 82%);
}

#canvas {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 5;
  display: none;
  border: 0;
  outline: 0;
  background: #000;
  object-fit: contain;
  touch-action: none;
}

.live-client.booting #canvas,
.live-client.running #canvas { display: block !important; }
.live-client.running .live-stage-shade { display: none; }
.live-client.running .live-stage {
  background: #000;
}

.live-stage-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.08), rgba(0,0,0,.42));
}

.live-launcher {
  position: relative;
  z-index: 2;
  width: min(100% - 40px, 560px);
  margin-right: min(42vw, 640px);
  padding: 52px 48px 46px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .5), inset 0 1px rgba(255,255,255,.04);
  backdrop-filter: blur(22px);
}

.live-brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 38px;
  font-size: 20px;
  font-weight: 950;
  letter-spacing: -.04em;
}

.live-brand-mark { color: var(--red); }
.live-brand-slash { color: #667384; }

.live-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 13px;
  color: #cbd2dc;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .2em;
}

.live-eyebrow span {
  width: 28px;
  height: 2px;
  background: var(--red);
  box-shadow: 0 0 16px rgba(239, 51, 64, .8);
}

h1 {
  margin: 0;
  font-size: clamp(42px, 5vw, 68px);
  line-height: .93;
  letter-spacing: -.075em;
}

h1 strong { color: var(--red); }

.live-intro {
  max-width: 470px;
  margin: 24px 0 32px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.live-server-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.035);
}

.live-server-card > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.live-label,
.live-select-label {
  color: #788596;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .16em;
}

.live-server-card strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-server-card small { color: #8d99a9; }

.live-pill {
  flex: none;
  padding: 6px 9px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  color: #aab4c1;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .1em;
}

.live-pill.live {
  border-color: rgba(239, 51, 64, .45);
  color: #ffadb3;
  background: rgba(239, 51, 64, .12);
}

.live-select-label {
  display: block;
  margin: 17px 0 7px;
}

.live-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  color: #eef2f7;
  background: #101721;
}

.live-select:focus { border-color: rgba(85, 168, 255, .6); }

.live-launch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 13px;
  padding: 16px 18px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #d91f2c, var(--red));
  box-shadow: 0 14px 38px rgba(239, 51, 64, .24);
  cursor: pointer;
  transition: transform .16s ease, filter .16s ease;
}

.live-launch:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.1); }
.live-launch:disabled { cursor: not-allowed; filter: grayscale(.55); opacity: .55; }
.live-launch span { font-size: 13px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.live-launch small { color: rgba(255,255,255,.68); font-size: 10px; }

.live-status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 20px;
  margin-top: 14px;
  color: #9aa5b4;
  font-size: 11px;
}

.live-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #738093;
  box-shadow: 0 0 0 4px rgba(115, 128, 147, .1);
}

.live-status.ready i { background: #50d890; box-shadow: 0 0 0 4px rgba(80,216,144,.12); }
.live-status.error i { background: var(--red-hot); box-shadow: 0 0 0 4px rgba(255,83,96,.12); }

.live-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 28px;
}

.live-links a {
  color: #8f9bab;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-decoration: none;
  text-transform: uppercase;
}

.live-links a:hover { color: #fff; }

.live-loading {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(90deg, rgba(2, 5, 9, .95), rgba(3, 7, 12, .78) 54%, rgba(3, 7, 12, .46)),
    radial-gradient(circle at 76% 38%, rgba(239, 51, 64, .2), transparent 34%),
    url("/assets/images/headers/header-live-orange.webp") center / cover no-repeat,
    #070a0f;
}

.live-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,.035) 4px);
  animation: loading-scan 10s linear infinite;
}

.live-loading-card {
  position: relative;
  width: min(100%, 620px);
  padding: 46px 48px 42px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 22px;
  background: rgba(7, 12, 18, .88);
  box-shadow: 0 30px 100px rgba(0,0,0,.58), inset 0 1px rgba(255,255,255,.05);
  backdrop-filter: blur(20px);
}

.live-loading-brand {
  display: flex;
  gap: 6px;
  margin-bottom: 42px;
  font-size: 18px;
  font-weight: 950;
  letter-spacing: -.04em;
}

.live-loading-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cbd2dc;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .2em;
}

.live-loading-kicker i {
  width: 26px;
  height: 2px;
  background: var(--red);
  box-shadow: 0 0 16px rgba(239,51,64,.8);
}

.live-loading h2 {
  margin: 13px 0 26px;
  font-size: clamp(38px, 5vw, 64px);
  line-height: .94;
  letter-spacing: -.065em;
}

.live-loading h2 strong { color: var(--red); }

.live-loading-message {
  margin: 0;
  color: #e5eaf1;
  font-size: 14px;
  font-weight: 700;
}

.live-loading-server {
  margin: 7px 0 24px;
  color: #8f9bab;
  font-size: 11px;
}

.live-loading-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
}

.live-loading-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #c91f2b, var(--red-hot));
  box-shadow: 0 0 18px rgba(239,51,64,.65);
  transition: width .28s ease;
}

.live-loading-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 11px;
  color: #8490a0;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .14em;
}

.live-loading-meta strong { color: #d7dde6; }

.live-loading-card > small {
  display: block;
  margin-top: 28px;
  color: #727f90;
  font-size: 10px;
  line-height: 1.5;
}

@keyframes loading-scan {
  to { transform: translateY(16px); }
}

.live-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  color: #eef2f7;
  background: #101721;
}

.live-input:focus { border-color: rgba(85, 168, 255, .6); }

.touch-keyboard-toggle {
  position: fixed;
  z-index: 30;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  display: none;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(216,179,74,.55);
  border-radius: 8px;
  color: #e9e2cd;
  background: rgba(12,12,10,.55);
  font-size: 22px;
}

.touch-keyboard-toggle:focus-visible,
.touch-keyboard-toggle.active { outline: 0; background: rgba(216,179,74,.85); color: #14120c; }
.live-client.running .touch-keyboard-toggle { display: flex; }

.touch-keyboard {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: none;
  padding: 6px 5px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(216,179,74,.45);
  background: rgba(10,10,8,.88);
  touch-action: none;
  user-select: none;
}
.touch-keyboard.open { display: block; }
.touch-keyboard-preview {
  height: 38px;
  margin-bottom: 6px;
  padding: 0 10px;
  overflow: hidden;
  border-radius: 6px;
  color: #14120c;
  background: #fff;
  font: 18px/38px system-ui, sans-serif;
  white-space: nowrap;
}
.touch-keyboard-preview.empty { color: rgba(20,18,12,.38); }
.touch-keyboard-row { display: flex; gap: 5px; margin-bottom: 5px; }
.touch-keyboard-row:last-child { margin-bottom: 0; }
.touch-keyboard-key {
  flex: 1 1 0;
  min-width: 0;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 6px;
  color: #e9e2cd;
  background: rgba(52,50,44,.92);
  font: 19px system-ui, sans-serif;
}
.touch-keyboard-key.small { font-size: 13px; }
.touch-keyboard-key.accent,
.touch-keyboard-key.down { color: #14120c; background: rgba(216,179,74,.9); }
.touch-keyboard-key.held { background: rgba(216,179,74,.4); border-color: rgba(216,179,74,.9); }

.touch-controls {
  position: fixed;
  z-index: 29;
  right: 18px;
  bottom: 18px;
  left: 18px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}
.touch-dpad,
.touch-actions { display: grid; gap: 8px; pointer-events: auto; }
.touch-dpad { grid-template-columns: repeat(3, 54px); }
.touch-dpad button:nth-child(1) { grid-column: 2; }
.touch-dpad button:nth-child(2) { grid-column: 1; grid-row: 2; }
.touch-dpad button:nth-child(3) { grid-column: 2; grid-row: 2; }
.touch-dpad button:nth-child(4) { grid-column: 3; grid-row: 2; }
.touch-actions { grid-template-columns: repeat(2, 76px); }
.touch-controls button {
  min-height: 50px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 10px;
  color: #fff;
  background: rgba(15,18,24,.72);
  font-size: 11px;
  font-weight: 800;
  touch-action: none;
  user-select: none;
}
.touch-controls button:active { background: rgba(239,51,64,.82); }
.live-client:not(.running) .touch-controls { display: none; }

.hidden { display: none !important; }

@media (max-width: 980px) {
  .live-launcher { margin-right: 0; }
}

@media (max-width: 620px) {
  .live-stage { align-items: end; }
  .live-launcher {
    width: 100%;
    padding: 34px 24px 28px;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 24px 24px 0 0;
  }
  .live-brand { margin-bottom: 24px; }
  .live-intro { margin-bottom: 22px; }
  .live-loading { padding: 16px; }
  .live-loading-card { padding: 34px 26px 30px; }
  .live-loading-brand { margin-bottom: 30px; }
  .live-actions { top: 12px; right: 12px; left: 12px; justify-content: flex-end; }
}
