:root {
  --text: #e9e6e1;
  --muted: #8d929c;
  --line: rgba(255, 255, 255, .08);
  --red: #d71a33;
  --red-dark: #6d0a17;
  --red-light: #ff5a6e;
  --ui: 'Oswald', 'Arial Narrow', 'Segoe UI', system-ui, sans-serif;
  --script: 'Great Vibes', 'Segoe Script', cursive;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --emoji: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; background: #121418; }

body {
  font-family: var(--ui);
  color: var(--text);
  background: radial-gradient(ellipse at 50% 42%, #262a31 0%, #16181c 58%, #0c0d10 100%);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

#bg-romance {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 34%, #a32d57 0%, #5f1534 36%, #2c0918 70%, #12030a 100%);
  opacity: 0;
  transition: opacity 3.5s ease;
  pointer-events: none;
}
body.romance #bg-romance { opacity: 1; }

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  transition: filter .6s ease;
}
#game.dim { filter: blur(4px) brightness(.5); }
#game.soft { filter: brightness(.55); }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: calc(64px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: linear-gradient(rgba(10, 11, 14, .92), rgba(10, 11, 14, 0));
}
.brand, .tools { flex: 1; display: flex; align-items: center; gap: 10px; }
.tools { justify-content: flex-end; gap: 8px; }
.brand { font-weight: 700; font-size: 15px; letter-spacing: .3em; text-transform: uppercase; color: #cfd2d8; }
.brand svg { width: 30px; height: 30px; flex: none; }
.lvl { display: flex; flex-direction: column; align-items: center; line-height: 1.15; text-transform: uppercase; white-space: nowrap; }
.lvl strong { font-size: 17px; font-weight: 600; letter-spacing: .14em; }
.lvl span { font-size: 11px; letter-spacing: .34em; color: var(--red-light); }
.timer { font-variant-numeric: tabular-nums; font-size: 16px; letter-spacing: .08em; color: #cfd2d8; min-width: 50px; text-align: right; }

.icon-btn {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  color: #e6e6e6;
  background: linear-gradient(#3b404a, #2a2e36);
  box-shadow: 0 4px 0 #16181c, 0 6px 12px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .08);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, background .3s, color .3s;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #16181c, 0 2px 6px rgba(0, 0, 0, .35); }
.icon-btn svg { width: 20px; height: 20px; }
#btn-sound .ico-off, #btn-sound.muted .ico-on { display: none; }
#btn-sound.muted .ico-off { display: block; }

@media (max-width: 560px) {
  .brand span { display: none; }
  .lvl strong { font-size: 15px; }
  .timer { font-size: 15px; min-width: 44px; }
  .icon-btn { width: 38px; height: 38px; }
}

/* ---------- progreso ---------- */
.progress {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  gap: 8px;
  transition: opacity 1s;
}
.progress i { width: 26px; height: 4px; border-radius: 2px; background: #30343c; transition: background .4s, box-shadow .4s; }
.progress i.current { background: #6b717c; }
.progress i.done { background: var(--red); box-shadow: 0 0 8px rgba(215, 26, 51, .6); }

/* ---------- botones ---------- */
.btn {
  font-family: var(--ui);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #fff;
  border: 0;
  border-radius: 14px;
  padding: 14px 44px 14px calc(44px + .22em);
  background: linear-gradient(#e8283f, #b3142a);
  box-shadow: 0 6px 0 var(--red-dark), 0 12px 24px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .25);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, filter .2s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--red-dark), 0 4px 10px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* ---------- paneles ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  transition: opacity .35s ease, visibility 0s;
}
.overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .35s ease, visibility 0s .35s; }

.card {
  width: min(440px, 100%);
  text-align: center;
  padding: 34px 26px 30px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(33, 36, 43, .95), rgba(18, 20, 24, .97));
  box-shadow: 0 30px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .05);
}
.card .logo { width: 64px; height: 64px; }
.card h1 {
  font-size: clamp(38px, 11vw, 62px);
  font-weight: 700;
  letter-spacing: .2em;
  padding-left: .2em;
  text-transform: uppercase;
  line-height: 1;
  margin-top: 12px;
}
.card .thread { display: block; width: 200px; max-width: 70%; height: 16px; margin: 10px auto 14px; }
.sub { color: #b9bcc3; font-size: 16px; letter-spacing: .06em; margin-bottom: 28px; }
.help { list-style: none; margin-top: 26px; color: var(--muted); font-size: 12.5px; letter-spacing: .1em; line-height: 2; text-transform: uppercase; }

.kicker { display: block; font-size: 13px; letter-spacing: .4em; padding-left: .4em; text-transform: uppercase; color: var(--red-light); }
.card h2 { font-size: clamp(34px, 9vw, 48px); font-weight: 700; letter-spacing: .16em; padding-left: .16em; text-transform: uppercase; margin: 6px 0 22px; }
.stats { display: flex; justify-content: center; gap: 12px; margin-bottom: 28px; }
.stats div { flex: 1; max-width: 160px; padding: 12px 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0, 0, 0, .22); }
.stats span { display: block; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.stats b { display: block; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ---------- rótulo de nivel ---------- */
.banner {
  position: fixed;
  left: 0;
  right: 0;
  top: 44%;
  transform: translateY(-50%);
  z-index: 4;
  text-align: center;
  pointer-events: none;
  opacity: 0;
}
.banner small { display: block; font-size: 14px; letter-spacing: .5em; padding-left: .5em; color: #b4b8c0; text-transform: uppercase; }
.banner strong {
  display: block;
  font-size: clamp(40px, 10vw, 78px);
  letter-spacing: .24em;
  padding-left: .24em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .85);
}
.banner.show { animation: banner 1.9s ease forwards; }
@keyframes banner {
  0% { opacity: 0; transform: translateY(-50%) scale(1.06); }
  18% { opacity: 1; transform: translateY(-50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- final ---------- */
body.romance .brand,
body.romance .lvl,
body.romance #timer,
body.romance #btn-restart,
body.romance .progress { opacity: 0; visibility: hidden; transition: opacity 1.2s, visibility 0s 1.2s; }
body.romance .hud { background: none; }
body.romance #btn-sound { background: rgba(255, 255, 255, .1); box-shadow: none; color: #f6d5dc; }

.final {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 16px 16px calc(max(4vh, 18px) + env(safe-area-inset-bottom));
  text-align: center;
  pointer-events: none;
}
.final.hidden { display: none; }
.final-msg { width: 100%; max-width: 760px; }
.final-msg > * { opacity: 0; transform: translateY(14px); }

.legend {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(16px, 2.6vw, 22px);
  line-height: 1.4;
  color: #f4c8d3;
  max-width: 30em;
  margin: 0 auto 10px;
}
.l1, .l2 { font-family: var(--script); font-weight: 400; color: #fff; word-spacing: .14em; }
.l1 { font-size: clamp(30px, min(8vw, 7vh), 58px); line-height: 1.15; color: #ffe6ec; text-shadow: 0 2px 20px rgba(255, 80, 120, .45); }
.l2 { font-size: clamp(40px, min(11vw, 10vh), 86px); line-height: 1.15; text-shadow: 0 2px 28px rgba(255, 70, 110, .6); }
.l2 .heart { display: inline-block; font-family: var(--emoji); font-size: .62em; vertical-align: .08em; animation: beat 1.3s ease-in-out infinite; }

.btn-soft {
  margin-top: 18px;
  font-size: 14px;
  padding: 10px 22px 10px calc(22px + .22em);
  color: #ffe3ea;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .28);
  box-shadow: none;
}
.btn-soft:active { transform: translateY(2px); box-shadow: none; }

.final.show .legend { animation: rise 1.6s ease forwards; }
.final.show .l1 { animation: rise 1.8s ease 1.5s forwards; }
.final.show .l2 { animation: rise 2s ease 2.8s forwards; }
.final.show #btn-again { animation: rise 1.2s ease 6s forwards; pointer-events: auto; }

#btn-again { visibility: hidden; }
@keyframes rise { to { opacity: 1; transform: none; visibility: visible; } }
@keyframes beat {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.2); }
  28% { transform: scale(1); }
  42% { transform: scale(1.12); }
  60% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .banner.show { animation-duration: 1.2s; }
  .final.show .l1 { animation-delay: .5s; }
  .final.show .l2 { animation-delay: 1s; }
  .final.show #btn-again { animation-delay: 2s; }
  .l2 .heart { animation: none; }
}
