:root {
  color-scheme: light;
  --paper: #f8f5ed;
  --card: #fffdf7;
  --line: #e4ddce;
  --ink: #241f18;
  --muted: #625d51;
  --forest: #244e40;
  --dark: #183b30;
  --pale: #e8eee4;
  --rust: #9c5133;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 0;
  background: radial-gradient(ellipse at 42% 19%, #fffcf4 0%, var(--paper) 65%);
}
button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, select { color: inherit; }
button, h1, h2, h3, p { margin: 0; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, input:focus-visible, canvas:focus-visible { outline: 2px solid var(--rust); outline-offset: 4px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.shell { width: min(1280px, calc(100% - 88px)); margin-inline: auto; }

.masthead { border-bottom: 1px solid var(--line); background: #faf7efcc; }
.masthead-inner {
  min-height: 68px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: none;
  font: 700 31px/1 var(--serif);
  letter-spacing: -0.085em;
  color: var(--dark);
}
.brand-ball {
  background: radial-gradient(at 30% 26%, #527765, #234c3d 57%, #14342b);
  border-radius: 50%;
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 3px #203d3440, inset 0 0 0 1px #ffffff25;
}
.brand-ball > span {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  background: #f8eed7;
  border-radius: 50%;
  font: 700 15px/1 var(--serif);
  letter-spacing: 0;
}
.brand-point { color: var(--rust); }
.masthead-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.header-button, .text-button {
  border: 0;
  background: none;
  color: var(--dark);
  padding: 10px 12px;
  font-size: 0.83rem;
  font-weight: 650;
  line-height: 1.2;
  border-radius: 8px;
}
.header-button:hover, .text-button:hover { background: var(--pale); }
.help-button {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  padding-inline: 13px;
  background: #fbf8f0;
}
.question {
  display: grid;
  place-items: center;
  border: 1px solid #6b8274;
  border-radius: 50%;
  font-size: 0.72rem;
  width: 17px;
  height: 17px;
}

.intro { padding: 28px 0 23px; }
.eyebrow {
  color: var(--rust);
  font-size: 0.69rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.19em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.eyebrow span {
  width: 7px;
  height: 7px;
  background: #b36c43;
  transform: rotate(45deg);
  border-radius: 1px;
}
h1 {
  color: var(--dark);
  font: 400 clamp(3.2rem, 5vw, 4.45rem)/1.06 var(--serif);
  letter-spacing: -0.071em;
  margin: 5px 0 7px;
}
.intro > p:last-child {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}
.modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.mode {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fffcf6;
  padding: 11px 15px;
  border-radius: 13px;
  transition: background 160ms, color 160ms, border-color 160ms, box-shadow 160ms;
}
.mode:hover { border-color: #9aab98; background: #f1f2e9; }
.mode[aria-pressed='true'] {
  background: linear-gradient(115deg, #305a4a, #21483a 75%);
  color: #fff8e8;
  border-color: #21483a;
  box-shadow: 0 4px 9px #25382c24;
}
.mode-icon {
  display: grid;
  place-items: center;
  flex: 0 0 43px;
  height: 43px;
  width: 43px;
  position: relative;
  background: #f0ede0;
  border: 1px solid #eeeadc;
  border-radius: 9px;
  color: var(--dark);
}
.mode[aria-pressed='true'] .mode-icon {
  background: #ffffff17;
  border-color: #ffffff31;
  color: #fff0cd;
}
.mode-game > span {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--dark);
  color: #fff5da;
  font: 700 14px/1 var(--serif);
}
.mode[aria-pressed='true'] .mode-game > span { background: #f4e7c9; color: var(--dark); }
.mode-spin > span {
  width: 23px;
  height: 23px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  position: relative;
}
.mode-spin > span::before {
  content: '';
  position: absolute;
  width: 7px;
  height: 7px;
  background: currentColor;
  border-radius: 50%;
  top: 4px;
  right: 4px;
}
.mode-spin > span::after {
  content: '';
  position: absolute;
  width: 1px;
  height: 25px;
  background: currentColor;
  opacity: 0.42;
  transform: rotate(45deg);
  top: -2px;
  left: 10px;
}
.mode-maths > span {
  width: 23px;
  height: 21px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  position: relative;
}
.mode-maths > span::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 1.5px;
  background: currentColor;
  bottom: 1px;
  left: 2px;
  transform: rotate(-40deg);
  transform-origin: 0 50%;
}
.mode-maths > span::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 1.5px 1.5px 0 0;
  top: 2px;
  right: 1px;
  transform: rotate(6deg);
}
.mode-copy {
  display: grid;
  flex: 1;
  gap: 4px;
}
.mode-copy strong {
  font-size: 0.91rem;
  font-weight: 720;
  line-height: 1.13;
}
.mode-copy small {
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.28;
}
.mode[aria-pressed='true'] small { color: #e7e8d5; }
.mode-arrow { color: #676554; font-size: 1rem; }
.mode[aria-pressed='true'] .mode-arrow { color: #f2ddae; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 302px;
  align-items: start;
  gap: 20px;
}
.stage {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.table-card, .controls, .lesson, .analysis {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--card);
  box-shadow: 0 2px 8px #51442f08;
}
.table-card { padding: 13px 14px 1px; }
.table-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 1px 11px;
}
.scoreboard {
  display: flex;
  gap: 9px;
  align-items: center;
}
.player {
  min-height: 42px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.player.current { background: #edf1e7; border-color: #e3ebdf; }
.player-token {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #47745c;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px #00000012;
}
#player-two .player-token { background: #b2734d; }
.player-info {
  display: grid;
  font-size: 0.78rem;
  font-weight: 680;
  line-height: 1.1;
  white-space: nowrap;
  min-width: 60px;
  gap: 2px;
}
.player-info small {
  font-size: 0.65rem;
  font-weight: 560;
  color: #486051;
}
.player strong {
  min-width: 27px;
  text-align: right;
  color: var(--dark);
  font: 700 24px/1 var(--serif);
  font-variant-numeric: tabular-nums;
}
.score-divider {
  width: 1px;
  height: 24px;
  background: var(--line);
}
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: #fbf8f1;
  color: var(--dark);
  border-radius: 8px;
  min-height: 35px;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 680;
}
.secondary:hover { background: #edf1e7; border-color: #bccbbb; }
.reset span:first-child { font-size: 1.05rem; line-height: 1; }
.table-area { position: relative; }
canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1178 / 638;
  border-radius: 15px;
  box-shadow: 0 7px 12px #59351728, 0 1px 3px #26251b32;
  cursor: crosshair;
  touch-action: none;
}
canvas[aria-disabled='true'] { cursor: default; }
.table-bottom {
  display: flex;
  gap: 8px 14px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  min-height: 44px;
  padding: 8px 1px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}
#game-status { font-weight: 640; color: #3d5a4b; }
.aim-tip {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.aim-mobile { display: none; }
.aim-dot {
  flex: 0 0 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid #708678;
  box-shadow: inset 0 0 0 1px #fffcf5;
  background: #708678;
}
.trajectory-legend { display: flex; gap: 10px; }
.trajectory-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.trajectory-legend i { width: 12px; border-top: 2px dashed #518764; }
.trajectory-legend span + span i { border-color: #b87b32; }
#force-legend i { border-top: 2px solid #a35049; }
.exercise {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
}
.exercise label {
  color: var(--dark);
  font-size: 0.8rem;
  font-weight: 700;
}
.exercise select, .opponent select {
  border-radius: 7px;
  padding: 6px 6px 6px 8px;
  color: var(--dark);
  background: #fbf8f1;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 600;
}

.controls { padding: 16px; }
.controls-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 13px;
  margin-bottom: 13px;
}
h2 {
  color: var(--dark);
  font: 700 1.42rem/1.12 var(--serif);
  letter-spacing: -0.05em;
}
.controls-icon { color: var(--rust); font-size: 0.9rem; }
fieldset {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}
.control-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 7px 4px;
}
.control-row label, .opponent label { font-size: 0.79rem; font-weight: 710; }
.control-row output {
  font-size: 0.74rem;
  color: var(--dark);
  background: #eef0e6;
  padding: 3px 7px;
  border-radius: 5px;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
input[type='range'] {
  --fill: 50%;
  appearance: none;
  grid-column: 1 / -1;
  display: block;
  height: 19px;
  margin: 0;
  width: 100%;
  cursor: pointer;
  background: transparent;
  border-radius: 7px;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 5px;
  background: linear-gradient(to right, #547964 0 var(--fill), #e7e3d7 var(--fill) 100%);
  border-radius: 9px;
}
input[type='range']::-moz-range-track {
  height: 5px;
  background: linear-gradient(to right, #547964 0 var(--fill), #e7e3d7 var(--fill) 100%);
  border-radius: 9px;
}
input[type='range']::-webkit-slider-thumb {
  appearance: none;
  margin-top: -5px;
  height: 15px;
  width: 15px;
  border-radius: 50%;
  border: 2px solid #fefcf2;
  background: #315c48;
  box-shadow: 0 0 0 1px #315c48;
}
input[type='range']::-moz-range-thumb {
  height: 12px;
  width: 12px;
  border-radius: 50%;
  border: 2px solid #fefcf2;
  background: #315c48;
  box-shadow: 0 0 0 1px #315c48;
}
input[type='range']:disabled, .impact-ball:disabled, .presets button:disabled { opacity: 0.54; cursor: default; }
.impact-control {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 10px 0 12px;
  padding: 12px 0;
}
.impact-stage {
  position: relative;
  display: grid;
  justify-items: center;
  align-items: center;
  padding: 12px 0 11px;
}
.impact-ball {
  --impact-x: 0%;
  --impact-y: 0%;
  position: relative;
  padding: 0;
  width: 100px;
  height: 100px;
  border: 1px solid #d1c7b1;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 26%, #fffef7 3%, #fbf3e1 39%, #e4d8bf 66%, #ae9a7e 97%);
  cursor: crosshair;
  touch-action: none;
  box-shadow: 6px 9px 14px #56453126, inset 0 0 3px #f2e7cd;
}
.impact-ball::before, .impact-ball::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.impact-ball::before { width: 84%; border-top: 1px dashed #8a7a5e75; }
.impact-ball::after { height: 84%; border-left: 1px dashed #8a7a5e75; }
.impact-guides {
  position: absolute;
  inset: 17%;
  border: 1px solid #8a7a5e73;
  border-radius: 50%;
}
.impact-marker {
  position: absolute;
  z-index: 1;
  left: calc(50% + var(--impact-x));
  top: calc(50% - var(--impact-y));
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border: 2px solid #fff9e8;
  background: #a45436;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #8a4e34;
}
.presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.presets button {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 27px;
  padding: 4px 3px;
  background: #fcf9f1;
  font-size: 0.72rem;
  font-weight: 640;
  color: #4e4a40;
}
.presets button:hover, .presets button[aria-pressed='true'] {
  background: var(--pale);
  border-color: #c8d4c5;
  color: var(--dark);
}
.primary {
  border: 1px solid #234838;
  border-radius: 8px;
  background: linear-gradient(110deg, #315e4b, #214939);
  color: #fff8e9;
  min-height: 42px;
  padding: 9px 12px;
  font-weight: 700;
  font-size: 0.83rem;
}
.primary:not(:disabled):hover { background: #173b2f; }
.primary:disabled { background: #657d70; border-color: #657d70; }
.shoot {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.shoot span { color: #f4d9a7; font-size: 1rem; }
.opponent {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
}
.preview-options {
  margin-top: 13px;
  color: var(--dark);
  font-size: 0.76rem;
}
.preview-options label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}
input[type='checkbox'] {
  accent-color: var(--forest);
  margin: 0;
  width: 15px;
  height: 15px;
}

.lesson, .analysis { padding: 15px 16px; }
.lesson-heading, .analysis-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lesson-heading .mode-icon { flex-basis: 34px; height: 34px; }
.lesson p, .analysis p {
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.5;
}
.lesson p { margin-top: 7px; }
#lesson-feedback { color: var(--dark); font-weight: 620; }
.analysis-heading { justify-content: space-between; margin: 0 0 12px; }
.analysis-heading p { margin-top: 4px; }
.calculation-unit {
  color: var(--muted);
  font-size: 0.75rem;
  text-align: right;
}
.calculation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.calculation-grid article {
  border: 1px solid var(--line);
  background: #f9f7ee;
  border-radius: 8px;
  padding: 11px;
}
.calculation-grid h3 { color: var(--dark); font-size: 0.82rem; }
.calculation-grid .formula {
  margin: 7px 0;
  color: #305747;
  font-family: ui-monospace, monospace;
  font-size: 0.79rem;
}
#force-values { margin-top: 3px; }
.analysis .analysis-note { margin-top: 10px; font-size: 0.74rem; }
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0 15px;
  color: var(--muted);
  font-size: 0.75rem;
}
.footer .text-button { font-size: 0.75rem; }

.result {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 20px;
  width: min(87%, 310px);
  background: #fffcf1f5;
  border: 1px solid #f3e7cc;
  box-shadow: 0 8px 40px #09241a8c;
  border-radius: 13px;
  text-align: center;
  color: var(--dark);
}
.result > span {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--rust);
}
.result strong {
  display: block;
  font: 700 1.62rem/1.1 var(--serif);
  margin: 6px 0;
}
.result p {
  margin-bottom: 9px;
  font-size: 0.86rem;
  color: var(--muted);
}
.result button { min-width: 120px; }
dialog {
  width: min(540px, calc(100% - 30px));
  max-height: calc(100% - 30px);
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--card);
  padding: 24px;
  color: var(--ink);
  box-shadow: 0 10px 50px #21382c52;
}
dialog::backdrop { background: #122a21a1; }
dialog .close {
  position: absolute;
  right: 15px;
  top: 15px;
  width: 35px;
  font-size: 1.3rem;
}
dialog h2 { font-size: 2rem; margin: 5px 0 8px; }
dialog h3 {
  color: var(--dark);
  font-size: 1rem;
  margin: 15px 0 4px;
}
dialog ol { padding-left: 22px; }
dialog p:not(.eyebrow), dialog li {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}
dialog li + li { margin-top: 7px; }

@media (min-width: 1450px) { .intro { padding-top: 35px; } }
@media (max-width: 1070px) {
  .shell { width: calc(100% - 52px); }
  .workspace { grid-template-columns: minmax(0, 1fr) 265px; gap: 14px; }
  .mode { padding-inline: 11px; gap: 9px; }
  .mode-icon {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }
  .control-row label, .opponent label { font-size: 0.76rem; }
}
@media (max-width: 820px) {
  .shell { width: calc(100% - 36px); }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .stage { display: contents; }
  .lesson, .analysis { grid-row: 3; }
  .controls { padding: 15px; }
  #shot-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 8px 16px;
  }
  #shot-controls .impact-control {
    grid-column: 2;
    grid-row: 1 / 4;
    margin: 0;
    padding: 0 0 0 14px;
    border: 0;
    border-left: 1px solid var(--line);
  }
  #shot-controls .shoot { margin-top: 0; }
}
@media (max-width: 560px) {
  .shell { width: calc(100% - 24px); }
  .masthead-inner { min-height: 54px; }
  .brand { font-size: 1.65rem; gap: 7px; }
  .brand-ball { width: 31px; height: 31px; }
  .brand-ball > span {
    width: 17px;
    height: 17px;
    font-size: 0.78rem;
  }
  .masthead-actions { gap: 2px; }
  .header-button {
    padding: 7px 8px;
    font-size: 0.73rem;
    min-height: 34px;
  }
  .help-button { gap: 4px; }
  .question {
    width: 14px;
    height: 14px;
    font-size: 0.66rem;
  }
  .intro { padding: 18px 0 14px; }
  h1 { font-size: clamp(2.45rem, 10vw, 3.35rem); }
  .intro > p:last-child { font-size: 0.81rem; }
  .modes { gap: 5px; margin-bottom: 11px; }
  .mode {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 5px;
    min-height: 71px;
    padding: 6px 3px;
    border-radius: 9px;
  }
  .mode-icon {
    width: 25px;
    height: 25px;
    border: 0;
    background: transparent;
  }
  .mode[aria-pressed='true'] .mode-icon { background: transparent; }
  .mode-game > span {
    width: 18px;
    height: 18px;
    font-size: 0.72rem;
  }
  .mode-spin > span, .mode-maths > span { transform: scale(0.75); }
  .mode-copy strong { font-size: 0.70rem; }
  .mode-copy small, .mode-arrow { display: none; }
  .table-card { padding: 7px 7px 0; border-radius: 11px; }
  .table-top {
    gap: 4px;
    padding-bottom: 6px;
    min-height: 38px;
  }
  .scoreboard { gap: 3px; }
  .player {
    padding: 3px 4px;
    gap: 4px;
    min-height: 34px;
  }
  .player-info { font-size: 0.64rem; min-width: 47px; }
  .player-info small { font-size: 0.52rem; }
  .player strong { min-width: 17px; font-size: 1.18rem; }
  .player-token { width: 6px; height: 6px; }
  .secondary {
    padding-inline: 5px;
    gap: 3px;
    min-height: 31px;
    font-size: 0.64rem;
  }
  canvas { border-radius: 8px; }
  .table-bottom {
    min-height: 32px;
    padding-block: 6px;
    font-size: 0.65rem;
  }
  .aim-full { display: none; }
  .aim-mobile { display: inline; }
  .controls { padding: 11px; }
  .controls-heading { margin-bottom: 10px; padding-bottom: 9px; }
  h2 { font-size: 1.26rem; }
  #shot-controls { column-gap: 10px; }
  #shot-controls .impact-control { padding-left: 9px; }
  .impact-control .control-row {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 3px;
  }
  .impact-ball { width: 84px; height: 84px; }
  .impact-stage { padding: 7px 0; }
  .presets { gap: 3px; }
  .presets button { font-size: 0.66rem; }
  .calculation-grid { grid-template-columns: 1fr; }
  .footer { padding-top: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
