* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: #101208;
  color: #d9d3bc;
  font-family: "Courier New", ui-monospace, monospace;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

main {
  width: min(1080px, 100%);
  padding: 16px 16px 28px;
  display: grid;
  grid-template-columns: auto minmax(260px, 400px);
  column-gap: 28px;
  row-gap: 14px;
  align-items: start;
  justify-content: center;
}

.tv {
  grid-column: 1;
  grid-row: 1 / span 3;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #1c1c1c;
  padding: 14px 14px 8px;
  border-radius: 18px 18px 28px 28px;
  box-shadow:
    inset 0 0 0 3px #3a3a3a,
    0 18px 40px rgba(0, 0, 0, 0.45);
}

.mark {
  margin: 8px 0 0;
  line-height: 0;
}

.mark img {
  width: 97px;
  height: 45px;
  opacity: 0.72;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.help { grid-column: 2; grid-row: 2; }
.room { grid-column: 2; grid-row: 1; }
.pad { grid-column: 2; grid-row: 3; }

canvas {
  display: block;
  width: min(46vw, calc((100dvh - 75px) * 160 / 192), 520px);
  height: auto;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
  touch-action: none;
}

.help {
  text-align: center;
  line-height: 1.45;
  font-size: 13px;
}

.help p { margin: 0 0 4px; }

.scores { color: #9aa484; }

.room {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 14px 14px 16px;
  text-align: center;
  font-size: 14px;
  background: #1a1e14;
  border: 2px solid #6e944b;
  border-radius: 12px;
}

.room-lead { margin: 0; color: #9aa484; }

.room-msg { margin: 0; color: #f0a24a; }

.room form,
.room #room-setup,
.room #room-lobby {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.room form[hidden],
.room #room-lobby[hidden],
.room #room-setup[hidden],
.room-msg[hidden] { display: none; }

.room label { display: flex; align-items: center; gap: 6px; }

.room input {
  font-family: inherit;
  font-size: 14px;
  color: #f0e7bf;
  background: #1c2116;
  border: 1px solid #5c6248;
  padding: 6px 8px;
  width: 9em;
}

.room button {
  font-family: inherit;
  font-size: 13px;
  color: #f0e7bf;
  background: #242818;
  border: 2px solid #6e944b;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
}

.room button:disabled { opacity: 0.45; cursor: default; }

.room ul {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.room li { margin: 0; }

kbd {
  display: inline-block;
  min-width: 1.2em;
  padding: 0 5px;
  border: 1px solid #5c6248;
  background: #1c2116;
  color: #f0e7bf;
  font-family: inherit;
}

.pad {
  display: none;
  width: 100%;
  max-width: 420px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.pad .fire { grid-column: 1 / -1; }

.pad button {
  font-family: inherit;
  font-size: 18px;
  color: #f0e7bf;
  background: #242818;
  border: 2px solid #6e944b;
  min-height: 52px;
  border-radius: 6px;
}

.pad button:active { background: #3a4a22; }

@media (max-width: 900px) {
  main {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }

  .room,
  .help,
  .pad {
    max-width: 100%;
  }

  .tv { grid-column: 1; grid-row: 1; }
  .room { grid-column: 1; grid-row: 2; }
  .help { grid-column: 1; grid-row: 3; }
  .pad { grid-column: 1; grid-row: 4; }

  canvas {
    width: min(92vw, calc((100dvh - 539px) * 160 / 192), 420px);
  }
}

@media (pointer: coarse), (max-width: 820px) {
  .pad { display: grid; }
  .help { font-size: 12px; }
}
