:root {
  --paper: #f3efe4;
  --paper-deep: #e6dfcf;
  --ink: #18383b;
  --ink-soft: #647777;
  --grid: #9aa7a3;
  --grid-bold: #284b4d;
  --coral: #e6644f;
  --coral-dark: #c94d3c;
  --sun: #edb84f;
  --white: #fffdf7;
  --museum-wall: #d8cfbf;
  --museum-shadow: rgba(73, 60, 43, .18);
  --cell: clamp(11.5px, 3.75vw, 30px);
  --row-clue: clamp(38px, 10vw, 74px);
  --col-clue: clamp(82px, 20vw, 126px);
  --puzzle-cols: 20;
  --puzzle-rows: 15;
  color-scheme: light;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  position: relative;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse 26% 44% at 15% -4%, rgba(255,255,255,.88) 0, rgba(255,255,255,.28) 45%, transparent 72%),
    radial-gradient(ellipse 30% 48% at 50% -6%, rgba(255,255,255,.82) 0, rgba(255,255,255,.22) 47%, transparent 73%),
    radial-gradient(ellipse 26% 44% at 85% -4%, rgba(255,255,255,.88) 0, rgba(255,255,255,.28) 45%, transparent 72%),
    linear-gradient(180deg, #e8e1d4 0%, var(--museum-wall) 70%, #c9bda9 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  z-index: 0;
  height: 68px;
  border-bottom: 1px solid rgba(81, 68, 50, .3);
  background:
    linear-gradient(180deg, rgba(255,255,255,.85), rgba(217,207,190,.78)),
    repeating-linear-gradient(90deg, transparent 0 78px, rgba(92,76,54,.08) 79px 80px);
  box-shadow:
    0 5px 0 rgba(255,255,255,.35),
    0 11px 20px rgba(70, 58, 42, .13);
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: auto 0 0;
  z-index: 0;
  height: 15vh;
  min-height: 90px;
  border-top: 1px solid rgba(86, 67, 44, .28);
  background:
    repeating-linear-gradient(104deg, transparent 0 76px, rgba(70,48,27,.11) 77px 79px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.08) 0 28px, rgba(76,53,31,.1) 29px 30px),
    linear-gradient(180deg, #b9a489, #91785d);
  box-shadow: 0 -10px 28px rgba(84, 65, 42, .1);
  pointer-events: none;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.paper-texture {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .42;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.72) 0 1px, transparent 1.4px),
    radial-gradient(circle at 70% 65%, rgba(82,65,44,.07) 0 1px, transparent 1.3px),
    repeating-linear-gradient(90deg, transparent 0 239px, rgba(91,73,51,.055) 240px 241px);
  background-size: 17px 17px, 23px 23px, auto;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1800px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 12px);
  grid-template-rows: repeat(2, 12px);
  gap: 3px;
  padding: 8px;
  background: var(--ink);
  transform: rotate(-3deg);
}

.brand-mark i { background: var(--paper); }
.brand-mark i:nth-child(1), .brand-mark i:nth-child(4) { background: var(--coral); }

.brand small, .timer-box span {
  display: block;
  margin-bottom: 2px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
}

.brand strong { font-size: clamp(18px, 3vw, 25px); letter-spacing: .04em; }

.timer-box {
  min-width: 92px;
  padding-left: 20px;
  border-left: 1px solid var(--grid);
  text-align: right;
}

.timer-box strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 21px;
  letter-spacing: .06em;
}

.intro {
  display: grid;
  grid-template-columns: 1fr 220px;
  align-items: end;
  gap: 32px;
  padding: 30px 0 22px;
}

.kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 9px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
}

.kicker span {
  display: inline-block;
  padding: 4px 8px;
  color: var(--white);
  background: var(--coral);
  letter-spacing: .1em;
}

h1 { margin: 0; font-size: clamp(21px, 4vw, 34px); line-height: 1.35; letter-spacing: .02em; }

.art-meta { margin: 11px 0 0; color: var(--ink); font-size: 13px; }
.art-meta strong { margin-right: 10px; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: 16px; }
.art-meta span { color: var(--ink-soft); }

.difficulty-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
}

.difficulty-meta span {
  padding: 3px 7px;
  color: var(--white);
  background: var(--ink);
  font: 700 10px ui-monospace, monospace;
  letter-spacing: .08em;
}

.difficulty-meta strong { color: var(--coral-dark); font: 700 11px ui-monospace, monospace; }

.progress-copy {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
}

.progress-copy strong { font-family: ui-monospace, monospace; font-size: 14px; }

.progress-track { height: 7px; overflow: hidden; background: var(--paper-deep); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--coral); transition: width .2s ease; }

.artist-switch {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin: 2px 0 10px;
}

.artist-tab {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  min-width: 260px;
  padding: 10px 14px;
  color: var(--ink-soft);
  background: rgba(255, 253, 247, .45);
  border: 1px solid var(--grid);
  cursor: pointer;
}

.artist-tab span { font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: 13px; font-weight: 700; }
.artist-tab small { font: 700 9px ui-monospace, monospace; letter-spacing: .1em; }
.artist-tab:hover { color: var(--ink); background: rgba(255, 253, 247, .85); }
.artist-tab.active { color: var(--white); background: var(--coral-dark); border-color: var(--coral-dark); }

.gallery-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--grid);
  border-left: 1px solid var(--grid);
  margin-bottom: 16px;
}

.gallery-tab {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 253, 247, .45);
  border: 0;
  border-right: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  text-align: left;
  cursor: pointer;
}

.gallery-tab:hover { background: rgba(255, 253, 247, .85); }
.gallery-tab.active { color: var(--white); background: var(--ink); }
.gallery-tab span:nth-child(2) { min-width: 0; }
.gallery-tab strong, .gallery-tab small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-tab strong { font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: 13px; }
.gallery-tab small { margin-top: 3px; color: var(--ink-soft); font-size: 9px; }
.gallery-tab.active small { color: rgba(255,255,255,.62); }
.gallery-no { font: 700 11px ui-monospace, monospace; opacity: .65; }
.gallery-tab i { width: 8px; height: 8px; border-radius: 50%; background: var(--paper-deep); }
.gallery-tab.solved i { background: var(--sun); box-shadow: 0 0 0 2px rgba(237,184,79,.25); }

.game-card {
  padding: clamp(14px, 3vw, 28px);
  background: rgba(255, 253, 247, .92);
  border: 1px solid rgba(75, 63, 47, .38);
  outline: 5px solid rgba(243, 239, 228, .62);
  box-shadow:
    0 20px 50px var(--museum-shadow),
    8px 8px 0 rgba(187, 174, 151, .7);
}

.game-card.info-open {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
  gap: 28px;
}

.game-main { min-width: 0; }

.board-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--paper-deep);
}

.board-toolbar > span strong { font: 700 13px ui-monospace, monospace; }
.board-toolbar > span small { margin-left: 6px; color: var(--ink-soft); font: 700 9px ui-monospace, monospace; letter-spacing: .12em; }

.zoom-controls { display: flex; align-items: center; border: 1px solid var(--grid); }
.zoom-controls button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 30px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.zoom-controls button:disabled { opacity: .25; cursor: default; }
.zoom-controls output { min-width: 48px; color: var(--ink-soft); font: 700 10px ui-monospace, monospace; text-align: center; }

.board-scroller {
  display: block;
  max-height: none;
  overflow: visible;
}

.puzzle-grid {
  position: relative;
  display: grid;
  grid-template-columns: var(--row-clue) repeat(var(--puzzle-cols), var(--cell));
  grid-template-rows: var(--col-clue) repeat(var(--puzzle-rows), var(--cell));
  width: max-content;
  margin: 0 auto;
  user-select: none;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

.corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 6;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 8px 8px 0;
  color: var(--ink-soft);
  font: 700 10px ui-monospace, monospace;
  letter-spacing: .05em;
  background: var(--white);
}

.col-clue, .row-clue {
  color: var(--ink);
  font: 700 clamp(8px, 1.4vw, 12px) ui-monospace, SFMono-Regular, Menlo, monospace;
  transition: opacity .2s ease, color .2s ease;
}

.col-clue {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--grid-bold);
  background: var(--white);
}

.row-clue {
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  padding-right: 9px;
  border-right: 2px solid var(--grid-bold);
  background: var(--white);
}

.col-clue span, .row-clue span { transition: opacity .2s ease, color .2s ease; }
.col-clue span.counted, .row-clue span.counted { color: var(--ink-soft); opacity: .26; }
.col-clue.has-error span, .row-clue.has-error span,
.col-clue.has-error span.counted, .row-clue.has-error span.counted { color: var(--coral-dark); opacity: 1; }
.col-clue.major-right { border-right: 2px solid var(--grid-bold); }
.row-clue.major-bottom { border-bottom: 2px solid var(--grid-bold); }

.cell {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  border: 0;
  border-right: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  color: var(--ink-soft);
  background: rgba(255, 253, 247, .72);
  cursor: pointer;
  touch-action: none;
}

.cell:nth-child(n) { font-size: clamp(12px, 2.8vw, 22px); line-height: 1; }
.cell.major-right { border-right: 2px solid var(--grid-bold); }
.cell.major-bottom { border-bottom: 2px solid var(--grid-bold); }
.cell.filled { background: var(--ink); color: transparent; }
.cell.revealed { border-color: rgba(255,255,255,.22); box-shadow: none; }
.cell.revealed { image-rendering: pixelated; }
.cell.revealed::before, .cell.revealed::after { display: none; }
.cell.crossed::before, .cell.crossed::after {
  content: "";
  position: absolute;
  width: 58%;
  height: 1.5px;
  background: var(--ink-soft);
}
.cell.crossed::before { transform: rotate(45deg); }
.cell.crossed::after { transform: rotate(-45deg); }
.cell:hover { box-shadow: inset 0 0 0 2px var(--coral); z-index: 1; }
.cell:focus-visible { z-index: 2; outline: 3px solid var(--sun); outline-offset: -3px; }

.puzzle-grid.compact-board .col-clue { gap: 2px; padding-bottom: 4px; font-size: calc(var(--cell) * .82); line-height: 1; }
.puzzle-grid.compact-board .row-clue { gap: 3px; padding-right: 4px; font-size: calc(var(--cell) * .78); line-height: 1; }
.puzzle-grid.compact-board .cell:hover { box-shadow: inset 0 0 0 1px var(--coral); }

.art-reveal {
  position: absolute;
  top: var(--col-clue);
  left: var(--row-clue);
  z-index: 8;
  width: calc(var(--cell) * var(--puzzle-cols));
  height: calc(var(--cell) * var(--puzzle-rows));
  padding: 0;
  overflow: hidden;
  border: 3px solid var(--ink);
  color: var(--white);
  background: var(--ink);
  box-shadow: 7px 8px 0 rgba(24, 56, 59, .2);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  filter: blur(8px);
  transform: translateY(14px) scale(.975);
  transition: opacity .8s ease, filter .8s ease, transform .8s cubic-bezier(.2,.8,.2,1);
}

.art-reveal.show {
  opacity: 1;
  pointer-events: auto;
  filter: none;
  transform: none;
}

.art-reveal img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.art-reveal span {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 7px 12px;
  background: rgba(24, 56, 59, .86);
  box-shadow: 3px 3px 0 rgba(255,255,255,.72);
  font-size: clamp(10px, 1.4vw, 13px);
  font-weight: 700;
  letter-spacing: .04em;
  transform: translateX(-50%);
}

.control-area {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--paper-deep);
}

.tool-switch { display: flex; gap: 8px; }

.tool-button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 120px;
  padding: 9px 12px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--grid);
  cursor: pointer;
}

.tool-button.active { color: var(--white); background: var(--ink); border-color: var(--ink); }
.tool-button strong, .tool-button small { display: block; text-align: left; }
.tool-button strong { font-size: 13px; }
.tool-button small { margin-top: 1px; color: var(--ink-soft); font-size: 10px; }
.tool-button.active small { color: rgba(255,255,255,.68); }

.fill-icon { width: 19px; height: 19px; background: currentColor; border: 1px solid currentColor; }
.tool-button.active .fill-icon { background: var(--coral); border-color: var(--coral); }
.cross-icon { display: grid; place-items: center; width: 19px; height: 19px; font: 400 23px/1 sans-serif; }
.pencil-icon { display: grid; place-items: center; width: 19px; height: 19px; font: 400 22px/1 serif; transform: rotate(-12deg); }

.cell.penciled::before {
  content: "";
  width: 34%;
  height: 34%;
  border: 1.5px solid var(--coral);
  transform: rotate(-10deg);
}

.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px 16px; }

.text-button {
  padding: 8px 0;
  color: var(--ink);
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.text-button:hover { border-bottom-color: currentColor; }
.text-button:disabled { opacity: .35; cursor: default; }
.text-button.danger { color: var(--coral-dark); }

.status-message { margin: 18px 0 0; color: var(--ink-soft); font-size: 12px; text-align: center; }

.ad-zone {
  width: min(100%, 970px);
  min-height: 100px;
  margin: 28px auto 18px;
  padding: 8px;
  border-block: 1px solid rgba(100, 119, 119, .28);
  background: rgba(255, 253, 247, .55);
  text-align: center;
}
.ad-zone[hidden] { display: none; }
.ad-label { display: block; margin-bottom: 5px; color: var(--ink-soft); font: 700 8px ui-monospace, monospace; letter-spacing: .15em; }

.site-footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 48px;
  padding: 24px 8px 30px;
  border-top: 1px solid rgba(100, 119, 119, .32);
  color: var(--ink-soft);
  font-size: 11px;
}
.site-footer a { color: inherit; }

.legal-shell {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - 28px));
  margin: 36px auto;
  padding: clamp(24px, 5vw, 54px);
  border: 1px solid var(--grid);
  background: var(--white);
  box-shadow: 8px 10px 0 rgba(73, 60, 43, .12);
}
.legal-shell h1 { margin: 0 0 24px; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; }
.legal-shell h2 { margin: 30px 0 10px; font-size: 17px; }
.legal-shell p, .legal-shell li { color: #3f5658; font-size: 14px; line-height: 1.9; }
.legal-back { display: inline-block; margin-top: 28px; color: var(--coral-dark); font-weight: 700; }

.art-info-panel {
  position: relative;
  display: none;
  min-width: 0;
  padding: 6px 0 4px 28px;
  border-left: 1px solid var(--grid);
}

.game-card.info-open .art-info-panel {
  display: block;
  animation: info-in .36s ease both;
}

@keyframes info-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

.info-close {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--grid);
  cursor: pointer;
}

.info-label {
  margin: 2px 40px 14px 0;
  color: var(--coral-dark);
  font: 700 10px ui-monospace, monospace;
  letter-spacing: .14em;
}

.art-info-panel > img {
  display: block;
  width: 100%;
  max-height: 240px;
  margin-bottom: 18px;
  border: 5px solid var(--paper-deep);
  outline: 1px solid var(--ink);
  object-fit: contain;
  background: var(--paper-deep);
}

.art-info-panel h2 {
  margin: 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 25px;
}

.info-artist { margin: 5px 0 17px; color: var(--ink-soft); font-size: 12px; }
.info-description { margin: 0 0 18px; font-size: 13px; line-height: 1.8; }

.art-facts { margin: 0 0 14px; border-top: 1px solid var(--paper-deep); }
.art-facts div { display: grid; grid-template-columns: 58px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--paper-deep); }
.art-facts dt { color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.art-facts dd { margin: 0; font-size: 11px; }

.source-link, .license-link {
  display: inline-block;
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  text-underline-offset: 3px;
}

.rights-note { margin: 0 0 17px; color: var(--ink-soft); font-size: 10px; line-height: 1.5; }
.rights-note .license-link { margin: 0; color: var(--coral-dark); }

.win-dialog {
  width: min(420px, calc(100% - 32px));
  padding: 38px 30px 30px;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--ink);
  box-shadow: 10px 10px 0 rgba(24, 56, 59, .2);
  text-align: center;
  overflow: hidden;
}
.win-dialog::backdrop { background: rgba(19, 40, 42, .65); backdrop-filter: blur(3px); }
.win-dialog .kicker { justify-content: center; }
.win-dialog h2 { margin: 10px 0 8px; font-size: 26px; }
.win-dialog p { margin: 0 0 24px; color: var(--ink-soft); }
.win-art {
  display: grid;
  grid-template-columns: repeat(20, 6px);
  grid-template-rows: repeat(15, 6px);
  width: max-content;
  margin: 0 auto 18px;
  border: 6px solid var(--paper-deep);
  outline: 2px solid var(--ink);
  background: #eee7d7;
  image-rendering: pixelated;
}
.win-art i { display: block; width: 6px; height: 6px; }

.primary-button {
  width: 100%;
  padding: 13px 20px;
  color: var(--white);
  background: var(--coral);
  border: 0;
  box-shadow: 4px 4px 0 var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.primary-button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }

.mobile-gamepad { display: none; }

.confetti span { position: absolute; width: 8px; height: 14px; animation: fall 1.2s ease-out both; }
@keyframes fall { from { transform: translateY(-50px) rotate(0); opacity: 1; } to { transform: translateY(380px) rotate(430deg); opacity: 0; } }

@media (max-width: 720px) {
  :root {
    --row-clue: 42px;
    --col-clue: 84px;
    --cell: min(24px, calc((100vw - 80px) / 20));
  }
  body { padding-bottom: calc(166px + env(safe-area-inset-bottom)); }
  body.gamepad-off { padding-bottom: calc(54px + env(safe-area-inset-bottom)); }
  .app-shell { width: min(100% - 4px, 620px); padding-top: 14px; }
  .topbar { padding-bottom: 14px; }
  .brand-mark { grid-template-columns: repeat(2, 9px); grid-template-rows: repeat(2, 9px); padding: 6px; }
  .intro { grid-template-columns: 1fr; gap: 17px; padding: 22px 2px 16px; }
  .progress-wrap { width: min(100%, 280px); }
  .game-card { padding: 10px 2px 16px; box-shadow: 3px 4px 0 var(--paper-deep); }
  .board-toolbar { margin-inline: 8px; }
  .board-scroller { position: relative; overflow: hidden; }
  .artist-switch { overflow-x: auto; scrollbar-width: thin; }
  .artist-tab { min-width: min(260px, 78vw); flex: 0 0 auto; }
  .gallery-nav {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(205px, 68vw);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
  }
  .gallery-tab { min-height: 58px; padding: 9px 12px; scroll-snap-align: start; }
  .corner { padding-right: 3px; font-size: 8px; }
  .corner, .col-clue, .row-clue { cursor: grab; touch-action: none; }
  .puzzle-grid.clue-dragging .corner,
  .puzzle-grid.clue-dragging .col-clue,
  .puzzle-grid.clue-dragging .row-clue { cursor: grabbing; }
  .col-clue { gap: 2px; padding-bottom: 4px; font-size: min(7px, calc(var(--cell) * .78)); }
  .row-clue { gap: 3px; padding-right: 3px; font-size: min(8px, calc(var(--cell) * .78)); }
  .col-clue span, .row-clue span { line-height: 1; white-space: nowrap; }
  .control-area { align-items: stretch; flex-direction: column; gap: 12px; margin-top: 16px; padding: 14px 5px 0; }
  .tool-switch {
    display: none;
  }
  .mobile-gamepad {
    position: fixed;
    left: 50%;
    bottom: calc(6px + env(safe-area-inset-bottom));
    z-index: 35;
    display: grid;
    grid-template-columns: 106px minmax(132px, 1fr) 48px;
    gap: 8px;
    width: min(430px, calc(100% - 10px));
    min-height: 116px;
    padding: 6px;
    border: 2px solid var(--ink);
    background: rgba(255,253,247,.97);
    box-shadow: 0 9px 30px rgba(24,56,59,.3), 3px 3px 0 var(--coral);
    backdrop-filter: blur(10px);
    transform: translateX(-50%);
  }
  .gamepad-settings {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }
  .gamepad-settings button {
    min-height: 28px;
    padding: 3px 6px;
    color: var(--ink);
    background: var(--paper-deep);
    border: 1px solid var(--grid-bold);
    font: 700 10px ui-monospace, monospace;
  }
  .gamepad-settings button[aria-pressed="false"] { color: var(--ink-soft); background: var(--white); }
  .mobile-gamepad.collapsed {
    grid-template-columns: 1fr;
    width: min(330px, calc(100% - 10px));
    min-height: 0;
    padding: 5px;
  }
  .mobile-gamepad.collapsed > :not(.gamepad-settings) { display: none; }
  .dpad {
    display: grid;
    grid-template: repeat(3, 34px) / repeat(3, 34px);
    gap: 1px;
    place-content: center;
    user-select: none;
    touch-action: none;
  }
  .dpad button, .dpad-center {
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--white);
    background: var(--ink);
    border: 0;
    font: 700 13px ui-monospace, monospace;
  }
  .dpad button:active { color: var(--ink); background: var(--sun); }
  .dpad-up { grid-area: 1 / 2; }
  .dpad-left { grid-area: 2 / 1; }
  .dpad-center {
    grid-area: 2 / 2;
    position: relative;
    z-index: 2;
    color: var(--ink-soft);
    background: var(--paper-deep);
    border: 1px solid var(--grid-bold);
    border-radius: 50%;
    font-size: 8px;
    touch-action: none;
    transform: translate(var(--stick-x, 0), var(--stick-y, 0)) rotate(var(--stick-angle, 0deg));
    transition: transform .1s ease;
  }
  .dpad.steering .dpad-center { color: var(--white); background: var(--coral); transition: none; }
  .dpad-right { grid-area: 2 / 3; }
  .dpad-down { grid-area: 3 / 2; }
  .gamepad-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }
  .gamepad-actions button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    padding: 5px 7px;
    color: var(--ink);
    background: var(--white);
    border: 1px solid var(--grid-bold);
    font-weight: 700;
  }
  .gamepad-actions button:active { color: var(--white); background: var(--coral); }
  .gamepad-actions .gamepad-fill { grid-column: 1 / -1; color: var(--white); background: var(--ink); }
  .gamepad-fill i { width: 15px; height: 15px; background: var(--coral); }
  .gamepad-actions strong { font: 700 21px/1 sans-serif; }
  .gamepad-zoom { display: grid; grid-template-rows: 1fr auto 1fr; border-left: 1px solid var(--paper-deep); }
  .gamepad-zoom button { padding: 0; color: var(--ink); background: transparent; border: 0; font-size: 24px; }
  .gamepad-zoom button:disabled { opacity: .25; }
  .gamepad-zoom output { font: 700 8px ui-monospace, monospace; text-align: center; }
  .cell.game-cursor { z-index: 5; box-shadow: inset 0 0 0 2px var(--coral), 0 0 0 1px var(--sun); }
  .tool-button { flex: 1; justify-content: center; min-width: 0; min-height: 52px; padding: 8px 5px; }
  .actions { justify-content: space-around; gap: 8px; }
  .status-message { margin-bottom: 8px; padding: 0 8px; line-height: 1.6; }
  .ad-zone { min-height: 84px; margin: 8px 2px 20px; }
  .site-footer { margin-top: 30px; padding-bottom: 18px; }
}

@media (max-width: 1050px) {
  .game-card.info-open { display: block; }
  .art-info-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 30;
    width: min(360px, calc(100% - 36px));
    height: 100vh;
    height: 100dvh;
    padding: 28px;
    overflow-y: auto;
    border-top: 0;
    border-left: 2px solid var(--ink);
    background: var(--white);
    box-shadow: -12px 0 30px rgba(24, 56, 59, .24);
  }
  .art-info-panel > img { width: 100%; }
}

@media (max-width: 720px) {
  .art-info-panel {
    width: min(390px, calc(100% - 12px));
    padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  }
  .art-info-panel > img { max-height: 34vh; }
}

@media (max-width: 390px) {
  :root { --row-clue: 38px; }
  .brand small { display: none; }
  .timer-box { min-width: 76px; padding-left: 10px; }
  .timer-box strong { font-size: 18px; }
  .col-clue { font-size: min(7px, calc(var(--cell) * .78)); }
  .row-clue { font-size: min(8px, calc(var(--cell) * .78)); }
  .row-clue { gap: 2px; }
  .tool-button small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
