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

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 190, 61, 0.22), transparent 34%),
    linear-gradient(180deg, #10263a, #081018 72%);
}

.app {
  width: min(100vw, 1120px);
  min-height: 100vh;
  padding: 12px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(4, 10, 16, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.top strong {
  display: block;
  font-size: 20px;
}

.top span {
  color: #b7c5d8;
  font-size: 12px;
}

.scorebar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-weight: 900;
}

.scorebar span {
  min-width: 68px;
  padding: 8px;
  color: #fff2a8;
  text-align: center;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.field {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
}

canvas {
  width: min(100%, calc((100vh - 86px) * 1.777));
  max-height: calc(100vh - 86px);
  aspect-ratio: 16 / 9;
  display: block;
  background: #277445;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  touch-action: manipulation;
}

.bat-controls {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: rgba(4, 10, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.bat-controls button {
  min-width: 38px;
  padding: 8px 10px;
  line-height: 1;
}

.bat-controls span {
  min-width: 76px;
  color: #f7fbff;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.menu,
.result,
.invite {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  padding: 20px;
  background: rgba(4, 10, 16, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.menu {
  inset: 0;
  place-content: center;
  background: linear-gradient(180deg, rgba(4, 10, 16, 0.36), rgba(4, 10, 16, 0.88));
}

.menu h1 {
  margin: 0;
  color: #ffd45c;
  font-size: clamp(42px, 9vw, 88px);
  line-height: 0.88;
  text-shadow: 0 5px 0 #7d3218;
}

.panel {
  display: grid;
  justify-items: center;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  width: min(340px, 78vw);
  color: #d7e3f4;
  text-align: left;
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 10px 11px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 12px 18px;
  color: #171006;
  background: #ffbd35;
  font-weight: 900;
  cursor: pointer;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.online {
  width: min(420px, 86vw);
  display: grid;
  gap: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.28);
}

#playersList {
  display: grid;
  gap: 6px;
  max-height: 150px;
  overflow: auto;
}

.player-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.09);
}

.player-row button {
  padding: 7px 10px;
}

.result {
  width: min(430px, 88vw);
}

.result img {
  width: min(280px, 70vw);
}

.result h2,
.result p {
  margin: 0;
}

.invite {
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(400px, 88vw);
  z-index: 4;
}

.invite div {
  display: flex;
  gap: 8px;
}

.hidden { display: none !important; }

@media (max-width: 680px) {
  .app { padding: 8px; }
  .top { align-items: flex-start; }
  .scorebar span { min-width: 54px; padding: 6px; font-size: 11px; }
  .bat-controls { right: 8px; bottom: 8px; }
}
