* { box-sizing: border-box; }
body {
  margin: 0 auto;
  max-width: 72rem;
  padding: 1rem 2vw 4rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1c1c1c;
  background: #fafaf8;
  line-height: 1.5;
}
header { text-align: center; }
header h1 { margin-bottom: 0.75rem; }
.info-button {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  width: 1.4rem;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid #ccc;
  background: #fff;
  color: #22304a;
  cursor: pointer;
  vertical-align: middle;
}
.info-button:hover { background: #ececec; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}
.modal[hidden] { display: none; }
.modal-box {
  position: relative;
  background: #fff;
  border-radius: 0.5rem;
  padding: 1rem 1.3rem;
  width: min(90%, 34rem);
  max-height: 80vh;
  overflow: auto;
}
.modal-box h3 { margin-top: 0; }
.modal-close {
  position: absolute;
  top: 0.4rem;
  right: 0.6rem;
  font: inherit;
  font-size: 1.2rem;
  border: none;
  background: none;
  color: #666;
  cursor: pointer;
}

.controls {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  background: #ffffffee;
  backdrop-filter: blur(6px);
  border: 1px solid #ddd;
  border-radius: 0.5rem;
  box-shadow: 0 0.15rem 0.5rem #00000014;
}
.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: center;
  gap: 0.6rem;
}
.control-row-nav { align-items: center; }
.control {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #666;
}
.control-finding { flex: 0 1 26rem; min-width: 0; }
.control select {
  font: inherit;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
  color: #1c1c1c;
  padding: 0.25rem 0.4rem;
  border: 1px solid #ccc;
  border-radius: 0.35rem;
  background: #fff;
  max-width: 100%;
}
.view-toggle { display: flex; gap: 0; }
.view-toggle button {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  color: #444;
}
.view-toggle button:first-child { border-radius: 0.35rem 0 0 0.35rem; }
.view-toggle button:last-child { border-radius: 0 0.35rem 0.35rem 0; border-left: none; }
.view-toggle button.active { background: #22304a; color: #fff; border-color: #22304a; }
.nav-buttons { display: flex; align-items: center; gap: 0.5rem; }
.nav-buttons button {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid #ccc;
  border-radius: 0.35rem;
  background: #fff;
  cursor: pointer;
}
.nav-buttons button:disabled { opacity: 0.45; cursor: default; }
.position { font-size: 0.85rem; color: #444; min-width: 5.5rem; text-align: center; }
.empty { color: #666; }

nav#toc { font-size: 0.9rem; margin-bottom: 1.5rem; }
nav#toc a { margin-right: 0.9rem; }
.round > h2 {
  border-bottom: 2px solid #333;
  padding-bottom: 0.3rem;
}
.round-date { color: #777; font-size: 0.85rem; }
.group { margin: 2rem 0; }
.group-browse { margin-top: 0; }
.group > h3 {
  background: #22304a;
  color: #fff;
  padding: 0.45rem 0.8rem;
  border-radius: 0.4rem;
}
.group-description { margin: 0.4rem 0 0.2rem; }
.group-status { color: #6b4a00; font-size: 0.9rem; margin-top: 0; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 26rem), 1fr));
  gap: 1rem;
}
.card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 0.5rem;
  padding: 0.9rem;
}
main#browse {
  max-width: 38rem;
  margin: 0 auto;
}
.group-line {
  text-align: center;
  font-weight: 600;
  color: #22304a;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
  font-size: 0.8rem;
  color: #444;
  margin-bottom: 0.5rem;
}
.badge {
  border-radius: 0.3rem;
  padding: 0.05rem 0.45rem;
  font-weight: 600;
}
.badge.high { background: #fbe0e0; color: #8c1c1c; }
.badge.medium { background: #fdf3d5; color: #7a5a00; }
.badge.low { background: #ececec; color: #444; }
.badge.resolved { background: #ddf3dd; color: #1c6b2a; }
.badge.new-defect { background: #e3ecfb; color: #1c3f8c; }
.board-wrap { margin: 0.5rem 0; }
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(100%, 22rem);
  aspect-ratio: 1;
  border-radius: 0.25rem;
  overflow: hidden;
  user-select: none;
}
.group-browse .board { margin: 0 auto; }
.group-browse .board-caption { text-align: center; }
.sq {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  aspect-ratio: 1;
}
.sq.light { background: #EFE9FF; }
.sq.dark { background: #8777B6; }
.hl { position: absolute; inset: 0; z-index: 1; }
.hl-from { background: rgba(48, 164, 108, 0.48); }
.hl-to { background: rgba(229, 72, 77, 0.48); }
.piece {
  position: relative;
  z-index: 2;
  width: 88%;
  height: 88%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sq svg { width: 100%; height: 100%; display: block; }
.sq .coord {
  position: absolute;
  bottom: 1%;
  right: 4%;
  z-index: 3;
  font-size: 0.5rem;
  font-weight: 600;
  pointer-events: none;
}
.sq.light .coord { color: #6c5da3; }
.sq.dark .coord { color: #EFE9FF; }
.board-caption { font-size: 0.85rem; color: #444; margin: 0.3rem 0 0; }
.fen-details { margin: 0.4rem 0; }
.fen-details summary {
  font-size: 0.78rem;
  color: #666;
  cursor: pointer;
  user-select: none;
}
.detail-line { font-size: 0.8rem; color: #666; margin: 0.3rem 0 0; }
.fen {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  word-break: break-all;
  color: #666;
  background: #f4f4f2;
  padding: 0.3rem 0.4rem;
  border-radius: 0.3rem;
}
.story-label {
  margin: 0.9rem 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #22304a;
}
.story-label-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: #666;
  margin-left: 0.5rem;
}
.story-text {
  background: #fff;
  border: 1px solid #c9d2e4;
  border-left: 0.3rem solid #22304a;
  border-radius: 0.35rem;
  padding: 0.7rem 0.9rem;
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
  line-height: 1.6;
}
.story-text mark, .story-label-hint mark { background: #ffd7d7; padding: 0 0.15rem; }
.why { margin: 0.5rem 0 0; }
.why b { color: #8c1c1c; }
