:root {
  color-scheme: dark;
  --bg: #0a1714;
  --panel: #132620;
  --line: #294238;
  --text: #eef5ec;
  --muted: #a6b8ac;
  --accent: #c8ef78;
  --danger: #ffad98;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text)
}

header,
main,
footer {
  max-width: 1120px;
  margin: auto;
  padding: 24px
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  gap: 16px
}

a {
  color: var(--accent);
  text-underline-offset: 4px
}

.brand {
  font-size: 17px;
  letter-spacing: 1px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800
}

.brand small {
  color: var(--accent);
  font-size: 10px
}

h1 {
  font-size: clamp(34px, 6vw, 68px);
  line-height: 1.06;
  letter-spacing: -2px;
  margin: 14px 0 24px
}

h2 {
  font-size: 23px
}

p {
  line-height: 1.65
}

.hero {
  padding: 44px 0 30px;
  max-width: 740px
}

.eyebrow,
small,
.camera-label {
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 700
}

.eyebrow {
  color: var(--accent)
}

.muted,
footer {
  color: var(--muted)
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0
}

button,
.button,
select {
  min-height: 46px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #1d352b;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none
}

button:hover,
.button:hover {
  border-color: var(--accent)
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px
}

.primary {
  background: var(--accent);
  color: #162411;
  font-weight: 750
}

.button span {
  margin-left: 24px
}

button:disabled {
  opacity: .4;
  cursor: not-allowed
}

.panel,
.status-grid article {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  margin: 20px 0
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px
}

.status-grid article {
  margin: 0
}

.status-grid strong {
  display: block;
  margin: 14px 0
}

.status-grid p {
  font-size: 13px;
  color: var(--muted)
}

canvas,
video {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
  background: #08110e
}

canvas {
  touch-action: manipulation
}

#camera {
  width: 100%;
  max-height: 55vh;
  object-fit: contain
}

#source {
  width: 100%;
  cursor: crosshair
}

#board {
  width: 100%
}

#preview-section {
  max-width: 700px
}

.play-heading {
  display: flex;
  justify-content: space-between;
  align-items: center
}

.play-heading h1 {
  font-size: 100px;
  color: var(--accent);
  margin: 4px 0
}

.turn-score {
  display: block;
  font-size: 44px
}

.play-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px
}

.darts {
  display: grid;
  gap: 10px
}

.dart {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  gap: 8px
}

.dart strong {
  font-size: 24px
}

.dart button {
  font-size: 12px;
  padding: 8px
}

.camera-panel {
  padding: 14px;
  background: var(--panel);
  border-radius: 16px;
  align-self: start
}

.camera-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px
}

.camera-label span {
  color: var(--accent);
  font-size: 9px
}

.state {
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  background: var(--panel)
}

#message {
  padding: 14px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: #38291f;
  color: #ffe6d4;
  margin: 12px 0;
  white-space: pre-line
}

label {
  display: block;
  line-height: 1.6;
  margin: 16px 0
}

input[type=checkbox] {
  width: 20px;
  height: 20px;
  vertical-align: middle;
  margin-right: 8px;
  accent-color: var(--accent)
}

dialog {
  width: min(94vw, 510px);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px
}

dialog::backdrop {
  background: #000b
}

dialog canvas {
  width: min(100%, 330px);
  margin: auto
}

.close {
  float: right;
  font-size: 24px
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px
}

.debug-grid canvas {
  width: 100%
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px
}

footer {
  font-size: 12px;
  margin-top: 32px;
  border-top: 1px solid var(--line)
}

[hidden] {
  display: none !important
}

@media(max-width:680px) {

  header,
  main,
  footer {
    padding: 18px
  }

  .status-grid,
  .play-grid {
    grid-template-columns: 1fr
  }

  .hero {
    padding-top: 26px
  }

  .hero .actions {
    flex-direction: column
  }

  .play-heading h1 {
    font-size: 88px
  }

  .debug-grid {
    grid-template-columns: 1fr 1fr
  }

  header>a:last-child {
    font-size: 13px
  }

  .camera-panel {
    margin-top: 8px
  }

  .panel {
    padding: 18px
  }
}

@media(max-width:680px) {
  .play-grid {
    display: flex;
    flex-direction: column
  }

  .camera-panel {
    order: -1;
    width: 100%;
    margin-top: 0
  }
}
