/* SPDX-License-Identifier: GPL-3.0-only */
:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #10191d;
  color: #e7ecec;
}

body {
  margin: 0;
}

main {
  width: min(60rem, 100%);
  margin: 0 auto;
  padding: 1.5rem;
  box-sizing: border-box;
}

h1, h2 {
  margin: 0 0 0.5rem;
}

header p, .hint {
  color: #aab9ba;
}

#setup {
  padding: 1rem;
  border: 1px solid #35474a;
  border-radius: 0.5rem;
  background: #182529;
}

#setup header {
  margin-bottom: 1rem;
}

#setup[hidden], #game[hidden] {
  display: none;
}

.options, .manager-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
}

fieldset {
  margin: 1rem 0;
  border: 1px solid #405458;
  border-radius: 0.4rem;
}

label {
  display: grid;
  gap: 0.3rem;
}

input, select, button {
  min-height: 2.4rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid #60787a;
  border-radius: 0.3rem;
  background: #102024;
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
  background: #276247;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

/* The game: only the BMH screen, as large as the window allows at 4:3. */
#game {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
  overflow: hidden;
}

#stage {
  position: relative;
  width: min(100vw, calc(100vh * 4 / 3));
  aspect-ratio: 4 / 3;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #143b2c;
  image-rendering: pixelated;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#touch-back { display: none; }

@media (any-pointer: coarse) {
  #touch-back {
    display: block;
    position: fixed;
    left: max(0.4rem, env(safe-area-inset-left));
    bottom: max(0.4rem, env(safe-area-inset-bottom));
    z-index: 2;
    min-width: 44px;
    min-height: 44px;
    background: rgba(16, 25, 29, 0.85);
    touch-action: manipulation;
  }
}

#screen[hidden] { display: none; }
#screen[data-high-resolution="true"] { image-rendering: auto; }

/* Errors appear over the screen and are closed with a click. */
#error-overlay {
  position: absolute;
  left: 50%;
  bottom: 4%;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 0.6rem 1rem;
  border: 1px solid #c98a3c;
  border-radius: 0.4rem;
  background: rgba(16, 25, 29, 0.92);
  color: #ffd08b;
  cursor: pointer;
  box-shadow: 0 0.3rem 1rem rgba(0, 0, 0, 0.6);
}

#error-overlay[hidden] { display: none; }

#error-overlay p {
  margin: 0 0 0.2rem;
}

#error-overlay small {
  color: #aab9ba;
}

/* The indicator on the right edge opens the sidebar with every other control. */
#sidebar-toggle {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 3;
  width: 1.4rem;
  min-height: 0;
  height: 4.5rem;
  padding: 0;
  border: 1px solid #60787a;
  border-right: none;
  border-radius: 0.4rem 0 0 0.4rem;
  background: rgba(24, 37, 41, 0.55);
  color: #b7c8bd;
  font-size: 1.1rem;
  transition: right 0.2s ease, background 0.2s ease;
  /* The arrow is drawn by CSS, so the button holds no text a caret could sit in. */
  user-select: none;
  caret-color: transparent;
}

#sidebar-toggle::before {
  content: "‹";
  display: inline-block;
}

#sidebar-toggle:hover, #sidebar-toggle:focus-visible {
  background: rgba(39, 98, 71, 0.9);
}

/* A decision waits in the sidebar. */
#sidebar-toggle[data-attention="true"] {
  background: rgba(201, 138, 60, 0.9);
  color: #10191d;
  animation: attention 1.2s ease-in-out infinite alternate;
}

@keyframes attention {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

#sidebar {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 2;
  box-sizing: border-box;
  width: min(22rem, 85vw);
  height: 100vh;
  padding: 1rem;
  overflow-y: auto;
  border-left: 1px solid #35474a;
  background: #182529;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

#game[data-sidebar="open"] #sidebar {
  transform: none;
}

#game[data-sidebar="open"] #sidebar-toggle {
  right: min(22rem, 85vw);
}

#game[data-sidebar="open"] #sidebar-toggle::before {
  transform: scaleX(-1);
}

#sidebar .toolbar {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

#seat-invites {
  display: grid;
  gap: 0.4rem;
}

#invite-link {
  width: 100%;
  box-sizing: border-box;
}

#desk-caption {
  margin: 0 0 0.5rem;
  color: #b7c8bd;
  font-variant-numeric: tabular-nums;
}

#decision-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #60787a;
  border-radius: 0.4rem;
  background: #102024;
}

#decision-panel[hidden] {
  display: none;
}

#decision-panel h2 {
  margin: 0 0 0.5rem;
}

#decision-panel form,
#decision-panel ul {
  margin: 0.75rem 0;
}

#decision-panel button {
  margin: 0.25rem 0.5rem 0.25rem 0;
}

#status {
  min-height: 1.5rem;
  color: #ffc978;
}
