:root {
  --blue: #336699;
  --blue2: #aac2da;
  --ink: #172235;
  --page: #eef4fb;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #fff 0%, var(--page) 100%);
}
.site-header {
  background: var(--blue);
  color: #fff;
  border-bottom: 4px solid var(--blue2);
}
.brand {
  width: min(1000px, calc(100% - 24px));
  margin: 0 auto;
  padding: 14px 0;
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo {
  background: #fff;
  color: var(--blue);
  border: 3px solid var(--blue2);
  border-radius: 10px;
  font-weight: 800;
  padding: 8px 10px;
}
h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.7rem); }
.site-header p { margin: 2px 0 0; color: #e9f2fb; }
.layout {
  width: min(1000px, calc(100% - 24px));
  margin: 18px auto 36px;
  display: grid;
  gap: 18px;
}
.game-card, .instructions {
  background: #fff;
  border: 2px solid #c8d6e7;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(30,55,90,.12);
}
.game-card {
  padding: 14px;
}
.status-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.status {
  flex: 1;
  min-height: 34px;
  border: 1px solid #b8c7d8;
  border-radius: 999px;
  background: rgba(255,255,255,.95);
  padding: 8px 14px;
  text-align: center;
  font-weight: 700;
}
.score-pill {
  min-width: 110px;
  text-align: center;
  color: #fff;
  background: var(--blue);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
}
.setup-panel {
  background: #f6f8fc;
  border: 1px solid #c8d6e7;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
}
.setup-line, .player-row, .controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 10px;
  align-items: center;
}
.player-rows {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.player-row {
  background: #fff;
  border: 1px solid #d6e1ee;
  border-radius: 10px;
  padding: 8px;
}
label {
  font-weight: 700;
}
input, select, button {
  font: inherit;
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid #91a8c2;
  padding: 6px 9px;
}
button {
  cursor: pointer;
  background: linear-gradient(#fff, #e6edf5);
  font-weight: 800;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }
.primary {
  color: #fff;
  background: linear-gradient(#477bb2, #285887);
  border-color: #1d456d;
}
.hidden { display: none !important; }
.canvas-shell {
  width: min(100%, 900px);
  margin: 0 auto;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 600 / 420;
  border: 3px solid #111;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  touch-action: none;
}
.controls {
  margin-top: 12px;
}
.hint {
  color: #34445c;
  background: rgba(255,255,255,.92);
  border: 1px solid #c8d6e7;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: .92rem;
}
.instructions {
  padding: 18px 22px;
  line-height: 1.5;
}
.instructions h2 { margin-top: 0; color: #244d76; }
@media (max-width: 720px) {
  .layout, .brand { width: min(100% - 12px, 1000px); }
  .game-card { padding: 8px; }
  .status-row { gap: 8px; align-items: stretch; }
  .status { font-size: .86rem; padding: 7px 10px; }
  .score-pill { min-width: 82px; padding: 7px 8px; }
  .hint { width: 100%; text-align: center; border-radius: 14px; }
  button { min-height: 42px; }
  .player-row input { max-width: 140px; }
  .instructions { padding: 14px; }
}


/* v2: level selector is only shown for computer players */
.player-row .level-label.hidden {
  display: none !important;
}


/* v7: mobile canvas uses a taller board-first layout */
@media (max-width: 720px), (pointer: coarse) {
  canvas {
    aspect-ratio: 600 / 880;
  }
  .canvas-shell {
    width: min(100%, 560px);
  }
}


/* v10: reduce mobile double-tap scroll/zoom feel while playing */
.canvas-shell,
canvas {
  touch-action: none;
  overscroll-behavior: contain;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}


/* v20: JGames standard header/footer + home badge */
body {
  position: relative;
  color: #162236;
}
.jgames-home-badge {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
  display: inline-flex;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 10px 28px rgba(10, 36, 76, .18);
  border: 1px solid rgba(0,0,0,.08);
  backdrop-filter: blur(2px);
}
.jgames-home-badge img {
  width: 48px;
  height: 48px;
  display: block;
}
.brand {
  padding-right: 76px;
}
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  min-height: 96px;
  padding: 10px;
}
.logo img {
  display: block;
  max-width: 72px;
  max-height: 72px;
  width: auto;
  height: auto;
  image-rendering: auto;
}
.footer {
  width: min(1000px, calc(100% - 24px));
  margin: 0 auto 36px;
  padding: 18px 18px 24px;
  background: #fff;
  border: 2px solid #c8d6e7;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(30,55,90,.12);
  text-align: center;
}
.footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 14px;
  margin-bottom: 14px;
}
.footer a {
  color: #244d76;
  text-decoration: none;
  font-weight: 700;
}
.footer a:hover,
.footer a:focus-visible {
  text-decoration: underline;
}
.footer p {
  margin: 8px 0 0;
  line-height: 1.45;
  color: #34445c;
}
.instructions p {
  margin-bottom: 0.95rem;
}
@media (max-width: 720px) {
  .jgames-home-badge {
    width: 56px;
    height: 56px;
    right: 10px;
    top: 10px;
    border-radius: 16px;
  }
  .jgames-home-badge img {
    width: 42px;
    height: 42px;
  }
  .brand {
    padding-right: 64px;
    gap: 10px;
  }
  .logo {
    min-width: 72px;
    min-height: 72px;
    padding: 8px;
  }
  .logo img {
    max-width: 54px;
    max-height: 54px;
  }
  .footer {
    width: min(100% - 12px, 1000px);
    padding: 14px 12px 18px;
    margin-bottom: 24px;
  }
}
