/* ---- puzzle preview panel (left column, replaces buddy panel on this page) ---- */
.preview-panel {
  background: #fff;
  border-right: 1px solid var(--chrome-dark);
  padding: 12px;
  overflow-y: auto;
}

.preview-panel-header {
  font-weight: bold;
  font-size: 14px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.preview-thumb-frame {
  border: 1px solid #7f9db9;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 1px 1px 0 #fff;
  margin-bottom: 12px;
}

.preview-thumb-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.preview-field {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

#open-picker {
  animation: buddy-picker-glow 1.1s ease-in-out 3;
}

@keyframes buddy-picker-glow {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 5px rgba(255,210,63,.55), 0 0 16px 4px rgba(255,210,63,.55); }
}

.selected-buddy-name {
  margin: 8px 0 12px;
  font-size: 15px;
  font-weight: bold;
  color: var(--title-start);
  text-align: center;
}

/* ---- buddy picker dialog ---- */
.picker-dialog {
  width: min(720px, 92vw);
  max-height: 85vh;
}

.picker-dialog-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(85vh - 32px);
}

.picker-search {
  padding: 8px 10px;
  border: 1px solid #7f9db9;
  border-radius: 3px;
  font-size: 14px;
  color: var(--ink);
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  overflow-y: auto;
  padding: 4px 2px;
}

.picker-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.picker-grid-item .picker-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  border: 2px solid transparent;
  background-size: cover;
  background-position: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.picker-grid-item:hover .picker-thumb {
  border-color: #7f9db9;
}

.picker-grid-item.is-selected .picker-thumb {
  border-color: var(--title-start);
  box-shadow: 0 0 0 2px var(--title-start);
}

.picker-grid-item .picker-item-label {
  font-size: 11px;
  color: var(--ink-muted);
  text-align: center;
  line-height: 1.2;
}

.picker-grid-item.is-selected .picker-item-label {
  color: var(--title-start);
  font-weight: bold;
}

.picker-empty {
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
  margin: 12px 0 4px;
}

.preview-field label {
  font-size: .68rem;
  font-weight: bold;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.preview-stats {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.preview-stats div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed #ddd;
  padding-bottom: 4px;
}

.preview-stats strong { color: var(--title-start); }

/* ---- board ---- */
.puzzle-board {
  display: grid;
  gap: 3px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: #7f9db9;
  border: 1px solid #4a4a4a;
  border-radius: 4px;
  padding: 3px;
  aspect-ratio: 1 / 1;
  transition: gap .35s ease, padding .35s ease;
}

.puzzle-tile {
  border: 0;
  padding: 0;
  cursor: pointer;
  background-color: #dfe9f5;
  background-repeat: no-repeat;
  border-radius: 2px;
  box-shadow: inset -1px -1px 0 rgba(0,0,0,.25), inset 1px 1px 0 rgba(255,255,255,.5);
  -webkit-tap-highlight-color: transparent;
}

.puzzle-tile:hover {
  filter: brightness(1.05);
}

.puzzle-tile.is-blank {
  background: repeating-linear-gradient(45deg, #dfe9f5, #dfe9f5 6px, #cbd9e8 6px, #cbd9e8 12px);
  box-shadow: inset 2px 2px 4px rgba(0,0,0,.2);
  cursor: default;
}

.puzzle-board.is-solved .puzzle-tile {
  box-shadow: none;
}

.puzzle-tile.is-final-reveal {
  animation: tile-reveal-fade .55s ease;
}

@keyframes tile-reveal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.puzzle-board.is-revealing {
  gap: 0;
  padding: 0;
  animation: puzzle-glow 1s ease;
}

.puzzle-board.is-revealing .puzzle-tile {
  border-radius: 0;
  transition: border-radius .35s ease;
}

@keyframes puzzle-glow {
  0% { box-shadow: 0 0 0 0 rgba(255,210,63,0); }
  35% { box-shadow: 0 0 26px 8px rgba(255,210,63,.85); }
  100% { box-shadow: 0 0 0 0 rgba(255,210,63,0); }
}

.peek-frame {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.peek-frame img {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 3px;
  z-index: 5;
}

.peek-frame.is-peeking img {
  display: block;
}

.peek-frame.is-peeking .puzzle-board {
  visibility: hidden;
}

@media (max-width: 640px) {
  .preview-panel {
    border-right: 0;
    border-bottom: 1px solid var(--chrome-dark);
    max-height: none;
  }
}
