  :root {
    --pink: #ff4d8d;
    --hotpink: #ff0066;
    --rose: #ff6eb4;
    --cream: #fff5f8;
    --dark: #2d0a1a;
    --purple: #9b2d6e;
    --gold: #ffd700;
    --red: #e63946;
  }

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

  body {
    font-family: 'Nunito', sans-serif;
    background: #0d0009;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
  }

  /* Animated background */
  .bg-hearts {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
  }
  .bg-heart {
    position: absolute;
    font-size: 1.5rem;
    animation: floatUp linear infinite;
    opacity: 0.07;
  }

  @keyframes floatUp {
    0% { transform: translateY(110vh) rotate(0deg); opacity: 0; }
    10% { opacity: 0.07; }
    90% { opacity: 0.07; }
    100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
  }

  /* Main container */
  #app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    max-width: 480px;
    padding: 0 8px;
  }

  /* SCREENS */
  .screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
  }
  .screen.active { display: flex; }

  /* ─── TITLE SCREEN ─── */
  #screen-title {
    gap: 24px;
    padding: 40px 20px;
    text-align: center;
  }

  .title-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .logo-hearts {
    font-size: 4rem;
    animation: pulse 1.5s ease-in-out infinite;
  }

  @keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
  }

  .title-text {
    font-family: 'Fredoka One', cursive;
    font-size: 3rem;
    color: #fff;
    text-shadow: 0 0 30px var(--pink), 0 4px 0 var(--purple);
    line-height: 1;
  }

  .title-sub {
    font-size: 1rem;
    color: var(--rose);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 700;
  }

  .title-desc {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,77,141,0.3);
    border-radius: 16px;
    padding: 16px 24px;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    line-height: 1.7;
    max-width: 340px;
  }

  .title-desc span {
    color: var(--rose);
    font-weight: 700;
  }

  .btn-primary {
    background: linear-gradient(135deg, var(--hotpink), var(--pink));
    border: none;
    border-radius: 50px;
    color: white;
    font-family: 'Fredoka One', cursive;
    font-size: 1.4rem;
    padding: 16px 48px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(255,0,102,0.5), 0 0 0 0 rgba(255,77,141,0.4);
    animation: glow 2s ease-in-out infinite;
    transition: transform 0.15s;
    letter-spacing: 0.05em;
  }
  .btn-primary:hover { transform: scale(1.05); }
  .btn-primary:active { transform: scale(0.97); }

  @keyframes glow {
    0%, 100% { box-shadow: 0 8px 24px rgba(255,0,102,0.5), 0 0 0 0 rgba(255,77,141,0.4); }
    50% { box-shadow: 0 8px 32px rgba(255,0,102,0.7), 0 0 0 12px rgba(255,77,141,0); }
  }

  .btn-secondary {
    background: transparent;
    border: 2px solid rgba(255,77,141,0.5);
    border-radius: 50px;
    color: var(--rose);
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    padding: 10px 32px;
    cursor: pointer;
    transition: all 0.2s;
  }
  .btn-secondary:hover {
    background: rgba(255,77,141,0.1);
    border-color: var(--pink);
    color: #fff;
  }

  /* High score on title */
  .title-hs {
    color: var(--gold);
    font-size: 0.95rem;
    font-weight: 700;
  }

  /* ─── GAME SCREEN ─── */
  #screen-game {
    gap: 0;
  }

  /* HUD */
  .hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px 12px 8px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,77,141,0.2);
  }

  .hud-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    min-width: 70px;
  }

  .hud-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255,255,255,0.4);
    font-weight: 700;
  }

  .hud-value {
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    color: #fff;
    text-shadow: 0 0 10px var(--pink);
    line-height: 1;
  }

  .hud-value.gold { color: var(--gold); text-shadow: 0 0 10px rgba(255,215,0,0.6); }

  /* Lives display */
  .lives-display {
    display: flex;
    gap: 4px;
    font-size: 1.1rem;
    line-height: 1;
  }

  .life { transition: all 0.3s; }
  .life.lost { opacity: 0.2; filter: grayscale(1); transform: scale(0.8); }

  /* Level badge */
  .level-badge {
    background: linear-gradient(135deg, var(--purple), var(--hotpink));
    border-radius: 20px;
    padding: 4px 14px;
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    color: white;
    text-shadow: 0 1px 0 rgba(0,0,0,0.3);
    box-shadow: 0 2px 8px rgba(255,0,102,0.4);
  }

  /* Canvas wrapper */
  .canvas-wrap {
    position: relative;
    width: 100%;
    background: linear-gradient(180deg, #1a0010 0%, #0d0009 100%);
  }

  #gameCanvas {
    display: block;
    width: 100%;
    cursor: none;
    touch-action: none;
  }

  /* Combo display overlay */
  #combo-overlay {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(255,215,0,0.8);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    white-space: nowrap;
  }
  #combo-overlay.visible { opacity: 1; }

  /* Level up flash */
  #level-flash {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,0,102,0.15);
    backdrop-filter: blur(4px);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s;
    z-index: 10;
    border-radius: 0;
  }
  #level-flash.visible { opacity: 1; }
  #level-flash-text {
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    color: white;
    text-shadow: 0 0 40px var(--pink), 0 4px 0 var(--purple);
    text-align: center;
    animation: flashPulse 0.4s ease-out;
  }
  @keyframes flashPulse {
    0% { transform: scale(0.5); }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); }
  }

  /* ─── GAME OVER SCREEN ─── */
  #screen-gameover {
    padding: 40px 20px;
    gap: 20px;
    text-align: center;
  }

  .go-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    color: #fff;
    text-shadow: 0 0 30px var(--red), 0 4px 0 var(--purple);
  }

  .go-heart { font-size: 3rem; animation: heartbreak 0.5s ease-out; }
  @keyframes heartbreak {
    0% { transform: scale(1.5); }
    100% { transform: scale(1); }
  }

  .score-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,77,141,0.3);
    border-radius: 20px;
    padding: 20px 32px;
    width: 100%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .score-row-label {
    color: rgba(255,255,255,0.5);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }
  .score-row-val {
    font-family: 'Fredoka One', cursive;
    font-size: 1.4rem;
    color: white;
  }
  .score-row-val.highlight {
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255,215,0,0.6);
  }
  .score-row-val.pink { color: var(--rose); }

  .new-record {
    background: linear-gradient(135deg, var(--gold), #ffa500);
    color: var(--dark);
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    padding: 6px 16px;
    border-radius: 20px;
    display: inline-block;
    animation: bounce 0.5s infinite alternate;
  }
  @keyframes bounce { to { transform: translateY(-4px); } }

  .btn-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
  }

  /* ─── LEADERBOARD SCREEN ─── */
  #screen-leaderboard {
    padding: 30px 20px;
    gap: 20px;
    width: 100%;
  }

  .lb-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    color: white;
    text-shadow: 0 0 20px var(--pink);
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .lb-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
  }

  .lb-item {
    display: grid;
    grid-template-columns: 40px 1fr auto auto;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,77,141,0.15);
    border-radius: 12px;
    padding: 12px 16px;
    transition: all 0.2s;
  }

  .lb-item.top1 { background: rgba(255,215,0,0.08); border-color: rgba(255,215,0,0.3); }
  .lb-item.top2 { background: rgba(192,192,192,0.08); border-color: rgba(192,192,192,0.25); }
  .lb-item.top3 { background: rgba(205,127,50,0.08); border-color: rgba(205,127,50,0.25); }
  .lb-item.current { background: rgba(255,0,102,0.1); border-color: rgba(255,0,102,0.4); }

  .lb-rank {
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    text-align: center;
  }
  .lb-item.top1 .lb-rank { color: var(--gold); }
  .lb-item.top2 .lb-rank { color: #c0c0c0; }
  .lb-item.top3 .lb-rank { color: #cd7f32; }
  .lb-rank:not(.top1 .lb-rank):not(.top2 .lb-rank):not(.top3 .lb-rank) { color: rgba(255,255,255,0.4); }

  .lb-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .lb-level {
    font-size: 0.75rem;
    color: var(--rose);
    font-weight: 600;
    background: rgba(255,77,141,0.12);
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
  }

  .lb-score {
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    color: white;
    text-align: right;
  }

  .lb-empty {
    text-align: center;
    color: rgba(255,255,255,0.3);
    padding: 40px;
    font-size: 0.95rem;
  }

  .lb-scroll::-webkit-scrollbar { width: 4px; }
  .lb-scroll::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 4px; }
  .lb-scroll::-webkit-scrollbar-thumb { background: var(--pink); border-radius: 4px; }

  /* Name input modal */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    display: none;
  }
  .modal-overlay.open { display: flex; }

  .modal-box {
    background: linear-gradient(135deg, #1a0010, #2d0a1a);
    border: 2px solid var(--pink);
    border-radius: 24px;
    padding: 32px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 0 60px rgba(255,0,102,0.3);
  }

  .modal-title {
    font-family: 'Fredoka One', cursive;
    font-size: 1.6rem;
    color: white;
  }

  .modal-sub { color: rgba(255,255,255,0.6); font-size: 0.9rem; }

  .name-input {
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,77,141,0.4);
    border-radius: 12px;
    color: white;
    font-family: 'Nunito', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 12px 16px;
    text-align: center;
    outline: none;
    width: 100%;
    transition: border-color 0.2s;
  }
  .name-input:focus { border-color: var(--pink); }
  .name-input::placeholder { color: rgba(255,255,255,0.2); }

  /* Sound toggle */
  .sound-btn {
    position: fixed;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,77,141,0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: all 0.2s;
  }
  .sound-btn:hover { background: rgba(255,77,141,0.2); }

  /* Pause button */
  .pause-btn {
    position: fixed;
    top: 12px;
    left: 12px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,77,141,0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    display: none;
  }
  .pause-btn.visible { display: flex; }
  .pause-btn:hover { background: rgba(255,77,141,0.2); }

  /* Pause overlay */
  #pause-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    z-index: 90;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
  }
  #pause-overlay.open { display: flex; }
  .pause-title {
    font-family: 'Fredoka One', cursive;
    font-size: 3rem;
    color: white;
  }

  /* Particles */
  .particle {
    position: absolute;
    pointer-events: none;
    font-size: 1.5rem;
    animation: particleFly 0.8s ease-out forwards;
  }
  @keyframes particleFly {
    0% { opacity: 1; transform: translate(0,0) scale(1); }
    100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0); }
  }

  /* Tutorial tips */
  .game-tip {
    background: rgba(0,0,0,0.6);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-align: center;
    font-style: italic;
  }

  /* Responsive */
  @media (max-width: 380px) {
    .title-text { font-size: 2.4rem; }
    .btn-primary { font-size: 1.2rem; padding: 14px 36px; }
  }
