    html { -webkit-text-size-adjust: 100%; }
    /* ===== Base page layout (header / main / footer) ===== */
    * { box-sizing: border-box; }
    html, body { height: 100%; }
    body {
      margin: 0;
      font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
      background: #0b0f16;     /* Dark app background */
      color: #e7ecf6;
      display: flex;
      flex-direction: column;
      min-height: 100vh;
    }

    /* ===== Header / Nav (shared) ===== */
    header.site-header{
      background:#111;
      color:#fff;
    }
    .site-header .nav{
      display:flex;
      justify-content:space-between;
      align-items:center;
      gap:16px;
      max-width:1200px;
      margin:0 auto;
      padding:12px 16px;
    }
    .brand{
      display:flex;
      align-items:center;
      gap:10px;
      text-decoration:none;
      color:#fff;
    }
    .brand-mark{
      font-family:"Shojumaru", system-ui;
      font-size:28px;
      letter-spacing:.5px;
      white-space:nowrap;
    }
    .primary-nav{
      display:flex;
      align-items:center;
      gap:20px;
      list-style:none;
      margin:0;
      padding:0;
    }
    .primary-nav a{
      color:#fff;
      text-decoration:none;
      padding:8px 10px;
      border-radius:6px;
    }
    .primary-nav a:hover{ background:#222; }

    /* Dropdown */
    .has-submenu{ position:relative; }
    .submenu{
      display:none;
      position:absolute;
      top:100%;
      left:0;
      background:#1b1b1b;
      list-style:none;
      padding:8px 0;
      margin:6px 0 0;
      min-width:200px;
      border:1px solid #2c2c2c;
      border-radius:8px;
      z-index:50;
    }
    .submenu a{ display:block; padding:8px 12px; }
    .has-submenu:hover .submenu{ display:block; }

    /* Main area centers the puzzle app between header and footer */
    main {
      flex: 1;
      display: grid;
      place-items: center;
      padding: 24px 16px 32px;
    }

    .description {
      text-align: center;
    }


    /* ===== App layout ===== */
    :root {
      --card:#0f131a; --text:#e7ecf6; --muted:#aab1c3;
      --accent:#6ea8fe; --ok:#48d597;
      --border:#233042;
    }
    .app {
      width: min(1300px, 98vw);
      display: grid;
      grid-template-columns: 420px 1fr;
      gap: 18px;
      align-items: start;
    }
    @media (max-width: 1100px) {
      .app { grid-template-columns: 1fr; }
    }

    .panel, .boardWrap {
      background: linear-gradient(180deg,#141a24,#111722);
      border: 1px solid var(--border);
      border-radius: 14px;
      box-shadow: 0 12px 28px rgba(0,0,0,.4);
    }

    .panel { padding: 14px; }
    .panel h1 { margin: 0 0 6px; font-size: 20px; }
    .muted { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }

    .row { display: grid; gap: 8px; margin-bottom: 10px; }
    .row2 { grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; }
    .row3 { grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
    select, button, input[type="search"] {
      width: 100%;
      padding: 10px 12px;
      background: var(--card);
      color: var(--text);
      border: 1px solid #2a3547;
      border-radius: 10px;
      outline: none;
    }
    button { cursor: pointer; }
    .primary { border-color: #3f5c9b; background: rgba(110,168,254,.12); }
    .warn    { border-color: #6d5731; background: rgba(255,181,76,.12); }
    .ok      { border-color: #356a57; background: rgba(72,213,151,.12); }

    /* Stats */
    .stats {
      display: grid; grid-template-columns: repeat(3, 1fr);
      gap: 8px; margin-top: 6px;
    }
    .stat {
      background: #0d121a; border: 1px solid var(--border);
      border-radius: 10px; padding: 8px 10px; text-align: center;
    }
    .stat big { display: block; font-weight: 700; font-size: 20px; }

    /* Reference (left panel) */
    .refWrap { padding: 12px; }
    .refImg {
      display: block; width: 100%; height: auto;
      border-radius: 12px; border: 3px solid var(--border);
      background: #f0f0f0;
    }

    /* Gallery (left panel) */
    .galleryWrap { display: flex; flex-direction: column; gap: 8px; }
    .galleryHeader {
      display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
    }
    .gallery {
      max-height: 320px; overflow: auto;
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 10px; background: #0d121a;
    }
    .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
    @media (max-width: 480px) { .grid { grid-template-columns: repeat(2, 1fr); } }
    .card {
      border: 1px solid #2a3547; border-radius: 10px; background: #121826;
      overflow: hidden; display: flex; flex-direction: column;
      transition: transform .08s ease, border-color .08s ease;
      cursor: pointer;
    }
    .card:hover { transform: translateY(-2px); border-color: #3f5c9b; }
    .thumb { display: block; width: 100%; aspect-ratio: 1/1; object-fit: contain; background: #0b0f16; }
    .label { padding: 6px 8px; font-size: 12px; color: #cdd5e7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .selected { outline: 2px solid var(--accent); outline-offset: 2px; }

    /* Board (right panel) */
    .boardWrap {
      padding: 12px;
      display: grid;
      place-items: center;
      position: relative; /* pin mini reference & overlay inside */
    }
    canvas {
      display: block;
      width: min(820px, 92vw);
      height: auto;
      max-height: 82vh;
      border: 1px solid var(--border);
      border-radius: 12px;
      background: #f0f0f0;
      touch-action: none;
    }

    /* Mini reference pinned at top-left of board */
    .refMini {
      position: absolute;
      top: 12px; left: 12px;
      width: 160px; height: auto;
      background: #070a0f;
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 4px;
      box-shadow: 0 6px 14px rgba(0,0,0,.35);
      opacity: .95;
      pointer-events: none; /* never blocks dragging puzzle pieces */
      z-index: 5;
    }

    /* Completion overlay (on board) */
    .overlay {
      position: absolute;
      inset: 12px;
      border-radius: 12px;
      background: rgba(0,0,0,.45);
      display: none;
      place-items: center;
      text-align: center;
      padding: 20px;
      border: 1px dashed #2a3b4f;
      z-index: 6;
    }
    .overlay.show { display: grid; }
    .overlay h2 { margin: 0 0 6px; }
    .overlay p  { margin: 0; color: var(--muted); }

    .legal { font-size: 12px; color: var(--muted); margin-top: 8px; }
    /* ===== Footer (2 columns) ===== */
.site-footer{ background:#111; color:#fff; padding:32px 16px 12px; }
.site-footer a{ color:#fff; text-decoration:none; }
.site-footer a:hover{ text-decoration:underline; }

.footer-inner.two-col{
  max-width:1200px; margin:0 auto;
  display:grid; grid-template-columns: 1.2fr 1fr;
  gap: 32px 28px; align-items:start;
}

/* Left column */
.footer-left{
  display:flex; flex-direction:column; align-items:center; text-align:center;
}
.footer-logo{
  font-family:"Shojumaru", system-ui, sans-serif;
  font-size:32px; line-height:1; margin:0;
}
.footer-tag{ margin-top:20px; opacity:.9; line-height:1.35; max-width:560px; }

/* 25px space BEFORE links list/socials block */
.links-block{ margin-top:25px; width:100%; }

/* Links list (inline + centered) */
.about-col ul{
  list-style:none; margin:0; padding:0;
  display:flex; gap:14px 18px; flex-wrap:wrap; justify-content:center;
}
.about-col li{ display:inline-flex; }
.about-col a{ padding:4px 0; opacity:.95; }

/* Socials under links, tighter gap than before */
.socials{
  list-style:none; margin:14px 0 0; padding:0;
  display:flex; justify-content:center; align-items:center; gap:12px; flex-wrap:wrap;
}
.socials li{ display:inline-flex; }
.socials a{ display:inline-flex; padding:6px; }

/* Right column (contact) */
.contact-col{ text-align:center; max-width:420px; justify-self:center; width:100%; }
.contact-col h4{ margin:0 0 10px; font-size:18px; }
#footer-contact{ display:flex; flex-direction:column; gap:10px; }
#footer-contact input, #footer-contact textarea{
  width:100%; padding:10px 12px; border-radius:8px; border:1px solid #2a2a2a;
  background:#1b1b1b; color:#fff; resize:vertical;
}
#footer-contact button{
  padding:10px 12px; border-radius:8px; border:1px solid #2a2a2a;
  background:#fff; color:#111; font-weight:600; cursor:pointer;
}
#footer-contact button:hover{ background:#e9e9e9; }
.fineprint{ font-size:.9rem; opacity:.8; }

/* Bottom bar */
.footer-bottom{
  max-width:1200px; margin:22px auto 0;
  display:flex; gap:12px; align-items:center; justify-content:space-between;
  border-top:1px solid #222; padding-top:12px;
}
.footer-bottom p{ margin:0 auto; text-align:center; flex:1; }
.back-to-top{ white-space:nowrap; }

.sr-only{
  position:absolute; width:1px; height:1px; margin:-1px; border:0; padding:0;
  clip:rect(0 0 0 0); overflow:hidden;
}

/* Responsive */
@media (max-width: 900px){
  .footer-inner.two-col{ grid-template-columns:1fr; }
  .contact-col{ justify-self:center; }
  .footer-bottom{ flex-direction:column; gap:10px; }
}
/* Reference area (container and/or canvas) */
#reference,
.reference,
#refCanvas,
.reference-canvas {
  background: #fff !important;
}

/* Gallery grid / tiles / piece canvases */
#gallery,
.gallery,
.gallery-grid,
.thumb,
.piece,
.piece-canvas {
  background: #fff !important;
}
/* keep existing rules; add this */
.has-submenu.open .submenu { display: block; }
@media (max-width: 600px){
  .gallery { max-height: 260px; }
  canvas { width: min(92vw, 640px); }
  select, button, input[type="search"] { font-size: 16px; } /* prevent iOS zoom */
}