:root {
  --bg: #1a1d23;
  --surface: #252a33;
  --surface2: #2e3540;
  --border: #3d4654;
  --text: #e8ecf1;
  --muted: #8b95a5;
  --accent: #c9a227;
  --accent-dim: #8a7020;
  --pin: #d4a574;
  --success: #4caf82;
  --error: #e05c5c;
  --hole: #1e232b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

.subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  margin: 1.25rem 0;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: rgba(232, 236, 241, 0.03);
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ad-slot-top {
  margin-top: 1.5rem;
}

.ad-slot-result {
  margin-top: 1rem;
}

.ad-slot-bottom {
  margin-bottom: 0;
}

.site-footer {
  margin-top: 1.25rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.72rem;
}

.site-footer p {
  margin: 0;
}

.steps {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.step-tab {
  flex: 1;
  min-width: 7rem;
  padding: 0.5rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.step-tab.active {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--accent);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.hint {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.digit-picker {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 2rem 0;
}

.digit-btn {
  width: 4rem;
  height: 4rem;
  font-size: 1.75rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}

.digit-btn:hover {
  border-color: var(--accent);
  background: var(--surface2);
  transform: scale(1.05);
}

.puzzle-board {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.line-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.line-label {
  width: 3.6rem;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--accent);
  text-align: right;
  flex-shrink: 0;
}

.line-track {
  position: relative;
  display: flex;
  gap: 4px;
  flex: 1;
  padding: 0.5rem 0.35rem;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.pin-marker {
  position: absolute;
  left: 50%;
  top: -6px;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: var(--muted);
  border-radius: 50%;
  opacity: 0.5;
  pointer-events: none;
  z-index: 2;
}

.hole {
  position: relative;
  flex: 1;
  min-width: 0;
  aspect-ratio: 1;
  max-width: 2.75rem;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--hole);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.hole:hover:not(:disabled) {
  border-color: var(--accent-dim);
}

.hole.active {
  border-color: var(--accent);
  background: #2a2618;
}

.hole:disabled {
  cursor: default;
}

.hole-num {
  position: absolute;
  bottom: 1px;
  font-size: 0.55rem;
  color: var(--muted);
  opacity: 0.7;
}

.pin-dot {
  width: 55%;
  height: 55%;
  background: radial-gradient(circle at 35% 35%, #f0d4a8, var(--pin));
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.panel-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn.primary {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--accent);
  flex: 1;
}

.btn.primary:hover {
  background: var(--accent);
  color: #1a1d23;
}

.btn.secondary {
  background: var(--surface);
  color: var(--text);
}

.btn.secondary:hover {
  background: var(--surface2);
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.rule-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.rule-card summary {
  padding: 0.85rem 1rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}

.rule-card summary::-webkit-details-marker {
  display: none;
}

.rule-card summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s;
}

.rule-card[open] summary::before {
  transform: rotate(90deg);
}

.rule-block {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
}

.rule-block h4 {
  margin: 0.75rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.rule-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.rule-select {
  flex: 1;
  max-width: 11rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.85rem;
}

.status {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.status.success {
  background: rgba(76, 175, 130, 0.15);
  border: 1px solid var(--success);
  color: var(--success);
}

.status.error {
  background: rgba(224, 92, 92, 0.12);
  border: 1px solid var(--error);
  color: var(--error);
}

.solution-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.solution-controls.hidden {
  display: none;
}

#moveCounter {
  font-variant-numeric: tabular-nums;
  min-width: 5rem;
  text-align: center;
  color: var(--muted);
}

.move-list {
  margin: 1rem 0 0;
  padding-left: 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.9rem;
  color: var(--muted);
}

.move-list li {
  margin-bottom: 0.4rem;
  cursor: pointer;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
}

.move-list li:hover {
  color: var(--text);
  background: var(--surface2);
}

.move-list li.current {
  color: var(--accent);
  font-weight: 600;
}

.move-action {
  display: block;
  color: var(--text);
  font-weight: 600;
}

.move-positions {
  display: block;
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.guide-card {
  margin-top: 1.25rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.guide-copy h2 {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-size: 1.05rem;
}

.guide-copy p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.guide-copy .guide-note {
  margin-bottom: 1rem;
  color: var(--text);
}

.guide-figure {
  margin: 0;
}

.guide-figure picture {
  display: block;
  max-width: 100%;
}

.guide-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
}

.guide-figure figcaption {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.row-order-note {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(201, 162, 39, 0.08);
  color: var(--text);
}

.solution-note {
  margin-top: 1rem;
}

.seo-content {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text);
}

.seo-content h2 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
  color: var(--accent);
}

.seo-content h2:first-child {
  margin-top: 0;
}

.seo-content h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}

.seo-content p,
.seo-content li {
  font-size: 0.9rem;
  color: var(--muted);
}

.seo-content ul {
  margin: 0.75rem 0 0;
  padding-left: 1.25rem;
}

.faq-item {
  margin-top: 0.85rem;
}

@media (max-width: 480px) {
  .hole {
    max-width: 2.2rem;
  }

  .line-label {
    width: 3.1rem;
    font-size: 0.72rem;
  }

  .step-tab {
    min-width: calc(50% - 0.35rem);
  }
}
