/* melody.games · 国际象棋 — full-bleed 3D board you learn by touching.
   No teaching text: the board's colours and motion carry the rules. */

:root {
  --move-fill: #57b673;
  --capture-fill: #d8694e;
  --castle-fill: #cea23a;
  --focus-ring: rgba(201, 166, 74, 0.48);
}

body {
  height: 100dvh;
  min-height: unset;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(135deg, rgba(255, 250, 240, 0.76), rgba(227, 216, 191, 0.58)),
    var(--paper);
}

.paper-grain { opacity: 0.38; }

.site-header {
  min-height: 74px;
  padding: 14px 24px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto;
  align-items: center;
  gap: 18px;
  background: rgba(255, 250, 240, 0.92);
  border-bottom-color: rgba(42, 53, 84, 0.14);
}

.brand-text { display: grid; gap: 4px; min-width: 0; }

.brand-tagline {
  font-family: var(--font-cn-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer {
  position: relative;
  z-index: 5;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  padding: 16px;
  overflow: hidden;
}

.canvas-frame {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: linear-gradient(145deg, #f8f0dd 0%, #dbe5cf 48%, #b8c9b2 100%);
  box-shadow: 0 5px 0 rgba(42, 53, 84, 0.18);
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  touch-action: none;
}

/* Name badge — appears only while a piece is selected (兵 Pawn …). */
.piece-name {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 20px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.92);
  box-shadow: 0 4px 0 rgba(42, 53, 84, 0.16);
  backdrop-filter: blur(8px);
  animation: pn-pop 0.22s ease;
}

.piece-name[hidden] { display: none; }

.pn-zh {
  font-family: var(--font-cn-body);
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}

.pn-en {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: rgba(42, 53, 84, 0.62);
}

@keyframes pn-pop {
  from { transform: translateX(-50%) translateY(-6px) scale(0.92); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}

/* Shapes-only legend: green dot = move · red ring = capture · gold = special. */
.legend {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1.5px solid rgba(42, 53, 84, 0.18);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.85);
  box-shadow: 0 4px 0 rgba(42, 53, 84, 0.12);
  backdrop-filter: blur(8px);
}

.legend-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-block;
}

.lg-move {
  background: var(--move-fill);
  box-shadow: 0 0 0 5px rgba(87, 182, 115, 0.18);
}

.lg-capture {
  background: transparent;
  border: 4px solid var(--capture-fill);
}

.lg-castle {
  background: var(--castle-fill);
  box-shadow: 0 0 0 5px rgba(206, 162, 58, 0.2);
}

.reset-btn {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(42, 53, 84, 0.18);
  transition: transform 0.12s ease, background 0.12s ease;
}

.reset-btn:hover { transform: translateY(-1px); background: var(--paper-2); }
.reset-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(42, 53, 84, 0.18); }
.reset-btn:focus-visible { outline: 4px solid var(--focus-ring); outline-offset: 2px; }

.site-footer {
  flex-shrink: 0;
  margin-top: 0;
  padding-bottom: 12px;
}

.explore-title { text-transform: none; }

.site-footer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

@media (max-width: 900px) {
  body { height: 100dvh; overflow: hidden; }
  .viewer { padding: 12px; }
}

@media (max-width: 560px) {
  .site-header {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 14px 18px;
  }

  .viewer { padding: 10px; }

  .legend { left: 10px; bottom: 10px; padding: 8px 11px; gap: 10px; }
  .legend-dot { width: 16px; height: 16px; }
  .reset-btn { right: 10px; bottom: 10px; width: 46px; height: 46px; }
  .piece-name { top: 10px; padding: 6px 15px; gap: 8px; }
  .pn-zh { font-size: 22px; }
  .pn-en { font-size: 12px; }
}
