:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101116;
  color: #f6f2e8;
}

* {
  box-sizing: border-box;
}

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

body {
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(33, 177, 154, 0.2), transparent 34%),
    linear-gradient(315deg, rgba(234, 75, 93, 0.22), transparent 42%),
    #101116;
}

.game-shell {
  width: min(1420px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  margin: 0 auto;
}

.main-column {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.topbar,
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(16, 17, 22, 0.82);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.brand,
.statusbar div {
  display: grid;
  gap: 2px;
}

.brand strong {
  font-size: 1rem;
}

.brand span,
.statusbar span,
.connection {
  color: #b9c0c6;
  font-size: 0.78rem;
  text-transform: uppercase;
}

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

button,
input {
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #f6f2e8;
  font: inherit;
}

button {
  min-width: 78px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #44d7be;
  background: rgba(68, 215, 190, 0.18);
}

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

input {
  width: 82px;
  padding: 0 10px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0;
}

.arena-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 38 / 27;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #161922;
}

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

.overlay {
  position: absolute;
  left: 50%;
  top: 18px;
  width: min(520px, calc(100% - 28px));
  transform: translateX(-50%);
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(16, 17, 22, 0.94);
  text-align: center;
  pointer-events: none;
}

.overlay span {
  color: #c8ced2;
  font-size: 0.86rem;
}

.statusbar {
  justify-content: start;
}

.statusbar div {
  min-width: 110px;
}

.rooms-panel {
  min-height: 0;
  align-self: stretch;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(16, 17, 22, 0.82);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

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

.panel-title span,
.room-meta,
.room-state,
.empty-room {
  color: #b9c0c6;
  font-size: 0.78rem;
}

.rooms-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.room-item {
  width: 100%;
  height: auto;
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 10px;
  text-align: left;
}

.room-item.active {
  border-color: #44d7be;
  background: rgba(68, 215, 190, 0.14);
}

.room-code {
  font-weight: 800;
  letter-spacing: 0;
}

.room-players {
  color: #f6f2e8;
  font-size: 0.88rem;
  line-height: 1.25;
}

.empty-room {
  padding: 12px 2px;
}

@media (max-width: 760px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .rooms-panel {
    order: 2;
    position: static;
    max-height: none;
  }

  body {
    padding: 10px;
  }

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

  .room-controls {
    justify-content: start;
  }

  button {
    min-width: 68px;
    padding: 0 10px;
  }

  .statusbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .statusbar div {
    min-width: 0;
  }
}
