:root {
  --bg: #08111f;
  --bg-soft: #11213a;
  --panel: rgba(7, 16, 30, 0.82);
  --panel-strong: rgba(9, 20, 36, 0.9);
  --line: rgba(151, 182, 255, 0.18);
  --text: #eef4ff;
  --muted: #8ea4cb;
  --accent: #5df4c7;
  --accent-warm: #ffb86b;
  --accent-hot: #ff6f91;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(
      circle at top left,
      rgba(93, 244, 199, 0.16),
      transparent 28%
    ),
    radial-gradient(
      circle at 85% 10%,
      rgba(255, 111, 145, 0.14),
      transparent 22%
    ),
    linear-gradient(135deg, #07111d 0%, #0a1628 42%, #132546 100%);
  color: var(--text);
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
}

body {
  overflow: hidden;
}

.page-shell {
  display: grid;
  grid-template-columns: 286px 1fr;
  height: 100vh;
  min-height: 100vh;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  gap: 10px;
  overflow: hidden;
}

.sidebar,
.stage-panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 16px 16px 14px;
  gap: 12px;
  overflow: hidden;
}

.brand-block h1,
.hero-strip h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2.3rem);
  line-height: 0.96;
  letter-spacing: -0.06em;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.68rem;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
  max-width: 24rem;
  word-break: break-word;
}

.game-nav {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  gap: 8px;
}

.game-tab {
  border: 1px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 11px 12px 10px;
  text-align: left;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.game-tab:hover,
.game-tab.active {
  transform: translateY(-2px);
  border-color: rgba(93, 244, 199, 0.34);
  background: linear-gradient(
    135deg,
    rgba(93, 244, 199, 0.12),
    rgba(255, 111, 145, 0.1)
  );
}

.game-tab span,
.game-tab small {
  display: block;
}

.game-tab span {
  margin-bottom: 4px;
  color: var(--accent-warm);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
}

.game-tab strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.94rem;
}

.game-tab small {
  color: var(--muted);
  font-size: 0.8rem;
}

.info-card,
.hud-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  padding: 12px;
  min-height: 0;
}

.info-card {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
}

.info-title,
.hud-label {
  margin: 0 0 8px;
  color: var(--accent-warm);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.stage-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 12px;
  gap: 10px;
  overflow: hidden;
}

.hero-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.room-bar {
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
  padding: 10px 12px;
  border: 1px solid rgba(93, 244, 199, 0.18);
  border-radius: 18px;
  background: linear-gradient(
    135deg,
    rgba(93, 244, 199, 0.08),
    rgba(255, 111, 145, 0.06)
  );
}

.room-bar[hidden] {
  display: none;
}

.room-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.room-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.invite-slot {
  width: 128px;
  display: flex;
  justify-content: flex-end;
  flex: 0 0 128px;
}

.room-label {
  margin: 0 0 4px;
  color: var(--accent-warm);
  font-size: 0.66rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.room-headline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.room-headline strong {
  font-size: 0.88rem;
  letter-spacing: 0.12em;
}

.room-headline span {
  color: var(--muted);
}

.invite-btn,
.queue-player button {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.invite-btn {
  width: 100%;
  padding: 7px 12px;
  white-space: nowrap;
}

.mode-segment {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.mode-option {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 12px;
  white-space: nowrap;
  transition:
    background 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

.mode-option.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(93, 244, 199, 0.2), rgba(255, 111, 145, 0.16));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24);
}

.invite-btn:hover,
.queue-player button:hover {
  border-color: rgba(93, 244, 199, 0.36);
  background: rgba(93, 244, 199, 0.12);
}

.player-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.queue-player {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 9px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 16, 30, 0.56);
}

.queue-player.is-self {
  border-color: rgba(93, 244, 199, 0.26);
}

.queue-player.is-active {
  background: rgba(255, 255, 255, 0.1);
}

.queue-player.is-defender {
  box-shadow: inset 0 0 0 1px rgba(93, 244, 199, 0.24);
}

.queue-player.is-challenger {
  box-shadow: inset 0 0 0 1px rgba(255, 216, 107, 0.24);
}

.queue-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 11px;
  color: #06101c;
  font-weight: 700;
  font-size: 0.85rem;
}

.queue-player button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 0;
  background: transparent;
  border: 0;
  min-width: 0;
}

.queue-player strong,
.queue-player small {
  white-space: nowrap;
}

.queue-player small {
  color: var(--muted);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.pill-row span {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.74rem;
}

.play-surface {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 210px);
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
  flex: 1 1 auto;
  height: 100%;
  overflow: hidden;
  min-height: 0;
  align-items: stretch;
}

.canvas-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent),
    rgba(5, 9, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.canvas-glow {
  position: absolute;
  inset: auto 5% -40px;
  height: 120px;
  background: radial-gradient(
    circle,
    rgba(93, 244, 199, 0.14),
    transparent 68%
  );
  filter: blur(18px);
  pointer-events: none;
}

.virtual-pad {
  position: absolute;
  left: 18px;
  bottom: 18px;
  display: none;
  width: min(38vw, 164px);
  aspect-ratio: 1;
  pointer-events: none;
  z-index: 2;
}

.virtual-pad[hidden] {
  display: none;
}

.virtual-pad__button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 31%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.08));
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  color: var(--text);
  font: inherit;
  font-size: clamp(0.82rem, 1.8vw, 1rem);
  font-weight: 700;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.virtual-pad__button span {
  opacity: 0.96;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
}

.virtual-pad__button.is-pressed {
  transform: translateY(1px) scale(0.98);
  background: linear-gradient(180deg, rgba(93, 244, 199, 0.34), rgba(255, 255, 255, 0.12));
  border-color: rgba(93, 244, 199, 0.56);
}

.virtual-pad__button--up {
  top: 0;
  left: 34.5%;
}

.virtual-pad__button--left {
  top: 34.5%;
  left: 0;
}

.virtual-pad__button--down {
  bottom: 0;
  left: 34.5%;
}

.virtual-pad__button--right {
  top: 34.5%;
  right: 0;
}

.hud-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.hud-card {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
}

.hud-stats,
.hud-controls,
#game-description {
  display: grid;
  flex: 1 1 auto;
  gap: 6px;
  color: var(--muted);
  line-height: 1.4;
  font-size: 0.9rem;
}

#game-description {
  overflow: hidden;
}

.stat-line,
.control-line,
.desc-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.stat-line strong,
.control-line strong,
.desc-line strong {
  color: var(--text);
  font-weight: 500;
}

kbd {
  display: inline-flex;
  min-width: 1.6em;
  padding: 0.15em 0.4em;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  font: inherit;
  justify-content: center;
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .page-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .stage-panel {
    order: 1;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    order: 2;
    height: auto;
    overflow: visible;
  }

  .play-surface {
    grid-template-columns: 1fr;
    height: auto;
    align-items: start;
  }

  .canvas-frame {
    min-height: clamp(360px, 62dvh, 760px);
    max-width: 100%;
  }

  .hud-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 0 0 auto;
  }

  .room-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .room-actions {
    width: 100%;
    justify-content: space-between;
  }

  .invite-slot {
    width: 128px;
    flex-basis: 128px;
  }

  .info-card {
    flex: 0 0 auto;
  }
}

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

  .page-shell {
    padding: 12px;
    gap: 12px;
  }

  .sidebar,
  .stage-panel {
    padding: 16px;
    border-radius: 22px;
  }

  .hero-strip,
  .hud-panel {
    grid-template-columns: 1fr;
    display: grid;
  }

  .pill-row {
    justify-content: flex-start;
  }

  .hero-strip {
    gap: 8px;
  }

  .stage-panel,
  .sidebar {
    background: linear-gradient(180deg, rgba(10, 21, 38, 0.94), rgba(7, 16, 30, 0.86));
  }

  .stage-panel {
    gap: 12px;
  }

  .play-surface {
    gap: 12px;
  }

  .canvas-frame {
    width: 100%;
    min-height: clamp(460px, 74dvh, 760px);
    aspect-ratio: 5 / 7;
    margin-inline: auto;
    border-radius: 26px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent),
      var(--panel-strong);
  }

  #game-canvas {
    touch-action: manipulation;
  }

  .room-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .invite-slot {
    width: 100%;
    flex-basis: auto;
  }

  .mode-segment {
    width: 100%;
  }

  .mode-option {
    flex: 1 1 50%;
  }

  .hud-panel {
    grid-template-columns: 1fr;
  }

  .desc-line,
  .control-line,
  .stat-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .virtual-pad {
    display: block;
    left: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
    width: min(42vw, 176px);
  }
}

@media (max-width: 520px) {
  .page-shell {
    padding: 10px;
    gap: 10px;
  }

  .sidebar,
  .stage-panel {
    padding: 14px;
    border-radius: 20px;
  }

  .brand-block h1,
  .hero-strip h2 {
    font-size: clamp(1.28rem, 7vw, 1.7rem);
  }

  .subtitle,
  .hud-stats,
  .hud-controls,
  #game-description {
    font-size: 0.84rem;
  }

  .canvas-frame {
    min-height: clamp(420px, 70dvh, 680px);
  }

  .virtual-pad {
    width: min(44vw, 168px);
    left: 12px;
  }
}
