:root {
  --bg-top: #f5ecd7;
  --bg-bottom: #d9c4a6;
  --ink: #2d1a12;
  --card: rgba(255, 248, 233, 0.86);
  --line: rgba(77, 53, 41, 0.32);
  --peg: #714231;
  --peg-highlight: #c77634;
  --empty: #f3e6cf;
  --accent: #9f4f1c;
  --hint: #146a4f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 20%, rgba(255, 255, 255, 0.6), transparent 32%),
    radial-gradient(circle at 82% 70%, rgba(120, 62, 29, 0.14), transparent 35%),
    linear-gradient(170deg, var(--bg-top), var(--bg-bottom));
  color: var(--ink);
  font-family: "Trebuchet MS", "Avenir Next", "Gill Sans", sans-serif;
  padding: 24px 16px 48px;
}

.app {
  max-width: 920px;
  margin: 0 auto;
  background: var(--card);
  border: 2px solid rgba(66, 42, 31, 0.18);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 14px 32px rgba(33, 15, 8, 0.16);
}

h1 {
  margin: 0;
  font-size: clamp(1.4rem, 1rem + 2vw, 2.2rem);
  letter-spacing: 0.03em;
}

.subtitle {
  margin: 8px 0 0;
  font-size: 0.98rem;
}

.controls {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

label {
  font-weight: 700;
}

.help-toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-weight: 600;
}

select,
button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid rgba(72, 43, 31, 0.45);
  padding: 8px 12px;
  background: #fff7e8;
  color: var(--ink);
}

button {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

button:hover:not(.hole) {
  transform: translateY(-1px);
  box-shadow: 0 5px 10px rgba(63, 35, 19, 0.18);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.status {
  margin-top: 16px;
  min-height: 50px;
}

.status p {
  margin: 4px 0;
}

#result-text {
  font-weight: 700;
  color: var(--accent);
}

.board-wrap {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.board {
  position: relative;
  width: min(92vw, 520px);
  aspect-ratio: 1 / 0.92;
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 12%, #c4936a 10%, #ad7248 56%, #8b5336 100%);
  box-shadow:
    inset 0 0 0 3px rgba(62, 37, 27, 0.45),
    inset 0 10px 25px rgba(255, 219, 178, 0.18);
}

.hole {
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(69, 41, 27, 0.45);
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  font-weight: 700;
  line-height: 1;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
  z-index: 2;
}

.hole.peg {
  color: #f8f8f8;
  box-shadow:
    0 2px 5px rgba(22, 11, 5, 0.35),
    inset 0 -4px 5px rgba(40, 16, 10, 0.38);
}

.hole.peg.color-blue {
  background: radial-gradient(circle at 34% 28%, #77befb 10%, #1d5fa5 56%, #113d6d 100%);
}

.hole.peg.color-orange {
  background: radial-gradient(circle at 34% 28%, #ffd08d 10%, #e17b1f 56%, #b4580f 100%);
}

.hole.peg.color-yellow {
  background: radial-gradient(circle at 34% 28%, #fff8b4 10%, #f0d33c 56%, #be9d15 100%);
  color: #3d2f10;
}

.hole.peg.color-white {
  background: radial-gradient(circle at 34% 28%, #ffffff 0%, #ece8e1 58%, #cbc4b9 100%);
  color: #2d2d2d;
}

.hole.empty {
  background:
    radial-gradient(circle at 52% 55%, #4e2c1f 0 26%, #3d2217 27% 100%);
  color: #e8c9a3;
}

.hole.selected {
  box-shadow: 0 0 0 4px rgba(255, 233, 170, 0.8);
  transform: translate(-50%, -50%) scale(1.07);
}

.hole:hover {
  transform: translate(-50%, -50%) scale(1.04);
}

.hole.selected:hover {
  transform: translate(-50%, -50%) scale(1.07);
}

.hole.legal-target {
  box-shadow: 0 0 0 4px rgba(46, 171, 131, 0.85);
}

.hole small {
  font-size: 0.7rem;
  letter-spacing: 0.03em;
}

.help-arrows {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

.help-arrow-line {
  stroke: #1e8f67;
  stroke-width: 2.4;
  stroke-linecap: butt;
  filter: drop-shadow(0 0 3px rgba(30, 143, 103, 0.4));
}

.help-arrow-head {
  fill: #1e8f67;
  filter: drop-shadow(0 0 3px rgba(30, 143, 103, 0.4));
}

.help-panel {
  margin-top: 16px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 248, 232, 0.62);
  border: 1px solid rgba(88, 58, 42, 0.24);
}

.help-panel h2 {
  margin: 0;
  font-size: 1rem;
}

#help-summary {
  margin: 8px 0;
  color: var(--hint);
  font-weight: 600;
}

#help-path {
  margin: 0;
  padding-left: 20px;
  max-height: 132px;
  overflow: auto;
}

@media (max-width: 640px) {
  .board {
    width: min(95vw, 450px);
  }

  .hole {
    width: 44px;
    height: 44px;
  }

  .controls {
    gap: 8px;
  }
}
