:root {
  --ink: #1d3fbf;
  --ink-dark: #12277a;
  --paper: #fdfdf7;
  --grid: rgba(120, 150, 220, 0.28);
  --accent: #e8792b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif; color: #222; background: #2c2f38; }
h1, h2, .btn, .title, kbd, .hint, .keybar-item b { font-family: "Chalkboard SE", "Comic Sans MS", "Segoe Print", "Marker Felt", sans-serif; }
.hidden { display: none !important; }

/* ---------- ekrany na "kartce w kratkę" ---------- */
.screen {
  min-height: 100%; padding: 18px 28px 40px;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink-dark);
}
.title { text-align: center; font-size: 56px; letter-spacing: 6px; margin: 0 0 12px; color: var(--ink); text-decoration: underline; text-underline-offset: 10px; }
h2 { font-size: 22px; margin: 14px 0 8px; color: var(--ink); text-transform: uppercase; }
.cols { display: flex; gap: 28px; justify-content: center; flex-wrap: wrap; }
.col { min-width: 220px; max-width: 290px; flex: 1 1 250px; }
.mapcol { max-width: 340px; flex: 1 1 300px; }
.picker { list-style: none; padding: 0; margin: 0; }
.picker li {
  border: 2px solid var(--ink); padding: 6px 10px; margin: -2px 0 0; cursor: pointer; user-select: none;
  font-size: 18px; text-transform: uppercase; background: rgba(255,255,255,0.7); display: flex; justify-content: space-between; align-items: center;
}
.picker li:first-child { margin-top: 0; }
.picker li:hover { background: #eef2ff; }
.picker li.on { background: #dfe7ff; font-weight: bold; }
.picker li.on::after { content: "✓"; font-size: 22px; color: var(--ink); }
.picker li.disabled { opacity: 0.4; cursor: not-allowed; }
.picker li .badge { font-size: 13px; background: var(--ink); color: #fff; border-radius: 10px; padding: 1px 8px; margin-right: 8px; }
.picker.numbers li { justify-content: center; font-size: 20px; }
.picker.numbers li.on::after { content: ""; }
.picker li .sw { width: 22px; height: 14px; border: 1px solid #333; margin-right: 8px; display: inline-block; }
.hint { font-size: 16px; margin: 8px 0; color: var(--ink); }
.hint.small { font-family: inherit; font-size: 12px; text-transform: none; color: #556; }
.route-info { font-size: 14px; margin: 10px 0; min-height: 30px; line-height: 1.5; }
.route-info b { color: var(--ink); }
.btn {
  display: block; width: 100%; margin: 10px 0 0; padding: 10px 14px; font-size: 22px; letter-spacing: 2px;
  border: 3px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer; text-transform: uppercase;
  box-shadow: 3px 3px 0 var(--ink);
}
.btn:hover { background: #eef2ff; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.big { font-size: 44px; padding: 18px 10px 12px; margin-top: 16px; line-height: 1; }
.btn.big span { display: block; font-size: 16px; letter-spacing: 3px; margin-top: 6px; }
#trainPreview { width: 100%; height: auto; margin: 6px 0; }
#menuMap { width: 100%; height: auto; border: 2px solid var(--ink); background: #fff; }

/* ---------- jak grać ---------- */
.lead { text-align: center; font-size: 22px; font-family: "Chalkboard SE", "Comic Sans MS", sans-serif; }
.howto-cols { display: flex; gap: 40px; justify-content: center; flex-wrap: wrap; }
.howto-cols > div { max-width: 480px; }
.keys { list-style: none; padding: 0; font-size: 18px; }
.keys li { margin: 8px 0; text-transform: uppercase; }
kbd { display: inline-block; min-width: 40px; text-align: center; border: 2px solid var(--ink); padding: 3px 8px; margin-right: 10px; font-size: 18px; background: #fff; box-shadow: 2px 2px 0 var(--ink); }
kbd.wide { min-width: 120px; }
.rules { font-size: 17px; line-height: 1.6; }
.rules.plain { list-style: disc; }
.row { display: flex; gap: 20px; justify-content: center; max-width: 600px; margin: 20px auto 0; }
.row .btn { width: auto; min-width: 200px; }

/* ---------- gra ---------- */
#game { position: fixed; inset: 0; display: flex; flex-direction: column; background: #111; }
#keybar { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 12px; background: #1b1e26; color: #ddd; font-size: 13px; border-bottom: 2px solid #333; }
.keybar-item { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.keybar-item kbd { min-width: 26px; padding: 1px 6px; margin: 0; font-size: 13px; border-color: #999; box-shadow: 1px 1px 0 #999; background: #eee; color: #222; }
.keybar-item.active kbd { background: #ffd54a; border-color: #ffb300; box-shadow: 0 0 10px #ffd54a; }
.keybar-item.dim { opacity: 0.35; }
#gameCanvas { flex: 1 1 auto; width: 100%; height: 100%; display: block; cursor: default; }
.message {
  position: absolute; left: 50%; top: 60px; transform: translateX(-50%); max-width: 80%;
  background: rgba(255, 244, 180, 0.96); color: #222; border: 3px solid #e0a800; border-radius: 12px;
  padding: 10px 22px; font-size: 20px; font-family: "Chalkboard SE", "Comic Sans MS", sans-serif; text-align: center; box-shadow: 0 4px 18px rgba(0,0,0,0.4);
}
.message.red { background: rgba(255, 210, 210, 0.97); border-color: #d32f2f; }
.message.green { background: rgba(215, 250, 215, 0.97); border-color: #2e7d32; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.55); }
.panel { background: var(--paper); border: 4px solid var(--ink); padding: 24px 36px; min-width: 380px; max-width: 560px; text-align: center; color: var(--ink-dark); box-shadow: 6px 6px 0 var(--ink); }
.panel h2 { font-size: 34px; margin: 0 0 12px; }
.panel p { font-size: 18px; margin: 8px 0; }
.panel .stat { font-size: 20px; margin: 4px 0; }
.panel .stat b { color: var(--ink); font-size: 26px; }
.panel .btn { margin-top: 14px; }
