:root {
  color-scheme: light;
  font-family: Chicago, Geneva, "Helvetica Neue", Arial, sans-serif;
  background: #777;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background: #777;
  color: #000;
}

button,
input {
  font: inherit;
}

.soccer-app {
  width: min(100%, 780px);
  padding: clamp(6px, 2vw, 18px);
  display: grid;
  justify-items: center;
  gap: 8px;
}

.game-frame {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 8px;
}

canvas {
  display: block;
  width: min(100%, calc((100svh - 150px) * 512 / 342), 768px);
  height: auto;
  aspect-ratio: 512 / 342;
  background: #fff;
  border: 1px solid #111;
  border-radius: 0;
  box-shadow: 7px 7px 0 rgb(0 0 0 / 30%);
  image-rendering: pixelated;
  outline: none;
  touch-action: manipulation;
}

canvas:focus-visible {
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px #111, 7px 7px 0 rgb(0 0 0 / 30%);
}

.direction-controls {
  width: min(100%, 620px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.control-group {
  display: grid;
  grid-template-columns: auto repeat(3, minmax(42px, 1fr));
  align-items: center;
  gap: 4px;
}

.control-group > span {
  padding-right: 3px;
  font-size: 13px;
  font-weight: 700;
}

.direction-controls button,
.utility-controls button,
.dialog-panel button {
  min-height: 38px;
  padding: 5px 8px;
  border: 1px solid #111;
  border-radius: 0;
  background: #eee;
  color: #000;
  box-shadow: inset 1px 1px #fff, inset -1px -1px #777;
  cursor: pointer;
  touch-action: manipulation;
}

.direction-controls button:active,
.direction-controls button.is-selected,
.utility-controls button:active,
.dialog-panel button:active {
  color: #fff;
  background: #111;
  box-shadow: none;
}

.direction-controls button:disabled {
  color: #777;
  cursor: default;
  opacity: 0.55;
}

.utility-controls {
  width: min(100%, 620px);
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, 1fr));
  gap: 5px;
}

.visible-status {
  min-height: 1.3em;
  margin: 0;
  text-align: center;
  font-size: 13px;
}

.hypercard-dialog {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(0 0 0 / 42%);
}

.hypercard-dialog[hidden] {
  display: none;
}

.dialog-panel {
  width: min(100%, 390px);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 18px;
  border: 2px solid #000;
  background: #fff;
  box-shadow: 6px 6px 0 rgb(0 0 0 / 45%);
}

.dialog-panel label {
  grid-column: 1 / -1;
  font-weight: 700;
}

.dialog-input {
  min-width: 0;
  min-height: 38px;
  padding: 5px 7px;
  border: 2px solid #000;
  border-radius: 0;
  background: #fff;
  color: #000;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 620px) {
  body {
    place-items: start center;
  }

  .soccer-app {
    padding: max(6px, env(safe-area-inset-top)) 4px 8px;
  }

  canvas {
    width: 100%;
  }

  .direction-controls {
    grid-template-columns: 1fr;
  }

  .control-group {
    grid-template-columns: 58px repeat(3, minmax(40px, 1fr));
  }

  .visible-status {
    padding-inline: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

/* Reserve room for the common player controls in portrait and landscape. */
.hc-player-active canvas {
  width: min(100%, calc((100dvh - var(--hc-controls-height) - 150px) * 512 / 342), 768px);
}
