:root {
  --page-bg: #f4f1fb;
  --card-bg: #fff;
  --ink: #211d2e;
  --muted: #625a75;
  --accent: #4c3b9b;
  --line: #d8d0ec;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  overscroll-behavior: none;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(151,151,255,.35), transparent 30rem),
    linear-gradient(180deg, #fbf8ff, var(--page-bg));
}
.site-header {
  max-width: 1040px;
  margin: 0 auto;
  padding: 18px 16px 10px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.brand-img {
  width: 78px;
  height: auto;
  image-rendering: auto;
}
h1 { margin: 0; font-size: clamp(2.1rem, 6vw, 4rem); line-height: 1; letter-spacing: -.04em; }
.site-header p { margin: 6px 0 0; color: var(--muted); }
.page-shell {
  max-width: 1040px;
  margin: 0 auto 48px;
  padding: 0 16px;
}
.game-card, .instructions {
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(47, 34, 93, .13);
}
.game-card { padding: 12px; }
.start-screen {
  min-height: 465px;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 14px;
  border: 1px solid #b9b2da;
  background: #ece9ff;
}
.title-art-wrap {
  position: relative;
  width: min(100%, 620px);
}
.title-art {
  width: 100%;
  height: auto;
  display: block;
}
.start-overlay {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 18%;
  display: grid;
  gap: 8px;
  justify-items: center;
}
.start-buttons, .start-options, .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 10px;
}
.status {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: #eeeaff;
  border: 1px solid #cbc1ff;
  font-weight: 700;
}
.meta { color: var(--muted); font-size: .95rem; white-space: nowrap; }
.canvas-frame {
  display: flex;
  justify-content: center;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid #8f89bb;
  background-image: url("pics/back1.gif");
  background-repeat: repeat;
}
canvas {
  display: block;
  width: min(100%, 620px);
  height: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  image-rendering: auto;
}
.controls { padding: 12px 2px 0; }
button, .check, .level-picker {
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid #a69bc8;
  background: #f7f4ff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}
button { padding: 0 14px; cursor: pointer; }
button:hover { background: #e9e1ff; }
.check, .level-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
}
.level-picker select {
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid #a69bc8;
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  padding: 0 8px;
}
.hidden { display: none; }
.instructions {
  margin-top: 18px;
  padding: 22px;
  line-height: 1.55;
}
.instructions h2 { margin-top: 0; }
.asset-note { color: var(--muted); }
@media (max-width: 720px) {
  .site-header { align-items: flex-start; }
  .brand-img { width: 58px; }
  .status-row { align-items: stretch; flex-direction: column; }
  button, .check, .level-picker { flex: 1 1 auto; justify-content: center; }
  .instructions { padding: 18px; }
}

.designer-button{background:#fff1b8;border-color:#d8b33d}

@media (max-width: 640px) {
  .start-overlay {
    position: static;
    margin-top: 10px;
  }
}

@media (min-width: 641px) {
  .start-overlay { top: 18% !important; }
}



/* v2j fit-to-window mode */
body.schnauser-fit-active {
  overflow: hidden !important;
}
body.schnauser-fit-active .site-header,
body.schnauser-fit-active .instructions {
  display: none !important;
}
.game-card.fit-mode {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483000 !important;
  margin: 0 !important;
  padding: 8px !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  border-radius: 0 !important;
  border: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  background: #ece9ff !important;
}
.game-card.fit-mode #gameWrap {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  min-height: 0 !important;
}
.game-card.fit-mode .status-row {
  flex: 0 0 auto !important;
  padding: 0 4px 6px !important;
}
.game-card.fit-mode .canvas-frame {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
}
.game-card.fit-mode canvas {
  width: min(calc(100vw - 16px), calc((100vh - 112px) * 1.24731183)) !important;
  height: auto !important;
  max-width: calc(100vw - 16px) !important;
  max-height: calc(100vh - 112px) !important;
}
.game-card.fit-mode .controls {
  flex: 0 0 auto !important;
  padding: 8px 0 0 !important;
}

/* v2l: mobile-only Fit-mode escape hatch */
.mobile-fit-exit {
  display: none;
}
@media (max-width: 720px), (pointer: coarse) {
  .game-card.fit-mode .mobile-fit-exit {
    display: grid;
    place-items: center;
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    z-index: 2147483001;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,.35);
    background: rgba(255,255,255,.94);
    color: #111;
    font-size: 30px;
    line-height: 1;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
  }
}

/* v4.0 JGames page shell additions */
.site-header {
  padding-right: 72px;
}
.brand-img {
  width: 112px;
  max-width: 22vw;
  height: auto;
}
.jgames-home-badge{
  position:fixed;
  top:12px;
  right:12px;
  z-index:10000;
  width:44px;
  height:44px;
  display:grid;
  place-items:center;
  border-radius:14px;
  background:#fff;
  border:1px solid rgba(76,59,155,.18);
  box-shadow:0 8px 22px rgba(76,59,155,.18);
  transition:transform .12s ease, box-shadow .12s ease;
}
.jgames-home-badge img{
  width:32px;
  height:32px;
  display:block;
}
.jgames-home-badge:hover{
  transform:translateY(-1px);
  box-shadow:0 12px 28px rgba(76,59,155,.22);
}
.footer{
  margin:34px auto 0;
  padding:22px 14px 28px;
  max-width:1040px;
  color:#625a75;
  text-align:center;
  font:14px/1.45 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;
  border-top:1px solid rgba(76,59,155,.16);
}
.footer nav{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:8px 14px;
  margin-bottom:12px;
  font-weight:700;
}
.footer a{
  color:#4c3b9b;
  text-decoration:none;
}
.footer a:hover{
  color:#d80d16;
  text-decoration:underline;
}
.footer p{
  margin:6px 0 0;
}
body.schnauser-fit-active .footer,
body.schnauser-fit-active .jgames-home-badge{
  display:none !important;
}
@media (max-width: 720px) {
  .site-header {
    padding-right: 60px;
  }
  .brand-img {
    width: 82px;
    max-width: 20vw;
  }
  .jgames-home-badge{
    width:40px;
    height:40px;
    border-radius:13px;
  }
  .jgames-home-badge img{
    width:29px;
    height:29px;
  }
}


/* v4.1 shared Schnauser level memory badges */
.shared-level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: .78rem;
  line-height: 1;
  font-weight: 900;
  letter-spacing: .02em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.shared-level-badge-new {
  background: #eaf6ff;
  border-color: #b8d7ee;
  color: #245176;
}
.shared-level-badge-played {
  background: #fff5d8;
  border-color: #dec46f;
  color: #745500;
}
.shared-level-badge-solved {
  background: #e7f8e2;
  border-color: #8dc27e;
  color: #276221;
}


/* v4.5 shared Schnauser level page */
.site-header.shared-site-header{
  align-items:center;
}
.shared-site-header .shared-header-copy{
  flex:1 1 auto;
  min-width:0;
}
.shared-site-header .shared-header-row{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:16px;
  flex-wrap:nowrap;
  min-width:0;
}
.shared-site-header .shared-header-row h1{
  flex:0 1 auto;
  white-space:nowrap;
  min-width:0;
}
.shared-more-link{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 auto;
  min-height:36px;
  padding:7px 14px;
  border-radius:999px;
  border:1px solid #a69bc8;
  background:linear-gradient(#6d5bd6,#4c3b9b);
  color:#fff;
  font-weight:900;
  font-size:clamp(.78rem,1.35vw,.96rem);
  line-height:1.15;
  white-space:nowrap;
  text-decoration:none;
  box-shadow:0 5px 14px rgba(76,59,155,.22);
}
.shared-more-link:hover{
  color:#fff;
  text-decoration:none;
  transform:translateY(-1px);
}
.shared-site-header .shared-header-copy > p{
  max-width:100%;
}
@media(max-width:820px){
  .shared-site-header .shared-header-row{
    display:block;
  }
  .shared-more-link{
    margin-top:10px;
  }
}


/* v4.6 gameplay cursor */
canvas,
.canvas-frame{
  cursor: crosshair;
}

/* Mobile fit mode: reclaim side spacing */
@media (max-width: 720px), (pointer: coarse) {
  .game-card.fit-mode {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .game-card.fit-mode canvas {
    width: min(100vw, calc((100vh - 112px) * 1.24731183)) !important;
    max-width: 100vw !important;
  }
}

/* Mobile: let the Schnauser game use the full viewport width */
@media (max-width: 720px), (pointer: coarse) {
  .page-shell {
    padding-left: 0;
    padding-right: 0;
  }

  .game-card {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
}
