.screen-main {
  width: min(960px, calc(100% - 24px));
  margin: 0 auto 32px;
}

.screen-picker {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
  font-weight: 600;
}

.screen-picker select {
  font-weight: 400;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

#screen-status,
#device-meta {
  margin: 0 0 8px;
}

.board-frame {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  background: #141a22;
  display: grid;
  place-items: center;
}

#board {
  width: 100%;
  height: auto;
  aspect-ratio: 480 / 320;
  display: block;
  touch-action: none;
}

.card-note {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.card-note h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.card-note p {
  margin: 0 0 12px;
}

@media (max-width: 800px), (max-height: 520px) {
  .topbar {
    justify-content: flex-end;
    padding: 8px 12px 0;
  }

  .screen-title {
    display: none;
  }

  .screen-main {
    width: calc(100% - 16px);
    margin-bottom: 16px;
  }

  .board-frame {
    width: min(100%, calc((100vh - 132px) * 480 / 320 + 16px));
    width: min(100%, calc((100dvh - 132px) * 480 / 320 + 16px));
    margin-inline: auto;
    margin-top: 4px;
    padding: 8px;
  }

  #board {
    width: 100%;
  }
}

:fullscreen {
  background: #141a22;
}

:-webkit-full-screen {
  background: #141a22;
}

:fullscreen body {
  background: #141a22;
}

:-webkit-full-screen body {
  background: #141a22;
}

:fullscreen .screen-title,
:fullscreen .topbar a,
:fullscreen #screen-status,
:fullscreen #device-meta,
:fullscreen .screen-picker {
  display: none;
}

:-webkit-full-screen .screen-title,
:-webkit-full-screen .topbar a,
:-webkit-full-screen #screen-status,
:-webkit-full-screen #device-meta,
:-webkit-full-screen .screen-picker {
  display: none;
}

:fullscreen .topbar {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  z-index: 5;
  padding: 0;
  background: transparent;
}

:-webkit-full-screen .topbar {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  z-index: 5;
  padding: 0;
  background: transparent;
}

:fullscreen .screen-main {
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0;
}

:-webkit-full-screen .screen-main {
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0;
}

:fullscreen .board-frame {
  width: 100%;
  height: 100%;
  margin: 0;
  display: grid;
  place-items: center;
  background: #141a22;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

:-webkit-full-screen .board-frame {
  width: 100%;
  height: 100%;
  margin: 0;
  display: grid;
  place-items: center;
  background: #141a22;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

:fullscreen #board {
  width: min(100%, calc(100vh * 480 / 320));
  max-height: 100%;
  height: auto;
}

:-webkit-full-screen #board {
  width: min(100%, calc(100vh * 480 / 320));
  max-height: 100%;
  height: auto;
}

html.is-fullscreen {
  background: #141a22;
  height: 100%;
}

html.is-fullscreen body {
  background: #141a22;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
}

html.is-fullscreen .screen-title,
html.is-fullscreen .topbar a,
html.is-fullscreen #screen-status,
html.is-fullscreen #device-meta,
html.is-fullscreen .screen-picker {
  display: none;
}

html.is-fullscreen .topbar {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  z-index: 5;
  padding: 0;
  background: transparent;
}

html.is-fullscreen .screen-main {
  width: 100%;
  max-width: none;
  height: 100dvh;
  margin: 0;
}

html.is-fullscreen .board-frame {
  width: 100%;
  height: 100%;
  margin: 0;
  display: grid;
  place-items: center;
  background: #141a22;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

html.is-fullscreen #board {
  width: min(100%, calc(100vh * 480 / 320));
  width: min(100%, calc(100dvh * 480 / 320));
  max-height: 100%;
  height: auto;
}
