/* Pip's Flight: the game box (#pf) and everything drawn over the 3D view. */
.pf {
  --ink: #1c2a4a; --ink2: #50608a; --blue: #38a8ff; --blue2: #2563d9; --coral: #ff7a45; --coral2: #e2502a; --gold: #ffc531;
  --card: rgba(255, 255, 255, 0.93); --line: rgba(28, 42, 74, 0.1);
  position: relative; width: 100%; height: 100%; overflow: hidden; user-select: none; -webkit-user-select: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; background: #87c6ff;
  font-family: 'Fredoka', 'Nunito', 'Segoe UI', system-ui, sans-serif; color: var(--ink); contain: layout paint; container-type: size;
}
.pf.pf-flying { touch-action: none; cursor: pointer; }
.pf-canvas { position: absolute; inset: 0; display: block; z-index: 0; }
.pf button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pf svg { width: 1em; height: 1em; fill: currentColor; display: block; }

/* ---------------------------------------------------------------- loading */
.pf-loading { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(120% 90% at 50% 10%, #bfe3ff 0%, #6fb7ff 55%, #3d8fe8 100%); transition: opacity .6s; color: #fff; }
.pf-loading.out { opacity: 0; pointer-events: none; }
.pf-loading p { margin: 0; font-weight: 600; font-size: 15px; opacity: .9; max-width: 80%; text-align: center; }
.pf-loadbar { width: 160px; height: 8px; border-radius: 6px; background: rgba(255, 255, 255, .35); overflow: hidden; }
.pf-loadbar i { display: block; height: 100%; width: 40%; border-radius: 6px; background: #fff; animation: pfLoad 1.1s ease-in-out infinite; }
@keyframes pfLoad { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* ---------------------------------------------------------------- the logo */
.pf-logo { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: .18em; font-family: 'Fredoka', 'Fredoka One', sans-serif; font-weight: 700;
  font-size: clamp(38px, 12cqw, 86px); line-height: .95; letter-spacing: .01em; transform: rotate(-3deg); }
.pf-logo span { color: #fff; -webkit-text-stroke: .085em var(--blue2); paint-order: stroke fill; text-shadow: 0 .09em 0 #173f99, 0 .16em .25em rgba(10, 30, 80, .35); }
.pf-logo .b { color: #ffd84a; -webkit-text-stroke-color: #d9531f; text-shadow: 0 .09em 0 #a83a12, 0 .16em .25em rgba(80, 20, 0, .35); }
.pf-logo.small { font-size: 46px; }

/* ---------------------------------------------------------------- round corner buttons */
.pf-round { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; color: var(--ink) !important;
  background: rgba(255, 255, 255, .88) !important; box-shadow: 0 3px 0 rgba(28, 42, 74, .18), 0 6px 16px rgba(10, 30, 80, .18); transition: transform .12s; }
.pf-round:hover { transform: translateY(-1px) scale(1.04); }
.pf-round:active { transform: translateY(1px) scale(.96); }
.pf-round.off { color: #9aa6c4 !important; }
.pf-corner { position: absolute; right: 12px; top: 12px; z-index: 12; display: none; gap: 8px; }
.pf-corner.on { display: flex; }

/* ---------------------------------------------------------------- HUD */
.pf-hud { position: absolute; left: 0; right: 0; top: 0; z-index: 8; display: none; align-items: flex-start; gap: 12px; padding: 12px 14px; pointer-events: none; }
.pf-hud.on { display: flex; }
.pf-hud > * { pointer-events: auto; }
.pf-prog { flex: 1; max-width: 520px; margin: 4px auto 0; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none !important; }
.pf-track { position: relative; width: 100%; height: 12px; border-radius: 8px; background: rgba(255, 255, 255, .55); box-shadow: inset 0 2px 3px rgba(10, 30, 80, .18), 0 2px 0 rgba(255, 255, 255, .4); }
.pf-track .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 8px; background: linear-gradient(90deg, #6fd0ff, var(--blue)); }
.pf-track .dot { position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: var(--blue);
  border: 3px solid #fff; box-shadow: 0 2px 6px rgba(10, 30, 80, .35); }
.pf-track .dot::after { content: ''; position: absolute; right: -6px; top: 5px; border: 4px solid transparent; border-left: 6px solid var(--coral); }
.pf-track .cp { position: absolute; top: -5px; width: 4px; height: 22px; margin-left: -2px; border-radius: 2px; background: rgba(255, 255, 255, .9); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.pf-track .cp.on { background: var(--gold); }
.pf-track::after { content: '🏁'; position: absolute; right: -6px; top: -9px; font-size: 22px; }
.pf-prog .count { font-weight: 700; font-size: 15px; color: #fff; text-shadow: 0 2px 0 rgba(10, 30, 80, .45); }
.pf-score { display: none; position: absolute; left: 50%; top: 10px; transform: translateX(-50%); font-weight: 700; font-size: clamp(40px, 8cqw, 64px); color: #fff;
  -webkit-text-stroke: 6px #173f99; paint-order: stroke fill; text-shadow: 0 4px 0 #173f99; pointer-events: none !important; }
.pf-score.pop { animation: pfPop .22s ease-out; }
@keyframes pfPop { 0% { transform: translateX(-50%) scale(1.25); } 100% { transform: translateX(-50%) scale(1); } }
.pf-hud.endless .pf-score { display: block; }
.pf-hud.endless .pf-prog { visibility: hidden; }
.pf-feathers { display: flex; gap: 4px; align-items: center; padding: 6px 10px; border-radius: 20px; background: rgba(255, 255, 255, .55); box-shadow: inset 0 2px 3px rgba(10, 30, 80, .12); pointer-events: none !important; }
.pf-feathers .fe { font-size: 22px; color: rgba(28, 42, 74, .25); transition: transform .3s, color .3s; }
.pf-feathers .fe.got { color: var(--gold); filter: drop-shadow(0 1px 0 #b86d00); transform: scale(1.15); }
.pf-feathers b { font-weight: 700; font-size: 18px; color: var(--ink); margin-left: 2px; }
.pf-best { display: none; position: absolute; right: 14px; top: 58px; font-weight: 600; font-size: 14px; color: #fff; text-shadow: 0 2px 0 rgba(10, 30, 80, .45); }
.pf-hud.endless .pf-best { display: block; }

/* ---------------------------------------------------------------- ready hint and toasts */
.pf-hint { position: absolute; left: 0; right: 0; top: 22%; z-index: 7; display: none; flex-direction: column; align-items: center; gap: 14px; pointer-events: none; }
.pf-hint.on { display: flex; }
.pf-banner { padding: 8px 18px; border-radius: 22px; background: rgba(255, 255, 255, .9); font-weight: 600; font-size: 18px; box-shadow: 0 4px 0 rgba(28, 42, 74, .15); }
.pf-banner b { color: var(--blue2); }
.pf-banner .cp { color: var(--coral2); font-weight: 600; }
.pf-tap { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; color: #fff; text-shadow: 0 2px 0 rgba(10, 30, 80, .5); margin-top: 18cqh; }
.pf[data-tall] .pf-tap { margin-top: 26cqh; }
.pf-tap .hand { font-size: 34px; animation: pfTap 1s ease-in-out infinite; }
@keyframes pfTap { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px) scale(.92); } }
.pf-toast { position: absolute; left: 50%; top: 70px; transform: translate(-50%, -10px); z-index: 9; display: flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 22px;
  background: rgba(255, 255, 255, .94); font-weight: 700; font-size: 18px; box-shadow: 0 4px 0 rgba(28, 42, 74, .15); opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; }
.pf-toast.on { opacity: 1; transform: translate(-50%, 0); }
.pf-toast.flag .ic { color: var(--coral); font-size: 20px; }
.pf-toast.world { font-size: 24px; padding: 12px 26px; top: 26%; color: var(--blue2); }

/* ---------------------------------------------------------------- screens */
.pf-screen { position: absolute; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center; padding: 64px 16px 16px; overflow-y: auto; }
.pf-screen.on { display: flex; animation: pfFade .25s ease-out; }
.pf-screen.dim { background: rgba(14, 24, 52, .32); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.pf-screen.dim.soft { background: rgba(14, 24, 52, .22); backdrop-filter: none; -webkit-backdrop-filter: none; }
.pf-screen.title { background: linear-gradient(180deg, rgba(20, 40, 90, .18) 0%, rgba(20, 40, 90, 0) 35%, rgba(20, 40, 90, 0) 60%, rgba(20, 40, 90, .25) 100%); }
.pf-screen.map { background: rgba(14, 24, 52, .25); }
@keyframes pfFade { from { opacity: 0; } to { opacity: 1; } }

.pf-title { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; margin-top: -4%; }
.pf-sub { margin: 4px 0 6px; font-weight: 600; font-size: clamp(14px, 3.4cqw, 19px); color: #fff; text-shadow: 0 2px 0 rgba(10, 30, 80, .45); }
.pf-title-btns { display: flex; flex-direction: column; gap: 12px; width: min(320px, 82cqw); }
.pf-stars-total { margin: 4px 0 0; display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; color: #fff; text-shadow: 0 2px 0 rgba(10, 30, 80, .45); }
.pf-stars-total .fe, .pf-line .fe { color: var(--gold); font-size: 18px; display: inline-block; vertical-align: -3px; }

.pf-btn { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 10px 22px; border-radius: 16px;
  font-weight: 700 !important; font-size: 18px; color: var(--blue2) !important; background: #fff !important;
  box-shadow: 0 4px 0 #b9c7e6, 0 8px 18px rgba(10, 30, 80, .18); transition: transform .1s, box-shadow .1s; }
.pf-btn:hover { transform: translateY(-1px); }
.pf-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b9c7e6, 0 3px 8px rgba(10, 30, 80, .18); }
.pf-btn:focus-visible { outline: 3px solid #ffd84a; outline-offset: 3px; }
.pf-btn .ic { font-size: 22px; }
.pf-btn.big { min-height: 58px; font-size: 22px; border-radius: 20px; }
.pf-btn.primary { color: #fff !important; background: linear-gradient(180deg, #ff9a5c, var(--coral)) !important; box-shadow: 0 5px 0 var(--coral2), 0 10px 22px rgba(200, 70, 20, .3); text-shadow: 0 2px 0 rgba(160, 50, 10, .35); }
.pf-btn.primary:active { box-shadow: 0 2px 0 var(--coral2), 0 4px 10px rgba(200, 70, 20, .3); }
.pf-btn.danger { color: #d23b3b !important; box-shadow: 0 4px 0 #f0c4c4, 0 8px 18px rgba(10, 30, 80, .12); }
.pf-btn.small { min-height: 40px; font-size: 15px; }
.pf-btn.icon { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
.pf-btn.ghost { background: rgba(255, 255, 255, .85) !important; }

.pf-card { width: min(380px, 100%); padding: 22px 22px 18px; border-radius: 26px; background: var(--card); box-shadow: 0 8px 0 rgba(28, 42, 74, .12), 0 24px 60px rgba(10, 30, 80, .3);
  text-align: center; animation: pfPopIn .3s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pfPopIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.pf-card h2 { margin: 0 0 6px; font-weight: 700; font-size: 32px; color: var(--blue2); }
.pf-card.fail h2 { color: var(--coral2); }
.pf-line { margin: 4px 0 10px; font-weight: 600; font-size: 17px; color: var(--ink2); }
.pf-line.small { font-size: 15px; margin-top: -4px; }
.pf-line.good { color: #2f9a3a; }
.pf-big { font-weight: 700; font-size: 64px; line-height: 1; color: var(--ink); margin: 6px 0; }
.pf-tip { margin: 12px 0 0; font-size: 13px; color: var(--ink2); opacity: .8; }
.pf-col { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.pf-meter { position: relative; height: 12px; margin: 6px 6px 4px; border-radius: 8px; background: #e3e9f6; overflow: visible; }
.pf-meter i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 8px; background: linear-gradient(90deg, #6fd0ff, var(--blue)); }
.pf-meter b { position: absolute; top: -4px; width: 4px; height: 20px; margin-left: -2px; border-radius: 2px; background: #b9c7e6; }
.pf-meter b.on { background: var(--gold); }
.pf-stars { display: flex; justify-content: center; gap: 14px; margin: 10px 0 8px; }
.pf-stars i { font-size: 54px; color: #dfe5f2; display: block; }
.pf-stars i.got { color: var(--gold); filter: drop-shadow(0 3px 0 #c27a00); animation: pfStar .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pfStar { from { transform: scale(0) rotate(-40deg); } to { transform: scale(1) rotate(0); } }
.pf-ribbon { margin: 8px -6px 0; padding: 8px 12px; border-radius: 14px; background: linear-gradient(90deg, #ffe58a, #ffd04a); color: #7a4a00; font-weight: 700; font-size: 16px; }

/* settings */
.pf-sets { display: flex; flex-direction: column; gap: 4px; margin: 10px 0 0; text-align: left; }
.pf-sets.compact { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); }
.pf-set { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 4px; font-weight: 600; font-size: 16px; color: var(--ink); }
.pf-set input[type=range] { width: 52%; accent-color: var(--blue); }
.pf-toggle { position: relative; width: 52px; height: 30px; border-radius: 16px; background: #cfd8ea !important; transition: background .2s; flex: none; }
.pf-toggle i { position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.pf-toggle.on { background: var(--blue) !important; }
.pf-toggle.on i { transform: translateX(22px); }

/* ---------------------------------------------------------------- the level map */
.pf-map { width: min(760px, 100%); padding: 16px 16px 18px; border-radius: 26px; background: var(--card); box-shadow: 0 8px 0 rgba(28, 42, 74, .12), 0 24px 60px rgba(10, 30, 80, .3); animation: pfPopIn .3s cubic-bezier(.2, 1.4, .4, 1); }
.pf-map-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.pf-map-head h2 { margin: 0; font-weight: 700; font-size: 26px; color: var(--blue2); }
.pf-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pf-tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px 8px; border-radius: 16px; color: #fff !important;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .18); transition: transform .12s; min-width: 0; }
.pf-tab.w0 { background: linear-gradient(180deg, #8cd3ff, #4fb04a) !important; }
.pf-tab.w1 { background: linear-gradient(180deg, #ff9f7a, #8a4fa0) !important; }
.pf-tab.w2 { background: linear-gradient(180deg, #4a3d8f, #1f1a45) !important; }
.pf-tab.w3 { background: linear-gradient(180deg, #2c3f86, #0d1433) !important; }
.pf-tab.on { transform: translateY(-3px); outline: 3px solid #ffd84a; outline-offset: 2px; }
.pf-tab.locked { filter: grayscale(.75) brightness(.85); }
.pf-tab .em { font-size: 26px; line-height: 1.1; height: 30px; }
.pf-tab .lk { font-size: 24px; height: 30px; display: grid; place-items: center; }
.pf-tab .nm { font-weight: 700; font-size: 14px; text-shadow: 0 1px 0 rgba(0, 0, 0, .3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pf-tab .st { display: flex; align-items: center; gap: 3px; font-weight: 600; font-size: 13px; opacity: .95; }
.pf-tab .st i { color: var(--gold); font-size: 14px; }
.pf-world { margin-top: 14px; padding: 14px; border-radius: 20px; background: #eef4ff; }
.pf-world-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; margin: 0 4px 12px; }
.pf-world-name b { font-weight: 700; font-size: 22px; color: var(--ink); }
.pf-world-name span { font-weight: 500; font-size: 15px; color: var(--ink2); }
.pf-levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.pf-level { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px 10px; border-radius: 18px; background: #fff !important;
  box-shadow: 0 4px 0 #c8d4ee; transition: transform .1s; min-width: 0; }
.pf-level:hover { transform: translateY(-2px); }
.pf-level:active { transform: translateY(2px); box-shadow: 0 1px 0 #c8d4ee; }
.pf-level:focus-visible { outline: 3px solid #ffd84a; outline-offset: 2px; }
.pf-level .num { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 24px; color: #fff;
  background: linear-gradient(180deg, #ff9a5c, var(--coral)); box-shadow: 0 3px 0 var(--coral2); }
.pf-level.done .num { background: linear-gradient(180deg, #6fd0ff, var(--blue)); box-shadow: 0 3px 0 var(--blue2); }
.pf-level.locked .num { background: #cfd8ea; box-shadow: 0 3px 0 #aab6d0; color: #7a88aa; font-size: 20px; }
.pf-level .nm { font-weight: 600; font-size: 13px; line-height: 1.15; color: var(--ink); text-align: center; min-height: 2.3em; display: flex; align-items: center; }
.pf-level.locked .nm { color: #8a96b4; }
.pf-level .fs { display: flex; gap: 2px; }
.pf-level .fs i { font-size: 16px; color: #dbe2f0; }
.pf-level .fs i.got { color: var(--gold); }
.pf-level.nope, .pf-tab.nope { animation: pfNope .35s; }
@keyframes pfNope { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* ---------------------------------------------------------------- small and tall boxes */
.pf[data-small] .pf-round { width: 40px; height: 40px; font-size: 20px; }
.pf[data-small] .pf-card { padding: 16px 16px 14px; border-radius: 22px; }
.pf[data-small] .pf-card h2 { font-size: 26px; }
.pf[data-small] .pf-btn { min-height: 44px; font-size: 17px; }
.pf[data-small] .pf-btn.big { min-height: 52px; font-size: 19px; }
.pf[data-small] .pf-col { gap: 8px; margin-top: 10px; }
.pf[data-small] .pf-big { font-size: 52px; }
.pf[data-small] .pf-stars i { font-size: 44px; }
.pf[data-small] .pf-screen { padding-top: 56px; }
.pf[data-tall] .pf-levels { grid-template-columns: 1fr; gap: 8px; }
.pf[data-tall] .pf-level { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 8px 12px; }
.pf[data-tall] .pf-level .num { width: 38px; height: 38px; font-size: 20px; flex: none; }
.pf[data-tall] .pf-level .nm { flex: 1; text-align: left; min-height: 0; font-size: 15px; }
.pf[data-tall] .pf-tab .nm { font-size: 11px; }
.pf[data-tall] .pf-tab .st { font-size: 11px; }
.pf[data-tall] .pf-map { padding: 12px; }
.pf[data-tall] .pf-world { padding: 10px; }
.pf[data-tall] .pf-world-name span { display: none; }
.pf[data-tall] .pf-feathers .fe { font-size: 18px; }
.pf[data-tall] .pf-prog .count { font-size: 13px; }
@container (max-height: 460px) {
  .pf-title { gap: 8px; }
  .pf-logo { font-size: 44px; }
  .pf-title-btns { flex-direction: row; width: auto; }
  .pf-sub { margin: 0; }
  .pf-levels { gap: 6px; }
  .pf-level { padding: 8px 4px; }
  .pf-level .num { width: 38px; height: 38px; font-size: 20px; }
  .pf-world-name { margin-bottom: 8px; }
  .pf-map-head { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .pf-tap .hand, .pf-loadbar i { animation: none; }
}
