:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-2: #8f73ff;
  --gold: #ffc93c;
  --mint: #3ee6a8;
  --red: #ff4d6d;
  --text: #fff;
  --muted: #aaadbe;
  --line: rgba(255, 255, 255, 0.08);
  font-family: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 800;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
}
body {
  padding: 8px 10px 6px;
  overflow-x: hidden;
}
button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
kbd {
  display: inline-block;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--panel-2);
  border-bottom: 2px solid #0a0a14;
  font: inherit;
  font-size: 0.92em;
}

/* ---------- Layout ---------- */
.hf-shell {
  width: min(960px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hf-hud {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}
.hf-brand {
  font-size: 22px;
  font-weight: 900;
  line-height: 0.88;
  letter-spacing: -0.02em;
  color: #ffe16b;
  text-shadow:
    0 2px 0 #e0761b,
    0 4px 0 #8a3a12,
    0 7px 12px rgba(0, 0, 0, 0.45);
  padding: 2px 6px 0 2px;
  align-self: center;
  white-space: nowrap;
}
.hf-brand span {
  display: block;
  color: #7ee8ff;
  margin-left: 14px;
  text-shadow:
    0 2px 0 #2a8fd6,
    0 4px 0 #1d3f8a,
    0 7px 12px rgba(0, 0, 0, 0.45);
}
.hf-chip {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.hf-label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hf-chip strong {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hf-chip-level strong {
  color: #b9a8ff;
}
.hf-chip-found strong {
  color: var(--mint);
}
.hf-chip-score strong {
  color: var(--gold);
}
.hf-timebar {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 5px;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.hf-timebar b {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3ee6a8, #7ee8ff);
  transform-origin: left center;
  transition: transform 0.25s linear;
}
.hf-chip-time.is-low strong {
  color: var(--red);
  animation: hf-throb 1s ease-in-out infinite;
}
.hf-chip-time.is-low .hf-timebar b {
  background: linear-gradient(90deg, #ff4d6d, #ff9a3c);
}
.hf-chip-time.is-hit {
  animation: hf-shake 0.35s ease;
  box-shadow:
    0 0 0 2px rgba(255, 77, 109, 0.7),
    0 6px 14px rgba(0, 0, 0, 0.3);
}
.pop {
  animation: hf-pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.hf-hud-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.hf-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #33344a, #2a2b3d);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease;
}
.hf-icon-btn svg {
  width: 22px;
  height: 22px;
}
.hf-icon-btn:active {
  transform: scale(0.92);
}
.hf-icon-btn[aria-pressed="false"] #sound-waves {
  opacity: 0.15;
}

.hf-body {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 184px;
  gap: 10px;
  min-width: 0;
}
.hf-stage {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 20px;
  overflow: hidden;
  background: #241a2c;
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.45),
    0 0 0 3px #2a2b3d,
    0 0 0 5px rgba(104, 66, 255, 0.35);
  min-width: 0;
}
.hf-stage.is-shaking {
  animation: hf-shake 0.3s ease;
}
#scene {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}
#scene.is-dragging {
  cursor: grabbing;
}
#scene:focus-visible {
  outline: none;
}
.hf-stage:has(#scene:focus-visible) {
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.45),
    0 0 0 3px #fff;
}

.hf-zoom {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  gap: 6px;
}
.hf-round-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(20, 20, 38, 0.62);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease;
}
.hf-round-btn svg {
  width: 20px;
  height: 20px;
}
.hf-round-btn:active {
  transform: scale(0.9);
}
.hf-hint {
  --p: 1;
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0;
  color: #5a3100;
  background: radial-gradient(circle at 35% 28%, #fff6c7 0 12%, #ffd84a 30%, #ff9f1c 78%, #d76a00 100%);
  box-shadow:
    0 6px 0 #a24d00,
    0 10px 18px rgba(0, 0, 0, 0.45),
    inset 0 -4px 8px rgba(160, 60, 0, 0.35);
  transition:
    transform 0.15s ease,
    filter 0.2s ease;
}
.hf-hint svg {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.6));
}
.hf-hint-label {
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hf-hint-ring {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(#fff calc(var(--p) * 360deg), rgba(255, 255, 255, 0.12) 0);
  -webkit-mask: radial-gradient(circle, transparent 36px, #000 37px);
  mask: radial-gradient(circle, transparent 36px, #000 37px);
  pointer-events: none;
}
.hf-hint:disabled {
  cursor: default;
  filter: grayscale(0.85) brightness(0.7);
}
.hf-hint.is-ready {
  animation: hf-bob 1.6s ease-in-out infinite;
}
.hf-hint:not(:disabled):active {
  transform: translateY(4px) scale(0.96);
}
.hf-toast {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translate(-50%, -10px);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(20, 20, 38, 0.85);
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.25s ease;
}
.hf-toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}
.hf-toast.is-bad {
  background: rgba(190, 30, 60, 0.92);
}

/* ---------- Object list ---------- */
.hf-list-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px 8px;
  border-radius: 20px;
  background: linear-gradient(180deg, #25263a, var(--panel));
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  min-width: 0;
}
.hf-list-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.hf-list-head strong {
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: none;
}
.hf-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-rows: repeat(10, minmax(0, 1fr));
  gap: 4px;
  flex: 1;
  min-height: 0;
}
.hf-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 8px 2px 3px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.05);
  min-width: 0;
  min-height: 0;
  transition:
    background 0.25s ease,
    opacity 0.25s ease;
}
.hf-item canvas {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: radial-gradient(circle at 50% 40%, #3b3c56, #262738);
}
.hf-item span {
  font-size: 14.5px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
}
.hf-item.is-found {
  background: rgba(62, 230, 168, 0.12);
  border-color: rgba(62, 230, 168, 0.25);
}
.hf-item.is-found span {
  color: #7d809a;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}
.hf-item.is-found canvas {
  opacity: 0.45;
}
.hf-item.is-found::after {
  content: "";
  position: absolute;
  left: 18px;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: var(--mint)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%230b3b2a' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 16px no-repeat;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  animation: hf-pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.hf-item.is-hinted {
  box-shadow: 0 0 0 2px var(--gold);
}

/* ---------- Overlays ---------- */
.hf-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 20px;
  background: radial-gradient(circle at 50% 40%, rgba(35, 25, 80, 0.72), rgba(10, 10, 22, 0.88));
  backdrop-filter: blur(3px);
  animation: hf-fade 0.25s ease;
}
.hf-overlay[hidden] {
  display: none;
}
.hf-card {
  width: min(380px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 20px 20px 18px;
  border-radius: 26px;
  background: linear-gradient(180deg, #2a2b40, #1c1d2b);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: hf-rise 0.4s cubic-bezier(0.2, 1.3, 0.4, 1);
}
.hf-card h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.hf-card p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
}
.hf-logo {
  font-size: 50px;
  font-weight: 900;
  line-height: 0.86;
  letter-spacing: -0.03em;
  color: #ffe16b;
  text-shadow:
    0 3px 0 #e0761b,
    0 6px 0 #8a3a12,
    0 12px 22px rgba(0, 0, 0, 0.5);
  margin: 4px 0 2px;
}
.hf-logo span {
  display: block;
}
.hf-logo span + span {
  color: #7ee8ff;
  text-shadow:
    0 3px 0 #2a8fd6,
    0 6px 0 #1d3f8a,
    0 12px 22px rgba(0, 0, 0, 0.5);
}
.hf-hero-items {
  display: flex;
  justify-content: center;
  gap: 4px;
  min-height: 52px;
}
.hf-hero-items canvas {
  width: 48px;
  height: 48px;
  animation: hf-bob 2.2s ease-in-out infinite;
}
.hf-hero-items canvas:nth-child(2n) {
  animation-delay: -0.6s;
}
.hf-hero-items canvas:nth-child(3n) {
  animation-delay: -1.2s;
}
.hf-btn {
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 10px 22px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    filter 0.15s ease;
}
.hf-btn:active {
  transform: translateY(2px) scale(0.98);
}
.hf-btn-primary {
  background: linear-gradient(180deg, #8a6bff, var(--accent));
  box-shadow:
    0 5px 0 #3f22b8,
    0 10px 20px rgba(104, 66, 255, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.hf-btn-primary:hover {
  filter: brightness(1.08);
}
.hf-btn-big {
  min-height: 56px;
  font-size: 21px;
}
.hf-btn-secondary {
  background: #2a2b3d;
  box-shadow:
    0 4px 0 #15151f,
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.hf-btn-secondary span {
  color: var(--gold);
  margin-left: 6px;
}
.hf-row {
  display: flex;
  gap: 8px;
}
.hf-row > * {
  flex: 1;
}
.hf-sub {
  font-size: 14px;
}
.hf-win-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 54px;
  line-height: 1;
}
.hf-win-stars b {
  color: #3a3b52;
  text-shadow: 0 3px 0 #15151f;
  transform: scale(0.3);
  opacity: 0;
}
.hf-win-stars b:nth-child(2) {
  font-size: 66px;
  margin-top: -10px;
}
.hf-win-stars b.is-on {
  color: #ffd23f;
  text-shadow:
    0 3px 0 #c77800,
    0 0 22px rgba(255, 210, 63, 0.6);
}
.hf-win-stars b.is-in {
  animation: hf-star 0.5s cubic-bezier(0.2, 1.7, 0.4, 1) forwards;
}
.hf-win-stats {
  display: flex;
  gap: 8px;
}
.hf-win-stats p {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
}
.hf-win-stats span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.hf-win-stats strong {
  color: #fff;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}
.hf-unlock {
  padding: 8px 12px;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(62, 230, 168, 0.18), rgba(126, 232, 255, 0.18));
  color: #bff7e3 !important;
  font-weight: 900;
}
.hf-lose-items {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}
.hf-lose-items canvas {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

/* Level map */
.hf-card-map {
  width: min(560px, 100%);
}
.hf-map-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hf-map-stars {
  color: var(--gold);
  font-size: 17px;
}
.hf-map {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hf-chapter {
  border-radius: 18px;
  padding: 8px 10px 10px;
  text-align: left;
}
.hf-chapter h3 {
  margin: 0 0 6px 2px;
  font-size: 15px;
  font-weight: 900;
  display: flex;
  justify-content: space-between;
}
.hf-chapter h3 span {
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
}
.hf-chapter-library {
  background: linear-gradient(135deg, #7a4a2c, #4b2a1c);
}
.hf-chapter-beach {
  background: linear-gradient(135deg, #2b9fd0, #e6b660);
}
.hf-chapter-kitchen {
  background: linear-gradient(135deg, #3aa38a, #d77f55);
}
.hf-chapter-levels {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.hf-level-btn {
  min-height: 52px;
  border-radius: 14px;
  border: 0;
  padding: 4px 0;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(235, 232, 255, 0.9));
  color: #2c2157;
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.3),
    inset 0 -2px 0 rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  gap: 3px;
  font-size: 19px;
  font-weight: 900;
}
.hf-level-btn small {
  font-size: 11px;
  letter-spacing: 1px;
  color: #c9c6d8;
}
.hf-level-btn small b {
  color: #f0a500;
}
.hf-level-btn.is-current {
  box-shadow:
    0 0 0 3px #ffe16b,
    0 4px 0 rgba(0, 0, 0, 0.3);
}
.hf-level-btn:disabled {
  cursor: default;
  background: rgba(0, 0, 0, 0.28);
  color: rgba(255, 255, 255, 0.55);
  box-shadow: none;
}

/* Ghost hand */
.hf-ghost {
  position: fixed;
  z-index: 30;
  width: 54px;
  height: 54px;
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}
.hf-ghost-tip {
  position: fixed;
  z-index: 31;
  max-width: 250px;
  padding: 10px 14px;
  border-radius: 16px;
  background: #fff;
  color: #2c2157;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 900;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
  animation: hf-rise 0.35s cubic-bezier(0.2, 1.3, 0.4, 1);
}
.hf-flyer {
  position: fixed;
  z-index: 25;
  left: 0;
  top: 0;
  pointer-events: none;
}

.hf-help {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
}

/* ---------- Animations ---------- */
@keyframes hf-pop {
  0% {
    transform: scale(0.4);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes hf-rise {
  from {
    transform: translateY(18px) scale(0.94);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@keyframes hf-fade {
  from {
    opacity: 0;
  }
}
@keyframes hf-star {
  0% {
    transform: scale(0.3) rotate(-30deg);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}
@keyframes hf-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}
@keyframes hf-throb {
  50% {
    transform: scale(1.08);
  }
}
@keyframes hf-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(5px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(2px);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  body {
    padding: 6px 6px 4px;
  }
  .hf-brand {
    display: none;
  }
  .hf-hud {
    gap: 5px;
  }
  .hf-chip {
    padding: 5px 9px;
    border-radius: 16px;
  }
  .hf-chip strong {
    font-size: 17px;
  }
  .hf-label {
    font-size: 9.5px;
    letter-spacing: 0.04em;
  }
  .hf-timebar {
    left: 9px;
    right: 9px;
    bottom: 3px;
  }
  .hf-icon-btn {
    width: 40px;
    height: 40px;
  }
  .hf-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
  .hf-stage {
    aspect-ratio: 1 / 1;
    max-height: 64vh;
    width: 100%;
    border-radius: 16px;
  }
  .hf-list-panel {
    padding: 6px;
    border-radius: 16px;
  }
  .hf-list-head {
    display: none;
  }
  .hf-list {
    grid-template-rows: none;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .hf-item {
    flex-direction: column;
    gap: 1px;
    padding: 4px 2px 3px;
    border-radius: 12px;
  }
  .hf-item canvas {
    width: 32px;
    height: 32px;
  }
  .hf-item span {
    font-size: 11px;
    max-width: 100%;
  }
  .hf-item.is-found::after {
    left: 50%;
    top: 20px;
  }
  .hf-hint {
    width: 60px;
    height: 60px;
  }
  .hf-hint-ring {
    -webkit-mask: radial-gradient(circle, transparent 32px, #000 33px);
    mask: radial-gradient(circle, transparent 32px, #000 33px);
  }
  .hf-help {
    display: none;
  }
  .hf-logo {
    font-size: 42px;
  }
}
@media (max-width: 380px) {
  .hf-chip-score {
    display: none;
  }
  .hf-card {
    padding: 16px 14px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .hf-win-stars b {
    transform: none;
    opacity: 1;
  }
}
