html {
  font-size: 87.5%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  background: #f0f0f0;
  color: #333;
  line-height: 1.6;
  padding: 0.5rem;
}

header {
  text-align: center;
  margin-bottom: 1rem;
}

header h1 a {
  color: inherit;
  text-decoration: none;
}

header h1 a:hover {
  opacity: 0.7;
}

.assessment-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0.5rem;
  z-index: 100;
  background: #fff;
  padding: 0.25rem 0.3rem;
  margin: 0 auto 0.5rem;
  max-width: 800px;
  border: 1px solid #000;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgb(0 0 0 / 10%);
}

.assessment-item {
  font-weight: bold;
  font-size: 0.8rem;
}

.summary {
  max-width: 800px;
  margin: 0 auto 0.5rem;
  background: #fff;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgb(0 0 0 / 10%);
}

body > h2 {
  max-width: 1200px;
  margin: 1rem auto 0.5rem;
  padding: 0 0.75rem;
}

.summary h2 {
  margin-bottom: 0.5rem;
}

.assessment {
  font-weight: bold;
}

/*
 * Assessment levels are small bold text on a white background, so each shade
 * is darkened to >= 4.5:1 contrast while keeping its original hue and
 * saturation. Do not swap these back for the brighter Tailwind 500 shades.
 */
.assessment.unknown {
  color: #757575;
}

.assessment.beginner {
  color: #e81414;
}

.assessment.novice {
  color: #c35305;
}

.assessment.learner {
  color: #a26807;
}

.assessment.developing {
  color: #937005;
}

.assessment.intermediate {
  color: #54810e;
}

.assessment.competent {
  color: #178640;
}

.assessment.proficient {
  color: #0c855d;
}

.assessment.advanced {
  color: #0e8376;
}

.assessment.expert {
  color: #048096;
}

.assessment.master {
  color: #8453f5;
}

#shotList {
  list-style: none;
  font-size: 0.85rem;

  /*
   * buildSummaryList() appends one <li> per .question-block, and it runs from
   * a deferred module script, so it lands after first paint. Without a
   * reserved height the Shot List card grows by ~513px and pushes every
   * question block down the page, which is the whole of this page's CLS.
   * Sized for the 20 blocks in threecushion.html:
   * 20 x (0.85rem x 1.6 + 0.4rem padding + 1px border) = 20 x 25.64px.
   * Update these if a page gains shots.
   */
  min-height: 520px;
}

@media (width >= 600px) {
  #shotList {
    columns: 2;
    column-gap: 8rem;

    /* Two columns, so 10 rows instead of 20. */
    min-height: 265px;
  }
}

#shotList li {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0;
  border-bottom: 1px solid #eee;
  break-inside: avoid;
}

#shotList a {
  color: inherit;
  text-decoration: none;
}

#shotList a:hover {
  text-decoration: underline;
}

/* See note on the .assessment shades above for the contrast floor. */
.status-unknown {
  color: #757575;
}

.status-pass {
  color: #178640;
}

.status-fail {
  color: #e81414;
}

.question-block {
  max-width: 1200px;
  margin: 0 auto 0.75rem;
  background: #fff;
  padding: 0.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgb(0 0 0 / 10%);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-margin-top: 4rem;
}

@media (width >= 768px) {
  .question-block {
    flex-direction: row;
    align-items: flex-start;
  }

  .question-text {
    flex: 1;
  }

  .question-diagram {
    flex: 2;
  }
}

.question-diagram svg.billiards-table {
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* SVG Diagram Style Overrides */
.manual-line {
  opacity: 0.5;
}

.fine-stroke {
  stroke-dasharray: 0.06 0.03;
}

.play-btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.375rem 0.75rem;
  background-color: #2563eb;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.play-btn:hover {
  background-color: #1d4ed8;
}

@keyframes ring-expand-green {
  0% {
    box-shadow: 0 0 0 0 rgb(34 197 94 / 80%);
    color: inherit;
  }

  50% {
    color: #16a34a;
  }

  100% {
    box-shadow: 0 0 0 20px rgb(34 197 94 / 0%);
    color: inherit;
  }
}

@keyframes ring-expand-red {
  0% {
    box-shadow: 0 0 0 0 rgb(239 68 68 / 80%);
    color: inherit;
  }

  50% {
    color: #dc2626;
  }

  100% {
    box-shadow: 0 0 0 20px rgb(239 68 68 / 0%);
    color: inherit;
  }
}

.q-stats.updated.q-pass {
  animation: ring-expand-green 2s ease-out 2;
}

.q-stats.updated.q-fail {
  animation: ring-expand-red 2s ease-out 2;
}

/* Background darkened so the white label clears 4.5:1. */
.reset-btn {
  padding: 0.25rem 0.5rem;
  background-color: #e81414;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  margin-left: 0.25rem;
}

.reset-btn:hover {
  background-color: #dc2626;
}

.lobby-btn {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background-color: #2563eb;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.lobby-btn:hover {
  background-color: #1d4ed8;
}

/* Iframe overlay */
#gameOverlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgb(0 0 0 / 80%);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

#gameOverlay.active {
  display: flex;
}

.iframe-container {
  width: 80%;
  height: 80%;
  background: #000;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
}

.iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #fff;
  color: #000;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
}
