:root {
  color-scheme: dark;
  --bg: #080a0d;
  --panel: #111820;
  --panel-2: #16212b;
  --line: rgba(255, 255, 255, 0.15);
  --text: #f4f7fb;
  --muted: #9aa9ba;
  --cyan: #48e5ff;
  --coral: #ff5b7d;
  --lime: #b8ff6a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
}

body {
  align-items: center;
  background:
    radial-gradient(circle at 18% 20%, rgba(72, 229, 255, 0.17), transparent 28rem),
    radial-gradient(circle at 82% 78%, rgba(255, 91, 125, 0.15), transparent 30rem),
    linear-gradient(135deg, #080a0d, #0e141b 52%, #090b10);
  color: var(--text);
  display: flex;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  justify-content: center;
  padding: clamp(8px, 1.6vw, 22px);
  user-select: none;
}

button,
select,
input {
  font: inherit;
}

.shell {
  display: grid;
  gap: 14px;
  max-width: 1680px;
  width: min(96vw, calc((100vh - 178px) * 1.7778));
}

.topbar {
  align-items: center;
  background: rgba(17, 24, 32, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 18px;
}

.eyebrow {
  color: var(--cyan);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0 0 3px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 3.4rem);
  line-height: 1;
  margin: 0;
}

.controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

button,
select,
input {
  background: var(--panel-2);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: var(--text);
  min-height: 42px;
}

button {
  cursor: pointer;
  font-weight: 800;
  padding: 0 18px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

button:hover {
  background: #1b2a36;
  border-color: rgba(72, 229, 255, 0.55);
  transform: translateY(-1px);
}

.select-wrap {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.84rem;
  gap: 8px;
}

select {
  cursor: pointer;
  padding: 0 34px 0 12px;
}

input {
  outline: none;
  padding: 0 12px;
  text-transform: uppercase;
  width: 104px;
}

input:focus {
  border-color: rgba(72, 229, 255, 0.72);
}

.online-panel {
  align-items: center;
  background: rgba(17, 24, 32, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
}

.online-panel[hidden] {
  display: none;
}

.room-field {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.84rem;
  gap: 8px;
}

.online-status {
  color: var(--muted);
  flex: 1 1 280px;
  font-size: 0.9rem;
  margin: 0;
}

.arena-wrap {
  aspect-ratio: 16 / 9;
  background: #020305;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(72, 229, 255, 0.08) inset;
  overflow: hidden;
  position: relative;
  touch-action: none;
  width: 100%;
}

canvas {
  display: block;
  height: 100%;
  width: 100%;
}

.message {
  align-items: center;
  background: rgba(5, 8, 12, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  left: 50%;
  max-width: min(470px, calc(100% - 28px));
  padding: 18px 20px;
  pointer-events: none;
  position: absolute;
  text-align: center;
  top: 50%;
  transform: translate(-50%, -50%);
}

.message strong {
  font-size: clamp(1.35rem, 4vw, 2.7rem);
  line-height: 1;
}

.message span {
  color: var(--muted);
  font-size: clamp(0.85rem, 2.4vw, 1rem);
}

.message.hidden {
  opacity: 0;
}

@media (max-width: 720px) {
  html,
  body {
    min-height: 100dvh;
  }

  body {
    align-items: start;
    padding: 8px;
  }

  .shell {
    gap: 8px;
    width: 100%;
  }

  .topbar {
    align-items: stretch;
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  h1 {
    font-size: clamp(2.1rem, 12vw, 3rem);
  }

  .controls {
    justify-content: start;
  }

  button {
    flex: 1 1 96px;
    padding: 0 12px;
  }

  .select-wrap {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  .online-panel {
    align-items: stretch;
  }

  .online-panel button {
    flex: 1 1 120px;
  }

  .room-field {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  input {
    flex: 0 1 142px;
  }

  .arena-wrap {
    aspect-ratio: auto;
    height: min(68dvh, calc(100dvh - 246px));
    min-height: 430px;
  }
}

@media (max-width: 720px) and (orientation: landscape) {
  body {
    padding: 6px;
  }

  .shell {
    grid-template-rows: auto 1fr;
    height: calc(100dvh - 12px);
  }

  .topbar {
    grid-template-columns: 1fr auto;
    padding: 8px 10px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: 1.55rem;
  }

  .arena-wrap {
    height: 100%;
    min-height: 0;
  }
}
