/* Jump to It! interface, with light and dark themes. */
:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --radius: 16px;
  --brand-ink: #102e37;
  --brand-cream: #fff2d7;
  --brand-yellow: #ffc550;
  --brand-wave: #008b80;
  --light-panel: rgba(255, 250, 238, 0.97);
  --light-panel-solid: #fffaee;
  --accent: #00756b;
  --accent-fg: #ffffff;
  --coin: #ffc928;
  --key: #3fb4ff;
  --ok: #2fa36b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
html[data-theme="light"] {
  --bg: #bfe2f5;
  --panel: var(--light-panel);
  --panel-solid: var(--light-panel-solid);
  --fg: #1d2433;
  --muted: #5b6577;
  --line: rgba(29, 36, 51, 0.14);
  --btn: #eef2f7;
  --btn-hover: #e1e8f1;
  --btn-fg: #1d2433;
  --seg-on: #1d2433;
  --seg-on-fg: #ffffff;
  --card: #f4f7fb;
  --track: rgba(29, 36, 51, 0.12);
  --hud-fg: #ffffff;
  --hud-shadow: rgba(0, 0, 0, 0.45);
  --shadow: 0 12px 40px rgba(20, 40, 70, 0.25);
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0b1f26;
  --panel: rgba(16, 46, 55, 0.96);
  --panel-solid: var(--brand-ink);
  --accent: #51c8be;
  --accent-fg: var(--brand-ink);
  --fg: #eef1f8;
  --muted: #a3acc2;
  --line: rgba(238, 241, 248, 0.14);
  --btn: #21434b;
  --btn-hover: #2a515a;
  --btn-fg: #eef1f8;
  --seg-on: #eef1f8;
  --seg-on-fg: var(--brand-ink);
  --card: #193b43;
  --track: rgba(238, 241, 248, 0.14);
  --hud-fg: #ffffff;
  --hud-shadow: rgba(0, 0, 0, 0.7);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); font-family: var(--font); }
body { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }

#game { position: fixed; inset: 0; height: 100dvh; overflow: hidden; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.flash { position: absolute; inset: 0; pointer-events: none; background: #ffffff; opacity: 0; }
.flash.go { animation: flash 0.45s ease-out; }
.flash.red { background: #ff3020; }
@keyframes flash { 0% { opacity: 0.55; } 100% { opacity: 0; } }

/* ---------- screens ---------- */
.screen {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: max(12px, var(--safe-top)) max(12px, var(--safe-right))
    max(12px, var(--safe-bottom)) max(12px, var(--safe-left));
  background: rgba(0, 0, 0, 0.18);
}
.screen.side { justify-content: flex-start; background: linear-gradient(90deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0) 60%); }
.panel {
  width: min(420px, 100%); max-height: 100%; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 18px 16px; display: flex; flex-direction: column; gap: 10px; text-align: center;
  border: 1px solid var(--line);
}
.panel.wide { width: min(580px, 100%); text-align: left; padding-bottom: 0; }
.menu-panel { width: min(420px, 100%); border-top: 4px solid var(--brand-wave); }
.side .panel.wide { width: min(500px, 100%); overflow: hidden; }
.side .shop-list { overflow-y: auto; min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; padding: 2px; }
.side .sticky-bottom { position: static; flex: none; }
h1 { margin: 0; font-size: clamp(28px, 7vw, 40px); line-height: 1.1; letter-spacing: -0.5px; color: var(--accent); }
.brand-title { flex: none; }
.brand-title img {
  display: block; margin-inline: auto; width: min(250px, 80%); height: auto;
  max-height: min(152px, 24dvh); object-fit: contain;
}
h2 { margin: 0; font-size: 26px; }
h3 { margin: 8px 0 0; font-size: 17px; }
.sub { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.35; }
.hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
#h-rio-attribution a { color: inherit; }
.footer { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.35; opacity: 0.85; }
.legal-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: 12px; }
.legal-links a { color: var(--muted); padding-block: 5px; }
.stats, .results { display: flex; gap: 8px; justify-content: center; }
.stats > div, .results > div {
  flex: 1; background: var(--btn); border-radius: 12px; padding: 7px 6px; display: flex; flex-direction: column; gap: 2px; min-width: 0; text-align: center;
}
.stats span, .results span { font-size: 12px; color: var(--muted); }
/* numbers never break: one line each; too long for four in a row - two rows of two, then a smaller font (fitStats in app.js) */
.stats b, .results b { font-size: 19px; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.2; }
.stats span, .results span { white-space: nowrap; }
.stats.grid2, .results.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 8px; }
.stats.grid2 > div, .results.grid2 > div { padding: 4px 6px; gap: 0; }
.stats.grid2-h > div, .results.grid2-h > div { flex-direction: row; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 9px; }
.grid2-h > div > span { flex: none; text-align: left; }
.stats .st-label { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; }
.stats .st-ico { width: 15px; height: 15px; flex: none; }
.stats .coin-dot.st-ico { width: 13px; height: 13px; margin: 1px; box-shadow: 0 1px 2px rgba(0,0,0,0.35); }
.record { background: var(--coin); color: #3b2a00; font-weight: 700; border-radius: 10px; padding: 6px; animation: pop 0.6s ease-out; }
@keyframes pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.08); } 100% { transform: scale(1); } }
.row { display: flex; gap: 10px; }
.row > .btn { flex: 1; min-width: 0; }

.btn {
  font: inherit; font-size: 16px; font-weight: 600; min-height: 44px; padding: 9px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--btn); color: var(--btn-fg); cursor: pointer;
  transition: background 0.12s, transform 0.08s;
}
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .seg button:focus-visible, .key:focus-visible, input:focus-visible, .card-btn:focus-visible, .tabs button:focus-visible, .shop-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--brand-yellow); color: var(--brand-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { font-size: 20px; min-height: 52px; }
.btn.ghost { background: transparent; }
.btn.small { font-size: 13px; min-height: 34px; padding: 5px 10px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* cards in the menu: the daily challenge and the missions */
.card-btn {
  font: inherit; color: var(--fg); text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
}
.card-btn:hover { background: var(--btn-hover); }
.card-btn.daily { border-left: 5px solid var(--key); }
.card-btn.daily.done { border-left-color: var(--ok); }
.card-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-text { font-size: 14px; }
.card-note { font-size: 12px; color: var(--muted); }
.mult-badge { background: var(--accent); color: var(--accent-fg); border-radius: 8px; padding: 1px 7px; font-size: 13px; }
.mini-missions { display: flex; flex-direction: column; gap: 4px; font-size: 13px; text-align: left; }
.mini-missions .mm { display: grid; grid-template-columns: 16px 1fr auto; gap: 6px; align-items: center; }
.mini-missions .mm i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); display: inline-block; }
.mini-missions .mm.done i { background: var(--ok); border-color: var(--ok); }
.mini-missions .mm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-missions .mm em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }

/* settings */
#s-rio-gameplay { display: grid; gap: 8px; }
#s-rio-difficulty {
  min-height: 44px; padding: .45rem .6rem; border: 1px solid var(--muted); border-radius: .55rem;
  background: var(--panel-solid); color: var(--fg); font: inherit;
}
.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.field > span { font-weight: 600; }
.field input[type="range"] { flex: 1; min-width: 140px; max-width: 280px; accent-color: var(--accent); }
.seg { display: inline-flex; background: var(--btn); border-radius: 12px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button {
  font: inherit; font-size: 14px; border: 0; background: transparent; color: var(--btn-fg); padding: 7px 11px;
  border-radius: 9px; cursor: pointer; min-height: 36px;
}
.seg button[aria-checked="true"] { background: var(--seg-on); color: var(--seg-on-fg); font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.keys { display: grid; grid-template-columns: minmax(80px, 1fr) repeat(3, minmax(0, 1fr)); gap: 6px; align-items: center; }
.keys .act { font-weight: 600; }
.key {
  font: inherit; font-size: 14px; min-height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--btn); color: var(--btn-fg); cursor: pointer; padding: 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.key.empty { color: var(--muted); }
.key.wait { background: var(--accent); color: var(--accent-fg); }
.sticky-bottom {
  position: sticky; bottom: 0; margin: 4px -18px 0; padding: 12px 18px 14px; background: var(--panel-solid);
  border-top: 1px solid var(--line); display: flex; justify-content: flex-end; z-index: 1;
}
.sticky-bottom .btn { min-width: 140px; }

/* optional player account */
#m-settings-row { flex-wrap: wrap; }
#m-settings-row > .btn { flex-basis: auto; }
.account-panel { text-align: left; }
.account-panel h2:focus { outline: none; }
.account-panel p { margin: 0; }
.account-flow { display: flex; flex-direction: column; gap: 8px; }
.account-flow label { font-weight: 600; }
.account-flow input {
  width: 100%; min-height: 44px; padding: 9px 12px; font: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--btn); color: var(--fg);
  user-select: text; -webkit-user-select: text;
}
.account-flow input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.account-secondary-actions .btn { color: var(--accent); }
.account-footer { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.account-panel #a-identity { font-weight: 600; overflow-wrap: anywhere; user-select: text; }
.account-error { font-size: 14px; font-weight: 600; line-height: 1.4; }
.account-conflict-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(146px, 100%), 1fr)); gap: 8px; }
.account-save { display: flex; flex-direction: column; gap: 7px; padding: 10px; border-radius: 10px; background: var(--card); }
.account-save h3 { margin: 0; }
.account-save p { white-space: pre-line; }
.account-save .btn { margin-top: auto; }

/* shop */
.tabs { display: flex; gap: 4px; background: var(--btn); border-radius: 12px; padding: 3px; flex-wrap: wrap; }
.tabs button { flex: 1; font: inherit; font-size: 14px; border: 0; background: transparent; color: var(--btn-fg); padding: 8px 6px; border-radius: 9px; cursor: pointer; min-height: 38px; min-width: 0; }
.tabs button[aria-selected="true"] { background: var(--seg-on); color: var(--seg-on-fg); font-weight: 600; }
.shop-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.shop-list.rows { grid-template-columns: 1fr; }
.shop-card {
  font: inherit; color: var(--fg); background: var(--card); border: 2px solid transparent; border-radius: 12px; padding: 8px;
  display: flex; flex-direction: column; gap: 4px; align-items: stretch; text-align: left; cursor: pointer; min-width: 0;
}
.shop-card.on { border-color: var(--accent); }
.shop-card .pic { height: 74px; border-radius: 9px; display: grid; place-items: center; overflow: hidden; background: var(--btn); }
.shop-card .pic svg { height: 70px; width: auto; }
.shop-card .name { font-weight: 700; }
.shop-card .desc { font-size: 12px; color: var(--muted); line-height: 1.3; min-height: 2.6em; }
.shop-card .btn { font-size: 13px; min-height: 34px; padding: 4px 8px; }
.shop-card .btn.owned { background: var(--ok); color: #fff; border-color: transparent; }
.board-pic { width: 86%; height: 26px; border-radius: 13px; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3); }
.upg { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; background: var(--card); border-radius: 12px; padding: 9px; }
.upg .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }
.upg .ico svg { width: 30px; height: 30px; }
.upg .name { font-weight: 700; }
.upg .desc { font-size: 13px; color: var(--muted); }
.upg .lvl { display: flex; gap: 4px; margin-top: 4px; }
.upg .lvl i { width: 14px; height: 6px; border-radius: 3px; background: var(--line); }
.upg .lvl i.on { background: var(--accent); }
.upg .btn { font-size: 14px; min-height: 40px; white-space: nowrap; }
.howto { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 7px; line-height: 1.4; }

/* missions */
.mult-big { font-size: 22px; font-weight: 800; color: var(--accent); }
.mission-list { display: flex; flex-direction: column; gap: 8px; }
.mission { background: var(--card); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; }
.mission.done { outline: 2px solid var(--ok); }
.mission .txt { font-weight: 600; }
.mission .rew { font-size: 13px; color: var(--muted); white-space: nowrap; }
.mission .prog { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-line { flex: 1; height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar-line i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.mission.done .bar-line i { background: var(--ok); }
.daily-box { background: var(--card); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }

/* achievements */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ach { background: var(--card); border-radius: 12px; padding: 8px; display: grid; grid-template-columns: 48px 1fr; gap: 8px; align-items: center; }
.ach svg { width: 48px; height: 48px; }
.ach.locked svg { filter: grayscale(1); opacity: 0.35; }
.ach > div { min-width: 0; }
.ach .name { font-weight: 700; font-size: 14px; overflow-wrap: break-word; }
.ach .desc { font-size: 12px; color: var(--muted); line-height: 1.3; overflow-wrap: break-word; }
/* 2.1.0: tiers of the achievements and the mystery boxes */
.ach .tier { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-top: 2px; }
.ach.tier-bronze { box-shadow: inset 3px 0 0 #c47c3c; } .ach.tier-bronze .tier { color: #b06a2a; }
.ach.tier-silver { box-shadow: inset 3px 0 0 #9aa6b4; } .ach.tier-silver .tier { color: #7f8b99; }
.ach.tier-gold { box-shadow: inset 3px 0 0 #e7b100; } .ach.tier-gold .tier { color: #c48f00; }
.box-shelf { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.box-tile { background: var(--card); border-radius: 12px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; text-align: center; border-bottom: 3px solid transparent; }
.box-tile.tier-bronze { border-bottom-color: #c47c3c; } .box-tile.tier-silver { border-bottom-color: #9aa6b4; } .box-tile.tier-gold { border-bottom-color: #e7b100; }
.box-tile .box-svg { width: 44px; height: 44px; }
.box-tile.empty .box-svg { filter: grayscale(1); opacity: 0.4; }
.box-tile:not(.empty) .box-svg { animation: box-wiggle 2.4s ease-in-out infinite; }
.bt-name { font-size: 12px; font-weight: 700; max-width: 100%; overflow-wrap: break-word; }
.bt-n { font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.box-tile .bt-open { width: 100%; padding: 5px 4px; }
#m-ach { position: relative; }
.box-dot { position: absolute; top: -7px; right: -5px; min-width: 22px; padding: 1px 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); border-radius: 10px; background: var(--accent); color: var(--accent-fg); font-size: 12px; line-height: 18px; white-space: nowrap; text-align: center; }
.box-open { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.55); padding: 16px; }
.box-stage { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); width: min(300px, 100%); padding: 18px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.box-pic .box-svg { width: 120px; height: 120px; overflow: visible; }
.box-pic .box-lid { transform-box: fill-box; transform-origin: 50% 100%; }
.box-open.shaking .box-pic .box-svg { animation: box-shake 0.55s ease-in-out; }
.box-open.popping .box-lid, .box-open.opened .box-lid { animation: lid-off 0.4s ease-out forwards; }
.box-open.opened .box-pic { display: none; }
.box-open.opened .box-reward { animation: pop 0.45s ease-out; }
.box-reward { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 120px; justify-content: center; }
.box-reward b { font-size: 22px; white-space: nowrap; }
.box-reward .bo-ico svg { width: 56px; height: 56px; }
.box-reward .bo-ico .board-pic { width: 120px; }
.coin-dot.big { display: inline-block; width: 48px; height: 48px; }
.bo-rare { font-weight: 800; color: #3b2a00; background: var(--coin); border-radius: 8px; padding: 2px 10px; font-size: 13px; }
.box-open.rare .box-stage { box-shadow: 0 0 0 3px var(--coin), var(--shadow); }
@keyframes box-wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-7deg); } 90% { transform: rotate(6deg); } 95% { transform: rotate(-3deg); } }
@keyframes box-shake { 0%, 100% { transform: translate(0, 0) rotate(0); } 15% { transform: translate(-4px, 0) rotate(-6deg); } 30% { transform: translate(4px, -2px) rotate(6deg); } 45% { transform: translate(-5px, 0) rotate(-8deg); } 60% { transform: translate(5px, -3px) rotate(8deg); } 80% { transform: translate(-2px, 0) rotate(-3deg); } }
@keyframes lid-off { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(14px, -26px) rotate(28deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .box-tile:not(.empty) .box-svg, .box-open .box-pic .box-svg, .box-open .box-lid, .box-open.opened .box-reward { animation: none; }
  .box-open.opened .box-lid { opacity: 0; }
}

/* records */
.runs { display: flex; flex-direction: column; gap: 4px; font-variant-numeric: tabular-nums; }
.runs .run { display: grid; grid-template-columns: 26px 1fr 1fr 1fr; gap: 6px; background: var(--card); border-radius: 9px; padding: 6px 10px; font-size: 14px; }
.runs .run b { color: var(--accent); }
.runs .run small { color: var(--muted); }
.stat-list { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; font-size: 14px; }
.stat-list dt { color: var(--muted); }
.stat-list dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* continue and results */
.timer { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.timer i { display: block; height: 100%; background: var(--key); }
.news { display: flex; flex-direction: column; gap: 4px; }
.news:empty { display: none; }
.news div { background: var(--card); border-radius: 9px; padding: 6px 10px; font-size: 14px; font-weight: 600; }
.mini-missions.left { background: var(--card); border-radius: 12px; padding: 8px 10px; }
.mini-missions:empty { display: none; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: max(12px, var(--safe-top)) max(14px, var(--safe-right)) max(16px, var(--safe-bottom)) max(12px, var(--safe-left));
  pointer-events: none; color: var(--hud-fg); text-shadow: 0 2px 6px var(--hud-shadow);
}
.icon-btn {
  pointer-events: auto; position: absolute; left: 0; top: 0;
  width: 48px; height: 48px; border-radius: 14px; border: 0; background: rgba(0, 0, 0, 0.35); color: #fff; cursor: pointer; display: grid; place-items: center;
}
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn:hover { background: rgba(0, 0, 0, 0.5); }
.hud-right { position: absolute; right: 0; top: 0; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.hud-scoreline { display: flex; align-items: center; gap: 8px; }
.hud-score { font-size: clamp(26px, 6vw, 38px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.hud-mult { background: var(--accent); color: var(--accent-fg); text-shadow: none; font-weight: 800; border-radius: 8px; padding: 2px 7px; font-size: 15px; }
.hud-mult.x2 { background: var(--coin); color: #5a1200; animation: pulse 0.8s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
.hud-coins { display: flex; align-items: center; gap: 6px; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud-dist { font-size: 14px; font-weight: 600; opacity: 0.9; font-variant-numeric: tabular-nums; }
.coin-dot { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2a8, var(--coin) 55%, #c98b00); box-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.hud-powers { position: absolute; left: 0; top: 58px; display: flex; flex-direction: column; gap: 6px; }
.chip { display: flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, 0.38); border-radius: 10px; padding: 4px 8px 4px 4px; text-shadow: none; }
.chip svg { width: 22px; height: 22px; }
.chip .bar { width: 64px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.chip .bar i { display: block; height: 100%; background: #fff; }
.chip.low .bar i { background: #ff7a5a; }
.hud-combo { position: absolute; left: 50%; top: 2px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 3px; opacity: 0; transition: opacity 0.2s; }
.hud-combo.show { opacity: 1; }
.hud-combo b { font-size: 22px; font-weight: 900; color: #ffe14f; }
.hud-combo .bar { width: 90px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.hud-combo .bar i { display: block; height: 100%; background: #ffe14f; }
.hud-trick { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); font-size: 20px; font-weight: 800; color: #ffffff; opacity: 0; white-space: nowrap; }
.hud-trick.go { animation: trick 0.9s ease-out; }
@keyframes trick { 0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -18px) scale(1); } }
.hud-banner { position: absolute; left: 50%; top: 15%; transform: translateX(-50%); font-size: clamp(20px, 5vw, 30px); font-weight: 900; letter-spacing: 1px; opacity: 0; white-space: nowrap; text-transform: uppercase; }
.hud-banner.go { animation: banner 2.4s ease-out; }
@keyframes banner { 0% { opacity: 0; letter-spacing: 12px; } 15% { opacity: 1; letter-spacing: 2px; } 75% { opacity: 1; } 100% { opacity: 0; } }
.board-btn {
  pointer-events: auto; position: absolute; right: 0; bottom: 0;
  min-width: 64px; height: 52px; border-radius: 16px; border: 0; background: rgba(0, 0, 0, 0.38); color: #fff; cursor: pointer;
  display: flex; align-items: center; gap: 6px; padding: 0 10px; font: inherit; font-weight: 800; font-size: 18px;
}
.board-btn svg { width: 30px; height: 30px; }
.board-btn:disabled { opacity: 0.45; cursor: default; }
.board-btn:hover:not(:disabled) { background: rgba(0, 0, 0, 0.55); }
.rio-skill {
  position: absolute; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 11px; border: 1px solid #ffe580; border-radius: 14px;
  color: #fff7df; background: #15594f; text-shadow: none; font-size: 14px; font-weight: 800;
}
.rio-skill[hidden] { display: none; }
.rio-skill[data-kind="bicycle"] { background: #3c4875; }
.rio-skill[data-kind="glider"] { background: #923822; }
.rio-skill svg { display: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rio-skill[data-kind="scooter"] [data-icon="scooter"],
.rio-skill[data-kind="bicycle"] [data-icon="bicycle"],
.rio-skill[data-kind="glider"] [data-icon="glider"] { display: block; }
.rio-skill b { color: #ffe580; }
#hud-rio-time { min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }
.rio-ladder {
  position: absolute; bottom: clamp(52px, 12dvh, 94px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: min(430px, calc(100% - 32px)); padding: 10px 14px;
  background: #103e38ed; border: 1px solid #85e8c9; border-radius: 13px; color: #f6fffc;
  font-size: clamp(14px, 3.6vw, 17px); font-weight: 800; text-shadow: none; text-align: center;
}
.rio-ladder-progress { display: flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; }
.rio-ladder[data-phase="glide"] { bottom: 0; }
.rio-ladder-coach { display: flex; align-items: center; justify-content: center; gap: 10px; }
.rio-ladder-cues { min-width: 0; }
.rio-ladder-guide:not([hidden]) + .rio-ladder-cues { text-align: left; }
.rio-ladder-technique { color: #c1f7e8; font-size: 12px; font-weight: 600; line-height: 1.35; margin-top: 3px; }
.rio-ladder-guide {
  display: flex; flex: none; align-items: center; padding: 0 3px;
  border: 1px solid #55a393; border-radius: 8px; background: #0b322e;
  --ladder-hop-beat: .36s;
  --ladder-hop-cycle: calc(2 * var(--ladder-hop-beat));
}
.rio-ladder-figure { width: 51px; height: 56px; position: relative; }
.rio-ladder-figure::after {
  content: ""; position: absolute; bottom: 3px; left: 6px; right: 6px; height: 1px; background: #55a393;
}
.rio-ladder-figure-alt { display: none; }
.rio-ladder-actor {
  position: absolute; inset: 0;
  animation: rio-hop-body var(--ladder-hop-beat) infinite;
}
.rio-ladder-body {
  position: absolute; left: 21px; top: 16px; width: 9px; height: 15px;
  border-radius: 5px 6px 3px 4px; background: #d2f4eb; transform: rotate(3deg);
}
.rio-ladder-body::before {
  content: ""; position: absolute; top: -12px; left: 0; width: 9px; height: 10px;
  border-radius: 55% 45% 43% 57%; background: inherit; box-shadow: 3px 1px 0 -2px #d2f4eb;
}
.rio-ladder-body::after {
  content: ""; position: absolute; top: 1px; left: 0; width: 4px; height: 15px;
  border-radius: 3px; transform: rotate(15deg); background: #adc8c0;
}
.rio-ladder-leg, .rio-ladder-leg span {
  position: absolute; width: 4px; height: 12px; border-radius: 3px;
  background: currentColor; transform-origin: 50% 1px;
}
.rio-ladder-leg {
  top: 29px; color: #a1c8bf;
  animation: rio-hop-thigh var(--ladder-hop-cycle) infinite cubic-bezier(.3, 0, .3, 1);
  animation-delay: var(--hop-offset);
}
.rio-ladder-leg-left { left: 22px; --hop-offset: 0s; }
.rio-ladder-leg-right { left: 26px; --hop-offset: calc(-1 * var(--ladder-hop-beat)); }
.rio-ladder-leg span {
  left: 0; top: 10px;
  animation: rio-hop-calf var(--ladder-hop-cycle) infinite cubic-bezier(.3, 0, .3, 1);
  animation-delay: var(--hop-offset);
}
.rio-ladder-leg span::after {
  content: ""; position: absolute; bottom: -1px; left: 0; width: 8px; height: 3px;
  border-radius: 2px; background: currentColor;
}
@keyframes rio-hop-body {
  0%, 14%, 92%, 100% { transform: translateY(0); }
  14% { animation-timing-function: cubic-bezier(.16, .7, .36, 1); }
  50% { transform: translateY(-4px); animation-timing-function: cubic-bezier(.52, 0, .83, .63); }
}
@keyframes rio-hop-thigh {
  0%, 44%, 100% { transform: rotate(0); color: #a1c8bf; }
  21%, 26% { transform: rotate(-46deg); color: #86f6cf; }
}
@keyframes rio-hop-calf {
  0%, 45%, 100% { transform: rotate(0); }
  22%, 28% { transform: rotate(56deg); }
}
@media (prefers-reduced-motion: reduce) {
  .rio-ladder-actor, .rio-ladder-leg, .rio-ladder-leg span { animation: none; }
  .rio-ladder-actor { transform: translateY(-4px); }
  .rio-ladder-figure-alt { display: block; }
  .rio-ladder-figure:not(.rio-ladder-figure-alt) .rio-ladder-leg-left,
  .rio-ladder-figure-alt .rio-ladder-leg-right { transform: rotate(-46deg); color: #86f6cf; }
  .rio-ladder-figure:not(.rio-ladder-figure-alt) .rio-ladder-leg-left span,
  .rio-ladder-figure-alt .rio-ladder-leg-right span { transform: rotate(56deg); }
}
@media (orientation: landscape) and (max-height: 500px) {
  .rio-ladder[data-phase="climb"] {
    left: 0; bottom: max(61px, 17dvh); transform: none;
    max-width: min(305px, 43%);
  }
}
.rio-ladder-progress progress { flex: 1; height: 14px; accent-color: #85e8c9; }
.rio-ladder[data-motion="down"] .rio-ladder-progress progress { accent-color: #ffc26b; }
.rio-ladder-progress span { font-size: 13px; }
.rio-ladder-step {
  width: max-content; max-width: 100%; margin: 1px auto 0; padding: 2px 7px; border-radius: 5px;
  color: #c1f7e8; font-size: 12px;
}
.rio-ladder-step:is([data-side="left"], [data-side="right"]) { background: #9aefcd; color: #103e38; }
.rio-ladder-cross { display: none; }
.rio-ladder:is([data-phase="climb"], [data-phase="return"]) .rio-ladder-cross {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 6px; padding-top: 6px; border-top: 1px solid #55a393;
  color: #c1f7e8; font-size: 12px; font-weight: 600; line-height: 1.35; text-align: left;
}
.rio-ladder-cross progress { flex: none; width: clamp(60px, 9vw, 92px); height: 12px; accent-color: #ffe580; }
.rio-ladder[data-phase="return"] .rio-ladder-cross { justify-content: center; }
.rio-ladder[data-phase="return"] .rio-ladder-cross-hint { display: none; }
.rio-ladder button {
  margin-top: 6px; padding: 5px 10px; min-height: 36px; font: inherit; font-size: 13px;
  border: 1px solid #85e8c9; border-radius: 8px; background: #1d5047; color: inherit;
  pointer-events: auto; cursor: pointer;
}
#hud-rio-ladder [hidden], .rio-ladder[hidden] { display: none; }
.rio-open-arms {
  position: absolute; top: 4px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 5px; padding: 5px 10px;
  border: 1px solid #ffe580; border-radius: 12px; background: #20333b;
  color: #ffe580; text-shadow: none; font-size: 15px; font-weight: 800;
}
.rio-open-arms[hidden] { display: none; }
.rio-open-arms svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
#hud-combo.show ~ .rio-open-arms { top: 40px; }
@media (orientation: portrait) {
  .rio-open-arms { top: 40px; }
}
.hud-hint {
  position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 154px); text-align: center; font-size: 15px; font-weight: 600;
  background: rgba(0, 0, 0, 0.42); border-radius: 12px; padding: 8px 14px; opacity: 0; transition: opacity 0.4s; text-shadow: none;
}
.hud-hint.show { opacity: 1; }
@media (orientation: landscape) {
  #hud-hint[data-flight] {
    top: 58px; bottom: auto; left: 0; transform: none;
    max-width: min(270px, 31vw); padding: 7px 10px; text-align: left;
  }
}
.hud-tut {
  position: absolute; left: 50%; top: 58%; transform: translateX(-50%); width: max-content; max-width: 100%;
  text-align: center; font-size: clamp(17px, 4.2vw, 24px); font-weight: 800; background: rgba(20, 24, 40, 0.72); border: 2px solid var(--coin);
  border-radius: 14px; padding: 10px 16px; opacity: 0; transition: opacity 0.25s; text-shadow: none;
}
.hud-tut.show { opacity: 1; }
.hud-count { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(70px, 18vw, 140px); font-weight: 900; }
.hud-count:empty { display: none; }
.hud-toast {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-size: 21px; font-weight: 800; text-align: center;
  opacity: 0; transition: opacity 0.3s; max-width: calc(100% - 24px); background: rgba(0, 0, 0, 0.35); border-radius: 12px; padding: 6px 14px;
}
.hud-toast.show { opacity: 1; }
.hud-fps { position: absolute; left: max(8px, var(--safe-left)); bottom: max(6px, var(--safe-bottom)); font: 12px/1 ui-monospace, Consolas, monospace; color: #fff; background: rgba(0,0,0,0.45); padding: 3px 6px; border-radius: 6px; pointer-events: none; }
#motion-panel { z-index: 6; }
#motion-panel .panel { width: min(500px, 100%); }
#motion-panel .motion-intro, #motion-panel .motion-feedback { display: flex; flex-direction: column; gap: 8px; }
#motion-panel .motion-intro h2 { font-size: clamp(20px, 4vw, 26px); }
#motion-panel .motion-guide, #motion-panel .motion-prompt { margin: 0; font-size: 14px; line-height: 1.4; }
#motion-panel .motion-guide { color: var(--muted); }
#motion-panel .motion-prompt { font-weight: 600; }
#motion-panel .motion-video { position: relative; overflow: hidden; border-radius: 9px; background: #151515; }
#motion-panel video { display: block; width: 100%; max-height: 48dvh; object-fit: contain; }
#motion-panel :is(video, .motion-video canvas) { transform: scaleX(-1); }
#motion-panel .motion-video canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#motion-panel progress { width: 100%; accent-color: var(--accent); }
#motion-panel[data-mode="preview"] {
  inset: auto auto max(14px, var(--safe-bottom)) max(14px, var(--safe-left));
  padding: 0; background: none; pointer-events: none;
}
#motion-panel[data-mode="preview"] .panel { width: clamp(64px, 19vw, 112px); padding: 0; border-radius: 9px; overflow: hidden; }
#motion-panel[data-mode="preview"] video { max-height: 16dvh; }
#motion-panel[data-mode="preview"] :is(.motion-intro, .motion-feedback) { display: none; }
@media (orientation: landscape) and (min-width: 560px) and (max-height: 520px) {
  #motion-panel[data-mode="calibrating"] .panel:has(.motion-video:not([hidden])) {
    display: grid; align-items: center; width: min(780px, 100%); column-gap: 16px;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-areas: "video intro" "video feedback";
  }
  #motion-panel[data-mode="calibrating"] .motion-video { grid-area: video; }
  #motion-panel[data-mode="calibrating"] .motion-intro { grid-area: intro; }
  #motion-panel[data-mode="calibrating"] .motion-feedback { grid-area: feedback; }
  #motion-panel[data-mode="calibrating"] video { max-height: 68dvh; }
}
.fatal { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--bg); color: var(--fg); text-align: center; font-size: 18px; }

@media (max-width: 380px) {
  .panel { padding: 16px 12px 12px; }
  .panel.wide { padding-bottom: 0; }
  .sticky-bottom { margin: 4px -12px 0; padding: 10px 12px 12px; }
  .keys { grid-template-columns: minmax(64px, 1fr) repeat(3, minmax(0, 1fr)); }
  .btn { font-size: 15px; }
  .shop-list, .ach-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ach { grid-template-columns: 38px 1fr; gap: 6px; padding: 8px 6px 8px 8px; }
  .ach svg { width: 38px; height: 38px; }
}
@media (max-width: 340px) {
  .ach-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .hud-hint { max-width: 100%; font-size: 13px; bottom: 62px; }
  .screen.side { align-items: flex-start; justify-content: center; background: linear-gradient(180deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0) 70%); }
  .side .panel.wide { max-height: 64%; }
  .tabs button { font-size: 13px; padding: 6px 3px; }
}
@media (max-width: 640px), (pointer: coarse) {
  .menu-panel {
    --panel: var(--light-panel);
    --panel-solid: var(--light-panel-solid);
    --fg: #1d2433;
    --muted: #5b6577;
    --line: rgba(29, 36, 51, 0.14);
    --accent: #00756b;
    --accent-fg: #ffffff;
    --btn: #eef2f7;
    --btn-hover: #e1e8f1;
    --btn-fg: var(--fg);
    --card: #f4f7fb;
    color: var(--fg);
    color-scheme: light;
  }
}
@media (max-height: 520px) {
  .panel { gap: 7px; padding-top: 12px; }
  .sub, .footer { display: none; }
  .btn.big { min-height: 44px; font-size: 18px; }
  .side .panel.wide { max-height: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .record, .hud-mult.x2 { animation: none; }
}

/* Copacabana route menu and results. */
#m-copacabana { display: block; width: 100%; text-align: center; text-decoration: none; }
html[data-scene="copacabana"] {
  --light-panel: rgba(255, 242, 215, .97);
  --light-panel-solid: var(--brand-cream);
}
html[data-scene="copacabana"] .menu-panel > :not(
  h1, .sub, [data-tv-rotate], #m-play, #m-copa-runner, #m-motion, #m-rio-checkpoint-difficulty,
  #m-rio-new, #m-rio-new-motion, #m-ad-fixture, #m-settings-row, .legal-links
),
html[data-scene="copacabana"] #m-records,
html[data-scene="copacabana"] #p-missions,
html[data-scene="copacabana"] #btn-board {
  display: none;
}
.ad-fixture:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--fg);
  font-size: 13px;
}
.ad-fixture select {
  padding: 6px 8px;
  border: 1px solid var(--muted);
  border-radius: 6px;
  background: var(--panel-solid);
  color: inherit;
  font: inherit;
}
html[data-scene="copacabana"] #scr-copa-result .panel {
  border-top: 4px solid var(--brand-wave);
}
#m-copa-runner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: .65rem;
  color: var(--fg);
  text-align: left;
}
#copa-runner {
  min-height: 44px;
  width: 100%;
  padding: .45rem .6rem;
  border: 1px solid #7a9386;
  border-radius: .55rem;
  background: var(--panel-solid);
  color: var(--fg);
  font: inherit;
}
html[data-scene="copacabana"] .hud-coins .coin-dot {
  border-radius: 0;
  clip-path: polygon(37% 100%, 5% 56%, 0 39%, 9% 25%, 20% 22%, 25% 11%, 39% 9%, 49% 0, 63% 8%, 75% 9%, 83% 21%, 94% 25%, 100% 42%, 91% 59%, 62% 100%);
  background: repeating-conic-gradient(from -62deg at 50% 92%, #ffe090 0 8deg, #e9931a 8deg 12deg);
}

/* The proposal runs this countdown over the live Rio course. */
.hud-count[data-launch] { pointer-events: none; z-index: 2; }
.hud-count[data-launch] > span {
  color: #ffc653;
  font-size: clamp(5rem, 24vmin, 13rem);
  font-weight: 950;
  line-height: 1;
  letter-spacing: -.045em;
  paint-order: stroke fill;
  -webkit-text-stroke: .065em #102e3a;
  text-shadow: 0 .065em #102e3a, 0 .08em .18em #091c25b0;
  animation: launch-beat 230ms cubic-bezier(.16, 1, .3, 1) both;
}
.hud-count[data-launch="go"] > span { color: #ffde83; }
@keyframes launch-beat {
  from { transform: translateY(.09em) scale(.88); opacity: .5; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .hud-count[data-launch] > span { animation: none; }
}
