:root {
    --navy:    #050a1a;
    --navy2:   #0a1228;
    --card:    #0e1933;
    --neon:    #00f5ff;
    --pink:    #ff2d78;
    --yellow:  #ffe600;
    --green:   #00ff88;
    --purple:  #b94fff;
    --white:   #e8f0ff;
    --dim:     #4a5a80;
    --dim2:    #2a3555;
  }

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { font-size: 16px; }

  body {
    font-family: 'Nunito', sans-serif;
    background: var(--navy);
    color: var(--white);
    min-height: 100vh;
    display: flex; flex-direction: column;
    align-items: center;
    padding: 2rem 1rem 3rem;
    overflow-x: hidden;
    cursor: none;
    position: relative;
  }

  /* ── SCANLINES ── */
  body::after {
    content: '';
    position: fixed; inset: 0; z-index: 9990;
    background: repeating-linear-gradient(
      0deg,
      rgba(0,0,0,0) 0px,
      rgba(0,0,0,0) 2px,
      rgba(0,0,0,0.07) 2px,
      rgba(0,0,0,0.07) 4px
    );
    pointer-events: none;
  }

  /* ── STARFIELD BG ── */
  .stars {
    position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  }
  .star {
    position: absolute; border-radius: 50%;
    background: white; opacity: 0;
    animation: twinkle var(--dur) var(--delay) infinite;
  }
  @keyframes twinkle {
    0%,100% { opacity: 0; transform: scale(.5); }
    50%      { opacity: var(--op); transform: scale(1); }
  }

  /* ── GLOW ORBS ── */
  .orb {
    position: fixed; border-radius: 50%; filter: blur(100px);
    pointer-events: none; z-index: 0; animation: drift var(--t) ease-in-out infinite alternate;
  }
  @keyframes drift { from { transform: translate(0,0); } to { transform: translate(var(--dx),var(--dy)); } }

  /* ── CUSTOM CURSOR ── */
  #cur {
    position: fixed; z-index: 9999; pointer-events: none;
    width: 28px; height: 28px;
    top: 0; left: 0;
    transition: transform .1s;
  }
  #cur svg { width: 100%; height: 100%; filter: drop-shadow(0 0 6px var(--neon)); }

  /* ── MAIN WRAPPER ── */
  .app {
    position: relative; z-index: 1;
    width: 100%; max-width: 560px;
    animation: bootIn .7s cubic-bezier(.16,1,.3,1) both;
  }
  @keyframes bootIn {
    from { opacity:0; transform: scale(.9) translateY(30px); }
    to   { opacity:1; transform: none; }
  }

  /* ── ARCADE HEADER ── */
  .arcade-header {
    text-align: center;
    margin-bottom: 2.5rem;
    position: relative;
  }

  .coin-insert {
    font-family: 'Press Start 2P', monospace;
    font-size: .45rem; letter-spacing: .15em;
    color: var(--yellow);
    margin-bottom: .8rem;
    animation: blink 1s step-end infinite;
  }
  @keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

  .game-title {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(1.1rem, 4vw, 1.6rem);
    line-height: 1.5;
    color: var(--neon);
    text-shadow:
      0 0 10px var(--neon),
      0 0 30px rgba(0,245,255,.4),
      4px 4px 0 #003a40;
    margin-bottom: .5rem;
    letter-spacing: 3px;
  }

  .game-sub {
    font-family: 'Press Start 2P', monospace;
    font-size: .4rem; letter-spacing: .1em;
    color: var(--pink);
    text-shadow: 0 0 8px var(--pink);
  }

  /* Score / lives bar */
  .hud {
    display: flex; justify-content: space-between; align-items: center;
    margin: 1.5rem 0 1rem;
    padding: .7rem 1rem;
    background: var(--navy2);
    border: 2px solid var(--dim2);
    border-radius: 4px;
    image-rendering: pixelated;
  }
  .hud-item { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
  .hud-label {
    font-family: 'Press Start 2P', monospace;
    font-size: .38rem; color: var(--dim); letter-spacing: .1em;
  }
  .hud-val {
    font-family: 'Press Start 2P', monospace;
    font-size: .75rem; color: var(--yellow);
    text-shadow: 0 0 8px rgba(255,230,0,.5);
  }
  .hud-val.green { color: var(--green); text-shadow: 0 0 8px rgba(0,255,136,.5); }
  .hud-val.pink  { color: var(--pink);  text-shadow: 0 0 8px rgba(255,45,120,.5); }

  /* XP bar */
  .xp-wrap { margin-bottom: 1.8rem; }
  .xp-label-row {
    display: flex; justify-content: space-between;
    margin-bottom: .4rem;
  }
  .xp-label {
    font-family: 'Press Start 2P', monospace;
    font-size: .38rem; color: var(--neon); letter-spacing: .1em;
  }
  .xp-bar-outer {
    height: 14px;
    background: var(--dim2);
    border: 2px solid var(--dim);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
  }
  .xp-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, var(--neon), var(--green));
    border-radius: 1px;
    transition: width .6s cubic-bezier(.16,1,.3,1);
    box-shadow: 0 0 14px rgba(0,245,255,.6);
    position: relative;
  }
  .xp-bar-inner::after {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
      90deg, transparent 0px, transparent 8px, rgba(255,255,255,.15) 8px, rgba(255,255,255,.15) 10px
    );
  }

  /* ── PANEL (chunky border) ── */
  .panel {
    background: var(--card);
    border: 3px solid var(--dim2);
    border-radius: 8px;
    box-shadow: 6px 6px 0 var(--dim2), inset 0 1px 0 rgba(255,255,255,.05);
    padding: 1.4rem;
    margin-bottom: 1.2rem;
    position: relative;
  }
  .panel-title {
    font-family: 'Press Start 2P', monospace;
    font-size: .45rem; letter-spacing: .12em; text-transform: uppercase;
    color: var(--dim); margin-bottom: 1rem;
  }

  /* ── PRIORITY SELECTOR ── */
  .pri-row { display: flex; gap: .5rem; flex-wrap: wrap; }
  .pri-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: .4rem; letter-spacing: .08em;
    padding: .5rem .8rem;
    background: var(--navy2); color: var(--dim);
    border: 2px solid var(--dim2);
    border-radius: 3px; cursor: pointer;
    transition: all .15s; box-shadow: 3px 3px 0 var(--dim2);
  }
  .pri-btn:active { box-shadow: 1px 1px 0 var(--dim2); transform: translate(2px,2px); }
  .pri-btn[data-p="easy"].sel   { background:#001a0d; border-color:var(--green); color:var(--green); box-shadow:3px 3px 0 #003322, 0 0 12px rgba(0,255,136,.2); }
  .pri-btn[data-p="normal"].sel { background:#1a1600; border-color:var(--yellow); color:var(--yellow); box-shadow:3px 3px 0 #332c00, 0 0 12px rgba(255,230,0,.2); }
  .pri-btn[data-p="hard"].sel   { background:#1a0010; border-color:var(--pink); color:var(--pink); box-shadow:3px 3px 0 #330020, 0 0 12px rgba(255,45,120,.2); }
  .pri-btn[data-p="boss"].sel   { background:#0f0021; border-color:var(--purple); color:var(--purple); box-shadow:3px 3px 0 #200040, 0 0 12px rgba(185,79,255,.2); }

  /* ── INPUT ROW ── */
  .input-row { display: flex; gap: .6rem; }
  .mission-input {
    flex: 1;
    background: var(--navy2); color: var(--white);
    border: 2px solid var(--dim2);
    border-radius: 4px; padding: .8rem 1rem;
    font-family: 'Nunito', sans-serif;
    font-size: .95rem; font-weight: 600;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    box-shadow: inset 0 2px 6px rgba(0,0,0,.3);
  }
  .mission-input::placeholder { color: var(--dim); }
  .mission-input:focus {
    border-color: var(--neon);
    box-shadow: 0 0 0 3px rgba(0,245,255,.1), inset 0 2px 6px rgba(0,0,0,.3);
  }
  .add-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: .5rem; letter-spacing: .05em;
    padding: .8rem 1rem;
    background: var(--pink); color: #fff;
    border: 2px solid #ff6fa0; border-radius: 4px;
    cursor: pointer; white-space: nowrap;
    box-shadow: 4px 4px 0 #880030, 0 0 16px rgba(255,45,120,.3);
    transition: all .12s;
  }
  .add-btn:hover { background: #ff4d8e; box-shadow: 4px 4px 0 #880030, 0 0 24px rgba(255,45,120,.5); }
  .add-btn:active { transform: translate(3px,3px); box-shadow: 1px 1px 0 #880030; }

  /* ── FILTER TABS ── */
  .filter-row { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
  .ftab {
    font-family: 'Press Start 2P', monospace;
    font-size: .38rem; letter-spacing: .06em;
    padding: .45rem .75rem;
    background: var(--navy2); color: var(--dim);
    border: 2px solid var(--dim2); border-radius: 3px;
    cursor: pointer;
    box-shadow: 2px 2px 0 var(--dim2);
    transition: all .12s;
  }
  .ftab:hover { color: var(--white); border-color: var(--dim); }
  .ftab:active { transform: translate(2px,2px); box-shadow: none; }
  .ftab.on {
    background: var(--neon); color: #000;
    border-color: #00c8d8;
    box-shadow: 3px 3px 0 #004a55, 0 0 14px rgba(0,245,255,.3);
    font-weight: 700;
  }

  /* ── MISSION LIST ── */
  #missionList { list-style: none; display: flex; flex-direction: column; gap: .6rem; min-height: 40px; }

  /* ── MISSION ITEM ── */
  .mission-item {
    display: flex; align-items: center; gap: .9rem;
    padding: .85rem 1rem;
    background: var(--navy2);
    border: 2px solid var(--dim2);
    border-radius: 5px;
    box-shadow: 3px 3px 0 var(--dim2);
    transition: transform .15s, box-shadow .15s, border-color .2s;
    animation: missionIn .35s cubic-bezier(.16,1,.3,1) both;
    position: relative; overflow: hidden;
  }
  .mission-item::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  }
  .mission-item[data-p="easy"]::before   { background: var(--green); box-shadow: 0 0 8px var(--green); }
  .mission-item[data-p="normal"]::before { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
  .mission-item[data-p="hard"]::before   { background: var(--pink); box-shadow: 0 0 8px var(--pink); }
  .mission-item[data-p="boss"]::before   { background: var(--purple); box-shadow: 0 0 8px var(--purple); }

  .mission-item:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 var(--dim2); }
  .mission-item.done  { opacity: .45; }
  .mission-item.done .mission-text { text-decoration: line-through; color: var(--dim); }
  .mission-item.removing { animation: missionOut .3s forwards; }

  @keyframes missionIn {
    from { opacity:0; transform: translateX(-30px) scale(.95); }
    to   { opacity:1; transform: none; }
  }
  @keyframes missionOut {
    to { opacity:0; transform: translateX(40px) scale(.9); }
  }

  /* Checkbox */
  .chk {
    width: 24px; height: 24px; flex-shrink: 0;
    border: 2px solid var(--dim);
    border-radius: 3px; background: var(--navy);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem; color: transparent;
    transition: all .15s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,.4);
  }
  .chk:hover { border-color: var(--neon); }
  .mission-item.done .chk {
    background: var(--green); border-color: var(--green);
    color: #000; box-shadow: 0 0 10px rgba(0,255,136,.4);
    animation: popIn .2s cubic-bezier(.16,1,.3,1);
  }
  @keyframes popIn { from{transform:scale(.5)} to{transform:scale(1)} }

  .mission-text {
    flex: 1; font-size: .95rem; font-weight: 700;
    color: var(--white); line-height: 1.4; word-break: break-word;
  }

  .item-right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
  .diff-badge {
    font-family: 'Press Start 2P', monospace;
    font-size: .32rem; padding: .25rem .45rem;
    border-radius: 2px; opacity: .9;
  }
  .diff-badge.easy   { background: rgba(0,255,136,.12); color: var(--green); border:1px solid rgba(0,255,136,.3); }
  .diff-badge.normal { background: rgba(255,230,0,.1);  color: var(--yellow);border:1px solid rgba(255,230,0,.3); }
  .diff-badge.hard   { background: rgba(255,45,120,.1); color: var(--pink);  border:1px solid rgba(255,45,120,.3); }
  .diff-badge.boss   { background: rgba(185,79,255,.1); color: var(--purple);border:1px solid rgba(185,79,255,.3); }

  .del-btn {
    width: 28px; height: 28px; flex-shrink: 0;
    background: rgba(255,45,120,.1); border: 1px solid rgba(255,45,120,.25);
    border-radius: 3px; color: rgba(255,45,120,.5);
    cursor: pointer; font-size: .85rem;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s; opacity: 0;
  }
  .mission-item:hover .del-btn { opacity: 1; }
  .del-btn:hover { background: rgba(255,45,120,.25); color: var(--pink); border-color: var(--pink); transform: scale(1.1); }

  /* ── EMPTY STATE ── */
  .empty {
    display: none; flex-direction: column; align-items: center; gap: 1rem;
    padding: 3rem 1rem; text-align: center;
  }
  .empty.show { display: flex; }
  .empty-sprite {
    font-size: 2.8rem;
    animation: float 2s ease-in-out infinite;
  }
  @keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
  .empty-msg {
    font-family: 'Press Start 2P', monospace;
    font-size: .55rem; color: var(--dim); letter-spacing: .1em; line-height: 2;
  }

  /* ── CLEAR BTN ── */
  .bottom-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: .8rem;
  }
  .list-count {
    font-family: 'Press Start 2P', monospace;
    font-size: .38rem; color: var(--dim); letter-spacing: .1em;
  }
  .clear-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: .38rem; letter-spacing: .05em;
    color: var(--dim); background: none; border: none;
    cursor: pointer; transition: color .15s;
    padding: .3rem .5rem;
  }
  .clear-btn:hover { color: var(--pink); }

  /* ── FOOTER ── */
  .footer {
    margin-top: 2rem; text-align: center;
    font-family: 'Press Start 2P', monospace;
    font-size: .35rem; color: var(--dim2);
    line-height: 2.2; letter-spacing: .06em;
  }
  .footer span { color: var(--pink); }
  .footer .neon { color: var(--neon); }

  /* ── TOAST ── */
  .toast {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(80px);
    font-family: 'Press Start 2P', monospace; font-size: .45rem; letter-spacing: .08em;
    padding: .7rem 1.4rem;
    background: var(--card); border: 2px solid var(--neon);
    border-radius: 4px; color: var(--neon);
    box-shadow: 4px 4px 0 #004a55, 0 0 20px rgba(0,245,255,.3);
    z-index: 9995; white-space: nowrap;
    transition: transform .4s cubic-bezier(.16,1,.3,1), opacity .4s;
    opacity: 0;
  }
  .toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

  /* ── EXPLOSION ── */
  .spark {
    position: fixed; pointer-events: none; z-index: 9997;
    border-radius: 50%;
    animation: explode var(--t) ease-out forwards;
  }
  @keyframes explode {
    0%   { transform: translate(0,0) scale(1); opacity:1; }
    100% { transform: translate(var(--dx),var(--dy)) scale(0); opacity:0; }
  }

  /* ── MOBILE ── */
  @media(max-width:480px) {
    .game-title { font-size: .9rem; }
    .hud-val { font-size: .55rem; }
    .pri-row { gap: .3rem; }
    .pri-btn { padding: .4rem .6rem; }
  }