* { box-sizing: border-box; }

  html, body { height: 100%; }
  html {
    background: #5a8edd url('../../Windows XP Background.svg') center center / cover no-repeat fixed;
  }
  body {
    margin: 0;
    min-height: 100vh;
    background: transparent;
    font-family: Tahoma, "Segoe UI", "MS Sans Serif", Arial, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    overscroll-behavior: contain;
    color: #000;
  }

  @media (max-width: 700px) {
    body { padding: 4px; align-items: flex-start; }
  }

  /* ─── Canonical XP window chrome — exact match for index.html ───
     Every game uses the same chrome values so dashboard → game looks
     like one app. Update the dashboard's chrome and re-paste this
     block into every game's CSS if you change anything here. */
  .xp-window {
    background: linear-gradient(to bottom, #0058e6 0%, #245edb 9%, #245edb 100%);
    border-radius: 8px 8px 0 0;
    padding: 0 3px 3px;
    box-shadow: 0 0 0 1px #003a99, 0 18px 32px rgba(0,0,0,0.35);
    overflow: hidden;
    max-width: 100%;
  }
  @media (min-width: 700px) {
    .xp-window { min-width: 640px; }
  }
  .xp-titlebar {
    background: linear-gradient(to bottom,
      #0058e6 0%, #3893ff 3%, #1d72e0 9%, #0c5fd5 50%, #045fda 90%, #0455b7 100%);
    color: #ffffff;
    font-weight: bold; font-size: 13px;
    padding: 3px 4px 3px 6px;
    height: 28px;
    display: flex; align-items: center; justify-content: space-between;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.35);
    border-radius: 6px 6px 0 0;
  }
  .xp-titlebar-left {
    flex: 1 1 auto;
    display: flex; align-items: center; gap: 6px;
    min-width: 0; overflow: hidden;
  }
  .xp-titlebar-left > span:last-child {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .xp-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; flex-shrink: 0;
  }
  .xp-icon svg { display: block; }
  .xp-titlebar-buttons { display: flex; gap: 2px; flex-shrink: 0; }
  .xp-tb-btn {
    width: 22px; height: 22px;
    background: linear-gradient(to bottom, #4791ed 0%, #2772d4 50%, #205fc4 100%);
    color: #ffffff;
    border: 1px solid rgba(0,0,0,0.55);
    border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
    cursor: default;
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.55),
      inset 0 -1px 0 rgba(0,0,0,0.18);
  }
  .xp-tb-btn svg { display: block; }
  .xp-tb-btn:hover { filter: brightness(1.1); }
  a.xp-tb-btn { text-decoration: none; }
  .xp-tb-btn.close {
    background: linear-gradient(to bottom, #e96d65 0%, #c93630 50%, #9d1410 100%);
    border-color: #500000;
  }
  .xp-menubar {
    background: linear-gradient(to bottom, #faf9f4 0%, #ece9d8 100%);
    padding: 2px 4px;
    display: flex; gap: 0;
    border-bottom: 1px solid #d4d0c8;
    /* Pin the font so the bar reads identically across every game. */
    font-family: Tahoma, "Segoe UI", "MS Sans Serif", Arial, sans-serif;
    font-size: 11px;
  }
  .xp-menubar span {
    padding: 3px 8px;
    cursor: default; user-select: none;
    border-radius: 3px;
    color: #000;
  }
  .xp-menubar span:hover { background: #316ac5; color: #ffffff; }
  .xp-menubar span u { text-underline-offset: 1px; }

  .xp-body {
    padding: 12px;
    background: #ece9d8;
    display: flex;
    gap: 14px;
  }

  @media (max-width: 700px) {
    .xp-body {
      flex-direction: column;
      padding: 6px;
      gap: 8px;
    }
    .side-panel {
      width: 100% !important;
      flex-direction: row !important;
      flex-wrap: wrap;
      gap: 6px !important;
    }
    .side-panel .info-group {
      flex: 1 1 45%;
      min-width: 120px;
      padding: 6px;
    }
    .side-panel .xp-btn {
      flex: 1 1 45%;
    }
    #board {
      width: 100% !important;
      max-width: 360px;
      height: auto !important;
      aspect-ratio: 1 / 2;
      display: block;
      margin: 0 auto;
    }
    .game-panel { padding: 4px; }
    .controls-hint { display: none; }
    .info-group h3 { font-size: 10px; }
    .info-row { font-size: 12px; }
  }

  /* ---------- Game Layout ---------- */
  .game-panel, .side-panel {
    background: #fff;
    border: 1px solid #919b9c;
    border-top-color: #91a0a4;
    box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #d4d0c8;
    padding: 6px;
  }

  .game-panel { position: relative; }

  /* ---------- Robot (stands in the side panel, tosses each capsule) ---------- */
  .robot-bay {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 10px 8px 6px;
    min-height: 172px;
  }
  .doctor {
    position: relative;
    width: 118px;
    max-width: 100%;
    margin: 0 auto;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s;
    transform-origin: 50% 100%;
    filter: drop-shadow(0 3px 3px rgba(0,0,0,0.3));
  }
  .doctor.show { opacity: 1; }
  .doctor > svg { display: block; width: 100%; height: auto; animation: robotIdle 2.6s ease-in-out infinite; }
  @keyframes robotIdle {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-2px); }
  }
  .doctor .rb-led { animation: ledPulse 1.3s ease-in-out infinite; }
  @keyframes ledPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
  }
  .doctor.throwing { animation: docThrow 0.45s ease-out; }
  @keyframes docThrow {
    0%   { transform: rotate(0deg); }
    30%  { transform: rotate(-11deg); }
    60%  { transform: rotate(4deg); }
    100% { transform: rotate(0deg); }
  }
  /* the throwing arm swings down as the capsule leaves the hand */
  .doctor .doc-arm { transform-box: view-box; transform-origin: 52px 48px; }
  .doctor.throwing .doc-arm { animation: docArm 0.45s ease-out; }
  @keyframes docArm {
    0%   { transform: rotate(0deg); }
    25%  { transform: rotate(-26deg); }
    60%  { transform: rotate(34deg); }
    100% { transform: rotate(0deg); }
  }
  /* the tossed capsule flies from the hand toward the flask mouth */
  /* The capsule that flies from the robot's hand into the jar's neck.
     Position-fixed so it can travel across panels; driven from JS. */
  #toss-fx {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 60;
    pointer-events: none;
    opacity: 0;
    will-change: transform, opacity;
  }
  #toss-fx svg { display: block; }

  /* ---------- Level-clear celebration ---------- */
  #level-clear {
    position: absolute;
    inset: 0;
    z-index: 80;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  #level-clear.active { display: flex; }
  #level-clear::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 40, 0.62);
    animation: lcHue 1s ease-in-out infinite alternate;
  }
  @keyframes lcHue {
    from { background: rgba(10, 10, 40, 0.62); }
    to   { background: rgba(36, 0, 54, 0.62); }
  }
  .lc-rays {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200vmax;
    height: 200vmax;
    margin: -100vmax 0 0 -100vmax;
    background: repeating-conic-gradient(from 0deg,
      rgba(255, 255, 255, 0.16) 0deg 7deg, transparent 7deg 14deg);
    animation: lcSpin 9s linear infinite;
  }
  @keyframes lcSpin { to { transform: rotate(360deg); } }
  .lc-confetti { position: absolute; inset: 0; pointer-events: none; }
  .lc-confetti i {
    position: absolute;
    top: -24px;
    width: 10px;
    height: 14px;
    border-radius: 2px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
    animation: lcFall 1.6s linear infinite;
  }
  @keyframes lcFall {
    0%   { transform: translateY(-24px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(104vh) rotate(560deg); opacity: 0.85; }
  }
  .lc-card {
    position: relative;
    text-align: center;
    animation: lcPop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1);
  }
  @keyframes lcPop {
    from { transform: scale(0.3); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
  }
  .lc-title {
    font-family: Tahoma, "Segoe UI", sans-serif;
    font-weight: bold;
    font-size: 32px;
    white-space: nowrap;
    color: #fff;
    letter-spacing: 1px;
    text-shadow: 0 0 12px #39d3e6, 2px 2px 0 #0a2a6a, -1px -1px 0 #9b3fd6;
    animation: lcBounce 0.7s ease-in-out infinite alternate;
  }
  @keyframes lcBounce {
    from { transform: translateY(2px) scale(1); }
    to   { transform: translateY(-8px) scale(1.04); }
  }
  .lc-sub {
    margin-top: 10px;
    font: bold 15px Tahoma, sans-serif;
    color: #ffe9a8;
    text-shadow: 1px 1px 0 #0a2a6a;
  }
  @media (max-width: 700px) {
    .lc-title { font-size: 24px; }
  }
  @media (max-width: 700px) {
    .robot-bay { min-height: 0; }
    .doctor { width: 96px; }
  }

  #board {
    display: block;
    background: #1a1a2e;
    border: 2px inset #aca899;
  }

  .side-panel {
    width: 180px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .info-group {
    background: #ece9d8;
    border: 1px solid #919b9c;
    box-shadow: inset 1px 1px 0 #fff;
    padding: 8px;
  }
  .info-group h3 {
    margin: 0 0 6px 0;
    font-size: 11px;
    font-weight: bold;
    color: #0058e6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #d4d0c8;
    padding-bottom: 3px;
  }
  .info-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin: 3px 0;
    font-family: "Tahoma", sans-serif;
  }
  .info-row b { color: #0058e6; }

  .legend-row {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    margin: 4px 0;
    font-family: "Tahoma", sans-serif;
  }
  .legend-swatch {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.5);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.45);
    flex-shrink: 0;
  }

  #next-canvas {
    display: block;
    background: #1a1a2e;
    margin: 0 auto;
    border: 1px inset #aca899;
  }

  /* ---------- XP Buttons ---------- */
  .xp-btn {
    background: linear-gradient(180deg,
      #fdfdfd 0%,
      #f3f1e6 45%,
      #e2dfcf 50%,
      #f3f1e6 100%);
    border: 1px solid #003c74;
    border-radius: 3px;
    padding: 4px 14px;
    font-family: "Tahoma", sans-serif;
    font-size: 12px;
    color: #000;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px #fff;
  }
  .xp-btn:hover:not(:disabled) {
    background: linear-gradient(to bottom,
      #fff7d2 0%, #ffe589 45%, #ffb04a 55%, #ffa12d 100%);
    border-color: #c66902;
  }
  .xp-btn:active:not(:disabled) {
    background: linear-gradient(to bottom, #d6d2c2 0%, #ddd9c0 45%, #ece9d8 55%, #f6f6f6 100%);
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.2);
  }
  .xp-btn:disabled { opacity: 0.5; cursor: not-allowed; }

  .controls-hint {
    font-size: 10px;
    color: #555;
    line-height: 1.5;
  }
  .controls-hint kbd {
    background: #ece9d8;
    border: 1px solid #919b9c;
    padding: 1px 4px;
    border-radius: 2px;
    font-family: "Tahoma";
    font-size: 9px;
    box-shadow: 1px 1px 0 #aca899;
  }

  .touch-hint {
    display: none;
    font-size: 11px;
    color: #333;
    line-height: 1.7;
  }
  .touch-hint b { color: #0058e6; }
  @media (max-width: 700px), (pointer: coarse) {
    .touch-hint { display: block; }
  }

  /* ---------- Status Bar ---------- */
  .xp-statusbar {
    background: #ece9d8;
    border-top: 1px solid #919b9c;
    padding: 3px 8px;
    font-size: 11px;
    color: #333;
    display: flex;
    justify-content: space-between;
  }
  .status-cell {
    border-right: 1px solid #aca899;
    padding-right: 8px;
    margin-right: 8px;
  }
  .status-cell:last-child { border-right: none; }

  /* ---------- Quiz Modal (XP dialog style) ---------- */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
  }
  .modal-overlay.active { display: flex; }

  .xp-dialog {
    background: #ece9d8;
    border: 1px solid #0831d9;
    border-radius: 8px 8px 0 0;
    box-shadow: 5px 5px 20px rgba(0,0,0,0.5);
    min-width: 420px;
    max-width: 480px;
    animation: dialogPop 0.18s ease-out;
  }

  @media (max-width: 700px) {
    .xp-dialog {
      min-width: 0;
      width: calc(100vw - 20px);
      max-width: calc(100vw - 20px);
      margin: 10px;
    }
    .dialog-body { padding: 12px; gap: 10px; }
    .dialog-icon { width: 32px; height: 32px; font-size: 18px; }
    .dialog-content h2 { font-size: 13px; }
    .answer-list li {
      padding: 12px 10px !important;
      font-size: 14px !important;
    }
  }
  @keyframes dialogPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }
  .xp-dialog .xp-titlebar { border-radius: 6px 6px 0 0; }

  .dialog-body {
    padding: 16px 18px;
    display: flex;
    gap: 14px;
  }
  .dialog-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: radial-gradient(circle at 35% 35%, #fff, #4a93ff 60%, #0042b0);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    font-weight: bold;
    box-shadow: 1px 2px 4px rgba(0,0,0,0.3);
  }
  .dialog-content { flex: 1; }
  .dialog-content h2 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #000;
  }
  .dialog-content p {
    margin: 0 0 12px 0;
    font-size: 13px;
    line-height: 1.4;
  }
  .answer-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .answer-list li {
    background: #fff;
    border: 1px solid #919b9c;
    padding: 7px 10px;
    cursor: pointer;
    font-size: 12px;
    border-radius: 2px;
    transition: background 0.1s;
  }
  .answer-list li:hover {
    background: #d4e3fc;
    border-color: #316ac5;
  }
  .answer-list li.correct {
    background: #c8f0c8;
    border-color: #2e7d32;
    color: #1b5e20;
    font-weight: bold;
  }
  .answer-list li.wrong {
    background: #f8c8c8;
    border-color: #c01818;
    color: #8b0000;
  }

  /* Quiz countdown timer */
  .quiz-timer-wrap {
    margin-bottom: 10px;
    background: #fff;
    border: 1px inset #aca899;
    height: 18px;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
  }
  .quiz-timer-bar {
    height: 100%;
    background: linear-gradient(180deg, #6fdc6f 0%, #2c8f2c 100%);
    width: 100%;
    transition: width 0.1s linear, background 0.3s;
  }
  .quiz-timer-bar.warning {
    background: linear-gradient(180deg, #ffc04c 0%, #d97c00 100%);
  }
  .quiz-timer-bar.danger {
    background: linear-gradient(180deg, #ff6b6b 0%, #c01818 100%);
    animation: pulse 0.4s ease-in-out infinite alternate;
  }
  @keyframes pulse {
    from { opacity: 0.7; }
    to { opacity: 1; }
  }
  .quiz-timer-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    color: #000;
    text-shadow: 0 0 2px rgba(255,255,255,0.8);
  }
  .dialog-footer {
    background: #ece9d8;
    border-top: 1px solid #aca899;
    padding: 8px 14px;
    text-align: right;
    font-size: 11px;
    color: #555;
  }

  /* ---------- Game Over (XP-style dialog inside the board) ---------- */
  .gameover-overlay {
    position: absolute;
    inset: 6px;
    background: rgba(0,0,0,0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 10px;
  }
  .gameover-overlay.active { display: flex; }
  .gameover-dialog {
    width: 100%;
    max-width: 260px;
    background: linear-gradient(to bottom, #0058e6 0%, #245edb 9%, #245edb 100%);
    border-radius: 6px 6px 0 0;
    padding: 0 3px 3px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.55);
    color: #000;
    font-family: Tahoma, "Segoe UI", "MS Sans Serif", Arial, sans-serif;
  }
  .gameover-titlebar {
    background: linear-gradient(to bottom,
      #0058e6 0%, #3893ff 3%, #1d72e0 9%, #0c5fd5 50%, #045fda 90%, #0455b7 100%);
    color: #fff;
    font-weight: bold;
    font-size: 12px;
    padding: 4px 8px;
    height: 26px;
    border-radius: 4px 4px 0 0;
    display: flex; align-items: center; gap: 6px;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.35);
  }
  .gameover-icon { display: inline-flex; align-items: center; }
  .gameover-icon svg { display: block; }
  .gameover-title-label { flex: 1; }
  .gameover-body {
    background: #ece9d8;
    padding: 14px 16px 12px;
    text-align: center;
  }
  .gameover-headline {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: bold;
    color: #003399;
  }
  .gameover-stat {
    margin: 2px 0;
    font-size: 11px;
    color: #000;
  }
  .gameover-newbest {
    display: none;
    margin: 8px 0 0;
    padding: 4px 8px;
    background: linear-gradient(to bottom, #fffbe1 0%, #fff5b3 100%);
    border: 1px solid #c08000;
    border-radius: 2px;
    font-size: 11px;
    font-weight: bold;
    color: #6a4400;
  }
  .gameover-newbest.show { display: block; }
  .gameover-footer {
    background: linear-gradient(to bottom, #f7f6ef 0%, #ece9d8 100%);
    border-top: 1px solid #d4d0c8;
    box-shadow: inset 0 1px 0 #fff;
    padding: 8px 10px;
    text-align: center;
  }
  .gameover-footer .xp-btn {
    min-width: 90px;
    font-size: 11px;
  }

  /* ─── Start / intro overlay (matches Bit Boost & Keyword Outbreak) ─── */
  .overlay {
    position: absolute;
    inset: 6px;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    z-index: 20;
  }
  .overlay.hidden { display: none; }
  .overlay-card {
    background: linear-gradient(to bottom, #0058e6 0%, #245edb 9%, #245edb 100%);
    border-radius: 6px 6px 0 0;
    padding: 0 3px 3px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.55);
    max-width: 280px;
    width: 100%;
  }
  .overlay-card > * { background: #ece9d8; }
  .overlay-card > *:first-child {
    background: linear-gradient(to bottom,
      #0058e6 0%, #3893ff 3%, #1d72e0 9%, #0c5fd5 50%, #045fda 90%, #0455b7 100%);
    color: #fff;
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.35);
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px 4px 0 0;
  }
  .overlay-card .oc-title { text-align: left; }
  .overlay-card .oc-sub {
    padding: 14px 16px 6px;
    font-size: 12px;
    color: #003399;
    text-align: center;
    line-height: 1.45;
  }
  .overlay-card ul.oc-controls {
    list-style: none;
    margin: 0; padding: 8px 16px;
    font-size: 11px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
  }
  .overlay-card ul.oc-controls li { display: flex; align-items: center; gap: 4px; }
  .overlay-card ul.oc-controls kbd {
    background: #fff;
    border: 1px solid #aca899;
    border-radius: 2px;
    padding: 1px 5px;
    font: 10px Tahoma, sans-serif;
    box-shadow: 1px 1px 0 #888;
  }
  .overlay-card .xp-btn {
    display: block;
    margin: 14px auto 14px;
    min-width: 160px;
  }
  .overlay-card .xp-btn.primary {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 0 0 1px #0855c4;
    font-weight: bold;
  }

  /* tiny XP-style start button look for fun */
  .xp-start-tag {
    display: inline-block;
    background: linear-gradient(180deg, #3ca33c 0%, #2c8f2c 50%, #207020 100%);
    color: white;
    font-style: italic;
    font-weight: bold;
    padding: 2px 12px 2px 8px;
    border-radius: 0 12px 12px 0;
    font-size: 11px;
    box-shadow: inset 1px 1px 0 rgba(255,255,255,0.3);
    margin-right: 4px;
  }