/* Borderdraw web edition: the stage the game's canvas sits on, the bar under it, the share sheet and the friend's
   result. The game draws everything inside the canvas; this sheet only frames it. Copied to
   public/games/borderdraw/style.css by tools/borderdraw/build.mjs. */
:root {
  --bd-bg: #e6dabd;
  --bd-ink: #1d2a4d;
  --bd-dim: #5f5848;
  --bd-accent: #a8261c;
  --bd-btn: #1d2a4d;
  --bd-btn-ink: #f7efdc;
  --bd-serif: 'Iowan Old Style', Palatino, Georgia, serif;
}
:root[data-bd-look='B'] {
  --bd-bg: #0f1d40;
  --bd-ink: #ffffff;
  --bd-dim: #c9d3ea;
  --bd-accent: #f9c81e;
  --bd-btn: #f9623a;
  --bd-btn-ink: #ffffff;
}

.bd-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  min-height: 420px;
  background: var(--bd-bg);
  color: var(--bd-ink);
  transition: background-color 600ms ease;
  overflow: hidden;
}
.bd-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#bd-canvas {
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transition: opacity 240ms ease;
}
.bd-stage.is-ready #bd-canvas { opacity: 1; }
@media (min-width: 560px) {
  #bd-canvas { border-radius: 22px; box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.55); }
}

.bd-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 24px 24px 80px;
  text-align: center;
  pointer-events: none;
}
.bd-stage.is-ready .bd-loading { display: none; }
.bd-loading .bd-word {
  margin: 0;
  color: var(--bd-ink);
  font: 700 46px/1.05 var(--bd-serif);
  letter-spacing: -0.5px;
}
.bd-loading p { margin: 0; font: italic 400 18px/1.4 var(--bd-serif); color: var(--bd-dim); }
.bd-status {
  position: absolute;
  left: 50%;
  top: calc(50% + 78px);
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  text-align: center;
  font: 600 15px/1.4 var(--display, sans-serif);
  color: var(--bd-dim);
  pointer-events: none;
}
.bd-stage.is-ready .bd-status:empty { display: none; }
.bd-stage.is-ready .bd-status:not(:empty) {
  top: auto;
  bottom: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
}
.bd-stage.is-broken .bd-status { color: var(--bd-accent); }

.bd-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 4px 12px calc(4px + env(safe-area-inset-bottom));
  font: 600 14px/1.2 var(--display, sans-serif);
}
.bd-bar a, .bd-bar button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--bd-ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.bd-bar a:focus-visible, .bd-bar button:focus-visible, .bd-sheet button:focus-visible, .bd-sheet a:focus-visible {
  outline: 3px solid var(--bd-accent);
  outline-offset: 2px;
}
.bd-bar .bd-get { background: var(--bd-btn); color: var(--bd-btn-ink); font-weight: 700; }

.bd-friend {
  position: absolute;
  z-index: 2;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 6px 6px 6px 16px;
  border-radius: 999px;
  background: var(--bd-btn);
  color: var(--bd-btn-ink);
  font: 700 14px/1.3 var(--display, sans-serif);
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.6);
}
.bd-friend[hidden] { display: none; }
.bd-friend button {
  min-width: 36px;
  min-height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.bd-sheet {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100svh - 24px);
  padding: 18px;
  border: 0;
  border-radius: 24px;
  background: #f6eed9;
  color: #1d2a4d;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
}
.bd-sheet::backdrop { background: rgba(8, 12, 28, 0.55); }
.bd-sheet h2 { margin: 0 0 10px; font: 700 22px/1.2 var(--bd-serif); }
.bd-card {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 630;
  border-radius: 12px;
  background: #e6dabd;
}
.bd-card[hidden] { display: none; }
.bd-share-text {
  margin: 12px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 500 13px/1.4 ui-monospace, Menlo, monospace;
  color: #5f5848;
}
.bd-share-note { min-height: 1.3em; margin: 8px 0 0; font: 600 14px/1.3 var(--display, sans-serif); color: #1f6b3f; }
.bd-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.bd-actions a, .bd-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 2px solid #1d2a4d;
  border-radius: 999px;
  background: transparent;
  color: #1d2a4d;
  font: 700 15px/1 var(--display, sans-serif);
  text-decoration: none;
  cursor: pointer;
}
.bd-actions .bd-send { background: #1d2a4d; color: #f7efdc; flex: 1 1 100%; }
.bd-actions a[hidden] { display: none; }
.bd-crux {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(29, 42, 77, 0.15);
  font: 500 14px/1.35 var(--display, sans-serif);
}
.bd-crux p { margin: 0; flex: 1; }
.bd-crux .app-store-badge { flex: 0 0 auto; }

@media (prefers-reduced-motion: reduce) {
  .bd-stage, #bd-canvas { transition: none; }
}
