:root {
  font-family: "Hiragino Sans GB", "PingFang SC", sans-serif;
  color: #352d37;
  background: #e8ad93;
  font-synthesis: none;
  --ink: #352d37;
  --accent: #784a75;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  cursor: pointer;
}
button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 3px solid #633f65;
  outline-offset: 5px;
}
button {
  color: inherit;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
[hidden] {
  display: none !important;
}
#game {
  height: 100svh;
  min-height: 540px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
#world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}
.topbar {
  position: absolute;
  left: 4.4%;
  right: 4.4%;
  top: max(34px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
}
.wordmark > svg {
  width: 40px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
}
.wordmark > svg circle {
  fill: currentColor;
  stroke: none;
}
.wordmark > span {
  font-size: 20px;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.wordmark small {
  display: block;
  font-size: 8px;
  letter-spacing: 0.18em;
  margin-top: 5px;
  font-weight: 600;
}
.tools {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}
.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #352d3730;
  border-radius: 50%;
  background: transparent;
  transition: background 0.2s;
}
.icon-button:hover {
  background: #ffffff38;
}
.icon-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.intro {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.intro-copy {
  position: absolute;
  top: 27%;
  left: 10.5%;
  width: 350px;
}
.intro h1 {
  font-size: clamp(46px, 4.8vw, 72px);
  line-height: 1.24;
  letter-spacing: -0.035em;
  margin: 0 0 24px;
  font-weight: 700;
}
.intro h1 > span {
  color: #865071;
}
.intro p {
  font-size: 14px;
  line-height: 2;
  color: #57414b;
  margin: 0 0 31px;
}
.primary {
  border: 0;
  border-radius: 100px;
  background: var(--ink);
  color: #fff8f2;
  min-height: 54px;
  padding: 15px 26px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 35px;
  pointer-events: auto;
  transition:
    transform 0.2s,
    background 0.2s;
}
.primary svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.primary:hover {
  background: #594354;
  transform: translateY(-2px);
}
.primary:active {
  transform: translateY(1px);
}
.best {
  font-size: 11px;
  margin: 19px 0;
  color: #5d4550;
}
.best strong {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  margin: 0 5px;
}
.intro-hint {
  position: absolute;
  right: 22%;
  bottom: 14%;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 14px;
  font-size: 11px;
  color: #5c4552;
}
.intro-hint svg {
  width: 58px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.footer {
  position: absolute;
  left: 4.4%;
  right: 4.4%;
  bottom: max(25px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: #59424c;
  gap: 20px;
}
.desktop-controls {
  margin-left: auto;
}
.separator {
  padding: 0 13px;
}
.text-button {
  background: none;
  border: 0;
  padding: 7px 0;
  font-size: 11px;
}
.text-button:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}
.footer .text-button {
  margin-left: 28px;
}
.footer .text-button span {
  margin-left: 9px;
}
.hud {
  position: absolute;
  top: 128px;
  left: 7%;
  right: 7%;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}
.distance > span {
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.distance > small {
  font-size: 12px;
  margin-left: 7px;
}
.distance > div {
  font-size: 10px;
  letter-spacing: 0.08em;
  margin-top: 1px;
}
.ball-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 13px;
}
.ball-stat svg {
  width: 25px;
  height: 25px;
  fill: #fff9ed;
  stroke: #735477;
  stroke-width: 1.5;
}
.ball-stat > span {
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ball-stat > small {
  font-size: 10px;
}
.play-tip {
  position: absolute;
  bottom: 12%;
  width: 100%;
  text-align: center;
  font-size: 12px;
  pointer-events: none;
}
.toast {
  position: absolute;
  top: 27%;
  left: 50%;
  transform: translate(-50%, 8px);
  font-size: 23px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 0.2s,
    transform 0.2s;
  white-space: nowrap;
}
.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.overlay {
  position: absolute;
  inset: 0;
  background: #e8bdacbf;
  display: grid;
  place-items: center;
  backdrop-filter: blur(9px);
}
.result {
  text-align: center;
  width: min(370px, 85vw);
}
.result h2 {
  font-size: 29px;
  letter-spacing: -0.025em;
  margin: 20px 0 12px;
}
.result > p {
  font-size: 13px;
  color: #604b58;
}
.result-icon {
  width: 45px;
  height: 45px;
  border: 2px solid #715478;
  border-radius: 50%;
  margin: 0 auto;
  background: #fff5df;
  box-shadow: 0 12px 24px #61475220;
}
.result-stats {
  display: flex;
  justify-content: center;
  gap: 45px;
  margin: 34px 0;
}
.result-stats strong {
  font-size: 40px;
  font-weight: 600;
  display: block;
  letter-spacing: -0.035em;
}
.result-stats span {
  display: block;
  font-size: 10px;
  margin-top: 8px;
}
.result .primary {
  margin: 13px auto;
  min-width: 220px;
}
.result > .text-button {
  margin-top: 12px;
}
dialog {
  border: 0;
  background: #fff7ef;
  color: var(--ink);
  border-radius: 18px;
  padding: 40px;
  width: min(480px, 90vw);
  max-height: 85svh;
  box-shadow: 0 24px 70px #352d3730;
}
dialog::backdrop {
  background: #352d3760;
  backdrop-filter: blur(5px);
}
dialog h2 {
  font-size: 24px;
  margin: 12px 0 22px;
}
dialog p,
dialog dd {
  font-size: 13px;
  line-height: 1.9;
  color: #655565;
}
dialog dl {
  margin: 25px 0;
}
dialog dl > div {
  margin: 18px 0;
}
dialog dt {
  font-size: 14px;
  font-weight: 600;
}
dialog dd {
  margin: 5px 0;
}
.close {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 30px;
  height: 30px;
  font-size: 22px;
}
.help-note {
  border-top: 1px solid #ddd0d0;
  padding-top: 18px;
}
.playing .footer > span:first-child {
  opacity: 0;
}
.playing .desktop-controls {
  margin-left: 0;
}
@media (min-width: 1500px) {
  .intro-copy {
    left: 14%;
    top: 29%;
  }
}
@media (max-width: 700px) {
  #game {
    min-height: 500px;
  }
  .topbar {
    left: 24px;
    right: 24px;
    top: max(24px, env(safe-area-inset-top));
  }
  .wordmark > span {
    font-size: 17px;
  }
  .wordmark > svg {
    width: 32px;
  }
  .wordmark {
    gap: 9px;
  }
  .wordmark small {
    font-size: 7px;
  }
  .icon-button {
    width: 36px;
    height: 36px;
  }
  .tools {
    gap: 8px;
  }
  .intro-copy {
    top: 18%;
    left: 27px;
    width: calc(100% - 54px);
  }
  .intro h1 {
    font-size: 43px;
    line-height: 1.19;
    margin-bottom: 15px;
  }
  .intro p {
    font-size: 12px;
    line-height: 1.8;
    margin-bottom: 20px;
    max-width: 220px;
  }
  .primary {
    min-height: 48px;
    padding: 13px 24px;
    font-size: 13px;
    gap: 28px;
  }
  .best {
    font-size: 10px;
    margin-top: 13px;
  }
  .intro-hint {
    right: 24px;
    bottom: 14%;
    font-size: 10px;
    gap: 8px;
  }
  .intro-hint svg {
    width: 42px;
  }
  .footer {
    left: 24px;
    right: 24px;
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  .desktop-controls {
    display: none;
  }
  .footer .text-button {
    margin-left: 0;
  }
  .hud {
    top: 100px;
    left: 27px;
    right: 27px;
  }
  .distance > span {
    font-size: 38px;
  }
  .ball-stat {
    gap: 7px;
    padding-top: 9px;
  }
  .ball-stat > span {
    font-size: 25px;
  }
  .ball-stat > small {
    font-size: 9px;
  }
  .toast {
    top: 25%;
    font-size: 20px;
  }
  .play-tip {
    font-size: 11px;
    bottom: 10%;
  }
  .result h2 {
    font-size: 25px;
  }
  .playing .footer > span:first-child {
    opacity: 1;
    font-size: 9px;
  }
  dialog {
    padding: 30px;
  }
  .result-stats {
    gap: 35px;
  }
}
@media (prefers-reduced-motion: reduce) {
  button,
  .toast {
    transition: none;
  }
}
/* Keep the total visible in the middle, even when the tail leaves the viewport. */
.ball-stat {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  padding: 0;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 80vw;
}
.ball-stat svg {
  display: none;
}
.ball-stat > span {
  font-size: 45px;
  line-height: 1.1;
  letter-spacing: -0.025em;
}
.ball-stat > small {
  font-size: 11px;
  align-self: flex-end;
  padding-bottom: 5px;
}
@media (max-width: 700px) {
  .ball-stat {
    top: 44%;
    gap: 8px;
  }
  .ball-stat > span {
    font-size: 35px;
  }
  .ball-stat > small {
    font-size: 10px;
  }
}
.ball-stat {
  top: 39%;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.ball-stat > small {
  align-self: center;
  padding: 0;
  font-size: 10px;
}
@media (max-width: 700px) {
  .ball-stat {
    top: 40%;
    gap: 4px;
  }
}
.overlay {
  z-index: 5;
  overflow-y: auto;
  padding: 30px 20px;
}
.overlay.has-ranking .result {
  width: min(920px, 94vw);
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  align-items: center;
  gap: 58px;
}
.result-main > .text-button {
  margin-top: 12px;
}
.ranking-panel {
  text-align: left;
  min-width: 0;
}
.rank-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}
.rank-heading h2 {
  margin: 0;
  font-size: 25px;
}
.rank-caption {
  font-size: 11px;
  margin: 8px 0 22px;
  color: #604b58;
}
.rank-form label {
  display: block;
  font-size: 11px;
  margin-bottom: 8px;
}
.rank-inputs {
  display: flex;
  gap: 9px;
}
.rank-inputs input {
  min-width: 0;
  width: 100%;
  font: inherit;
  font-size: 13px;
  background: #fff7ef;
  border: 1px solid #735b6c50;
  border-radius: 9px;
  padding: 11px 12px;
  color: var(--ink);
}
.rank-inputs input:focus-visible {
  outline: 2px solid #784a75;
  outline-offset: 2px;
}
.rank-inputs .primary {
  min-width: 104px;
  min-height: 42px;
  margin: 0;
  padding: 10px 15px;
  font-size: 12px;
  white-space: nowrap;
}
.rank-status {
  min-height: 32px;
  margin: 10px 0 4px;
  font-size: 11px;
  line-height: 1.6;
  color: #473b48;
}
.rank-status.error {
  color: #8c343e;
}
.rank-personal {
  font-size: 10px;
  color: #604b58;
  margin: 0 0 13px;
  line-height: 1.6;
}
.rank-scroll {
  max-height: min(310px, 37svh);
  min-height: 95px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border-top: 1px solid #735b6c40;
}
.rank-scroll table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.rank-scroll th {
  position: sticky;
  top: 0;
  background: #e8bdac;
  font-size: 10px;
  color: #604b58;
  font-weight: 400;
}
.rank-scroll td,
.rank-scroll th {
  padding: 11px 8px;
  border-bottom: 1px solid #735b6c25;
}
.rank-scroll td:nth-child(2) {
  overflow-wrap: anywhere;
  max-width: 180px;
}
.rank-scroll td:first-child {
  font-weight: 700;
  width: 46px;
}
.rank-scroll td:last-child,
.rank-scroll th:last-child {
  text-align: right;
  white-space: nowrap;
}
.rank-empty {
  font-size: 13px;
  line-height: 1.9;
  color: #604b58;
  text-align: center;
  margin: 24px 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (max-width: 700px) {
  .overlay.has-ranking {
    place-items: start center;
    padding: 28px 22px;
  }
  .overlay.has-ranking .result {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .has-ranking .result-icon {
    width: 30px;
    height: 30px;
  }
  .has-ranking .result-main h2 {
    font-size: 24px;
    margin: 16px 0 8px;
  }
  .has-ranking .result-stats {
    margin: 19px 0;
  }
  .has-ranking .result-stats strong {
    font-size: 32px;
  }
  .has-ranking .result-main > .primary {
    min-height: 43px;
  }
  .has-ranking .result-main > .text-button {
    margin-top: 0;
  }
  .rank-heading h2 {
    font-size: 22px;
  }
  .rank-caption {
    margin-bottom: 17px;
  }
  .rank-scroll {
    max-height: 300px;
  }
}

/* Two explicit camera choices, defaulting to the side view. */
.view-switch {
  display: flex;
  align-items: center;
  padding: 3px;
  border: 1px solid #352d3730;
  border-radius: 24px;
}
.view-switch button {
  border: 0;
  background: transparent;
  padding: 7px 13px;
  min-height: 34px;
  border-radius: 20px;
  font-size: 12px;
  line-height: 1;
}
.view-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff8f2;
}
.view-switch button:hover:not([aria-pressed="true"]) {
  background: #ffffff38;
}
@media (max-width: 700px) {
  .view-switch {
    padding: 2px;
  }
  .view-switch button {
    padding: 6px 10px;
    min-height: 30px;
    font-size: 11px;
  }
}
@media (max-width: 370px) {
  .topbar {
    left: 16px;
    right: 16px;
  }
  .tools {
    gap: 5px;
  }
  .view-switch button {
    padding-inline: 8px;
  }
  .wordmark {
    gap: 6px;
  }
  .wordmark > svg {
    width: 26px;
  }
  .wordmark > span {
    font-size: 16px;
  }
}
