* { 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;
  font-size: 11px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  color: #000;
}

/* ─── XP window chrome ─── */
.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);
  width: 100%;
  max-width: 540px;
}

.xp-titlebar {
  background: linear-gradient(to bottom,
    #0058e6 0%, #3893ff 3%, #1d72e0 9%, #0c5fd5 50%, #045fda 90%, #0455b7 100%);
  color: #fff;
  padding: 3px 4px 3px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: bold;
  font-size: 13px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.35);
  height: 28px;
  border-radius: 6px 6px 0 0;
}
.xp-titlebar-left { display: flex; align-items: center; gap: 6px; }
.xp-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; }
.xp-icon svg { display: block; }
.xp-titlebar-buttons { display: flex; gap: 2px; }
.xp-tb-btn {
  width: 22px; height: 22px;
  background: linear-gradient(to bottom, #4791ed 0%, #2772d4 50%, #205fc4 100%);
  border: 1px solid rgba(0,0,0,0.55);
  border-radius: 3px;
  color: #fff;
  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.close {
  background: linear-gradient(to bottom, #e96d65 0%, #c93630 50%, #9d1410 100%);
  border-color: #500000;
}
.xp-tb-btn:hover { filter: brightness(1.12); }
a.xp-tb-btn { text-decoration: none; }

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

/* ─── Toolbar ─── */
.xp-toolbar {
  background: linear-gradient(to bottom, #f7f6ef 0%, #ece9d8 100%);
  padding: 5px 8px;
  border-bottom: 1px solid #d4d0c8;
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.toolbar-spacer { flex: 1; }
.toolbar-stat {
  font-size: 11px;
  color: #003399;
  background: #fff;
  border: 1px inset #aca899;
  padding: 2px 8px;
  border-radius: 2px;
  font-variant-numeric: tabular-nums;
}
.toolbar-stat b { color: #000; }

.xp-btn {
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  background: linear-gradient(to bottom,
    #f6f6f6 0%, #ece9d8 45%, #ddd9c0 55%, #d6d2c2 100%);
  border: 1px solid #003c74;
  border-radius: 3px;
  padding: 3px 12px;
  color: #000;
  cursor: pointer;
  min-width: 75px;
  min-height: 22px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), inset 0 -1px 0 rgba(0,0,0,0.05);
}
.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%);
}
.xp-btn.primary {
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 0 0 1px #0855c4;
  font-weight: bold;
}

/* ─── Game area ─── */
.game-area {
  position: relative;
  padding: 4px;
  background: #ece9d8;
}

/* ─── Question banner ─── */
.question-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 8px;
  margin-bottom: 6px;
  background: linear-gradient(to bottom, #f7faff 0%, #d8e3f7 100%);
  border: 1px solid #b5c4e6;
  border-radius: 3px;
  min-height: 42px;
}
.question-strip .qs-label {
  font-size: 10px;
  font-weight: bold;
  color: #003399;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.question-strip .qs-text {
  flex: 1;
  font-size: 12px;
  color: #003399;
  line-height: 1.3;
  min-width: 180px;
}
.question-strip .qs-slots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.question-strip .qs-slot {
  width: 22px; height: 28px;
  background: #fafaf6;
  border: 1px dashed #7f9db9;
  border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  font: bold 15px Tahoma, sans-serif;
  color: transparent;
  text-transform: uppercase;
}
.question-strip .qs-slot.filled {
  background: linear-gradient(to bottom, #fff5b3 0%, #ffd24a 50%, #d8a000 100%);
  color: #4a3000;
  border-style: solid;
  border-color: #6a4400;
  text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
}

/* ─── Canvas ─── */
#board {
  display: block;
  background: linear-gradient(to bottom, #050823 0%, #0e1444 50%, #1b1052 100%);
  border: 2px inset #aca899;
  /* Scale to fit the viewport while keeping the 480×720 aspect ratio.
     The internal canvas resolution stays 480×720 so JS coordinates and
     game logic don't change — only the display size shrinks/grows. */
  height: min(640px, calc(100vh - 190px));
  width:  auto;
  aspect-ratio: 480 / 720;
  max-width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  margin: 0 auto;
}

/* ─── Overlays ─── */
.overlay {
  position: absolute;
  inset: 10px;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.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: 420px;
  width: 100%;
  margin: 0 16px;
}
.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;
}
.overlay-card .oc-stat {
  padding: 4px 16px;
  font-size: 12px;
  color: #000;
  text-align: center;
}
.overlay-card .oc-stat b { color: #003399; }
.overlay-card ul.oc-controls {
  list-style: none;
  margin: 0; padding: 8px 18px;
  font-size: 11px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;
}
.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;
}

/* New-high-score banner on the game-over card */
.overlay-card .oc-new-best {
  text-align: center;
  font: bold 14px Tahoma, "Segoe UI", sans-serif;
  letter-spacing: 0.14em;
  color: #b07000;
  padding: 8px 16px 2px;
  text-shadow: 1px 1px 0 #fff5b3;
}

/* Definition overlay (shown on keyword completion) */
.overlay-card .def-word {
  text-align: center;
  font: bold 34px Tahoma, "Segoe UI", sans-serif;
  letter-spacing: 0.18em;
  padding: 14px 12px 6px;
  color: #b07000;
  text-shadow: 1px 1px 0 #fff5b3, 2px 2px 0 rgba(0,0,0,0.18);
}
.overlay-card .def-text {
  text-align: center;
  font-size: 13px;
  padding: 4px 18px 10px;
  color: #003399;
  line-height: 1.45;
}

/* ─── Status bar ─── */
.xp-statusbar {
  background: #ece9d8;
  border-top: 1px solid #919b9c;
  padding: 2px 8px;
  font-size: 11px;
  color: #333;
  display: flex;
  justify-content: space-between;
}
.status-cell { border-left: 1px solid #aca899; padding-left: 8px; margin-left: 8px; }
.xp-start-tag {
  display: inline-block;
  background: linear-gradient(to bottom, #3ca33c 0%, #2c8f2c 50%, #207020 100%);
  color: #fff;
  font-style: italic;
  font-weight: bold;
  padding: 2px 12px 2px 8px;
  border-radius: 0 12px 12px 0;
  font-size: 11px;
  margin-right: 4px;
}

@media (max-width: 540px) {
  body { padding: 4px; }
  .xp-toolbar { flex-wrap: wrap; gap: 4px; }
  #board { width: 100%; height: auto; aspect-ratio: 480 / 720; }
}
