/* Layout: full-bleed sky; HUD glass pinned to the corners; cards centred over the view.
   On touch screens the stick and buttons take the bottom corners and the gauges move up. */
:root {
  color-scheme: dark;
  --glass: rgba(27, 20, 56, .56);
  --glass-strong: rgba(24, 18, 50, .86);
  --glass-edge: rgba(255, 218, 180, .22);
  --ink: #fff4e8;
  --dim: #cfbdd9;
  --gold: #ffc65c;
  --jet: #ff8a3d;
  --danger: #ff5a4e;
  --slip: #9fd2ff;
  --puffin: #ff9bd0;
  --night: #150f2b;
  --display: "Lilita One", "Trebuchet MS", system-ui, sans-serif;
  --body: "Nunito", "Trebuchet MS", system-ui, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
}
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink); font-family: var(--body);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
kbd { font: 800 11px var(--body); background: rgba(255, 255, 255, .14); border-radius: 4px; padding: 1px 5px; color: var(--ink); }
[hidden] { display: none !important; }

.panel { position: fixed; box-sizing: border-box; background: var(--glass); border: 1px solid var(--glass-edge); border-radius: 14px;
  padding: 10px 14px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 0 8px 26px rgba(10, 4, 30, .35); }
.k { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.v small { font-size: 12px; font-weight: 800; color: var(--dim); margin-left: 3px; }

#info { top: calc(14px + var(--st)); left: calc(14px + var(--sl)); width: 262px; }
#info .name { font-family: var(--display); font-size: 27px; line-height: 1.05; margin: 3px 0 8px; }
#info .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 9px; }
#info .chips span { font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18); }
#info .chips #i-mode { background: var(--gold); color: #3a2a1a; border-color: transparent; }
#info .keys { display: flex; flex-wrap: wrap; gap: 5px 10px; font-size: 12px; color: var(--dim); }
#info .keys span { white-space: nowrap; }

#flight { bottom: calc(14px + var(--sb)); left: 50%; transform: translateX(-50%); display: flex; gap: 16px; align-items: center; }
#flight .bars { display: grid; gap: 6px; width: 120px; }
.bar { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 6px; }
.bar i { display: block; height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.bar b { display: block; height: 100%; width: 50%; border-radius: 4px; background: var(--gold); transition: width .1s linear; }
.bar b.boost { background: linear-gradient(90deg, #ff6a3d, var(--jet)); }
.bar b.boost.locked { background: rgba(255, 255, 255, .35); }
#smoke { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; padding: 6px 10px;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, .35); color: var(--dim); white-space: nowrap; }
#smoke.on { background: rgba(255, 250, 240, .92); color: #3a2a4d; border-color: transparent; }
#flight .chips2 { display: grid; gap: 5px; }
#slip { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; padding: 6px 10px; text-align: center;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, .2); color: rgba(207, 189, 217, .55); white-space: nowrap; transition: background .15s, color .15s; }
#slip.on { background: var(--slip); color: #10243f; border-color: transparent; box-shadow: 0 0 18px rgba(140, 205, 255, .8); }

#score { top: calc(14px + var(--st)); right: calc(14px + var(--sr)); display: flex; gap: 16px; }
#score .gold { color: var(--gold); }

/* a challenge: its name, the clock, the goal and how far along it you are */
#chal { top: calc(14px + var(--st)); left: calc(14px + var(--sl)); width: 262px; }
#chal .row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 2px 0 6px; }
#chal .name { font-family: var(--display); font-size: 24px; line-height: 1.05; }
#chal .clock { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
#chal .clock.low { color: var(--danger); }
#chal .goal { display: flex; align-items: baseline; gap: 8px; }
#chal .gv { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--gold); white-space: nowrap; }
#chal .gx { margin-left: auto; font-size: 13px; font-weight: 800; color: var(--dim); white-space: nowrap; }
.meter { position: relative; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .14); margin-top: 6px; }
.meter b { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 4px; background: var(--gold); transition: width .15s linear; }
.meter i { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: rgba(255, 244, 232, .75); border-radius: 1px; }
.meter.marked { margin-bottom: 13px; }
.meter i::after { content: "★"; position: absolute; top: 13px; left: -5px; font-size: 10px; line-height: 1; color: var(--dim); font-style: normal; }
.meter i.got::after { color: var(--gold); }
#chal .hint { font-size: 13px; font-weight: 800; color: var(--slip); margin-top: 7px; min-height: 0; }
#chal .hint:empty { display: none; }

/* a Skywrite's judges' window: the sky from where the audience stands (the view is drawn into the canvas
   underneath, at this box's place) */
#judge { position: fixed; top: calc(14px + var(--st)); right: calc(14px + var(--sr)); width: clamp(160px, 27vw, 360px); aspect-ratio: 1.3;
  box-sizing: border-box; border: 2px solid rgba(255, 210, 120, .85); border-radius: 12px; box-shadow: 0 8px 26px rgba(10, 4, 30, .35);
  touch-action: none; cursor: zoom-in; }
#judge .tag { position: absolute; left: 8px; bottom: 6px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; background: rgba(24, 18, 50, .75); color: var(--gold); white-space: nowrap; }
#judge .tag kbd { font-size: 10px; }
body.judging #flight, body.judging #globe-wrap, body.judging #chal { visibility: hidden; }   /* the whole picture, while watching from the square */
#judge-full { position: fixed; top: calc(14px + var(--st)); left: 50%; transform: translateX(-50%); padding: 7px 14px; border-radius: 999px;
  background: rgba(24, 18, 50, .78); color: var(--gold); font-weight: 800; font-size: 14px; pointer-events: none; white-space: nowrap; }

/* where to go next: a ring round it, or an arrow at the edge when it's off the screen */
#pointer { position: fixed; left: 0; top: 0; pointer-events: none; }
#pointer .ring { position: absolute; width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 50%; border: 2px solid var(--gold);
  box-shadow: 0 0 10px rgba(255, 200, 90, .6); }
#pointer .arrow { position: absolute; width: 0; height: 0; margin: -12px 0 0 -9px; border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-bottom: 24px solid var(--gold); filter: drop-shadow(0 0 6px rgba(255, 200, 90, .7)); transform-origin: 9px 12px; }
#pointer span { position: absolute; top: 22px; left: -40px; width: 80px; text-align: center; font-size: 12px; font-weight: 800; color: var(--ink);
  text-shadow: 0 1px 3px rgba(20, 10, 40, .9); }
#pointer.off .ring, #pointer.on .arrow { display: none; }
#pointer.gap .ring { border-color: var(--slip); box-shadow: 0 0 10px rgba(140, 205, 255, .6); }
#pointer.gap .arrow { border-bottom-color: var(--slip); }
#pointer.puffin .ring { border-color: var(--puffin); box-shadow: 0 0 10px rgba(255, 155, 208, .6); }
#pointer.puffin .arrow { border-bottom-color: var(--puffin); }

#globe-wrap { right: calc(14px + var(--sr)); bottom: calc(14px + var(--sb)); padding: 8px; border-radius: 50%; }
#globe { display: block; width: 120px; height: 120px; }

#stamp { position: fixed; top: 30%; left: 50%; transform: translate(-50%, -50%) rotate(-6deg); font-family: var(--display); font-size: 64px;
  letter-spacing: .08em; color: var(--danger); text-shadow: 0 4px 0 #5c1712, 0 0 30px rgba(255, 80, 60, .6); pointer-events: none;
  animation: shake .12s infinite alternate; }
@keyframes shake { from { margin-left: -3px; } to { margin-left: 3px; } }
body.stalled::after { content: ""; position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 90px rgba(255, 60, 40, .55); }
#warn { position: fixed; top: calc(14px + var(--st)); left: 50%; transform: translateX(-50%); font-weight: 800; font-size: 14px;
  padding: 7px 14px; border-radius: 999px; background: rgba(255, 198, 92, .92); color: #3a2a1a; pointer-events: none; white-space: nowrap; }
#toast { position: fixed; top: 40%; left: 50%; transform: translate(-50%, 0) scale(.9); opacity: 0; font-family: var(--display); font-size: 30px;
  color: var(--ink); text-shadow: 0 3px 0 rgba(30, 14, 60, .8); pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.card { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); box-sizing: border-box; width: min(460px, calc(100vw - 32px));
  max-height: calc(100% - 32px); overflow-y: auto; background: var(--glass-strong); border: 1px solid var(--glass-edge); border-radius: 20px;
  padding: 22px 24px; box-shadow: 0 20px 60px rgba(8, 2, 24, .6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); text-align: center; }
.card .title { font-family: var(--display); font-size: 52px; letter-spacing: .04em; line-height: 1; color: var(--ink);
  text-shadow: 0 4px 0 #b24a1c; }
.card .title.small { font-size: 36px; text-shadow: none; }
.card .sub { font-weight: 800; color: var(--gold); letter-spacing: .14em; text-transform: uppercase; font-size: 13px; margin-top: 8px; }
.card .lede { font-size: 15px; line-height: 1.45; color: var(--ink); margin: 12px auto 14px; max-width: 34ch; }
.card .note, .card .hint { font-size: 12.5px; line-height: 1.45; color: var(--dim); margin: 12px 0 0; }
.howto { display: grid; gap: 6px; text-align: left; margin: 0 auto 16px; width: fit-content; font-size: 14px; }
.howto div { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 10px; }
.howto b { justify-self: end; display: flex; gap: 3px; font-weight: 800; }
.howto span { color: var(--dim); }
button.primary { background: var(--gold); color: #3a2a1a; border: 0; border-radius: 999px; padding: 11px 22px; font-weight: 800; font-size: 15px; }
.row-buttons { display: flex; gap: 10px; justify-content: center; margin: 16px 0 6px; }
.row-buttons button:not(.primary) { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px; padding: 10px 20px; font-weight: 800; }
.settings { display: grid; gap: 10px; margin-top: 14px; text-align: left; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.setting > span { font-weight: 800; font-size: 14px; }
.seg { display: flex; border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 6px 12px; font-weight: 800; font-size: 13px; color: var(--dim); }
.seg button.on { background: var(--gold); color: #3a2a1a; }
.settings .hint { margin: -4px 0 0; }

/* the menu: Meadow's challenges, then free flight */
.levels { display: grid; gap: 8px; margin: 4px 0 8px; }
button.lvl { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .16); border-radius: 14px; padding: 9px 12px; }
button.lvl:hover { background: rgba(255, 255, 255, .13); }
button.lvl .num { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: #3a2a1a;
  font-family: var(--display); font-size: 18px; }
button.lvl .nm { display: grid; gap: 1px; }
button.lvl .nm b { font-size: 16px; }
button.lvl .nm small { font-size: 12.5px; color: var(--dim); }
.st i { font-style: normal; font-size: 17px; color: rgba(255, 255, 255, .22); }
.st i.on { color: var(--gold); text-shadow: 0 0 8px rgba(255, 200, 90, .5); }
button.lvl.free { grid-template-columns: 34px 1fr; margin-bottom: 4px; }
button.lvl.free .num { background: rgba(159, 210, 255, .9); color: #10243f; }
button.lvl:disabled { opacity: .45; cursor: default; }
.total { font-weight: 800; font-size: 14px; color: var(--dim); margin: 6px 0 4px; }
.total .gold, .gold { color: var(--gold); }
.menu-mode { justify-content: center; margin-top: 10px; }
#menu-mode-hint { margin: 6px auto 0; max-width: 36ch; }
details.how { margin-top: 12px; text-align: center; }
details.how summary { cursor: pointer; font-weight: 800; font-size: 14px; color: var(--dim); }
details.how .howto { margin-top: 10px; }

/* a challenge's card, and how it went */
.goals { list-style: none; padding: 0; margin: 4px auto 10px; display: grid; gap: 6px; width: fit-content; text-align: left; font-size: 14px; }
.goals li { display: flex; gap: 10px; align-items: center; }
.goals .st i { font-size: 15px; }
.card .best { font-size: 13px; font-weight: 800; color: var(--dim); margin: 0; }
.bigstars { display: flex; justify-content: center; gap: 10px; margin: 10px 0 2px; }
.bigstars i { font-style: normal; font-size: 54px; line-height: 1; color: rgba(255, 255, 255, .16); transform: scale(.6); transition: transform .25s, color .25s; }
.bigstars i.on { color: var(--gold); transform: scale(1); text-shadow: 0 0 22px rgba(255, 200, 90, .8), 0 4px 0 #b26a1c; }
.newbest { display: inline-block; margin: 0 0 4px; padding: 4px 12px; border-radius: 999px; background: var(--slip); color: #10243f; font-weight: 800; font-size: 13px; }

body.at-menu .panel, body.at-menu #touch, body.at-menu #pausebtn, body.at-menu #judge { visibility: hidden; }

#pausebtn { display: none; position: fixed; top: calc(12px + var(--st)); right: calc(12px + var(--sr)); width: 44px; height: 44px; border-radius: 50%;
  background: var(--glass); border: 1px solid var(--glass-edge); font-size: 14px; letter-spacing: -2px; }
#touch { display: none; }
.touchonly { display: none; }

/* touch screens */
body.touch .keysonly { display: none; }
body.touch .touchonly { display: inline; }
body.touch .howto.touchonly { display: grid; }
body.touch #info { display: none; }
body.touch #pausebtn { display: block; }
body.touch #flight { top: calc(12px + var(--st)); bottom: auto; left: calc(12px + var(--sl)); transform: none; gap: 10px; padding: 8px 11px; }
body.touch #flight .bars { width: 70px; }
body.touch #flight .bar { grid-template-columns: 1fr; gap: 2px; }
body.touch #flight .bar .k { display: none; }
body.touch .v { font-size: 20px; }
body.touch #smoke { display: none; }
body.touch #slip { padding: 4px 7px; font-size: 10px; }
body.touch #score { top: calc(74px + var(--st)); right: auto; left: calc(12px + var(--sl)); gap: 12px; padding: 6px 11px; }
body.touch #globe-wrap { top: calc(64px + var(--st)); bottom: auto; right: calc(12px + var(--sr)); padding: 5px; }
body.touch #globe { width: 76px; height: 76px; }
body.touch #warn { top: auto; bottom: calc(190px + var(--sb)); }
body.touch #touch { display: block; }
body.touch #chal { top: calc(74px + var(--st)); left: calc(12px + var(--sl)); width: 240px; padding: 6px 11px; }
body.touch #chal > .k { display: none; }
body.touch #judge { top: calc(64px + var(--st)); right: calc(12px + var(--sr)); width: clamp(150px, 30vw, 260px); }
body.touch.skywrite #globe-wrap { display: none; }
body.touch #chal .name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch #chal .clock { font-size: 20px; }
body.touch #chal .row { margin: 0 0 3px; }
#stick { position: fixed; left: calc(22px + var(--sl)); bottom: calc(22px + var(--sb)); width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .08) 0 60%, rgba(255, 255, 255, .14) 61%); border: 1px solid var(--glass-edge); touch-action: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
  background: rgba(255, 244, 232, .85); box-shadow: 0 4px 14px rgba(10, 4, 30, .45); pointer-events: none; }
#tbtns { position: fixed; right: calc(18px + var(--sr)); bottom: calc(18px + var(--sb)); display: grid; grid-template-columns: repeat(2, 76px); gap: 10px; }
#tbtns button { height: 60px; border-radius: 18px; background: var(--glass); border: 1px solid var(--glass-edge); font-weight: 800; font-size: 13px; touch-action: none; }
#tbtns button.big { background: rgba(255, 138, 61, .55); }
#tbtns button.on { background: var(--gold); color: #3a2a1a; }
#t-smoke.lit { background: rgba(255, 250, 240, .85); color: #3a2a4d; }

@media (max-width: 720px) {
  #info { width: 220px; padding: 8px 11px; }
  #info .name { font-size: 21px; }
  #info .keys { display: none; }
  #flight { left: calc(14px + var(--sl)); transform: none; gap: 10px; padding: 8px 11px; }
  #flight .bars { width: 80px; }
  .bar { grid-template-columns: 1fr; gap: 2px; }
  .v { font-size: 20px; }
  #globe { width: 84px; height: 84px; }
  .card .title { font-size: 40px; }
  #chal { width: 220px; padding: 8px 11px; }
  #chal .name { font-size: 19px; }
}
@media (max-height: 520px) {
  #info .keys { display: none; }
  .card { padding: 14px 18px; }
  .card .title { font-size: 34px; }
  .card .lede { margin: 6px auto 8px; }
  .howto { gap: 3px; margin-bottom: 10px; font-size: 13px; }
  #stick { width: 120px; height: 120px; }
  #tbtns { grid-template-columns: repeat(2, 68px); }
  #tbtns button { height: 50px; }
  body.touch #warn { bottom: auto; top: calc(12px + var(--st)); }
}
@media (prefers-reduced-motion: reduce) { #stamp { animation: none; } #toast, .bigstars i { transition: none; } }
