:root {
  --blue: #336699;
  --blue2: #aac2da;
  --ink: #172235;
  --page: #eef4fb;
  --purple: #4d00e7;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    url("back.gif"),
    linear-gradient(180deg, #ffffff 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: rgba(255,255,255,.96);
  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;
}
.start-panel {
  max-width: 760px;
  margin: 18px auto;
  padding: 18px;
  background: rgba(255,255,255,.96);
  border: 2px solid #111;
  border-radius: 12px;
}
.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.setup-box {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 14px;
  border: 1px solid #c5d0df;
  border-radius: 12px;
  background: #fff;
}
.setup-box h2 { margin: 0 0 4px; color: #244d76; font-size: 1.2rem; }
.setup-box label { display: grid; gap: 4px; font-weight: 700; }
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; }
.game-panel {
  display: grid;
  gap: 12px;
  justify-items: center;
}
.board-stack {
  width: min(100%, 820px);
  margin: 0 auto;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border: 3px solid #111;
  background: var(--purple);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  touch-action: none;
}
.column-buttons {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: 100%;
  gap: 0;
  padding-left: 6.25%;
  padding-right: 6.25%;
}
.column-buttons button {
  min-width: 0;
  min-height: 36px;
  padding-inline: 0;
  border-radius: 0;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 10px;
  align-items: center;
}
.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; }
  .setup-grid { grid-template-columns: 1fr; }
  .start-panel { padding: 12px; margin: 8px auto; }
  button { min-height: 42px; }
  .board-stack {
    width: min(100%, calc(100vh - 260px));
  }
  .column-buttons {
    padding-left: 6.25%;
    padding-right: 6.25%;
    gap: 0;
  }
  .column-buttons button {
    min-height: 30px;
    font-size: .82rem;
    padding: 2px 0;
    border-radius: 0;
  }
  .hint { width: 100%; text-align: center; border-radius: 14px; }
  .instructions { padding: 14px; }
}


/* v4 JGames standardization */
body {
  position: relative;
}
.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 {
  background: #fff;
  border: 3px solid var(--blue2);
  border-radius: 16px;
  min-width: 96px;
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}
.logo img {
  display: block;
  max-width: 72px;
  max-height: 72px;
  width: auto;
  height: auto;
}
.footer {
  width: min(1000px, calc(100% - 24px));
  margin: 0 auto 36px;
  padding: 18px 18px 24px;
  background: rgba(255,255,255,.96);
  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;
  }
  .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;
  }
}
