:root {
  --page-padding: 12px;
  --stats-height: 24px;
  --panel-gap: 8px;
  --board-size: min(
    640px,
    calc(100vw - var(--page-padding) - var(--page-padding)),
    calc(
      100dvh - var(--page-padding) - var(--page-padding) - var(--stats-height) -
        var(--panel-gap)
    )
  );
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #d3d3d3;
  color: #111;
  font-family: Arial, Helvetica, sans-serif;
  overscroll-behavior: none;
}

.page-layout {
  width: 100vw;
  height: 100dvh;
  padding: var(--page-padding);
}

.game-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--panel-gap);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.stats {
  display: flex;
  align-items: center;
  gap: clamp(3px, 0.7vw, 12px);
  width: var(--board-size);
  height: var(--stats-height);
  overflow: hidden;
  font-size: clamp(8px, 1vmin, 13px);
  line-height: 1;
  white-space: nowrap;
}

.stats > * {
  flex: 0 0 auto;
}

.privacy-link {
  margin-left: auto;
  color: #0000ee;
  text-decoration: underline;
}

.privacy-link:visited {
  color: #0000ee;
}

.board-container {
  position: relative;
  width: var(--board-size);
  aspect-ratio: 1;
  touch-action: none;
}

#game-board {
  display: block;
  width: 100%;
  height: 100%;
  background: #b9b9b9;
  outline: 1px solid #000;
  outline-offset: -1px;
  image-rendering: pixelated;
}

.overlay {
  position: absolute;
  inset: 1px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgb(211 211 211 / 88%);
  text-align: center;
}

.overlay[hidden],
.overlay p[hidden] {
  display: none;
}

.overlay p {
  margin: 0;
}

#overlay-message {
  font-size: clamp(16px, 3vmin, 24px);
}

#overlay-details {
  margin-top: 8px;
  font-size: clamp(13px, 2.2vmin, 18px);
  line-height: 1.4;
  white-space: pre-line;
}

@media (max-width: 360px) {
  .stats {
    gap: 2px;
    font-size: 7px;
  }
}
