/* Puzzles style v20260925n */
:root {
  --bg: #0f1419;
  --bg2: #1a222c;
  --bg3: #243040;
  --border: #2f3d4d;
  --text: #e7eef6;
  --muted: #9aabbc;
  --accent: #81b64c;
  --accent2: #4ea1d3;
  --bad: #e74c3c;
  --warn: #f0ad4e;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; overflow-x: hidden; }
a { color: var(--accent2); text-decoration: none; }
.hidden { display: none !important; }

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.6rem 1.25rem; background: var(--bg2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.brand-icon { font-size: 1.5rem; line-height: 1; color: var(--accent); }
.brand-name { font-weight: 700; font-size: 1.15rem; }
.site-nav { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.nav-link {
  display: inline-flex; align-items: center; padding: 0.38rem 0.8rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg3); color: var(--text);
  font-size: 0.88rem; font-weight: 600; white-space: nowrap;
}
.nav-link:hover { border-color: var(--accent2); text-decoration: none; }

/* ---------- layout ---------- */
.pz-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem;
  max-width: 1180px; margin: 0 auto; padding: 1rem 1.25rem 2rem; align-items: start;
}
.board-col { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.board-wrap { position: relative; width: 100%; max-width: calc(100vh - 235px); min-width: 240px; }
#board { margin: 0 auto; touch-action: none; -webkit-user-select: none; user-select: none; }
#board .board-b72b1 { border: none; border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); }
#board img { -webkit-user-drag: none; }
.side-col { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }

/* board colors close to the live-tournaments app */
#board .white-1e1d7 { background-color: #f0d9b5; color: #b58863; }
#board .black-3c85d { background-color: #b58863; color: #f0d9b5; }

/* ---------- square highlights ---------- */
#board .square-55d63 { position: relative; }
#board .square-55d63.hl-last { box-shadow: inset 0 0 0 999px rgba(205, 210, 106, 0.55); }
#board .square-55d63.hl-sel { box-shadow: inset 0 0 0 999px rgba(20, 85, 30, 0.5); }
#board .square-55d63.hl-good { box-shadow: inset 0 0 0 999px rgba(129, 182, 76, 0.7); }
#board .square-55d63.hl-bad { box-shadow: inset 0 0 0 999px rgba(231, 76, 60, 0.7); }
#board .square-55d63.hl-check { background-image: radial-gradient(circle, rgba(255, 0, 0, 0.85) 0%, rgba(231, 0, 0, 0.45) 40%, rgba(169, 0, 0, 0) 72%); }
#board .square-55d63.hl-dest::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%;
  transform: translate(-50%, -50%); border-radius: 50%; background: rgba(20, 85, 30, 0.45); pointer-events: none; z-index: 3;
}
#board .square-55d63.hl-dest.hl-cap::after {
  width: 86%; height: 86%; background: transparent; border: 5px solid rgba(20, 85, 30, 0.45);
}
#board .square-55d63.hl-hint::before {
  content: ""; position: absolute; inset: 6%; border-radius: 50%; border: 4px solid #4ea1d3;
  box-shadow: 0 0 12px rgba(78, 161, 211, 0.9); pointer-events: none; z-index: 3; animation: pz-pulse 1s ease-in-out infinite alternate;
}
@keyframes pz-pulse { from { opacity: 0.55; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }

.board-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(15, 20, 25, 0.55); color: var(--text); font-weight: 600; border-radius: 6px; z-index: 12;
}

/* ---------- promotion ---------- */
.promo { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.55); z-index: 20; border-radius: 6px; }
.promo-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem 1rem; text-align: center; box-shadow: var(--shadow); }
.promo-card p { margin: 0 0 0.5rem; font-weight: 600; }
.promo-row { display: flex; gap: 0.4rem; justify-content: center; margin-bottom: 0.5rem; }
.promo-row button { width: 64px; height: 64px; border-radius: 10px; border: 1px solid var(--border); background: #f0d9b5; cursor: pointer; padding: 4px; }
.promo-row button:hover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.promo-row img { width: 100%; height: 100%; }

/* ---------- status ---------- */
.status-card {
  width: 100%; display: flex; align-items: center; gap: 0.75rem;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.7rem 0.9rem;
}
.status-card.good { border-color: rgba(129, 182, 76, 0.7); background: linear-gradient(0deg, rgba(129, 182, 76, 0.1), rgba(129, 182, 76, 0.1)), var(--bg2); }
.status-card.bad { border-color: rgba(231, 76, 60, 0.7); background: linear-gradient(0deg, rgba(231, 76, 60, 0.1), rgba(231, 76, 60, 0.1)), var(--bg2); }
.turn-dot { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 22px; border: 2px solid var(--border); background: #fff; }
.turn-dot.black { background: #111; border-color: #667; }
.status-text { flex: 1 1 auto; min-width: 0; }
.status-main { font-weight: 700; font-size: 1rem; }
.status-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.1rem; }
.delta { font-weight: 800; font-size: 1.1rem; padding: 0.2rem 0.55rem; border-radius: 8px; white-space: nowrap; }
.delta.up { color: #b7f28a; background: rgba(129, 182, 76, 0.18); }
.delta.down { color: #ffb3ab; background: rgba(231, 76, 60, 0.18); }
.delta.zero { color: var(--muted); background: var(--bg3); }

/* ---------- buttons ---------- */
.actions { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.4fr); gap: 0.5rem; }
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--bg3); color: var(--text);
  border-radius: 8px; padding: 0.55rem 0.7rem; font: inherit; font-size: 0.92rem; font-weight: 600; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; touch-action: manipulation;
}
.btn:hover:not(:disabled) { border-color: var(--accent2); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: linear-gradient(180deg, #8fc45a, #6fa23c); border-color: #5f8f32; color: #0f1a08; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); border-color: #5f8f32; }
.btn.small { padding: 0.3rem 0.7rem; font-size: 0.82rem; }
.btn.ghost { background: transparent; }
.btn.pulse { animation: pz-glow 1.2s ease-in-out infinite alternate; }
@keyframes pz-glow { from { box-shadow: 0 0 0 0 rgba(129, 182, 76, 0.2); } to { box-shadow: 0 0 0 4px rgba(129, 182, 76, 0.35); } }

/* ---------- side cards ---------- */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem; }
.label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.rating-main { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.rating-val { font-size: 2.2rem; font-weight: 800; line-height: 1.1; }
.prov { color: var(--muted); font-size: 1.2rem; margin-left: 0.1rem; }
.streak { text-align: right; }
.streak-val { font-size: 1.6rem; font-weight: 800; color: var(--warn); line-height: 1.1; }
.streak-val .best { display: block; font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.rating-stats { color: var(--muted); font-size: 0.85rem; margin-top: 0.5rem; }
.recent { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 0.6rem; }
.recent span {
  min-width: 34px; padding: 1px 4px; border-radius: 5px; font-size: 0.7rem; font-weight: 700; text-align: center;
  background: rgba(129, 182, 76, 0.2); color: #b7f28a;
}
.recent span.miss { background: rgba(231, 76, 60, 0.2); color: #ffb3ab; }
.recent span.assist { background: var(--bg3); color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; }
select {
  width: 100%; font: inherit; font-size: 0.95rem; color: var(--text); background: var(--bg3);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.6rem;
}
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.9rem; font-weight: 600; padding: 0.4rem 0; border-radius: 6px; cursor: pointer; touch-action: manipulation; }
.seg button.on { background: var(--accent); color: #0f1a08; }
.hint-text { color: var(--muted); font-size: 0.8rem; margin: 0; }
.puzzle-info { margin-top: 0.35rem; font-size: 0.9rem; color: var(--text); line-height: 1.45; }
.puzzle-info .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 0.35rem; }
.puzzle-info .tags span { background: var(--bg3); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; font-size: 0.78rem; color: var(--muted); }
.foot { color: var(--muted); font-size: 0.78rem; line-height: 1.45; margin: 0; }
.linkish { appearance: none; border: 0; background: none; color: var(--accent2); font: inherit; padding: 0; cursor: pointer; text-decoration: underline; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .pz-layout { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; padding: 0.5rem 0.5rem 1.5rem; }
  .board-wrap { max-width: 640px; min-width: 0; }
  .side-col { gap: 0.7rem; }
}
@media (max-width: 520px) {
  .topbar { padding: 0.5rem 0.6rem; gap: 0.4rem; }
  .brand-name { font-size: 1.05rem; }
  .nav-link { padding: 0.32rem 0.6rem; font-size: 0.8rem; }
  .pz-layout { padding: 0.35rem 0.35rem 1.5rem; }
  .actions { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.4rem; }
  .actions #btnNext { grid-column: 1 / -1; padding: 0.7rem; font-size: 1rem; }
  .btn { padding: 0.55rem 0.3rem; font-size: 0.85rem; }
  .status-card { padding: 0.6rem 0.7rem; }
  .rating-val { font-size: 1.9rem; }
}
@media (max-width: 360px) {
  .brand-name { display: none; }
}

/* v20260925l: sound toggle */
.icon-btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 34px; padding: 0; border-radius: 999px; cursor: pointer; flex-shrink: 0;
  border: 1px solid var(--border); background: var(--bg3); color: var(--text); touch-action: manipulation;
}
.icon-btn:hover { border-color: var(--accent2); }
.icon-btn:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.icon-btn .snd-mute { display: none; }
.icon-btn.off { color: var(--muted); }
.icon-btn.off .snd-wave { display: none; }
.icon-btn.off .snd-mute { display: inline; }
@media (max-width: 520px) {
  .icon-btn { width: 32px; height: 30px; }
  .icon-btn svg { width: 18px; height: 18px; }
}
@media (max-width: 400px) {
  .site-nav { gap: 0.3rem; }
  .nav-link { padding: 0.32rem 0.5rem; }
}

/* v20260925n: rating milestone popup */
.cg-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: rgba(5, 8, 12, 0.62); animation: cg-fade 0.2s ease-out;
}
.cg-card {
  width: min(360px, 100%); text-align: center; background: var(--bg2); border: 1px solid var(--border);
  border-top: 3px solid #f0ad2e; border-radius: 16px; padding: 1.4rem 1.4rem 1.2rem; box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  animation: cg-pop 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}
.cg-badge { position: relative; width: 64px; height: 64px; margin: 0 auto 0.6rem; animation: cg-spin 0.7s ease-out; }
.cg-badge svg { display: block; filter: drop-shadow(0 3px 8px rgba(240, 173, 46, 0.45)); }
.cg-spark { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #ffe58a; opacity: 0; animation: cg-spark 0.9s ease-out 0.15s; }
.cg-spark.s1 { left: -6px; top: 10px; } .cg-spark.s2 { right: -6px; top: 6px; }
.cg-spark.s3 { left: 2px; bottom: -4px; } .cg-spark.s4 { right: 0; bottom: -2px; }
.cg-text { margin: 0 0 1.1rem; font-size: 1.05rem; line-height: 1.5; color: var(--text); }
.cg-text strong { display: block; font-size: 1.35rem; margin-bottom: 0.2rem; color: #ffd86b; }
.cg-num { font-weight: 800; }
.cg-ok { min-width: 120px; padding: 0.6rem 1.4rem; font-size: 1rem; }
@keyframes cg-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cg-pop { from { opacity: 0; transform: translateY(12px) scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes cg-spin { from { transform: scale(0.4) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cg-spark { 0% { opacity: 0; transform: scale(0.3); } 40% { opacity: 1; transform: scale(1.3); } 100% { opacity: 0; transform: scale(0.6) translateY(-10px); } }
@media (prefers-reduced-motion: reduce) {
  .cg-overlay, .cg-card, .cg-badge, .cg-spark { animation: none; }
}
