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

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 30% 15%, rgba(76, 139, 245, 0.18), transparent 36%),
    linear-gradient(180deg, #121923 0%, #070a0f 100%);
}

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

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 12, 18, 0.78);
}

.hud strong {
  display: block;
  font-size: 20px;
  letter-spacing: 0;
}

.hud span {
  color: #b9c3d4;
  font-size: 12px;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-weight: 800;
}

.stats span {
  min-width: 64px;
  padding: 7px 8px;
  text-align: center;
  color: #fff4c2;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

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

canvas {
  display: block;
  width: min(100%, calc((100vh - 92px) * 0.5625));
  max-height: calc(100vh - 92px);
  aspect-ratio: 9 / 16;
  background: #163b61;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.45);
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: linear-gradient(180deg, rgba(7, 10, 15, 0.6), rgba(7, 10, 15, 0.86));
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  margin: 0;
  font-size: clamp(38px, 9vw, 76px);
  line-height: 0.95;
  color: #ffdf5a;
  text-shadow: 0 4px 0 #7d2d15;
}

.overlay p {
  margin: 0;
  color: #dbe6f8;
}

button {
  border: 0;
  border-radius: 6px;
  background: #ffb02e;
  color: #14100a;
  font-weight: 900;
  padding: 12px 20px;
  cursor: pointer;
}

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

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

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

.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.24);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.hidden {
  display: none !important;
}

.list {
  display: grid;
  gap: 6px;
  max-height: 150px;
  overflow: auto;
}

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

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

.invite {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  width: min(380px, 86%);
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 12px;
  text-align: center;
  background: rgba(7, 12, 20, 0.94);
  border: 1px solid rgba(255, 214, 90, 0.5);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.36);
  z-index: 4;
}

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

.overlay small {
  max-width: 420px;
  color: #9eaabd;
}

.roll {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(67, 162, 255, 0.86);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.38);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.38);
}

@media (max-width: 640px) {
  .shell {
    padding: 8px;
  }

  .hud {
    align-items: flex-start;
  }

  .stats {
    gap: 6px;
  }

  .stats span {
    min-width: 58px;
    padding: 6px;
    font-size: 11px;
  }
}
