body { gap: 18px; }

/* scoreboard chips */
#score {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* difficulty (disk count) button group — copied from peg-solitaire */
#difficulty {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.diff-btn {
  padding: 8px 18px;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
}
.diff-btn:hover { opacity: 1; background: var(--surface-3); }
.diff-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}
#difficulty[hidden] { display: none; }

/* the board holds three pegs side by side */
#board {
  --peg-h: 200px;       /* height of a peg column */
  --disk-h: 26px;       /* height of one disk */
  --base-w: 150px;      /* width of a peg's base / column */
  display: flex;
  gap: 14px;
  padding: 16px 16px 0;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 10px 40px var(--shadow);
}

/* a single peg: a column where disks stack from the bottom up */
.peg {
  position: relative;
  width: var(--base-w);
  height: var(--peg-h);
  display: flex;
  flex-direction: column-reverse;   /* stack from the bottom */
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding-bottom: 12px;             /* room for the base bar */
}

/* the vertical spindle */
.peg::before {
  content: "";
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: calc(var(--peg-h) - 12px);
  background: var(--surface-3);
  border-radius: 4px;
  z-index: 0;
}

/* the base bar each peg sits on */
.peg::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 12px;
  background: var(--surface-2);
  border-radius: 6px;
  box-shadow: inset 0 2px 4px var(--shadow);
}

/* a disk: width scales with its size (1..N) */
.disk {
  position: relative;
  z-index: 1;
  height: var(--disk-h);
  width: calc(28px + (var(--base-w) - 28px) * var(--frac));
  margin-top: 4px;
  border-radius: 13px;
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.30), 0 2px 5px var(--shadow);
  transition: transform 0.12s ease;
}

/* the lifted (selected) top disk floats above its peg */
.peg.selected .disk:last-child {
  transform: translateY(-12px);
  background: var(--green);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.30), 0 0 0 3px var(--green), 0 4px 10px var(--shadow);
}

/* a peg that is a valid drop target for the lifted disk */
.peg.target::before { background: var(--green); }
.peg.target { cursor: pointer; }

/* illegal-drop feedback: a quick red shake */
.peg.bad {
  animation: hanoiShake 0.35s ease;
}
.peg.bad::before { background: var(--red); }
@keyframes hanoiShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* solved celebration: disks on the winning peg bounce */
#board.won .peg:last-child .disk {
  animation: hanoiWin 0.6s ease-in-out infinite alternate;
}
@keyframes hanoiWin {
  from { transform: translateY(0); }
  to   { transform: translateY(-4px); filter: brightness(1.25); }
}

@media (max-width: 560px) {
  #board { --peg-h: 150px; --disk-h: 20px; --base-w: 100px; gap: 8px; padding: 12px 10px 0; }
  .disk { font-size: 0.72rem; }
}
@media (max-width: 380px) {
  #board { --base-w: 88px; gap: 6px; }
}
