:root {
  color-scheme: dark;
  font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  background: #191725;
  color: #f9f6ef;
}

* { box-sizing: border-box; }

body { margin: 0; }

main {
  width: min(100% - 2rem, 40rem);
  margin: clamp(1rem, 4vh, 2.5rem) auto;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem 1rem;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3.5rem);
  line-height: 1;
  letter-spacing: -.08em;
}

#connection {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  color: #f6d74e;
  font-size: .875rem;
}

#connection::before {
  content: '';
  width: .48rem;
  aspect-ratio: 1;
  background: currentColor;
}

#connection[data-state='live'] { color: #61cea7; }

#instructions {
  margin: .75rem 0 1rem;
  color: #d5cfe0;
  font-size: .875rem;
  line-height: 1.5;
}

.palette-tools {
  margin-bottom: .625rem;
}

.swatches {
  display: grid;
  gap: clamp(.25rem, 1.4vw, .5rem);
}

#palette { grid-template-columns: repeat(12, minmax(0, 1fr)); }

button {
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.swatches button {
  min-height: 2.25rem;
  border: 2px solid #777087;
  border-radius: .25rem;
  background: var(--color);
}

.swatches button[aria-pressed='true'] {
  border-color: #fff;
  box-shadow: inset 0 0 0 2px #191725;
}

#open-colors { display: none; }
#open-colors span {
  width: .875rem;
  height: .875rem;
  flex: none;
  border-radius: .1875rem;
  border: 1px solid #d5cfe0;
  background: var(--color);
}

.player .palette-tools { margin-bottom: .375rem; }

@media (max-width: 41.99rem) {
  .palette-tools { display: flex; align-items: stretch; gap: .5rem; }
  #palette { flex: 1; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  #palette button:not([data-quick]) { display: none; }
  #palette button { min-height: 2.75rem; }
  #open-colors { display: inline-flex; align-items: center; gap: .375rem; }
}

.player .palette-tools { display: flex; align-items: stretch; gap: .5rem; }
.player #palette { flex: 1; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.player #palette button:not([data-quick]) { display: none; }
.player #palette button { min-height: 2.25rem; }
.player #open-colors { display: inline-flex; align-items: center; gap: .375rem; }

#color-dialog {
  position: fixed;
  inset: auto 0 0;
  margin: 0 auto;
  width: min(100%, 30rem);
  max-width: 100%;
  max-height: min(95vh, 32rem);
  max-height: min(95dvh, 32rem);
  padding: .875rem .875rem max(.875rem, env(safe-area-inset-bottom));
  border: 1px solid #777087;
  border-radius: .875rem .875rem 0 0;
  background: #211e30;
  color: inherit;
  overflow: auto;
}

#color-dialog::backdrop { background: #100e1aba; }
body:has(#color-dialog[open]) { overflow: hidden; }
.color-dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.color-dialog-header h2 { margin: 0; font-size: 1rem; }
#all-colors { grid-template-columns: repeat(6, minmax(0, 1fr)); }
#all-colors button { min-height: 2.75rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .375rem;
  margin-bottom: .625rem;
}

.toolbar button,
#open-colors,
#close-colors,
#jump button,
#jump input {
  border: 1px solid #777087;
  border-radius: .25rem;
  background: #29263a;
  color: inherit;
  font: inherit;
  font-size: .875rem;
  min-height: 2.25rem;
  padding: .25rem .625rem;
}

.toolbar button { min-width: 2.25rem; }
button:disabled { opacity: .42; cursor: default; }

#zoom-status {
  margin-left: auto;
  color: #d5cfe0;
  font-size: .875rem;
}

.board-frame {
  border: 1px solid #777087;
  background: #302d40;
}

#board {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  user-select: none;
  touch-action: none;
  cursor: zoom-in;
}

#board[data-can-place='true'][data-live='true'] { cursor: crosshair; }
#board[data-can-place='true'][data-live='false'] { cursor: grab; }
#board:active { cursor: grabbing; }

:focus-visible {
  outline: 2px solid #f9f6ef;
  outline-offset: 2px;
}

#board:focus-visible {
  outline-offset: -2px;
  outline-color: #537bff;
}

.board-footer {
  margin-top: .75rem;
  font-size: .875rem;
}

#jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

#jump label { display: flex; align-items: center; gap: .25rem; }
#jump input { width: 4.5rem; font-size: 1rem; }
#share-fallback { margin-top: .6rem; }
#share-fallback:not([hidden]) { display: flex; align-items: center; gap: .5rem; }
#spot-link { min-width: 0; flex: 1; font: inherit; }
.board-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .25rem .75rem;
  margin-top: .6rem;
}

#notice { margin: 0; color: #d5cfe0; }
#notice[data-error='true'] { color: #ff9da6; }
.creator-link { margin-left: auto; color: #d5cfe0; text-underline-offset: .2em; }

.player main {
  width: min(100% - 1rem, 40rem);
  height: 100vh;
  height: 100svh;
  margin: 0 auto;
  padding: .5rem 0;
  display: flex;
  flex-direction: column;
}

.player header { gap: .375rem .625rem; }
.player h1 { font-size: 1.375rem; }
.player .full-board { color: #d5cfe0; font-size: .875rem; }
.player #instructions { margin: .375rem 0; }
.player .toolbar { margin-bottom: .375rem; }
.player .board-frame { flex: 1; min-height: 0; }
.player #board { height: 100%; aspect-ratio: auto; }
.player #jump { display: none; }
.player .board-footer { margin-top: 0; }
.player .board-meta { margin-top: .375rem; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
