/* Paint by Number v2 — tavern-craft kids' art styling. */
:root {
  --void: #030206; --gold: #c4902a; --gold-lt: #e6b040; --gold-dim: #8a6018;
  --parch: #d0bc98; --mist: #9a8fb5; --panel: #120d20;
  --ff-title: 'Cinzel Decorative', serif; --ff-head: 'Cinzel', serif; --ff-body: 'IM Fell English', Georgia, serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--void); color: var(--parch); font-family: var(--ff-body); font-size: 1.05rem; line-height: 1.6; min-height: 100vh; overflow-x: hidden; }

.ka-head {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 0.7rem 1rem; background: rgba(3,2,6,0.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(196,144,42,0.3);
}
.ka-brand { font-family: var(--ff-title); color: var(--gold-lt); text-decoration: none; font-size: 1rem; }
.ka-nav { display: flex; gap: 8px; }
.ka-nav a {
  color: var(--parch); text-decoration: none; font-family: var(--ff-head); font-weight: 700; font-size: 0.8rem;
  border: 1px solid rgba(196,144,42,0.45); border-radius: 8px; padding: 8px 12px; background: rgba(196,144,42,0.08);
}
.ka-nav a:hover { background: rgba(196,144,42,0.22); }

.pbn-main { max-width: 860px; margin: 0 auto; padding: 18px 14px 30px; }
.ka-title { font-family: var(--ff-title); color: var(--gold-lt); font-size: clamp(1.7rem, 6vw, 2.5rem); text-align: center; margin: 8px 0 4px; }
.ka-howto { text-align: center; font-style: italic; color: var(--mist); max-width: 560px; margin: 0 auto 18px; }
.ka-h2 { font-family: var(--ff-head); color: var(--gold-lt); font-size: 1.05rem; letter-spacing: 0.05em; margin: 20px 0 10px; }
.pbn-cur-title { color: var(--parch); }
.ka-note { text-align: center; color: var(--mist); font-style: italic; margin-top: 22px; font-size: 0.95rem; }
.ka-foot { border-top: 1px solid rgba(196,144,42,0.25); text-align: center; padding: 18px 12px 26px; color: var(--mist); }
.ka-foot a { color: var(--gold-lt); }
.ka-foot-small { font-size: 0.85rem; margin-top: 6px; }

.ka-btn {
  min-height: 48px; padding: 10px 18px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--gold-dim); background: rgba(196,144,42,0.1); color: #e8d9b8;
  font-family: var(--ff-head); font-weight: 700; font-size: 0.92rem;
}
.ka-btn:hover { background: rgba(196,144,42,0.24); }
.ka-btn-main { background: linear-gradient(160deg, #e6b040, #c4902a); color: #241703; border-color: var(--gold-lt); }
.ka-btn:focus-visible, .ka-nav a:focus-visible, .pbn-pick:focus-visible, .pbn-color:focus-visible, .ka-zbtn:focus-visible {
  outline: 3px solid #ffd454; outline-offset: 2px;
}

/* picture picker — real art thumbnails */
.pbn-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pbn-pick {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 8px 12px; border-radius: 12px; cursor: pointer; min-height: 92px;
  background: var(--panel); border: 2px solid rgba(196,144,42,0.35); color: var(--parch);
  font-family: var(--ff-body);
}
.pbn-pick:hover { border-color: var(--gold); }
.pbn-pick.active { border-color: var(--gold-lt); background: #1d1533; box-shadow: 0 0 0 3px rgba(230,176,64,0.25); }
.pbn-pick-img { width: 100%; height: 92px; object-fit: cover; border-radius: 8px; border: 1px solid rgba(196,144,42,0.35); }
.pbn-pick-name { font-family: var(--ff-head); font-weight: 700; font-size: 0.9rem; text-align: center; }
.pbn-pick-prog { font-size: 0.82rem; color: var(--mist); font-style: italic; }

/* zoom viewport + world */
.ka-viewport {
  position: relative; width: min(100%, 72vh); margin: 0 auto; aspect-ratio: 1 / 1;
  overflow: hidden; border-radius: 14px; border: 2px solid rgba(196,144,42,0.5);
  background: radial-gradient(circle at 50% 38%, #181130, #070512 78%);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.ka-world { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
.ka-zoombar { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 0 auto 10px; }
.ka-zbtn {
  min-width: 50px; min-height: 50px; padding: 6px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--gold-dim); background: rgba(196,144,42,0.12); color: #e8d9b8;
  font-family: var(--ff-head); font-weight: 900; font-size: 1.25rem; line-height: 1;
}
.ka-zbtn:hover { background: rgba(196,144,42,0.26); }
.ka-zoom-level { font-family: var(--ff-head); font-weight: 700; color: var(--gold-lt); min-width: 52px; text-align: center; }
.ka-zoom-hint { color: var(--mist); font-style: italic; font-size: 0.88rem; width: 100%; text-align: center; }

/* stage */
.pbn-svg { width: 100%; height: 100%; display: block; }
.pbn-region { stroke: #4a3b28; stroke-width: 1.1; cursor: pointer; transition: fill 0.25s ease; }
.pbn-region:hover { stroke: #e6b040; stroke-width: 1.8; }
.pbn-region.filled { cursor: default; }
.pbn-region:focus-visible { outline: none; stroke: #ffd454; stroke-width: 2.4; }
.pbn-num {
  font-family: var(--ff-head); font-weight: 700; fill: #6b532f;
  text-anchor: middle; dominant-baseline: central; pointer-events: none; user-select: none;
}

/* peek: the finished painting as a faint underlay beneath the outlines.
   The <img> lives inside the zoom world (under the SVG); while peeking,
   unfilled regions go translucent so the art shows through and the
   numbers/outlines stay readable on top. */
.pbn-peek-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.3s ease; pointer-events: none; user-select: none;
}
.pbn-svg { position: relative; }
.pbn-peeking .pbn-peek-img { opacity: 0.92; }
.pbn-peeking .pbn-region { fill-opacity: 0.22; }
.pbn-peeking .pbn-region.filled { fill-opacity: 1; }
.ka-peek-btn { font-size: 0.95rem; font-weight: 700; }
.ka-peek-btn[aria-pressed="true"] { background: rgba(255,212,84,0.3); border-color: #ffd454; }

/* finished-painting reference thumbnail beside the palette */
.pbn-ref { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; }
.pbn-ref[hidden] { display: none; }
.pbn-ref-img { width: 92px; height: 92px; object-fit: cover; border-radius: 10px; border: 2px solid rgba(196,144,42,0.5); }
.pbn-ref-cap { font-style: italic; color: var(--mist); font-size: 0.95rem; }

.pbn-progress-wrap { height: 16px; background: #0a0812; border: 1px solid rgba(196,144,42,0.4); border-radius: 8px; margin: 12px auto 0; overflow: hidden; max-width: 640px; }
.pbn-progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #c4902a, #ffd454); transition: width 0.35s ease; }
.pbn-progress-text { text-align: center; font-family: var(--ff-head); font-weight: 600; margin-top: 7px; min-height: 1.4em; }
.pbn-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
.pbn-celebrate { border-color: #ffd454; box-shadow: 0 0 26px rgba(255, 212, 84, 0.45); }

/* palette */
.pbn-palette { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 9px; }
.pbn-color {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 6px; border-radius: 12px; cursor: pointer; min-height: 86px;
  background: var(--panel); border: 2px solid rgba(196,144,42,0.3); color: var(--parch); font-family: var(--ff-body);
}
.pbn-color:hover { border-color: var(--gold); }
.pbn-color.selected { border-color: #ffd454; box-shadow: 0 0 0 3px rgba(255,212,84,0.35); background: #1d1533; }
.pbn-color.done { opacity: 0.45; cursor: default; }
.pbn-swatch {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: var(--ff-head); font-weight: 900; font-size: 1.15rem; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.75); border: 2px solid rgba(255,255,255,0.55);
}
.pbn-color-name { font-size: 0.88rem; font-weight: 700; font-family: var(--ff-head); text-align: center; }
.pbn-color-left { font-size: 0.8rem; color: var(--mist); font-style: italic; }

/* feedback animations */
@keyframes pbn-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
@keyframes pbn-pop { 0% { opacity: 0.4; } 100% { opacity: 1; } }
@keyframes pbn-nudge { 0%,100% { stroke-width: 1.1; } 50% { stroke: #ffd454; stroke-width: 3; } }
.pbn-region.shake { animation: pbn-shake 0.28s ease; }
.pbn-region.pop { animation: pbn-pop 0.3s ease; }
.pbn-region.nudge { animation: pbn-nudge 0.5s ease; }
@media (prefers-reduced-motion: reduce) {
  .pbn-region.shake, .pbn-region.pop, .pbn-region.nudge { animation: none; }
  .pbn-region, .pbn-progress-bar { transition: none; }
}
