﻿:root {
  --bg: #f4f0e7;
  --ink: #2d2a26;
  --muted: #777063;
  --line: #4f4a40;
  --accent: #b65f18;
  --ok: #2e7d32;
  --bad: #c62828;
  --pending: #9b968a;
  --hint: #f1c40f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Serif SC", "Source Han Serif SC", "PingFang SC", serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 10%, #fffefb, var(--bg));
}

.build-badge {
  position: fixed;
  left: 14px;
  top: 12px;
  z-index: 1200;
  border: 1px solid #c9b462;
  background: #fff7d6;
  color: #6a5608;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.top-menu {
  position: fixed;
  right: 14px;
  top: 12px;
  z-index: 1200;
}

.menu-dropdown {
  position: relative;
}

.menu-dropdown summary {
  list-style: none;
  border: 1px solid #c8bda8;
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
}

.menu-dropdown summary::-webkit-details-marker {
  display: none;
}

.menu-icon {
  font-size: 20px;
  line-height: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.menu-dropdown[open] summary {
  border-color: var(--accent);
}

.menu-panel {
  position: absolute;
  right: 0;
  margin-top: 8px;
  min-width: 150px;
  border: 1px solid #d5cab5;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.15);
  padding: 8px;
  display: grid;
  gap: 6px;
}

.menu-link {
  display: block;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid #ece3d0;
  border-radius: 8px;
  padding: 7px 10px;
}

.menu-link:hover {
  border-color: var(--accent);
}

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 16px 36px;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: 0.04em;
}

.panel {
  margin-top: 12px;
  padding: 0;
}

.puzzle-meta {
  color: var(--muted);
  font-weight: 700;
}

.rule-circles {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.rule-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--pending);
  color: var(--pending);
  background: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
  cursor: default;
  user-select: none;
  transition: transform 120ms ease, border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.rule-circle.pass {
  border-color: var(--ok);
  color: var(--ok);
  background: #ebf7ec;
}

.rule-circle.fail {
  border-color: var(--bad);
  color: var(--bad);
  background: #fdecec;
}

.rule-circle.hovered {
  transform: scale(1.08);
}

.actions {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.easy-toggle {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  user-select: none;
}

.history-tools {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.attempt-indicator {
  min-width: 150px;
  color: var(--muted);
  font-weight: 700;
}

button {
  border: 1px solid #c8bda8;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

button:hover {
  border-color: var(--accent);
}

button:disabled,
.easy-toggle input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.board-wrap {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.board {
  --size: 56px;
  position: relative;
  display: grid;
  width: fit-content;
  border: 2px solid var(--line);
  background: #fff;
}

.cell {
  width: var(--size);
  height: var(--size);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  place-items: center;
  position: relative;
  font-size: 24px;
  cursor: pointer;
  user-select: none;
}

.cell.clue {
  font-size: 22px;
  font-weight: 700;
}

.cell.black {
  background: #1f1f1f;
  color: #f8f8f8;
}

.cell.dot::after {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(142, 135, 121, 0.75);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cell.highlight {
  box-shadow: inset 0 0 0 9999px rgba(198, 40, 40, 0.35);
}

.results-btn {
  margin-top: 14px;
}

.results-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
}

.results-modal.hidden {
  display: none;
}

.results-card {
  width: min(90vw, 420px);
  background: #fff;
  border-radius: 12px;
  border: 1px solid #dacfb8;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.results-card h2 {
  margin: 0;
  font-size: 24px;
}

.results-summary {
  margin: 0;
  color: var(--muted);
}

.rules-details {
  width: 100%;
  text-align: left;
}

.rules-details summary {
  cursor: pointer;
  user-select: none;
  font-weight: 700;
}

.rules-list {
  margin: 8px 0 0;
  padding-left: 22px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.archive-panel {
  margin-top: 16px;
}

.archive-list {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.archive-item {
  border: 1px solid #d8ccb5;
  border-radius: 10px;
  background: #fff;
  padding: 11px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.archive-link {
  color: inherit;
  text-decoration: none;
}

.archive-link:hover {
  border-color: var(--accent);
}

.archive-left,
.archive-right {
  display: grid;
  gap: 3px;
  text-align: left;
}

.archive-right {
  text-align: right;
}

.archive-date {
  font-size: 13px;
  color: var(--muted);
}

.archive-title {
  font-weight: 700;
}

.archive-author {
  color: var(--muted);
  font-size: 14px;
}

.archive-status.solved {
  color: var(--ok);
  font-weight: 700;
}

.archive-status.unsolved {
  color: var(--bad);
  font-weight: 700;
}

.archive-status.future {
  color: #7b6b28;
  font-weight: 700;
}

.archive-future {
  border-style: dashed;
}

.archive-today {
  font-size: 12px;
  color: var(--muted);
}

.archive-empty {
  margin-top: 16px;
  color: var(--muted);
}

@media (max-width: 700px) {
  .board {
    --size: 48px;
  }

  .cell {
    font-size: 20px;
  }

  .attempt-indicator {
    min-width: 130px;
  }

  .archive-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .archive-right {
    text-align: left;
  }
}
