:root {
  color-scheme: dark;
  font: 100% system-ui, sans-serif;
  color: #f3f8fc;
  background: #0a121a;
  --surface: #13212d;
  --line: #304457;
  --muted: #bacbd9;
  --accent: #dcfa79;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: radial-gradient(ellipse at 50% 0%, #162635, transparent 65%); }
main {
  display: grid;
  grid-template: auto 1fr / minmax(0, 1fr) minmax(16rem, 19rem);
  align-items: start;
  gap: 1.35rem;
  max-width: 72rem;
  margin: auto;
  padding: 1.5rem clamp(.75rem, 3.5vw, 2rem) 1.25rem;
}

.masthead {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: clamp(1.65rem, 5vw, 2.8rem);
  line-height: 1;
  font-weight: 950;
  font-style: italic;
  letter-spacing: -.075em;
  white-space: nowrap;
}
h1 span { color: var(--accent); }
h2, h3, p, dl, dd, ul, ol { margin: 0; }
h2 { font-size: 1rem; }
h3 { font-size: .875rem; }

button, select {
  min-height: 44px;
  border: 1px solid #4b657b;
  border-radius: .45rem;
  color: inherit;
  background: #182a38;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { opacity: .58; cursor: default; }
select { appearance: none; padding: 0 2rem 0 .7rem; }
.language { position: relative; }
.language::after {
  position: absolute;
  top: 17px;
  right: .8rem;
  width: .45rem;
  height: .45rem;
  border: solid var(--muted);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  content: "";
  pointer-events: none;
}

.table-header { display: flex; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; flex-wrap: wrap; margin-bottom: .65rem; }
#hint { color: var(--muted); font-size: .875rem; }
#challenge-date, #calendar-notice { color: var(--muted); font-size: .875rem; }
#calendar-notice { margin-bottom: .65rem; }
.challenge-links { display: flex; flex-wrap: wrap; column-gap: 1rem; margin-top: .15rem; }
.challenge-links a { color: var(--accent); padding: .65rem 0; min-height: 44px; font-size: .875rem; }
.challenge-links a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.table {
  overflow: hidden;
  border: 1px solid #46657c;
  border-radius: .8rem;
  background: #101d27;
  box-shadow: 0 12px 30px #050a1060;
}
canvas { display: block; width: 100%; aspect-ratio: 110 / 80; touch-action: none; user-select: none; cursor: crosshair; }
canvas[data-aiming] { cursor: grabbing; }
.legend { display: flex; flex-wrap: wrap; gap: .35rem 1.15rem; padding: .8rem 0 0; list-style: none; color: var(--muted); font-size: .875rem; }
.legend li { display: flex; align-items: center; gap: .4rem; }
.marker { display: inline-grid; place-items: center; width: .85rem; height: .85rem; border-radius: 50%; font-style: normal; flex: none; }
.marker.cue { background: #f4faff; outline: 1px dashed #b9d9ec; outline-offset: 2px; }
.marker.target { border: 3px double var(--accent); }
.marker.fixed { border: 1px solid #b2d5ef; background: #2b5b80; color: #fff; font-size: .625rem; font-weight: 800; }

.panel {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: var(--surface);
  margin-top: 1.85rem;
}
.panel-heading { display: flex; gap: .3rem 1rem; flex-wrap: wrap; justify-content: space-between; align-items: baseline; }
#finished { color: var(--accent); font-size: .875rem; font-weight: 700; }
.scoreboard { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; margin: .75rem 0 1rem; }
.scoreboard > div { display: flex; flex-direction: column; min-width: 0; padding: .58rem .65rem; border-radius: .45rem; background: #0e1a24; }
.scoreboard .score-total { grid-column: 1 / -1; border-left: 3px solid var(--accent); }
dt, .record { color: var(--muted); font-size: .875rem; line-height: 1.2; }
dd, .record strong, #results strong { font-variant-numeric: tabular-nums; }
dd { font-size: 1.65rem; line-height: 1.15; font-weight: 800; margin-top: auto; padding-top: .2rem; }
#total { color: var(--accent); font-size: 3rem; }
#results { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .25rem; padding: 0; margin-top: .45rem; list-style: none; }
#results li { padding: .3rem .1rem; text-align: center; border-radius: .3rem; color: var(--muted); background: #0e1a24; font-size: .75rem; }
#results strong { display: block; color: #f3f8fc; font-size: .95rem; }
.panel-bottom { display: grid; gap: .7rem; margin-top: .85rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.record { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.record strong { color: #f3f8fc; font-size: 1rem; }
.panel button { padding: .4rem .8rem; }
.panel[data-finished] { border-color: #9ab263; }
.panel[data-finished] button { background: var(--accent); border-color: var(--accent); color: #132119; }

@media (max-width: 47rem) {
  main { grid-template: auto auto auto / minmax(0, 1fr); gap: .75rem; padding-top: .6rem; }
  .masthead { padding-bottom: .5rem; }
  .panel { margin: 0; padding: .7rem; }
  .scoreboard { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: .5rem 0 .7rem; }
  .scoreboard .score-total { grid-column: auto; }
  #total { font-size: 1.65rem; }
  .panel-bottom { grid-template-columns: 1fr 1fr; align-items: center; }
  .legend { padding-top: .55rem; }
}

@media (orientation: landscape) and (max-height: 34rem) and (min-width: 36rem) {
  main {
    grid-template: auto 1fr / minmax(0, 1fr) minmax(13rem, 17rem);
    max-width: calc((100dvh - 8rem) * 1.375 + 20rem);
    gap: .6rem 1rem;
    padding-top: .45rem;
  }
  .masthead { padding-bottom: .4rem; }
  h1 { font-size: 1.75rem; }
  .panel { margin: 0; padding: .65rem; }
  .scoreboard { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: .5rem 0 .7rem; }
  .scoreboard .score-total { grid-column: auto; }
  .scoreboard > div { padding-inline: .4rem; }
  #total { font-size: 1.65rem; }
  .panel-bottom { grid-template-columns: 1fr 1fr; align-items: center; }
}

@media (max-width: 22rem) {
  .scoreboard > div { padding-inline: .4rem; }
  .legend { gap: .35rem .7rem; }
}
