* { box-sizing: border-box; }
html, body { height: 100%; }
:root {
  --topbar-pad-inline: 16px;
  --logo-shift: 40px;
  --right-shift: 36px;
  --logo-center-offset: calc(350px);
  --right-center-offset: calc(350px);
  --top-right-raise: 14px;
  --right-block-dy: calc(-1 * var(--top-right-raise));
  --board-scale: 0.8;
  --rotate-scale: 0.8;
  --moves-scale: 1;
  --moves-margin-top: 14px;
  --controls-gap-y: 10px;              
  --rotate-left-offset-x: 0px;         
  --rotate-right-offset-x: 0px;        
  --rotate-btn-width: 44px;            
  --rotate-btn-height: 28px;           
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: #101828;
  background: radial-gradient(1200px 600px at 10% -10%, #eff6ff 0%, rgba(239,246,255,0) 60%),
              radial-gradient(1200px 600px at 110% 110%, #ecfeff 0%, rgba(236,254,255,0) 60%),
              #f8fafc;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  padding-bottom: 0px;
  padding-inline: var(--topbar-pad-inline);
}
.title {
  font-size: 20px;
  line-height: 1.2;
  margin: 0;
  margin-left: calc(50vw - var(--topbar-pad-inline) - var(--logo-center-offset));
}
.logo { display: block; height: 100px; width: auto; }
.spacer { flex: 1; }
.top-right { display: inline-flex; align-items: center; gap: 8px; margin-right: calc(50vw - var(--topbar-pad-inline) - var(--right-center-offset)); transform: translateY(var(--right-block-dy)); }
.size-control { display: inline-flex; align-items: center; gap: 6px; }
.size-label { font-size: 14px; color: #334155; }
.size-select {
  appearance: none;
  border: 1px solid rgba(0,0,0,0.1);
  background: #ffffff;
  color: #0f172a;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.size-range { width: 120px; accent-color: #2563eb; }
.size-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  min-width: 42px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  background: #ffffff;
  color: #0f172a;
  font-weight: 700;
  line-height: 1;
}
.pattern-control { gap: 8px; }
.pattern-button {
  appearance: none;
  border: 1px solid rgba(0,0,0,0.1);
  background: #ffffff;
  color: #0f172a;
  padding: 6px 10px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 160ms ease, box-shadow 160ms ease, transform 80ms ease;
}
.pattern-button:hover { background: #f3f4f6; }
.pattern-button:active { transform: translateY(1px); }
.pattern-button:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }
.pattern-button .pattern-name { font-size: 14px; color: #334155; font-weight: 700; }
.pattern-button .swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
  display: grid;
  grid-template-columns: repeat(var(--sw, 3), 1fr);
  grid-auto-rows: 1fr;
  gap: 1px;
  background-color: #e5e7eb;
  overflow: hidden;
}
.pattern-button .swatch .sq { display: block; width: 100%; height: 100%; }
.style-button .style-name { font-size: 14px; color: #334155; font-weight: 700; }
.style-button .swatch { --gap: 1px; --tile-inset-scale: .7; --inset: calc(var(--gap) * var(--tile-inset-scale)); position: relative; }
.style-button .swatch .mini-tile { position: relative; width: 100%; aspect-ratio: 1 / 1; }
.style-button .swatch .slot, .style-button .swatch .cell { position: absolute; inset: 0; }
.pattern-picker { display: inline-flex; gap: 6px; }
.pattern-btn {
  appearance: none;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #ffffff;
  position: relative;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: background 160ms ease, box-shadow 160ms ease, transform 80ms ease;
}
.pattern-btn:hover { background: #f3f4f6; }
.pattern-btn:active { transform: translateY(1px); }
.pattern-btn:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }
.pattern-btn.is-active {
  box-shadow: 0 0 0 2px #fff, 0 0 0 5px rgba(59,130,246,0.35);
}
.pattern-btn .swatch {
  width: 80%;
  height: 80%;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}
.pat-horiz { background: none; }
.pat-vert { background: none; }
.pat-diag { background: none; }
.pat-rings { background: none; }
.button, .icon-button {
  appearance: none;
  border: 1px solid rgba(0,0,0,0.1);
  background: #ffffff;
  color: #0f172a;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: background 160ms ease, box-shadow 160ms ease, transform 80ms ease;
}
.top-right .button { height: 38px; display: inline-flex; align-items: center; }
.button:hover, .icon-button:hover { background: #f3f4f6; }
.button:active, .icon-button:active { transform: translateY(1px); }
.icon-button { width: 38px; height: 38px; padding: 0; font-weight: 800; }
.button.primary { background: #2563eb; color: #fff; border-color: #1d4ed8; }
.button.primary:hover { background: #1d4ed8; }
.main { display: flex; align-items: flex-start; justify-content: center; padding: 0px 16px 28px; }
.board-wrap { position: relative; width: fit-content; display: grid; grid-template-rows: auto auto; justify-items: center; }
.board-toolbar { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; margin-bottom: var(--controls-gap-y); }
#btn-rotate-left { margin-left: var(--rotate-left-offset-x); }
#btn-rotate-right { margin-right: var(--rotate-right-offset-x); }
.rotate-btn {
  width: var(--rotate-btn-width);
  height: var(--rotate-btn-height);
  border-radius: 6px;
  border: 0;
  color: #fff;
  background: linear-gradient(145deg, #60a5fa 0%, #2563eb 60%, #1e40af 100%);
  box-shadow:
    0 8px 16px rgba(37,99,235,0.25),
    inset 0 1px 0 rgba(255,255,255,0.6),
    inset 0 -1px 0 rgba(0,0,0,0.12);
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rotate-btn::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 120% at 30% 20%, rgba(255,255,255,0.25), rgba(255,255,255,0) 45%); pointer-events: none; }
.rotate-btn::after { display: none; }
.rotate-btn:hover { transform: translateY(0) scale(1.02); box-shadow: 0 12px 24px rgba(37,99,235,0.3), inset 0 1px 0 rgba(255,255,255,0.7), inset 0 -1px 0 rgba(0,0,0,0.14); }
.rotate-btn:active { transform: scale(0.98); }
.rotate-btn:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.rotate-btn i { font-size: 16px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25)); }
.grid {
  --gap: clamp(6px, 0.9vmin, 12px);
  --tile-inset-frac: 0.14;
  --inset: calc(var(--cell-size, 0px) * var(--tile-inset-frac));
  --sel-move: clamp(1px, calc(var(--inset) * 0.28), 6px);
  --sel-glow-size: 16px;
  position: relative;
  width: min(calc(73.6vmin * var(--board-scale)), calc(544px * var(--board-scale)));
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0.8)), #ffffff;
  box-shadow: 0 20px 40px rgba(2,6,23,0.08), inset 0 0 0 1px rgba(2,6,23,0.06);
  overflow: hidden;
  user-select: none;
  touch-action: none;
}
.slot {
  position: absolute;
  z-index: 0;
  background: var(--target-color);
  background-image:
    linear-gradient(145deg, rgba(255,255,255,0.18), rgba(0,0,0,0.08));
  background-blend-mode: overlay;
  box-shadow: inset 0 0 0 1px rgba(2,6,23,0.06);
}
.cell {
  position: absolute;
  cursor: pointer;
  will-change: transform, filter;
  z-index: 2;
}
.cell::before {
  content: "";
  position: absolute;
  inset: var(--inset);
  border-radius: 12px;
  background:
    linear-gradient(145deg,
      color-mix(in oklab, var(--tile-color), white 10%) 0%,
      color-mix(in oklab, var(--tile-color), black 14%) 100%);
  box-shadow:
    0 14px 24px rgba(2,6,23,0.18),
    0 4px 10px rgba(2,6,23,0.14),
    inset 0 1px 0 rgba(255,255,255,0.45),
    inset 0 -1px 0 rgba(0,0,0,0.08);
  transform: translate(0, 0) translateY(var(--lift, 0));
  transition: box-shadow 180ms ease, transform 180ms ease, filter 180ms ease;
}
.cell::after {
  content: "";
  position: absolute;
  left: calc(var(--inset) + 6px);
  right: calc(var(--inset) + 6px);
  top: calc(var(--inset) + 3px);
  height: 18px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.45), rgba(255,255,255,0) 70%);
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.7;
  transition: opacity 180ms ease;
}
.cell:hover::before { --lift: -2px; box-shadow: 0 18px 34px rgba(2,6,23,0.22), 0 8px 16px rgba(2,6,23,0.18), inset 0 1px 0 rgba(255,255,255,0.5), inset 0 -1px 0 rgba(0,0,0,0.08); }
.cell:hover::after { opacity: 0.85; }
.cell.selected::before {
  --lift: -3px;
  animation: sel-jiggle 1.5s ease-in-out infinite;
}
.grid .cell.selected { --sel-glow-color: color-mix(in srgb, var(--tile-color) 68%, white 10%); animation: sel-blink 1.15s ease-in-out infinite; }
@keyframes sel-blink { 0%, 100% { filter: drop-shadow(0 0 0 var(--sel-glow-color)); } 50% { filter: drop-shadow(0 0 var(--sel-glow-size, 16px) var(--sel-glow-color)); } }
@keyframes sel-jiggle {
  0%   { transform: translate(0, calc(var(--sel-move, 3px) * -1)) translateY(var(--lift, 0)); }
  25%  { transform: translate(0, var(--sel-move, 3px)) translateY(var(--lift, 0)); }
  50%  { transform: translate(var(--sel-move, 3px), 0) translateY(var(--lift, 0)); }
  75%  { transform: translate(calc(var(--sel-move, 3px) * -1), 0) translateY(var(--lift, 0)); }
  100% { transform: translate(0, calc(var(--sel-move, 3px) * -1)) translateY(var(--lift, 0)); }
}
.grid[data-style="neon"],
.grid[data-style="neonwire"],
.grid[data-style="jelly"],
.grid[data-style="rubber"] { --sel-glow-size: 22px; }
.cell.animating { z-index: 5; }
.cell.ghost { pointer-events: none; }
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15,23,42,0.6);
  padding: 16px;
  z-index: 9999;
}
.overlay[hidden] { display: none; }
.overlay-content {
  width: min(640px, 96vw);
  max-height: 90vh;
  background: #ffffff;
  border-radius: 16px;
  padding: 20px 18px 16px;
  box-shadow: 0 24px 60px rgba(2,6,23,0.25);
  display: flex;
  flex-direction: column;
}
.overlay-content h2 {
  margin: 0 0 8px 0;
  text-align: center;
}
.rules { margin: 8px 0 10px 18px; padding: 0 0 0 6px; }
.note { margin: 10px 0 6px; color: #475569; }
.note:empty { display: none; }
.consts { margin: 0 0 10px; color: #334155; font-weight: 600; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.pattern-list, .style-list { flex: 1 1 auto; overflow: auto; display: grid; gap: 10px; }
.pattern-list { grid-template-columns: repeat(6, 1fr); }
.style-list { grid-template-columns: repeat(6, 1fr); }
#style-overlay .style-list { margin-bottom: 16px; margin-top: 0px; padding-top: 6px; padding-bottom: 6px; padding-left: 8px; padding-right: 8px; }
#pattern-overlay .pattern-list { padding-top: 6px; padding-bottom: 6px; padding-left: 8px; padding-right: 8px; }
.style-btn {
  appearance: none;
  width: 100%;
  padding: 8px 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 160ms ease, box-shadow 160ms ease, transform 80ms ease;
}
.style-btn:hover { background: #f3f4f6; }
.style-btn:active { transform: translateY(1px); }
.style-btn:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }
.style-btn.is-active { box-shadow: 0 0 0 2px #fff, 0 0 0 5px rgba(59,130,246,0.35); }
.style-btn .swatch { width: 64px; height: 64px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr; gap: 1px; background-color: #e5e7eb; overflow: hidden; position: relative; --gap: 2px; --tile-inset-scale: .7; --inset: calc(var(--gap) * var(--tile-inset-scale)); }
.style-btn .swatch .sq { width: 100%; height: 100%; }
.style-btn .caption { font-size: 12px; color: #334155; text-align: center; line-height: 1.2; }
.style-btn .swatch .mini-tile { position: relative; width: 100%; aspect-ratio: 1 / 1; }
.style-btn .swatch .slot, .style-btn .swatch .cell { position: absolute; inset: 0; }
.style-btn .swatch .cell::before,
.style-btn .swatch .cell::after { transform: scale(0.5); transform-origin: center center; }
@media (prefers-reduced-motion: reduce) {
  .button, .icon-button, .cell, .cell::before, .cell::after { transition: none !important; }
  .grid .cell.selected { animation: none !important; }
  .grid .cell.selected::before { animation: none !important; }
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="flat"] { 
  --gap: clamp(4px, 0.7vmin, 10px);
  background: #ffffff;
  box-shadow: 0 16px 28px rgba(2,6,23,0.06), inset 0 0 0 1px rgba(2,6,23,0.05);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="flat"] .slot {
  background: color-mix(in oklab, var(--target-color), white 24%);
  background-image: none;
  box-shadow: inset 0 0 0 1px rgba(2,6,23,0.05);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="flat"] .cell::before {
  background: color-mix(in oklab, var(--tile-color), white 10%);
  box-shadow: 0 2px 4px rgba(2,6,23,0.08), inset 0 0 0 1px rgba(255,255,255,0.6);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="flat"] .cell::after { display: none; }
.grid[data-style="flat"] .cell:hover::before { --lift: -1px; box-shadow: 0 4px 8px rgba(2,6,23,0.12), inset 0 0 0 1px rgba(255,255,255,0.7); }
.grid[data-style="flat"] .cell.selected::before { box-shadow: 0 0 0 2px color-mix(in oklab, var(--tile-color), white 18%), 0 0 0 6px color-mix(in oklab, var(--tile-color) 50%, transparent), 0 6px 12px rgba(2,6,23,0.12), inset 0 0 0 1px rgba(255,255,255,0.7); }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="neon"] {
  --gap: clamp(6px, 0.9vmin, 12px);
  background: radial-gradient(600px 400px at 30% 10%, #0f1a3a 0%, rgba(15,26,58,0) 60%), #0b1020;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.06);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="neon"] .slot {
  background: color-mix(in srgb, var(--target-color) 50%, #0b1020);
  background-image: none;
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--target-color) 30%, transparent),
    0 0 18px color-mix(in srgb, var(--target-color) 45%, transparent);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="neon"] .cell::before {
  background: color-mix(in srgb, var(--tile-color) 28%, black);
  box-shadow:
    0 0 18px color-mix(in srgb, var(--tile-color) 55%, transparent),
    0 0 8px color-mix(in srgb, var(--tile-color) 50%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--tile-color) 60%, white 10%);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="neon"] .cell::after { display: none; }
.grid[data-style="neon"] .cell:hover::before { --lift: -1px; box-shadow:
    0 0 26px color-mix(in srgb, var(--tile-color) 70%, transparent),
    0 0 12px color-mix(in srgb, var(--tile-color) 55%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--tile-color) 70%, white 10%);
}
.grid[data-style="neon"] .cell.selected::before {
  box-shadow:
    0 0 36px color-mix(in srgb, var(--tile-color) 80%, transparent),
    0 0 18px color-mix(in srgb, var(--tile-color) 65%, transparent),
    0 0 0 2px color-mix(in srgb, var(--tile-color) 70%, white 30%),
    inset 0 0 0 1px color-mix(in srgb, var(--tile-color) 75%, white 10%);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="glass"] {
  --gap: clamp(8px, 1.2vmin, 14px);
  background: linear-gradient(135deg, rgba(255,255,255,0.35), rgba(255,255,255,0.12)),
              url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2240%22 height=%2240%22 viewBox=%220 0 40 40%22%3E%3Cg fill=%22%23ffffff%22 fill-opacity=%220.08%22%3E%3Ccircle cx=%225%22 cy=%225%22 r=%221%22/%3E%3Ccircle cx=%2225%22 cy=%2215%22 r=%221%22/%3E%3Ccircle cx=%2212%22 cy=%2230%22 r=%221%22/%3E%3Ccircle cx=%2230%22 cy=%2232%22 r=%221%22/%3E%3C/g%3E%3C/svg%3E') center/auto repeat,
              linear-gradient(180deg, #e0f2fe, #f5f3ff);
  backdrop-filter: blur(2px);
  box-shadow: 0 24px 50px rgba(2,6,23,0.16), inset 0 0 0 1px rgba(255,255,255,0.3);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="glass"] .slot {
  background: color-mix(in oklab, var(--target-color), white 20%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4), inset 0 0 10px rgba(255,255,255,0.25);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="glass"] .cell::before {
  background: color-mix(in oklab, var(--tile-color), white 40%);
  backdrop-filter: blur(6px) saturate(140%);
  border: 2px solid rgba(255,255,255,0.6);
  box-shadow: 0 10px 20px rgba(2,6,23,0.18), inset 0 1px 0 rgba(255,255,255,0.7);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="glass"] .cell::after { opacity: 0.9; }
.grid[data-style="glass"] .cell.selected::before {
  border: 2px solid color-mix(in oklab, var(--tile-color), white 40%);
  box-shadow:
    0 14px 26px rgba(2,6,23,0.22),
    0 0 0 3px color-mix(in oklab, var(--tile-color) 55%, transparent),
    inset 0 1px 0 rgba(255,255,255,0.9);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="pastel"] {
  --gap: clamp(6px, 1vmin, 12px);
  background: linear-gradient(180deg, #fff7ed, #f1f5f9);
  box-shadow: 0 18px 36px rgba(2,6,23,0.08), inset 0 0 0 1px rgba(2,6,23,0.05);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="pastel"] .slot {
  background: color-mix(in oklab, var(--target-color), white 45%);
  box-shadow: inset 0 0 0 1px rgba(2,6,23,0.04);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="pastel"] .cell::before {
  background: color-mix(in oklab, var(--tile-color), white 35%);
  box-shadow: 0 8px 16px rgba(2,6,23,0.08), inset 0 1px 0 rgba(255,255,255,0.9);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="pastel"] .cell::after { opacity: 0.75; }
.grid[data-style="pastel"] .cell.selected::before { box-shadow: 0 0 0 2px color-mix(in oklab, var(--tile-color), white 25%), 0 0 0 6px color-mix(in oklab, var(--tile-color) 40%, transparent), 0 8px 18px rgba(2,6,23,0.12), inset 0 1px 0 rgba(255,255,255,0.9); }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="retro"] {
  --gap: clamp(5px, 0.9vmin, 10px);
  background: linear-gradient(180deg, #faf5e6, #f4e9d8);
  box-shadow: 0 16px 28px rgba(106,72,41,0.15), inset 0 0 0 1px rgba(106,72,41,0.15);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="retro"] .slot {
  background: color-mix(in srgb, var(--target-color) 55%, #f4e9d8);
  background-image: none;
  box-shadow: inset 0 0 0 1px rgba(106,72,41,0.2);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="retro"] .cell::before {
  border-radius: 6px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tile-color) 70%, #fff), color-mix(in srgb, var(--tile-color) 40%, #e2d3c2));
  box-shadow: 0 6px 0 rgba(106,72,41,0.3), 0 8px 16px rgba(106,72,41,0.18), inset 0 0 0 1px rgba(255,255,255,0.5);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="retro"] .cell::after { display: none; }
.grid[data-style="retro"] .cell:hover::before { --lift: -1px; box-shadow: 0 7px 0 rgba(106,72,41,0.32), 0 10px 18px rgba(106,72,41,0.22), inset 0 0 0 1px rgba(255,255,255,0.6); }
.grid[data-style="retro"] .cell.selected::before { box-shadow: 0 0 0 2px color-mix(in oklab, var(--tile-color), white 22%), 0 0 0 6px color-mix(in oklab, var(--tile-color) 45%, transparent), 0 6px 0 rgba(106,72,41,0.3), 0 10px 18px rgba(106,72,41,0.22), inset 0 0 0 1px rgba(255,255,255,0.6); }
.moves {
  display: inline;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-weight: 700;
  font-size: calc(1rem * var(--moves-scale));
  text-align: center;
}
.moves-bar { display: none; }
.pattern-btn .swatch { background: none !important; }
.pat-horiz, .pat-vert, .pat-diag, .pat-rings { background: none !important; background-image: none !important; }
.pattern-btn .swatch {
  display: grid;
  grid-template-columns: repeat(var(--sw, 6), 1fr);
  grid-auto-rows: 1fr;
  gap: 1px;
  background-color: #e5e7eb;
  overflow: hidden;
}
.pattern-btn .swatch .sq {
  display: block;
  width: 100%;
  height: 100%;
}
.grid[data-style] .cell:hover::before { filter: saturate(105%); }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="gold"] { background: linear-gradient(180deg,#fff7e6,#fef3c7); }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="gold"] .slot { background: color-mix(in srgb, var(--target-color) 65%, #fde68a); box-shadow: inset 0 0 0 1px rgba(202,138,4,0.25); }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="gold"] .cell::before { border-radius: 10px; background: linear-gradient(145deg,#fff1a6 0%, color-mix(in srgb, var(--tile-color) 65%, #b45309) 40%, color-mix(in srgb, var(--tile-color) 55%, #7c2d12) 100%); box-shadow: 0 10px 0 rgba(180,83,9,0.35), 0 20px 36px rgba(180,83,9,0.25), inset 0 2px 0 rgba(255,255,255,0.8); }
.grid[data-style="gold"] .cell.selected::before { box-shadow: 0 0 0 2px color-mix(in oklab, var(--tile-color), white 20%), 0 0 0 6px color-mix(in oklab, var(--tile-color) 50%, transparent), 0 10px 0 rgba(180,83,9,0.4), 0 24px 40px rgba(180,83,9,0.3); }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="marble"] { background: linear-gradient(180deg,#fdfdfd,#f2f2f2); }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="marble"] .slot { background: color-mix(in oklab, var(--target-color), white 30%); }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="marble"] .cell::before { background: radial-gradient(200% 120% at -20% -10%, rgba(0,0,0,0.06), transparent 40%), radial-gradient(200% 120% at 120% 110%, rgba(0,0,0,0.06), transparent 40%), color-mix(in oklab, var(--tile-color), white 40%); box-shadow: 0 12px 22px rgba(2,6,23,0.16), inset 0 1px 0 rgba(255,255,255,0.9); }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="stone"] { background: linear-gradient(180deg,#f4f4f5,#e4e4e7) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="stone"] .slot{ background: color-mix(in srgb, var(--target-color) 55%, #e4e4e7) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="stone"] .cell::before{ border-radius: 14px; background: radial-gradient(60% 80% at 30% 20%, rgba(0,0,0,0.15), transparent 50%), radial-gradient(50% 90% at 70% 80%, rgba(0,0,0,0.1), transparent 50%), color-mix(in oklab, var(--tile-color), black 10%); box-shadow: 0 10px 18px rgba(2,6,23,0.18), inset 0 2px 0 rgba(255,255,255,0.4) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="leather"] { background: linear-gradient(180deg,#faf5e6,#f0ead2) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="leather"] .slot{ background: color-mix(in srgb, var(--target-color) 60%, #f0ead2) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="leather"] .cell::before{ background: radial-gradient(1px 1px at 2px 2px, rgba(0,0,0,0.08) 0 50%, transparent 51%) 0 0/6px 6px, color-mix(in srgb, var(--tile-color) 70%, #7c2d12); box-shadow: 0 8px 16px rgba(124,45,18,0.25), inset 0 1px 0 rgba(255,255,255,0.5) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="rubber"] { background:#111827 }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="rubber"] .slot{ background: color-mix(in srgb, var(--target-color) 40%, #111827); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="rubber"] .cell::before{ border-radius: 18px; background: radial-gradient(100% 100% at 50% 20%, rgba(255,255,255,0.12), rgba(0,0,0,0.2) 70%), color-mix(in srgb, var(--tile-color) 60%, #18181b); box-shadow: 0 16px 24px rgba(0,0,0,0.5), inset 0 2px 0 rgba(255,255,255,0.1) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="rubber"] .cell::after{ opacity:.35 }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="fabric"] { background: linear-gradient(180deg,#f8fafc,#eef2ff) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="fabric"] .slot { background: color-mix(in oklab, var(--target-color), white 30%); }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="fabric"] .cell::before{ background: repeating-linear-gradient(0deg, color-mix(in srgb, var(--tile-color) 80%, #fff) 0 2px, color-mix(in srgb, var(--tile-color) 70%, #ddd) 2px 4px), repeating-linear-gradient(90deg, transparent 0 2px, rgba(255,255,255,0.2) 2px 4px); filter: contrast(102%); box-shadow: 0 10px 18px rgba(2,6,23,0.14), inset 0 1px 0 rgba(255,255,255,0.9) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="pearl"] { background: linear-gradient(180deg,#fafafa,#eef2ff) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="pearl"] .slot{ background: color-mix(in oklab, var(--target-color), white 35%) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="pearl"] .cell::before{ border-radius: 50%; background: radial-gradient(100% 100% at 30% 20%, #fff, color-mix(in oklab, var(--tile-color), white 40%) 60%, color-mix(in oklab, var(--tile-color), black 10%)); box-shadow: 0 14px 24px rgba(2,6,23,0.18), inset 0 1px 0 rgba(255,255,255,0.9) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="bubble"] { background: linear-gradient(180deg,#e0f2fe,#f5f3ff) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="bubble"] .slot{ background: color-mix(in oklab, var(--target-color), white 30%) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="bubble"] .cell::before{ border-radius: 50%; background: radial-gradient(100% 100% at 30% 20%, rgba(255,255,255,0.9), rgba(255,255,255,0) 50%), color-mix(in oklab, var(--tile-color), white 25%); box-shadow: 0 20px 28px rgba(2,6,23,0.16), inset 0 1px 0 rgba(255,255,255,0.9) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="bubble"] .cell::after{ opacity: 1; height: 22px }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="jelly"] { background:#0f172a }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="jelly"] .slot{ background: color-mix(in srgb, var(--target-color) 50%, #0f172a) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="jelly"] .cell::before{ border-radius: 20px; background: radial-gradient(60% 80% at 50% 20%, rgba(255,255,255,0.3), rgba(255,255,255,0) 60%), color-mix(in srgb, var(--tile-color) 80%, #000); box-shadow: 0 18px 40px rgba(0,0,0,0.6), inset 0 -6px 16px rgba(0,0,0,0.35), inset 0 2px 0 rgba(255,255,255,0.5) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="graffiti"] { background: linear-gradient(180deg,#fef9c3,#f1f5f9) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="graffiti"] .slot{ background: color-mix(in srgb, var(--target-color) 60%, #fef08a) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="graffiti"] .cell::before{ border-radius: 8px; background: radial-gradient(40px 40px at 20% 20%, rgba(255,255,255,0.4), transparent 60%), conic-gradient(from 45deg, color-mix(in srgb, var(--tile-color) 80%, #fff), color-mix(in srgb, var(--tile-color) 60%, #000)); filter: contrast(110%) saturate(120%); box-shadow: 0 18px 30px rgba(2,6,23,0.22), inset 0 1px 0 rgba(255,255,255,0.85) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="flower"] { background: linear-gradient(180deg,#fef9c3,#fce7f3) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="flower"] .slot{ background: color-mix(in oklab, var(--target-color), white 26%) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="flower"] .cell::before{ border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--tile-color) 80%, #fff) 0 40%, transparent 41%), conic-gradient(from 0deg, color-mix(in srgb, var(--tile-color) 70%, #fff) 0 60deg, color-mix(in srgb, var(--tile-color) 40%, #000) 60deg 120deg, color-mix(in srgb, var(--tile-color) 70%, #fff) 120deg 180deg, color-mix(in srgb, var(--tile-color) 40%, #000) 180deg 240deg, color-mix(in srgb, var(--tile-color) 70%, #fff) 240deg 300deg, color-mix(in srgb, var(--tile-color) 40%, #000) 300deg 360deg); box-shadow: 0 16px 26px rgba(2,6,23,0.18), inset 0 1px 0 rgba(255,255,255,0.9) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="flower"] .cell::after{ display:none }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="shadowbox"] { background: linear-gradient(180deg,#f8fafc,#e5e7eb) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="shadowbox"] .slot{ background: color-mix(in oklab, var(--target-color), white 24%) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="shadowbox"] .cell::before{ border-radius: 8px; background: color-mix(in oklab, var(--tile-color), white 10%); box-shadow: 0 2px 0 rgba(2,6,23,0.2), 0 6px 0 rgba(2,6,23,0.16), 0 16px 28px rgba(2,6,23,0.12), inset 0 1px 0 rgba(255,255,255,0.8) }
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="neonwire"] {
  background:
    radial-gradient(600px 400px at 35% 15%, #121a2f 0%, rgba(18,26,47,0) 60%),
    #0e1426;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.06);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="neonwire"] .slot{
  background: color-mix(in srgb, var(--target-color) 46%, #0e1426);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="neonwire"] .cell::before{
  border-radius: 10px;
  background: color-mix(in srgb, var(--tile-color) 25%, #000);
  box-shadow: 0 0 22px color-mix(in srgb, var(--tile-color) 60%, transparent), 0 0 10px color-mix(in srgb, var(--tile-color) 50%, transparent), inset 0 0 0 2px color-mix(in srgb, var(--tile-color) 70%, #fff);
}
:is(.grid, .style-btn .swatch, .style-button .swatch)[data-style="neonwire"] .cell::after{ display:none }
.share-panel { margin-top: 10px; display: grid; gap: 0; align-self: center; width: max-content; max-width: 100%; }
.share-preview-wrap { position: relative; }
.share-preview-skeleton { height: 200px; border-radius: 12px; background: linear-gradient(90deg,#f1f5f9,#e5e7eb,#f1f5f9); background-size: 200% 100%; animation: shine 1.2s linear infinite; }
.share-preview { max-width: 100%; width: auto; height: auto; border-radius: 12px; display: block; margin-left: auto; margin-right: auto; box-shadow: 0 6px 16px rgba(2,6,23,0.12), inset 0 0 0 1px rgba(2,6,23,0.06); }
.share-actions { justify-content: space-around; flex-wrap: wrap; margin-top: 20px; margin-bottom: 7px; width: 100%; }
social-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.button.social { padding: 6px 10px; color: #fff; }
.button.social.fb { background: #1877F2; border-color: #1462c4; }
.button.social.x { background: #111827; border-color: #0b1220; }
.button.social.mail { background: #6b7280; border-color: #4b5563; }
.button.social.ln { background: #0A66C2; border-color: #084f99; }
.button.social.pin { background: #E60023; border-color: #b8001c; }
.button.social.rd { background: #FF4500; border-color: #cc3700; }
.button.social.wa { background: #25D366; border-color: #1da851; }
.button.social.tg { background: #229ED9; border-color: #1a86b8; }
@keyframes shine { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.share-label { font-weight: 700; color: #334155; margin-top: 4px; }
.share-row { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 7px; }
.share-row .share-label { margin: 0; }
.share-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}
.share-buttons a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  transition: opacity 0.2s ease;
}
.share-buttons a:hover { opacity: 0.8; }
.share-buttons .facebook   { background: #3b5998; }
.share-buttons .twitter    { background: #000000; }
.share-buttons .linkedin   { background: #0077b5; }
.share-buttons .pinterest  { background: #bd081c; }
.share-buttons .reddit     { background: #ff4500; }
.share-buttons .whatsapp   { background: #25d366; }
.share-buttons .telegram   { background: #0088cc; }
.share-buttons .email      { background: #666666; }
.grid[data-style="marble"] .cell.selected::before,
.grid[data-style="stone"] .cell.selected::before,
.grid[data-style="leather"] .cell.selected::before,
.grid[data-style="rubber"] .cell.selected::before,
.grid[data-style="fabric"] .cell.selected::before {
  border: 2px solid color-mix(in oklab, var(--tile-color), white 20%);
  box-shadow:
    0 18px 30px rgba(2,6,23,0.22),
    0 8px 16px rgba(2,6,23,0.18),
    0 0 0 4px color-mix(in oklab, var(--tile-color) 45%, transparent),
    inset 0 1px 0 rgba(255,255,255,0.8);
}
.grid[data-style="jelly"] .cell.selected::before {
  border: 3px solid color-mix(in oklab, var(--tile-color), white 28%);
  box-shadow:
    0 18px 30px rgba(2,6,23,0.22),
    0 8px 16px rgba(2,6,23,0.18),
    inset 0 1px 0 rgba(255,255,255,0.8);
}
.grid[data-style="pearl"] .cell.selected::before,
.grid[data-style="bubble"] .cell.selected::before {
  border: 3px solid color-mix(in oklab, var(--tile-color), white 28%);
  box-shadow:
    0 18px 30px rgba(2,6,23,0.22),
    0 8px 16px rgba(2,6,23,0.18),
    inset 0 1px 0 rgba(255,255,255,0.8);
}
.grid[data-style="graffiti"] .cell.selected::before,
.grid[data-style="shadowbox"] .cell.selected::before,
.grid[data-style="neonwire"] .cell.selected::before {
  border: 3px solid color-mix(in oklab, var(--tile-color), white 24%);
  box-shadow:
    0 18px 30px rgba(2,6,23,0.22),
    0 8px 16px rgba(2,6,23,0.18),
    inset 0 1px 0 rgba(255,255,255,0.8);
}
.grid[data-style="flower"] .cell.selected::before {
  border: 3px solid color-mix(in oklab, var(--tile-color), white 26%);
}
.grid[data-style="glass"] .cell.selected::before { border-color: color-mix(in oklab, var(--tile-color), black 26%); }
.grid[data-style="pastel"] .cell.selected::before { border: 2px solid color-mix(in oklab, var(--tile-color), black 18%); }
.grid[data-style="gold"] .cell.selected::before { border: 2px solid color-mix(in oklab, var(--tile-color), black 22%); }
.grid[data-style="fabric"] .cell.selected::before { border-color: color-mix(in oklab, var(--tile-color), black 22%); }
.grid[data-style="pearl"] .cell.selected::before,
.grid[data-style="bubble"] .cell.selected::before { border-color: color-mix(in oklab, var(--tile-color), black 24%); }
.grid[data-style="flower"] .cell.selected::before { border-color: color-mix(in oklab, var(--tile-color), black 22%); }
.grid[data-style="shadowbox"] .cell.selected::before,
.grid[data-style="neonwire"] .cell.selected::before { border-color: color-mix(in oklab, var(--tile-color), black 22%); }
.grid[data-style="3d"] .cell.selected::before {
  box-shadow:
    0 20px 38px rgba(30,64,175,0.22),
    0 10px 20px rgba(30,64,175,0.18),
    0 0 0 2px color-mix(in oklab, var(--tile-color), black 22%),
    0 0 0 8px color-mix(in oklab, var(--tile-color) 55%, transparent),
    inset 0 1px 0 rgba(255,255,255,0.5),
    inset 0 -1px 0 rgba(0,0,0,0.08);
}
.pattern-preview {
  display: grid;
  grid-template-columns: repeat(var(--sw, 6), minmax(0, 1fr));
  gap: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  width: min(92%, 260px);
  margin-left: auto;
  margin-right: auto;
}
.pattern-preview .sq {
  position: relative;
  width: 100%;
  padding-top: 100%;
  border: none;
  border-radius: 0;
  background: transparent !important;
}
.pattern-preview .sq::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 90%;
  height: 90%;
  transform: translate(-50%, -50%);
  border-radius: 6px;
  background: var(--sq-color);
  box-shadow: none;
}
.grid .cell::before {
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.14),
    inset 0 1px 0 rgba(255,255,255,0.45),
    inset 0 -1px 0 rgba(0,0,0,0.08);
}
.grid .cell.selected::before {
  box-shadow:
    0 0 0 2px rgba(0,0,0,0.22),
    0 0 22px 8px var(--tile-color),
    inset 0 1px 0 rgba(255,255,255,0.55),
    inset 0 -1px 0 rgba(0,0,0,0.1);
}
.grid .slot {
  background: var(--target-color);
  filter: brightness(0.92) saturate(1.02);
}
.grid .cell.selected::after {
  box-shadow: inset 0 0 0 999px rgba(255,255,255,0.04);
}
.grid[data-style="3d"] .cell::before {
  box-shadow:
    0 10px 20px rgba(0,0,0,0.10),
    0 0 0 1px rgba(0,0,0,0.15),
    inset 0 1px 0 rgba(255,255,255,0.50),
    inset 0 -1px 0 rgba(0,0,0,0.09);
}
.grid[data-style="3d"] .cell.selected::before {
  box-shadow:
    0 18px 32px rgba(0,0,0,0.18),
    0 0 0 2px rgba(0,0,0,0.24),
    0 0 24px 10px var(--tile-color),
    inset 0 1px 0 rgba(255,255,255,0.60),
    inset 0 -1px 0 rgba(0,0,0,0.10);
}
.grid[data-style="flat"] .cell::before {
  box-shadow: 0 0 0 1px rgba(0,0,0,0.18);
}
.grid[data-style="flat"] .cell.selected::before {
  box-shadow:
    0 0 0 3px rgba(0,0,0,0.28),
    0 0 18px 6px var(--tile-color);
}
.grid[data-style="neon"] .cell::before,
.grid[data-style="neonwire"] .cell::before {
  box-shadow: 0 0 0 1px rgba(0,0,0,0.18);
}
.grid[data-style="neon"] .cell.selected::before,
.grid[data-style="neonwire"] .cell.selected::before {
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.24),
    0 0 8px 0 var(--tile-color),
    0 0 18px 4px var(--tile-color),
    0 0 28px 8px var(--tile-color);
}
.grid[data-style="pastel"] .cell::before {
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.10),
    inset 0 1px 0 rgba(255,255,255,0.55);
}
.grid[data-style="pastel"] .cell.selected::before {
  box-shadow:
    0 0 0 2px rgba(0,0,0,0.16),
    0 12px 18px rgba(0,0,0,0.10);
}
.grid[data-style="glass"] .cell::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.35), rgba(255,255,255,0));
  pointer-events: none;
  border-radius: inherit;
}
.grid[data-style="jelly"], .grid[data-style="bubble"] .cell::before {
  box-shadow:
    0 10px 24px rgba(0,0,0,0.14),
    0 0 0 1px rgba(0,0,0,0.14),
    inset 0 1px 0 rgba(255,255,255,0.55);
}
.overlay-content { background: rgba(255,255,255,0.96); }
.grid .cell  { filter: none; } 
@media (max-width: 768px) {
  html, body { -webkit-text-size-adjust: 100%; }
  body { padding-bottom: 8px; }
  :root {
    --board-scale: 0.96;
    --controls-gap-y: 8px;
    --rotate-btn-width: 40px;
    --rotate-btn-height: 28px;
    --logo-center-offset: 0px;
    --right-center-offset: 0px;
    --right-block-dy: 0px;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px var(--topbar-pad-inline);
  }
  .title {
    margin: 0;
    width: 100%;
    display: flex;
    justify-content: center;
  }
  .logo {
    height: 72px;
  }
  .spacer { display: none; }
  .top-right {
    width: 100%;
    margin: 0;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .button, .icon-button, .pattern-button {
    min-height: 44px;
  }
  .icon-button { width: 44px; height: 44px; }
  .size-value { min-width: 40px; }
  .main {
    padding: 0 12px 20px;
  }
  .board-wrap {
    width: 100%;
    justify-items: center;
  }
  .board-toolbar {
    grid-template-columns: 1fr auto 1fr;
    column-gap: 8px;
    width: 100%;
  }
  #btn-rotate-left { justify-self: start; }
  #btn-rotate-right { justify-self: end; }
  #moves {
    justify-self: center;
    font-weight: 700;
  }
  .grid {
    width: min(92vw, 544px);
    --gap: 10px; 
  }
  .overlay-content {
    width: 96vw;
    padding: 16px 14px 12px;
    border-radius: 14px;
  }
  .overlay-content h2 {
    font-size: 1.125rem;
  }
  .rules {
    margin: 6px 0 8px 18px;
    padding-left: 4px;
  }
  .actions {
    gap: 10px;
  }
  .pattern-list,
  .style-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .style-btn .swatch { width: 56px; height: 56px; }
  .style-btn .caption { font-size: 11px; }
  #btn-rotate-left { margin-left: 0; }
  #btn-rotate-right { margin-right: 0; }
}
@media (max-width: 400px) {
  :root {
    --rotate-btn-width: 36px;
    --rotate-btn-height: 26px;
  }
  .logo { height: 64px; }
  #moves { font-size: 0.95rem; }
  .grid { width: 94vw; }
}
@media (max-width: 768px) and (min-resolution: 2dppx) {
  .cell::after { opacity: 0.6; }
}
@supports (padding: max(0px)) {
  .topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .overlay-content { padding-bottom: max(12px, calc(12px + env(safe-area-inset-bottom))); }
}

#btn-rotate-left,
#btn-rotate-right {
  filter: none;
  transition: filter .18s ease, box-shadow .18s ease, transform .1s ease;
}

#btn-rotate-left::before,
#btn-rotate-right::before {
  opacity: .12;
}

#btn-rotate-left:hover,
#btn-rotate-right:hover {
  filter: brightness(1.5);
  background: linear-gradient(145deg, #60a5fa 0%, #2563eb 60%, #1e40af 100%) !important;
}

#btn-rotate-left:hover::before,
#btn-rotate-right:hover::before {
  opacity: .18;
}

#btn-rotate-left:active,
#btn-rotate-right:active {
  filter: brightness(.95);
}

#btn-rotate-left:focus,
#btn-rotate-left:focus-visible,
#btn-rotate-right:focus,
#btn-rotate-right:focus-visible,
#btn-rotate-left:not(:hover):not(:active),
#btn-rotate-right:not(:hover):not(:active) {
  filter: none;
}

@media (max-width: 600px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 12px;
    gap: 8px;
  }

  .title {
    order: -1;
    width: auto;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    margin: 0;
  }

  .logo {
    height: 140px;
    width: auto;
    max-width: 90vw;
  }

  .top-right {
    order: 2;
    width: 100%;
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: wrap;
  }

  .spacer {
    display: none;
  }
}

@media (max-width: 600px) {
  .logo {
    height: var(--mobile-logo-size, clamp(120px, 24vw, 160px));
    width: auto;
    max-width: 90vw;
  }
}

html, body { overflow-x: hidden; }

@media (max-width: 768px) {
  :root {
    --logo-center-offset: 0px;
    --right-center-offset: 0px;
    --right-block-dy: 0px;
  }
  .topbar { flex-wrap: wrap; }
  .title { margin-left: 0; }
  .top-right { margin-right: 0; }
}

.topbar, .main, .overlay-content { max-width: 100%; }
.grid { max-width: 100%; }
