/* Finger chooser (tool "finger"). Uses the tokens of app.css / wheel.css (.lh-app scope).
   The touch area is a dark "game screen" in both themes; logical properties everywhere, except the finger
   circles, which are placed with physical left/top because they follow the physical pointer coordinates. */

/* ---------- Layout: area column + side column (≥ 1024 px) ---------- */
.lh-fg-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.lh-fg-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.lh-fg-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; min-width: 0; }
@media (min-width: 640px) and (max-width: 1023.98px) { .lh-fg-side { grid-template-columns: 1fr 1fr; align-items: start; } }
@media (min-width: 1024px) { .lh-fg-grid { grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; } }
html:not(.js) .lh-fg-js { display: none !important; }
.lh-fg-nojs { margin: 0; }

/* text for touch screens / mouse screens: CSS guess before JS, then the class set by the controller */
.lh-fg-t--mouse { display: none; }
@media (pointer: fine) { .lh-fg-t--touch { display: none; } .lh-fg-t--mouse { display: revert; } }
.lh-fg.is-touch .lh-fg-t--touch, .lh-fg.is-mouse .lh-fg-t--mouse { display: revert; }
.lh-fg.is-touch .lh-fg-t--mouse, .lh-fg.is-mouse .lh-fg-t--touch { display: none; }

/* ---------- Mode selector (radio group styled as a segmented control) ---------- */
.lh-fg-modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; min-width: 0; margin: 0; padding: 3px; border: 0; border-radius: 14px; background: var(--lh-surface-2); }
.lh-fg-mode { position: relative; display: block; min-width: 0; }
.lh-fg-mode input { position: absolute; inset: 0; z-index: 1; inline-size: 100%; block-size: 100%; margin: 0; opacity: 0; cursor: pointer; }
.lh-fg-mode__in {
  display: flex; align-items: center; justify-content: center; gap: 7px; min-block-size: 44px; padding: 4px 6px; border-radius: 11px;
  color: var(--lh-muted); font-weight: 700; font-size: .875rem; line-height: 1.15; text-align: center; transition: background-color .15s, color .15s;
}
.lh-fg-mode__in .lh-ic { flex: none; inline-size: 18px; block-size: 18px; }
.lh-fg-mode__l { min-width: 0; overflow-wrap: anywhere; }
.lh-fg-mode:hover .lh-fg-mode__in { color: var(--lh-text); }
.lh-fg-mode input:checked + .lh-fg-mode__in { background: var(--lh-surface); color: var(--lh-text); box-shadow: var(--lh-shadow-sm); }
.lh-fg-mode input:checked + .lh-fg-mode__in .lh-ic { color: var(--lh-brand); }
.lh-fg-mode input:focus-visible + .lh-fg-mode__in { outline: 2px solid var(--lh-focus); outline-offset: 1px; }
@media (max-width: 479.98px) { .lh-fg-mode__in { flex-direction: column; gap: 3px; min-block-size: 54px; padding: 4px 1px; font-size: .8125rem; } }
@media (max-width: 359.98px) { .lh-fg-mode__in { font-size: .75rem; letter-spacing: -.01em; } }

/* ---------- Options line: goal or stepper, full screen ---------- */
.lh-fg-opts { display: flex; align-items: center; gap: 12px; min-block-size: 48px; }
.lh-fg-goal { flex: 1; min-width: 0; margin: 0; color: var(--lh-muted); font-size: .9375rem; line-height: 1.35; }
.lh-fg-count { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.lh-fg-count__l { min-width: 0; font-weight: 700; font-size: .9375rem; line-height: 1.2; }
.lh-fg .lh-step__b { inline-size: 44px; block-size: 44px; font-size: 1.25rem; }
.lh-fg .lh-step .lh-num { inline-size: 52px; block-size: 44px; font-size: 1.0625rem; }
.lh-fg-fsbtn { flex: none; margin-inline-start: auto; min-block-size: 44px; }
.lh-fg-fsbtn .lh-ic { inline-size: 18px; block-size: 18px; }
@media (max-width: 479.98px) {
  .lh-fg-fsbtn { inline-size: 44px; min-inline-size: 44px; padding: 0; }
  .lh-fg-fsbtn__l { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- Touch area ---------- */
.lh-fg-pad {
  --d: 104px;
  position: relative; isolation: isolate; overflow: hidden; block-size: clamp(280px, calc(100svh - 150px), 760px);
  border-radius: 22px; color: #F2F2F7; cursor: pointer;
  background:
    radial-gradient(circle, rgba(255, 255, 255, .055) 1px, transparent 1.6px) 0 0 / 22px 22px,
    radial-gradient(130% 90% at 50% 0%, #2C2558 0%, #17152B 55%, #0D0C16 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), var(--lh-shadow-md);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: contain;
}
@supports not (height: 100svh) { .lh-fg-pad { block-size: clamp(280px, calc(100vh - 150px), 760px); } }
@media (min-width: 768px) { .lh-fg-pad { --d: 120px; block-size: clamp(360px, calc(100svh - 340px), 680px); } }
.lh-fg-pad:focus-visible { outline: 3px solid var(--lh-focus); outline-offset: 3px; }

/* full screen: the area alone (native API, or fixed overlay on iPhone) */
.lh-fg-pad.lh-app--fs { position: fixed; inset: 0; z-index: 1000; inline-size: 100vw; block-size: 100vh; block-size: 100dvh; margin: 0; border-radius: 0; }
.lh-fg-pad.lh-app--fs:fullscreen { inline-size: 100%; block-size: 100%; }
html.lh-fs, html.lh-fs body { overflow: hidden; }
.lh-fg-exit { display: none; }
.lh-fg-pad.lh-app--fs .lh-fg-exit {
  position: absolute; z-index: 6; inset-block-start: max(12px, env(safe-area-inset-top)); inset-inline-end: 12px;
  display: grid; place-items: center; inline-size: 48px; block-size: 48px; padding: 0; border: 1px solid rgba(255, 255, 255, .2); border-radius: 50%;
  background: rgba(10, 10, 18, .6); color: #FFFFFF; cursor: pointer;
}
.lh-fg-exit .lh-ic { inline-size: 20px; block-size: 20px; }
.lh-fg-tag { display: none; }
.lh-fg-pad.lh-app--fs .lh-fg-tag {
  position: absolute; z-index: 4; inset-block-end: max(12px, env(safe-area-inset-bottom)); inset-inline: 16px; display: block; margin: 0;
  color: rgba(255, 255, 255, .55); font-size: .875rem; font-weight: 650; text-align: center; pointer-events: none;
}

/* idle invitation */
.lh-fg-idle { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; pointer-events: none; }
.lh-fg-idle__ic { position: relative; display: grid; place-items: center; inline-size: 96px; block-size: 96px; margin-block-end: 10px; border-radius: 50%; background: rgba(255, 255, 255, .07); color: #CFC6FF; }
.lh-fg-idle__ic .lh-ic { inline-size: 44px; block-size: 44px; }
.lh-fg-idle__ring { position: absolute; inset: 0; border: 2px solid rgba(170, 152, 255, .55); border-radius: 50%; animation: lh-fg-ripple 2.4s ease-out infinite; }
.lh-fg-idle__ring + .lh-fg-idle__ring { animation-delay: 1.2s; }
@keyframes lh-fg-ripple { from { transform: scale(1); opacity: .85; } to { transform: scale(1.9); opacity: 0; } }
.lh-fg-idle__t { margin: 0; max-inline-size: 20ch; font-size: clamp(1.25rem, 5vw, 1.75rem); font-weight: 800; line-height: 1.2; text-wrap: balance; }
.lh-fg-idle__s { margin: 0; max-inline-size: 34ch; color: #BAB7CF; font-size: 1rem; line-height: 1.4; }

/* message pill (hold still, countdown, result) */
.lh-fg-msg {
  position: absolute; z-index: 5; inset-block-start: 12px; inset-inline: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  inline-size: fit-content; max-inline-size: calc(100% - 24px); min-block-size: 44px; margin: 0 auto; padding: 8px 18px; border-radius: 22px;
  background: rgba(9, 9, 16, .76); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
  color: #FFFFFF; text-align: center; pointer-events: none;
}
.lh-fg-pad.lh-app--fs .lh-fg-msg { inset-block-start: max(12px, env(safe-area-inset-top)); max-inline-size: calc(100% - 144px); }
.lh-fg-msg.is-low { inset-block-start: auto; inset-block-end: 12px; }
.lh-fg-pad.lh-app--fs .lh-fg-msg.is-low { inset-block-start: auto; inset-block-end: max(40px, calc(env(safe-area-inset-bottom) + 34px)); }
.lh-fg-msg__m { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 14px; font-size: 1.125rem; font-weight: 800; line-height: 1.25; }
.lh-fg-msg__s { color: rgba(255, 255, 255, .78); font-size: .8125rem; font-weight: 600; line-height: 1.3; }
.lh-fg-msg.is-num .lh-fg-msg__m { min-inline-size: 1.6em; font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.lh-fg-msg.is-win { background: rgba(9, 9, 16, .86); }
.lh-fg-msg.is-win .lh-fg-msg__m { font-size: 1.3125rem; }
.lh-fg-leg { display: inline-flex; align-items: center; gap: 6px; font-size: 1.0625rem; white-space: nowrap; }
.lh-fg-leg__dot { inline-size: 14px; block-size: 14px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px rgba(255, 255, 255, .3); }
.lh-fg-leg__n { color: rgba(255, 255, 255, .78); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Fingers ---------- */
.lh-fg-flood { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.lh-fg-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.lh-fg-dot {
  position: absolute; left: 0; top: 0; inline-size: var(--d); block-size: var(--d); translate: -50% -50%;
  transition: opacity .3s, scale .4s cubic-bezier(.3, 1.4, .5, 1); animation: lh-fg-in .24s cubic-bezier(.3, 1.5, .5, 1);
}
@keyframes lh-fg-in { from { scale: .3; opacity: 0; } }
.lh-fg-dot.is-gone { opacity: 0; scale: .5; animation: none; }
.lh-fg-dot__core {
  position: absolute; inset: 20%; border-radius: 50%; background: var(--c);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 35%, transparent), 0 0 34px 6px color-mix(in srgb, var(--c) 45%, transparent);
  transition: background-color .4s, box-shadow .4s;
}
.lh-fg-dot__halo { position: absolute; inset: 20%; border-radius: 50%; background: var(--c); opacity: 0; animation: lh-fg-pulse 1.4s ease-out infinite; }
@keyframes lh-fg-pulse { from { transform: scale(1); opacity: .55; } to { transform: scale(1.8); opacity: 0; } }
.lh-fg-dot.is-virtual .lh-fg-dot__core { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 35%, transparent), inset 0 0 0 3px rgba(255, 255, 255, .45); }
.lh-fg-dot.is-lifted .lh-fg-dot__halo { animation: none; opacity: 0; }

/* countdown ring: track while settling, filled clockwise during 3 · 2 · 1 */
.lh-fg-dot__ring { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; overflow: visible; rotate: -90deg; opacity: 0; transition: opacity .25s; }
.lh-fg-dot__ring circle { fill: none; stroke: var(--c); stroke-width: 5; }
.lh-fg-dot__track { opacity: .3; }
.lh-fg-dot__prog { stroke-linecap: round; stroke-dasharray: 100 100; stroke-dashoffset: 100; }
.lh-fg-pad[data-phase="settle"] .lh-fg-dot__ring, .lh-fg-pad[data-phase="count"] .lh-fg-dot__ring { opacity: 1; }
.lh-fg-pad[data-phase="count"] .lh-fg-dot__prog { animation: lh-fg-ring var(--cd, 1.8s) linear forwards; }
.lh-fg-pad[data-phase="count"] .lh-fg-dot__halo { animation-duration: .6s; }
@keyframes lh-fg-ring { to { stroke-dashoffset: 0; } }

/* results */
.lh-fg-dot.is-out { opacity: .16; scale: .72; }
.lh-fg-flood:not([hidden]) ~ .lh-fg-layer .lh-fg-dot.is-out { opacity: 0; }
.lh-fg-dot.is-win { z-index: 1; scale: 1.28; animation: lh-fg-win .9s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes lh-fg-win { 0% { scale: 1; } 35% { scale: 1.6; } 100% { scale: 1.28; } }
.lh-fg-dot.is-win .lh-fg-dot__core {
  box-shadow: 0 0 0 5px #FFFFFF, 0 0 0 10px color-mix(in srgb, var(--c) 60%, #000000), 0 0 60px 18px color-mix(in srgb, var(--c) 70%, transparent);
  animation: lh-fg-flash .9s ease-out;
}
@keyframes lh-fg-flash { 0%, 35% { filter: brightness(1.9) saturate(1.2); } 100% { filter: none; } }
.lh-fg-dot.is-win .lh-fg-dot__halo { animation-duration: 1s; }
.lh-fg-dot__lbl {
  position: absolute; z-index: 1; inset-block-start: -2px; inset-inline-end: -2px; display: grid; place-items: center;
  min-inline-size: 38px; block-size: 38px; padding-inline: 7px; border-radius: 19px; background: #FFFFFF; color: #14151A;
  box-shadow: 0 0 0 3px var(--c), 0 4px 12px rgba(0, 0, 0, .45); font-size: 1.25rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums;
  animation: lh-fg-pop .4s cubic-bezier(.3, 1.6, .5, 1) both;
}
.lh-fg-dot__lbl .lh-ic { inline-size: 22px; block-size: 22px; color: #D99A00; }
@keyframes lh-fg-pop { from { scale: 0; opacity: 0; } }
.lh-fg-dot.is-ranked .lh-fg-dot__lbl { animation-delay: calc(var(--i, 0) * 260ms); }
.lh-fg-dot.is-first { z-index: 1; scale: 1.14; }
.lh-fg-dot.is-first .lh-fg-dot__lbl { background: #FFD54A; }

/* ---------- Side cards ---------- */
.lh-fg-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 14px 16px 16px; border: 1px solid var(--lh-border); border-radius: 16px; background: var(--lh-surface); box-shadow: var(--lh-shadow-sm); }
.lh-fg-card__h { margin: 0; color: var(--lh-muted); font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
:lang(ar) .lh-fg-card__h { font-size: .875rem; letter-spacing: 0; }
.lh-fg-qr { display: flex; align-items: center; gap: 14px; }
.lh-fg-qr__img { flex: none; display: block; inline-size: 128px; block-size: 128px; overflow: hidden; border-radius: 10px; background: #FFFFFF; box-shadow: inset 0 0 0 1px var(--lh-border); }
.lh-fg-qr__img svg { display: block; inline-size: 100%; block-size: 100%; }
.lh-fg-qr .lh-hint { font-size: .875rem; }
.lh-fg-card .lh-hint { font-size: .875rem; }
.lh-fg-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.lh-fg-acts .lh-btn { min-block-size: 44px; }
.lh-fg-acts .lh-ic { inline-size: 18px; block-size: 18px; }
.lh-fg-vcount { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.lh-fg-card .lh-set__row { padding-block: 6px; }

/* ---------- Reduced motion: no pulses, pops or growth; the countdown ring is shown full ---------- */
@media (prefers-reduced-motion: reduce) {
  .lh-fg .lh-fg-dot, .lh-fg .lh-fg-dot *, .lh-fg-idle__ring { animation: none !important; }
  .lh-fg .lh-fg-dot { transition: opacity .2s; }
  .lh-fg [data-phase="count"] .lh-fg-dot__prog { stroke-dashoffset: 0; }
  .lh-fg-idle__ring { opacity: .3; }
}
.lh-reduced .lh-fg .lh-fg-dot, .lh-reduced .lh-fg .lh-fg-dot *, .lh-reduced .lh-fg-idle__ring { animation: none !important; }
.lh-reduced .lh-fg .lh-fg-dot { transition: opacity .2s; }
.lh-reduced .lh-fg [data-phase="count"] .lh-fg-dot__prog { stroke-dashoffset: 0; }
.lh-reduced .lh-fg-idle__ring { opacity: .3; }

@media print { .lh-fg-side, .lh-fg-opts, .lh-fg-modes { display: none !important; } }
