
  :root {
    color-scheme: dark;
    --bg: #0b0f14;
    --bg-panel: #0f172a;
    --bg-soft: #0b1220;
    --bg-elev: #111827;
    --ink: #e6eef8;
    --ink-dim: #c7d2fe;
    --border: #1f2937;
    --border-2: #334155;
    --brand: #2563eb;
    --brand-2: #1d4ed8;
    --ok: #34d399;
    --warn: #f59e0b;
    --err: #ef4444;
    --muted: #94a3b8;
    --focus: #22d3ee;
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
    background: radial-gradient(1200px 800px at 10% -10%, #0e1420 0%, #0b0f14 45%, #070a0f 100%);
    color: var(--ink);
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
  }

  header, footer {
    padding: 0.5rem 0.75rem;
    background: linear-gradient(180deg, #111827, #0b0f14);
    border-bottom: 1px solid var(--border);
  }
  footer { border-top: 1px solid var(--border); border-bottom: none; text-align: center; font-size: 0.85rem; opacity: 0.85; }

  .topbar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem;
    align-items: center;
  }
  .brand {
    display: flex; align-items: center; gap: 0.5rem; min-width: 0;
  }
  .brand h1 {
    margin: 0; font-size: 1rem; letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .brand .sub {
    font-size: 0.8rem; color: var(--muted); margin-left: 0.4rem;
  }
  .actions {
    display: flex; align-items: center; gap: 0.4rem; flex-wrap: nowrap;
  }
  .statusPills {
    display: flex; align-items: center; gap: 0.4rem; justify-content: flex-end; flex-wrap: wrap;
  }

  .btn {
    background: #172033; border: 1px solid var(--border-2); color: var(--ink);
    padding: 0.45rem 0.65rem; border-radius: 0.5rem; cursor: pointer;
    transition: transform 0.05s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease; user-select: none;
    font-size: 0.9rem; display: inline-flex; align-items: center; gap: 0.45rem;
  }
  .btn:hover { background: #1c2840; }
  .btn:hover {
  box-shadow: 0 0 12px rgba(59,130,246,0.5);
}
  .btn:active { transform: translateY(1px); }
  .btn:focus-visible { outline: none; box-shadow: 0 0 0 2px #0ea5e9; }
  .btn.primary { background: var(--brand); border-color: var(--brand-2); }
  .btn.primary:hover { background: var(--brand-2); }
  .btn.ghost { background: transparent; border-color: var(--border); }
  .iconBtn { padding: 0.35rem; width: 36px; height: 36px; justify-content: center; }
  .icon { display: inline-block; width: 18px; height: 18px; fill: currentColor; }

  .select, .range {
    background: #0f172a; border: 1px solid var(--border-2); color: var(--ink); padding: 0.4rem 0.55rem; border-radius: 0.5rem;
    font-size: 0.9rem;
  }
  .tag {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.2rem 0.55rem; border: 1px solid var(--border-2); background: var(--bg-soft);
    border-radius: 999px; font-size: 0.8rem; opacity: 0.95;
  }
  .pillRow { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
  .small { font-size: 0.85rem; opacity: 0.9; }
  .muted { color: var(--muted); }

  main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 0.5rem;
    min-height: 500px;
  }

  .panel {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 0.75rem; padding: 0.6rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25) inset, 0 1px 0 rgba(255,255,255,0.02);
  }

  .subbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem;
  }
  .leftControls, .rightControls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
  .inlineField { display: inline-flex; align-items: center; gap: 0.45rem; }

  #gamePanel { display: grid; gap: 0.6rem; }

  #canvasContainer {
    position: relative;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: linear-gradient(180deg, #05070a, #070a10);
    width: 100%;
    aspect-ratio: 25 / 17; /* updated dynamically */
    overflow: hidden;
  }

  #canvasContainer {
  box-shadow:
    0 0 30px rgba(56,189,248,0.15),
    inset 0 0 20px rgba(0,0,0,0.6);
}

  canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    border-radius: 0.75rem;

    /*added2*/
      mix-blend-mode: normal;
  }

  /*added2*/
@keyframes particleTrail {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.5); }
}


  .overlay {
    position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 8px;
    align-items: flex-end; pointer-events: none;
  }
  .pill {
    pointer-events: auto;
    display: inline-flex; align-items: center; gap: 0.45rem;
    background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(3px);
    border: 1px solid var(--border-2); color: var(--ink); padding: 0.28rem 0.6rem; border-radius: 999px; font-size: 0.85rem;
    box-shadow: 0 3px 14px rgba(0,0,0,0.35);
  }
  .lifeDots { display: inline-flex; gap: 5px; }
  .dot { width: 9px; height: 9px; border-radius: 999px; background: #223045; border: 1px solid #475569; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25); }
  .dot.live { background: #f87171; border-color: var(--err); }

  .squareWrap {
    pointer-events: auto;
    width: 58px; height: 58px; position: relative;
    display: grid; place-items: center;
    background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(3px);
    border: 1px solid var(--border-2); border-radius: 0.6rem;
    box-shadow: 0 3px 14px rgba(0,0,0,0.35);
  }
  .squareLabel { position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.85rem; }
  svg { display: block; }

  .pairTimerWrap {
    pointer-events: auto;
    width: 58px; height: 58px; position: relative;
    display: none; place-items: center;
    background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(3px);
    border: 1px solid var(--border-2); border-radius: 0.6rem;
    box-shadow: 0 3px 14px rgba(0,0,0,0.35);
  }
  .pairTimerWrap.show { display: grid; }
  .pairTimerLabel { position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.85rem; }

  .notice {
    border-left: 3px solid var(--brand); padding: 0.5rem 0.6rem; background: #0b1220;
    border: 1px solid var(--border); border-radius: 0.5rem; font-size: 0.9rem;
  }

  .staminaPill {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: var(--bg-soft); border: 1px solid var(--border-2); border-radius: 999px; padding: 0.25rem 0.6rem; font-size: 0.85rem;
  }
  .bar-bg {
    width: 110px; height: 10px; background: #1f2937; border-radius: 999px; overflow: hidden; border: 1px solid var(--border-2);
  }
  .bar-fg { height: 100%; width: 0%; background: linear-gradient(90deg, #34d399, #06b6d4); transition: width 0.12s ease; }

  .scorePill {
    display: inline-flex;
    align-items: center; gap: 0.4rem;
    background: var(--bg-soft); border: 1px solid var(--border-2); border-radius: 999px; padding: 0.25rem 0.65rem; font-size: 0.9rem;
  }

  #levelModal, #settingsModal, #helpModal {
    position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.55); z-index: 50;
  }
  .modalCard {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 0.75rem; padding: 0.85rem;
    width: 92%; max-width: 520px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.45);
  }

  .hr { border: none; border-top: 1px solid var(--border); margin: 0.6rem 0; }

  .hintMarquee {
    display: flex; gap: 0.4rem; align-items: center; color: var(--muted);
    font-size: 1.2rem;
  }
  .hintKey { background: #111827; border: 1px solid var(--border-2); border-bottom-width: 3px; padding: 0.12rem 0.4rem; border-radius: 0.4rem; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; font-size: 0.8rem; }

  .toast {
    position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(12px);
    background: rgba(16,23,41,0.9); color: var(--ink); border: 1px solid var(--border-2);
    padding: 0.45rem 0.7rem; border-radius: 999px; font-size: 0.9rem;
    opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 60; backdrop-filter: blur(3px);
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }



  /* added jan*/
#titleScreen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle,#0f172a,#020617);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  color: white;
  text-align: center;
  display:none;
}

#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30,41,59,0.9);
  color: white;
  padding: 12px 22px;
  border-radius: 12px;
  opacity: 0;
  transition: 0.4s;
  pointer-events: none;
  box-shadow: 0 0 15px rgba(56,189,248,0.3);
}

#toast.show {
  opacity: 1;
}

canvas {
  box-shadow:
    0 0 30px rgba(56,189,248,0.2),
    inset 0 0 20px rgba(0,0,0,0.6);
}

  @media (prefers-reduced-motion: reduce) {
    .btn, .bar-fg, .toast { transition: none; }
  }

  @media (min-width: 1024px) {
    main {
      grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr);
      grid-template-rows: 1fr;
      align-items: stretch;
    }
    #gamePanel { display: flex; flex-direction: column; min-height: 0; }
  }

  @media (max-width: 768px) {
    main { min-height: 400px; }
    .topbar {
      grid-template-columns: 1fr auto;
      grid-template-rows: auto auto;
      gap: 0.5rem;
    }
    .brand { grid-column: 1; grid-row: 1; }
    .actions { grid-column: 2; grid-row: 1; }
    .statusPills { grid-column: 1 / span 2; grid-row: 2; justify-content: center; margin-top: 0.25rem; }
    .subbar { flex-direction: column; align-items: stretch; gap: 0.6rem; }
    .leftControls, .rightControls { justify-content: center; width: 100%; }
    #canvasContainer { min-height: 260px; }
  }

  @media (max-width: 480px) {
    .panel { padding: 0.45rem; }
    .btn { padding: 0.38rem 0.55rem; font-size: 0.85rem; }
    .iconBtn { width: 34px; height: 34px; }
    .select, .range { font-size: 0.85rem; padding: 0.32rem 0.42rem; }
    .tag { font-size: 0.76rem; }
    #gamePanel { gap: 0.45rem; }
    .bar-bg { width: 86px; }
  }
