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%);
}

/*
 * Section headings (Basic / Intermediate / Advanced) are direct children of
 * main. Centred so they sit over the middle of the question column rather
 * than hugging the left edge of the viewport.
 */
main > h2 {
  max-width: 1200px;
  margin: 1rem auto 0.5rem;
  padding: 0 0.75rem;
  text-align: center;
}

.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;
}

/*
 * Attribution under the video. #555 keeps 7.5:1 on the white card.
 * Declared before the #shotList link rules: stylelint's
 * no-descending-specificity wants the less specific selector first.
 */
.summary-video-credit {
  margin-top: 0.4rem;
  font-size: 0.7rem;
  line-height: 1.4;
  color: #555;
}

.summary-video-credit a:any-link {
  color: inherit;
  text-decoration: underline;
}

#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;
}

/*
 * Optional video beside the shot list. The exam pages have no
 * .summary-with-video, .summary-body or .summary-video element, so none of
 * these rules match there and their layout is unchanged. Only the positional
 * page opts in, by adding those classes to its summary section.
 */
.summary-with-video {
  max-width: 1200px;
}

.summary-body {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.summary-body > #shotList {
  flex: 1 1 50%;
  min-width: 0;
}

/* Half the panel, so the video and the list split the card evenly. */
.summary-video {
  flex: 1 1 50%;
}

.summary-video iframe {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: 4px;
}

/* Too narrow to sit beside the list, so the video drops below it. */
@media (width < 900px) {
  .summary-body {
    flex-direction: column;
  }

  .summary-video {
    flex: none;
    width: 100%;
    max-width: 32rem;
  }
}

/* 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;
}

/*
 * A flat blue rectangle does not read as something to press, so the button
 * gets a shallow bevel: a light inset line along the top edge, a soft drop
 * shadow underneath, and a tinted glow that lifts it off the white card. The
 * :active state inverts the bevel and nudges the button down a pixel, so the
 * click itself is felt.
 */
.play-btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.375rem 0.75rem;
  background-color: #2563eb;
  background-image: linear-gradient(
    180deg,
    rgb(255 255 255 / 12%),
    rgb(0 0 0 / 6%)
  );
  color: white;
  text-decoration: none;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 30%),
    0 1px 2px rgb(0 0 0 / 20%),
    0 2px 6px rgb(37 99 235 / 25%);
  transition:
    background-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.05s ease;
}

.play-btn:hover {
  background-color: #1d4ed8;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 30%),
    0 2px 4px rgb(0 0 0 / 22%),
    0 4px 10px rgb(37 99 235 / 30%);
}

.play-btn:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 2px rgb(0 0 0 / 25%),
    0 1px 1px rgb(0 0 0 / 15%);
}

.play-btn:focus-visible {
  outline: 2px solid #1e3a8a;
  outline-offset: 2px;
}

@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;
}

/*
 * The three controls in the assessment bar - Guide, Lobby and Reset - are one
 * size, so their box metrics live here once. A <button> does not inherit the
 * page font and its UA line-height is `normal`, which made Reset come out in a
 * different typeface and taller than the <a> and <summary> beside it.
 */
.guide summary,
.lobby-btn,
.reset-btn {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border: none;
  border-radius: 4px;
  color: white;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.6;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
}

/* Background darkened so the white label clears 4.5:1. */
.reset-btn {
  background-color: #e81414;
  margin-left: 0.25rem;
}

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

.lobby-btn {
  background-color: #2563eb;
}

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

/*
 * "Guide" disclosure. The copy lives in the served HTML inside a <details>, so
 * a crawler reads it without running the script, and it opens as a card pinned
 * under the sticky assessment bar instead of pushing the shot list down. The
 * wrapper above it supplies the positioning context; .guide stays static so the
 * card hangs off the right-hand edge of the button group rather than off the
 * trigger, which would overflow a narrow viewport.
 */
.assessment-line > div {
  position: relative;
}

/* `<details>` is display: block in the UA stylesheet, which would put the
 * trigger on its own line above Lobby and Reset. */
.guide {
  display: inline-block;
}

/* Box metrics come from the shared control rule above the Reset button. */
.guide summary {
  background-color: #4b5563;
}

.guide summary::-webkit-details-marker {
  display: none;
}

.guide summary:hover {
  background-color: #374151;
}

.guide-panel {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  z-index: 200;
  width: min(26rem, calc(100vw - 2rem));
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  background: #fff;
  color: #333;
  border: 1px solid #000;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgb(0 0 0 / 25%);
  font-size: 0.8rem;
  text-align: left;
}

.guide-panel h2 {
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.guide-panel h2 + p {
  margin-bottom: 0.5rem;
}

/* 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: 90%;
  height: 90%;
  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;
}
