:root {
  color-scheme: dark;
  --bg: #0a0d13;
  --surface: rgba(15, 19, 28, 0.84);
  --surface-strong: rgba(23, 29, 42, 0.94);
  --line: rgba(255, 255, 255, 0.13);
  --text: #f7fbff;
  --muted: #9faec2;
  --cyan: #39d7ff;
  --gold: #ffd36b;
  --coral: #ff6b7c;
  --green: #67e8a5;
  --ink: #071018;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  min-height: 100%;
  background:
    linear-gradient(115deg, rgba(57, 215, 255, 0.08), transparent 30%),
    linear-gradient(245deg, rgba(255, 211, 107, 0.08), transparent 34%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 80px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.026) 0 1px, transparent 1px 80px),
    linear-gradient(180deg, #0b0f16, #11151d 52%, #07090e);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 44px;
  padding: 0 18px;
  box-shadow: 0 12px 28px rgba(57, 215, 255, 0.20);
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button:hover {
  filter: brightness(1.04);
  box-shadow: 0 16px 32px rgba(57, 215, 255, 0.26);
}

button:active {
  transform: translateY(1px);
}

.app {
  width: min(1180px, 100vw);
  max-width: 100vw;
  min-height: 100svh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  overflow: hidden;
}

.topbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold), var(--coral));
  color: #18110a;
  font-size: 18px;
  font-weight: 950;
  box-shadow: 0 14px 34px rgba(255, 107, 124, 0.18);
}

.brand h1 {
  margin: 2px 0 0;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1;
  white-space: nowrap;
}

.eyebrow {
  display: block;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
}

.session {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px;
  backdrop-filter: blur(18px);
}

.session span,
.session strong {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 13px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session span {
  color: #d8e4f3;
}

.session strong {
  background: rgba(255, 255, 255, 0.09);
  color: var(--green);
}

.hud {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(180px, 1.45fr) repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  backdrop-filter: blur(18px);
}

.metric-main {
  background: linear-gradient(135deg, rgba(57, 215, 255, 0.16), rgba(103, 232, 165, 0.10)), var(--surface-strong);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
}

.hud strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(20px, 3vw, 32px);
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #05070d;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.44);
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 420px;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(5, 7, 13, 0.38), rgba(5, 7, 13, 0.88)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 18px);
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  width: min(560px, 100%);
  max-width: calc(100vw - 48px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(10, 13, 19, 0.76);
  padding: clamp(22px, 5vw, 42px);
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.overlay h2 {
  margin: 0;
  font-size: clamp(44px, 9vw, 88px);
  line-height: 0.94;
  overflow-wrap: anywhere;
}

.overlay p {
  margin: 12px auto 18px;
  color: #d3deec;
  font-size: clamp(15px, 2.5vw, 19px);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.primary-action {
  min-width: 152px;
  min-height: 48px;
}

.controls {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.control-btn {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  min-height: 54px;
  font-size: 26px;
}

.control-btn-accent {
  background: linear-gradient(135deg, var(--gold), var(--coral));
  box-shadow: 0 12px 28px rgba(255, 107, 124, 0.18);
}

.control-btn[disabled] {
  cursor: not-allowed;
  filter: grayscale(0.5) brightness(0.78);
  opacity: 0.72;
}

@media (max-width: 680px) {
  .app {
    width: 100%;
    padding: 10px;
    gap: 10px;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }

  .session {
    width: 100%;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px;
  }

  .session span,
  .session strong {
    justify-content: center;
    min-width: 0;
    min-height: 26px;
    padding: 0 8px;
    font-size: 12px;
  }

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

  .metric-main {
    grid-column: 1 / -1;
  }

  .stage-wrap,
  canvas {
    min-height: 50svh;
  }

  button {
    padding: 0 10px;
  }

  .overlay {
    padding: 16px;
  }

  .overlay-content {
    max-width: calc(100vw - 32px);
    padding: 22px 18px;
  }

  .overlay h2 {
    font-size: clamp(38px, 14vw, 56px);
  }

  .overlay p {
    font-size: 14px;
  }

  .control-btn {
    padding: 0;
  }
}

@media (max-width: 420px) {
  .brand h1 {
    font-size: 24px;
  }

  .hud strong {
    font-size: 22px;
  }

  .control-btn {
    min-height: 58px;
  }
}
