* { 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; }
  }

  /* ---------- XP Window Chrome ---------- */
  .xp-window {
    background: #ece9d8;
    border: 1px solid #0831d9;
    border-radius: 8px 8px 0 0;
    box-shadow: 4px 4px 16px rgba(0,0,0,0.4);
    overflow: hidden;
    max-width: 100%;
  }

  @media (min-width: 700px) {
    .xp-window { min-width: 640px; }
  }

  .xp-titlebar {
    background: linear-gradient(180deg,
      #0058e6 0%,
      #3a93ff 8%,
      #1e6fdf 40%,
      #0058e6 88%,
      #0058e6 93%,
      #0042b0 100%);
    color: white;
    padding: 4px 6px 4px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: bold;
    font-size: 13px;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
    height: 28px;
  }
  .xp-titlebar-left { display: flex; align-items: center; gap: 6px; }
  .xp-icon {
    width: 16px; height: 16px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .xp-icon svg { display: block; }
  .xp-titlebar-buttons { display: flex; gap: 2px; }
  .xp-tb-btn {
    width: 22px; height: 22px;
    border-radius: 3px;
    background: linear-gradient(180deg, #3a93ff 0%, #0058e6 100%);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .xp-tb-btn.close {
    background: linear-gradient(180deg, #e96d65 0%, #c93630 50%, #9d1410 100%);
    border-color: #500000;
  }
  .xp-tb-btn:hover { filter: brightness(1.15); }
  a.xp-tb-btn { text-decoration: none; }

  .xp-menubar {
    background: #ece9d8;
    padding: 2px 6px;
    border-bottom: 1px solid #aca899;
    font-size: 12px;
    display: flex;
    gap: 4px;
  }
  .xp-menubar span {
    padding: 3px 8px;
    cursor: default;
    color: #000;
  }
  .xp-menubar span:hover { background: #316ac5; color: white; }

  .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; }

  #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; }

  #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 {
    background: linear-gradient(180deg,
      #fdfdfd 0%,
      #f7f5e8 45%,
      #e8e4d4 50%,
      #faf7e8 100%);
  }
  .xp-btn:active {
    background: linear-gradient(180deg, #e2dfcf 0%, #f3f1e6 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;
  }

  /* 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;
  }