:root {
  --ink: #1a2744;
  --panel: rgba(18, 40, 82, 0.88);
  --cream: #fffaf4;
  --gold: #ffc14a;
  --heart: #ff4d62;
  --accent: #ff8a3d;
  --easy: #5dff7a;
  --font: "Nunito", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app {
  width: 100%; height: 100%; overflow: hidden;
  background: #6ebfff url("./../assets/bg.webp") center center / cover no-repeat;
  font-family: var(--font);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#ui .hit { pointer-events: auto; }

.hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: max(0.75rem, env(safe-area-inset-top)) 0.8rem 0;
  gap: 0.5rem;
}
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--panel);
  color: var(--cream);
  border-radius: 999px;
  padding: 0.48rem 0.85rem;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 10px 28px rgba(10, 30, 60, 0.28);
  border: 2px solid rgba(255,255,255,0.14);
}
.hearts { display: flex; gap: 0.15rem; margin-left: 0.15rem; }
.heart {
  color: var(--heart);
  font-size: 1.15rem;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.18));
  -webkit-text-stroke: 1px rgba(80,0,20,0.25);
}
.heart.off { opacity: 0.25; filter: grayscale(1); }

.level-banner {
  position: absolute; top: max(0.75rem, env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  text-align: center; pointer-events: none; width: min(420px, 70vw);
}
.level-banner .title {
  display: inline-block;
  background: var(--panel);
  color: var(--cream);
  font-weight: 900;
  letter-spacing: 0.04em;
  font-size: 0.86rem;
  padding: 0.5rem 1.25rem;
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(10, 30, 60, 0.28);
  border: 2px solid rgba(255,255,255,0.12);
}
.level-banner .title .diff { color: var(--easy); }
.hint {
  margin-top: 0.85rem;
  color: #fff;
  font-weight: 800;
  font-size: clamp(0.95rem, 3.4vw, 1.15rem);
  text-shadow:
    0 2px 0 rgba(20, 50, 90, 0.35),
    0 8px 24px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.hint.show { opacity: 1; }

.icon-btn {
  width: 46px; height: 46px; border-radius: 14px;
  border: 3px solid rgba(255,255,255,0.55);
  background: linear-gradient(180deg, #ffb05a, #ff6a28);
  color: white; font-size: 1.2rem; font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 0 #d44a18, 0 12px 22px rgba(255, 100, 40, 0.35);
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 4px 0 #d44a18, 0 8px 14px rgba(255, 100, 40, 0.3); }
.hud-right { display: flex; gap: 0.45rem; }

.screen {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(90, 180, 255, 0.45), rgba(20, 55, 100, 0.6));
  backdrop-filter: blur(10px);
}
.screen.active { display: flex; pointer-events: auto; }

.card {
  width: min(400px, 94vw);
  background: rgba(255, 252, 248, 0.96);
  border-radius: 28px;
  padding: 1.4rem 1.25rem 1.5rem;
  text-align: center;
  box-shadow: 0 30px 70px rgba(20, 40, 80, 0.4);
  border: 2px solid rgba(255,255,255,0.7);
  color: var(--ink);
}
.card img.cover {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  border-radius: 18px;
  margin-bottom: 0.9rem;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25), 0 0 15px rgba(255, 106, 42, 0.3);
  border: 1px solid rgba(255, 106, 42, 0.4);
}
.card h1 {
  font-weight: 900;
  font-size: clamp(1.9rem, 6vw, 2.5rem);
  letter-spacing: -0.02em;
}
.card p { color: #4a5d7a; font-weight: 700; margin: 0.35rem 0 1rem; }
.stack { display: flex; flex-direction: column; gap: 0.6rem; }
.btn {
  appearance: none; border: none; cursor: pointer;
  font: inherit; font-weight: 900;
  padding: 0.95rem 1rem;
  border-radius: 999px;
  background: #e8eef8; color: var(--ink);
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(135deg, #ff9a4a, #ff5a2e);
  color: white;
  box-shadow: 0 10px 0 #d4451c, 0 16px 28px rgba(255, 90, 46, 0.35);
}
.toggle {
  display: flex; justify-content: space-between; align-items: center;
  background: #eef3fb; border-radius: 16px; padding: 0.9rem 1rem; font-weight: 800;
}
.score-big { font-size: 2.6rem; font-weight: 900; color: #ff6a2a; }

.floating-score {
  position: absolute; left: 50%; top: 40%;
  transform: translate(-50%, -50%);
  font-weight: 900; font-size: 1.7rem; color: #fff;
  text-shadow: 0 4px 14px rgba(0,0,0,0.4);
  pointer-events: none; opacity: 0;
}
.floating-score.pop { animation: popScore 0.9s ease forwards; }
@keyframes popScore {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -95%) scale(1); }
}

@media (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  #screen-menu {
    padding: 0.75rem;
  }

  #screen-menu .card {
    width: min(680px, calc(100vw - 1.5rem));
    display: grid;
    grid-template-columns: minmax(180px, 0.95fr) minmax(0, 1fr);
    column-gap: 1rem;
    align-items: center;
    padding: 1rem;
  }

  #screen-menu .card img.cover {
    grid-row: 1 / span 3;
    margin-bottom: 0;
  }

  #screen-menu .card p {
    margin: 0.25rem 0 0.75rem;
  }
}
