:root {
  font-family: "Nunito", "Trebuchet MS", "Segoe UI", sans-serif;
  color: #252c45;
  --ink: #252b43;
  --cream: #fff6da;
  --edge: clamp(12px, 2.1vmin, 30px);
  --left: max(var(--edge), env(safe-area-inset-left));
  --right: max(var(--edge), env(safe-area-inset-right));
  --top: max(var(--edge), env(safe-area-inset-top));
  --bottom: max(9px, env(safe-area-inset-bottom));
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { background: #242740; }
#scene { position: relative; isolation: isolate; width: 100%; height: 100%; height: 100dvh; overflow: hidden; touch-action: manipulation; user-select: none; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, #scene:has(canvas:focus-visible) #action:enabled { outline: 3px solid #fff; outline-offset: 3px; }
i, svg { display: inline-block; width: 1.25em; height: 1.25em; flex: none; font-style: normal; }
i > svg { display: block; width: 100%; height: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.score-hud { position: absolute; top: var(--top); left: var(--left); display: grid; justify-items: start; gap: 5px; pointer-events: none; }
.location { display: flex; align-items: center; gap: 6px; margin: 0; padding: 5px 12px 6px 9px;
  border: 2px solid #283044; border-radius: 6px 14px 12px 6px; background: #a6ecda; color: #233943;
  box-shadow: inset 0 2px #dcfff0, 1px 3px #253047; font-size: clamp(12px, 1.55vmin, 17px); line-height: 1; font-weight: 900; }
.location i { width: 1em; height: 1em; }
.distance { display: flex; align-items: baseline; gap: .09em; white-space: nowrap; font-size: clamp(46px, 7.6vmin, 88px);
  line-height: 1; font-weight: 1000; font-family: "Nunito", "Arial Black", "Segoe UI", sans-serif; letter-spacing: -.055em;
  font-variant-numeric: tabular-nums; color: #fff9e8; -webkit-text-stroke: .087em #25243f; paint-order: stroke fill;
  filter: drop-shadow(1px 3px 0 #24243c); }
.distance small { font-size: .56em; }
#launch-angle { margin-left: .38em; align-self: center; font: 900 clamp(13px,2vmin,20px)/1.1 "Trebuchet MS", sans-serif;
  letter-spacing: 0; color: #ffdf82; -webkit-text-stroke: 3px #29273c; }
.personal-best { display: flex; align-items: center; gap: 6px; border-radius: 8px; color: #fff5ce;
  background: #252941eb; padding: 4px 9px; font-weight: 800; font-size: clamp(12px,1.7vmin,16px); }
.personal-best i { color: #ffd169; }
.personal-best svg { fill: #e9a32d; stroke-width: 1.9px; }
.personal-best strong, .board-row { font-variant-numeric: tabular-nums; }

.game-tools { position: absolute; top: var(--top); right: var(--right); display: flex; align-items: flex-start; gap: 7px; }
.tool, .action { display: inline-flex; align-items: center; justify-content: center; gap: .45em; border: 2.5px solid var(--ink);
  border-radius: 14px 13px 15px 12px; font-weight: 900; line-height: 1; color: var(--ink);
  --cap: #e7f3fa; --sole: #9eb6c5; --shine: #fcffff;
  background: var(--cap); box-shadow: inset 0 3px var(--shine), inset 0 -4px var(--sole), 0 3px 0 var(--ink);
  transition: transform .12s ease, filter .12s ease; }
.tool { min-width: 46px; height: 46px; padding: 0 10px 3px; font-size: 16px; }
.tool i, .tool > svg { width: 22px; height: 22px; }
.tool svg { stroke-width: 2.35; }
.game-tools .world-button { --cap: #ffca5c; --shine: #fff1ab; --sole: #e79a39; min-height: 56px;
  padding-inline: 17px; font-size: 21px; border-radius: 18px 15px 19px 14px; transform-origin: center; }
.world-button i { width: 27px; height: 27px; }
.world-button:not(:focus-visible) { position: relative; }
#scene:is([data-phase="ready"],[data-phase="done"]) .world-button { animation: map-glimmer 8s ease-out infinite; }
@keyframes map-glimmer {
  0%,72%,88%,100% { filter: none; }
  79% { filter: brightness(1.09) drop-shadow(0 0 8px #ffdf72); }
}
#language { font-size: 14px; }
.help-button { --cap: #ffebc1; --shine: #fff6dd; --sole: #dab37a; }
.pause-button { --cap: #ffc85c; --shine: #ffe59a; --sole: #e69d38; }
@media (hover: hover) {
  button:enabled:hover { filter: brightness(1.075); }
  .tool:hover, .action:enabled:hover { transform: translateY(-1px); }
}
.tool:active, .action:enabled:active { transform: translateY(2px); }

.controls { position: absolute; right: var(--right); bottom: calc(var(--bottom) + 25px); display: flex; gap: 16px; align-items: center; }
#scene[data-phase="done"] .controls { left:50%;right:auto;transform:translateX(-50%);bottom:calc(var(--bottom) + 13px); }
.result-worlds { position:absolute; left:50%; top:51%; translate:-50% -50%;
  min-width:clamp(166px,24vmin,236px); min-height:clamp(58px,9vmin,78px); gap:.48em;
  padding:9px 24px; font-size:clamp(24px,4vmin,33px); border-radius:21px 17px 23px 16px;
  --cap:#ffd56d; --shine:#fff3b9; --sole:#e39835; animation:map-arrive .24s ease-out both; }
.result-worlds i { width:1.28em; height:1.28em; }
@keyframes map-arrive { from { opacity:0; scale:.88; } }
.callout { position: absolute; left: 69%; top: max(17%, calc(var(--top) + 65px)); transform: translateX(-50%);
  width: min(55%, 660px); display: grid; gap: 6px; justify-items: center; pointer-events: none; text-align: center;
  color: #fff9e5; --letter: #fff0a8; }
.callout-text { width:100%; display:grid; gap:inherit; justify-items:center; }
.speech { position:absolute; margin:0; width:max-content; max-width:clamp(118px,24vw,208px);
  padding:7px 13px 8px; border:2px solid var(--ink); border-radius:18px 19px 16px 21px;
  background:#fff; color:var(--ink); filter:drop-shadow(0 2px 0 #252b4355);
  font-size:clamp(14px,2.2vmin,19px); font-weight:800; line-height:1.15;
  text-align:center; text-wrap:balance; pointer-events:none; }
.speech:not([data-side]) { visibility:hidden; }
.speech::after { content:''; position:absolute; width:12px; height:12px; background:#fff; box-sizing:border-box;
  transform:translate(-50%,-50%) rotate(45deg); }
.speech[data-side="above"]::after { left:var(--tail); top:100%; border-right:2px solid; border-bottom:2px solid; }
.speech[data-side="left"]::after { left:100%; top:var(--tail); border-right:2px solid; border-top:2px solid; }
.speech[data-side="right"]::after { left:0; top:var(--tail); border-left:2px solid; border-bottom:2px solid; }
#attempt { font-size: clamp(12px,1.9vmin,17px); line-height: 1; font-weight: 900; color: #25334c; padding: 5px 11px;
  background: #afe9d8; border: 2px solid var(--ink); border-radius: 15px 7px 14px 6px; box-shadow: 1px 2px var(--ink); }
#state { display: block; font-family: "Nunito","Arial Black","Segoe UI",sans-serif; font-weight: 1000;
  font-size: clamp(31px,5.7vmin,70px); line-height: 1.12; letter-spacing: -.035em; color: var(--letter);
  -webkit-text-stroke: .105em #29233b; paint-order: stroke fill; transform: rotate(-2deg);
  filter: drop-shadow(1px 3px 0 #29233b); text-wrap: balance; }
#hint:not(:empty) { font-size: clamp(15px,2.3vmin,23px); font-weight: 800; line-height: 1.2; text-wrap: balance;
  background: #28283fee; border-radius: 5px 12px 5px 10px; padding: 5px 13px 7px; margin-top: 2px; }
.callout:is([data-message="record"],[data-message="arenaRecord"]) { --letter:#ffda64; }
.callout:is([data-message="miss"],[data-message="spent"]) { --letter:#ffbd9c; }
.callout[data-message="drop"] { --letter:#bbf2db; }
.callout[data-message="flight"] { left:var(--left); top:max(28%, calc(var(--top) + 135px)); width:32%; transform:none; }
.callout[data-message="flight"] #state { font-size:clamp(25px,4.6vmin,53px); }
.callout:is([data-message="flight"],[data-message="swing"],[data-message="spent"],[data-message="slide"]) #attempt { display:none; }
.action { --cap: #ffd064; --shine: #fff0b4; --sole: #e6a03b; min-height: 54px;
  padding: 8px 16px 11px; gap: 9px; font-size: clamp(18px,2.6vmin,26px); border-radius: 19px 16px 20px 15px; }
.action i { width: 1em; height: 1em; }
.action:disabled { cursor: default; --cap: #e0e7e4; --shine: #f5fbf6; --sole: #aabcb6; }
#action:disabled { display: none; }
kbd { border: 1px solid #946a33; border-bottom-width: 2px; border-radius: 5px; background: #fff3c2;
  padding: 3px 5px; color: #6c4821; font: 800 11px/1 "Trebuchet MS", sans-serif; }
.ruler { position: absolute; bottom: env(safe-area-inset-bottom, 0px); left: 0; right: 0; height: 22px; pointer-events: none;
  border-bottom: 2px solid #efe4cb66; overflow: hidden; color: #fff7df; }
.ruler-mark { position: absolute; left: 0; bottom: 0; border-left: 2px solid #fffae1ba; padding: 0 0 3px 4px;
  white-space: nowrap; font: 800 11px/1 "Trebuchet MS", sans-serif; text-shadow: 0 1px 2px #1d2133, 1px 0 2px #1d2133, -1px 0 2px #1d2133; }

.field-board { position: absolute; left: 0; top: 0; display: block; padding: 0; border: 0;
  aspect-ratio: 1 / 1; background: url("assets/scoreboard.webp") center / 100% 100% no-repeat;
  color: #fff4d1; container-type: inline-size; filter: drop-shadow(1px 2px 0 #25263760); }
.board-face { position: absolute; inset: 25% 16% 30%; display: flex; flex-direction: column; justify-content: center;
  font-size: clamp(10px, 9cqi, 16px); line-height: 1.07; text-shadow: 0 1px #1e3539; font-weight: 900; }
.board-title { color: #ffe19b; font-size: 1.14em; margin-bottom: .22em; }
.board-row { display: flex; align-items: center; justify-content: space-between; padding: 0 2%; }
.board-row b { font-size: .78em; color: #ffdc83; }
.board-row:nth-child(2) b { color: #c5dedc; }
.board-row:nth-child(3) b { color: #ecbca1; }
@container (max-width: 115px) {
  .board-title { display: none; }
  .board-row { font-size: 11px; line-height: 1.12; }
}
.finish-sign { position: absolute; width: 0; height: 0; pointer-events: none; }
.finish-sign::after { content:''; position:absolute; right:0; bottom:0; width:var(--flag-offset); border-bottom:2px dotted #ffedbf; }
.finish-sign::before { content:''; position:absolute; left:-4px; bottom:-3px; width:7px; height:7px;
  border:1px solid #69482d; background:#ffe6a9; transform:rotate(45deg); }
.finish-post { position: absolute; left:calc(-1 * var(--flag-offset)); bottom: 0; width: 10px; height: clamp(83px,20vmin,175px); background: #a97141;
  border: 2px solid #553b38; border-radius: 3px; transform-origin: bottom center; animation: stake .55s both; }
.finish-board { position: absolute; bottom: 65%; left: 50%; transform: translateX(-50%) rotate(-3deg); white-space: nowrap;
  padding: 7px 19px 9px; color: #452e2e; font-size: clamp(25px,4.3vmin,48px); line-height:1.05; font-weight: 1000; background: #ffdc91;
  border: 3px solid #533b3c; border-radius: 8px 5px 7px 4px; box-shadow: inset 0 2px #fff2c9, 0 2px #5c4336; }
@keyframes stake { 0% { opacity: 0; transform: translateY(-155px) rotate(-15deg); } 15% { opacity: 1; }
  57% { transform: rotate(6deg); } 72% { transform: translateY(-8px) rotate(-4deg); } 86% { transform: rotate(2deg); } }

dialog { color: var(--ink); background: #fff3d5; border: 3px solid var(--ink); border-radius: 25px 20px 24px 19px;
  width: min(620px, calc(100% - 28px)); max-height: calc(100dvh - 30px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0; box-shadow: inset 0 4px #fffbed, 0 7px 0 #25283e, 0 13px 44px #14162c66; }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #1a20376b; backdrop-filter: blur(3px); }
.dialog-head { padding: 15px 18px 10px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; font: 1000 clamp(25px,4.2vmin,35px)/1 "Nunito","Arial Black","Segoe UI",sans-serif; letter-spacing: -.04em; }
.dialog-head .tool { --cap: #ffe0ab; --sole: #d9ac79; --shine: #fff1d3; }
#panel-body { overflow: auto; overscroll-behavior: contain; padding: 5px 20px 23px; scrollbar-color: #a88260 #f7e4bc; }
.world-choices { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
@media (min-width: 820px) {
  dialog[data-kind="collection"] { width:min(890px,calc(100% - 40px)); }
  .world-choices { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
.world-card { position: relative; min-width: 0; display: flex; align-items: center; gap: 9px; padding: 6px;
  text-align: left; border: 2px solid #84755d; border-radius: 13px; background: #fff9e9; }
.world-card[aria-pressed="true"] { border-color: #326d61; background: #cff1da; }
.world-card img { width: 34%; max-width: 85px; aspect-ratio: 1.14; object-fit: cover; border-radius: 7px; }
.world-copy { display: grid; gap: 3px; }
.world-copy strong { font-size: 15px; line-height: 1.05; }
.world-copy > span, .world-note { font-size: 12px; color: #615a51; }
.world-copy small { font-size: 11px; font-weight: 900; color: #356452; }
.world-check { color: #24654e; position: absolute; left: 8px; top: 8px; line-height: 1; }
.world-check:not(:empty) { background: #ceffd9; border-radius: 50%; padding: 1px; }
.dialog-text { font-size: 16px; line-height: 1.45; margin: 6px 0 15px; }
.dialog-text ol { margin: 0; padding-left: 1.6em; }
.dialog-text li { margin-bottom: .55em; padding-left: .2em; }
.dialog-text li::marker { color: #69512d; font-weight: 900; }
.dialog-text b, .score-row strong { font-variant-numeric: tabular-nums; }
.pause-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.dialog-action { font-size: 18px; min-height: 46px; }
.score-row { display: flex; gap: 10px; align-items: center; padding: 7px 3px; border-bottom: 1px solid #dbc9a3; }
.score-row strong { margin-left: auto; white-space: nowrap; }
.score-title { font-size: 18px; margin-bottom: 3px; }
.score-title:first-child { margin-top: 0; }
.podium { list-style: none; padding: 0; margin: 10px 0 20px; display: flex; gap: 7px; }
.podium li { display: grid; gap: 2px; padding: 7px 12px; color: #24433f; background: #cfe9db; border-radius: 9px; }
.podium li:first-child { background: #ffdc8b; color: #573d25; }
.podium span { font-size: 12px; font-weight: 700; }
.podium strong { font-size: 19px; }
.world-note { margin-bottom: 0; }
noscript { position: absolute; bottom: 10%; left: 8%; padding: 16px; background: var(--cream); }
#screen-notice { position: absolute; top: 25%; left: 50%; transform: translateX(-50%); width: max-content; max-width: 80%;
  padding: 10px 15px; border-radius: 12px; color: #fff8dc; font-weight: 700; background: #292b44; pointer-events: none; }
@media (max-width: 760px) {
  .game-tools { gap: 5px; }
  .help-button span { display: none; }
}
@media (max-width: 540px) {
  .game-tools { display:grid; grid-template-columns:51px 51px 44px; justify-content:end; }
  .game-tools .world-button { grid-column: span 2; min-height:53px; font-size:19px; }
  #language { position:fixed; left:var(--left); top:calc(var(--top) + 117px); }
  .game-tools #pause { grid-column:3; grid-row:2; }
  .game-tools #help { grid-column:3; grid-row:1; }
  .callout { top: max(25%, calc(var(--top) + 150px)); left:50%; width:94%; gap:7px; }
  #state { font-size: clamp(31px,8.5vw,45px); }
  #hint:not(:empty) { max-width: 93%; }
  .game-tools .tool { min-width: 44px; height: 44px; padding-inline: 8px; }
  .controls { right: var(--right); left: var(--left); bottom:calc(var(--bottom) + 13px); justify-content: center; gap: 12px; }
  .action { padding-inline: 13px; }
  .world-choices { grid-template-columns: 1fr; }
  .world-card img { width: 68px; aspect-ratio: 1.4; }
  .distance { font-size: 50px; }
  kbd { display: none; }
}
@media (max-height: 500px) {
  :root { --edge: 9px; --bottom: 4px; }
  .score-hud { gap: 3px; }
  .location { font-size: 11px; padding-block: 3px; }
  .distance { font-size: 40px; }
  .personal-best { font-size: 11px; padding-block: 3px; }
  .game-tools { gap: 4px; }
  .game-tools .tool { min-width: 44px; height: 44px; }
  .controls { gap: 9px; bottom: calc(var(--bottom) + 18px); }
  .controls .action { min-height: 44px; font-size: 18px; padding-block: 6px 8px; }
  .callout { left:22%; top:max(28%,calc(var(--top) + 86px)); width:42%; gap:3px; }
  #state { font-size:clamp(22px,6.1vmin,33px); }
  #hint:not(:empty) { font-size:14px; }
  #attempt { display:none; }
  .game-tools .world-button { min-height:48px; font-size:18px; }
  .ruler { height: 16px; }
  .ruler-mark { padding-bottom: 2px; font-size: 10px; }
  .dialog-head { padding-block: 8px 6px; }
}
@media (max-width: 350px) {
  .game-tools { gap: 3px; }
  .location { font-size: 10px; }
  .distance { font-size:clamp(31px,10.9vw,38px); }
  #launch-angle { margin-left:.15em; }
}
@media (max-width:540px) and (min-height:501px) and (max-height:650px) {
  #scene[data-phase="done"] #attempt { display:none; }
  .callout[data-message="ready"] { gap:4px; }
  .callout[data-message="ready"] #state { font-size:clamp(23px,8vw,31px); }
  .result-worlds { top:55%; }
}
@media (min-width:541px) and (min-height:501px) and (max-aspect-ratio:2/1) {
  .callout[data-message="ready"] { left:var(--left); transform:none; width:36%; top:max(20%,calc(var(--top) + 128px)); }
}
@media (max-height:500px) and (orientation:landscape) {
  .result-worlds { top:40%; left:57%; }
  #scene[data-world="graveyard"] .callout[data-message="miss"] ~ .controls { left:var(--left); right:auto; transform:none; }
}
@media (max-height:350px) and (orientation:landscape) {
  #scene[data-phase="done"] .callout { top:max(31%,calc(var(--top) + 98px)); }
}
@media (orientation:portrait) {
  #scene .controls, #scene[data-phase="done"] .controls {
    top:var(--foot-line); bottom:auto; left:auto; right:var(--right); transform:translateY(-50%);
    width:max-content; max-width:38%; }
  .controls .action { max-width:100%; min-height:48px; }
  #scene[data-phase="done"] .callout[data-message="miss"] ~ .controls { left:var(--left); right:auto; }
}
@media (orientation:portrait) and (max-width:540px) {
  .controls .action { padding-inline:10px; gap:6px; }
}
@media (max-width: 550px) and (max-height: 450px) { .game-tools { display:flex; width:auto; } .game-tools .world-button span { display:none; } }
@media (pointer: coarse) { kbd { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media (prefers-reduced-motion: reduce) { #scene .world-button, .callout { animation:none !important; } }

